From 7541e1e9867dfd24429fc062b9529ceba14642a7 Mon Sep 17 00:00:00 2001 From: NikDizell Date: Wed, 4 Mar 2026 15:26:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=81=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80=D0=B0=20=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D1=82=D0=B8=D1=81=D1=82=D0=B8=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- programmer/static/django_ckeditor_5/app.js | 238 ++++ .../static/django_ckeditor_5/dist/bundle.js | 3 + .../dist/bundle.js.LICENSE.txt | 20 + .../django_ckeditor_5/dist/bundle.js.map | 1 + .../static/django_ckeditor_5/dist/styles.css | 114 ++ .../django_ckeditor_5/dist/styles.css.map | 1 + .../django_ckeditor_5/dist/translations/af.js | 1 + .../django_ckeditor_5/dist/translations/ar.js | 1 + .../dist/translations/ast.js | 1 + .../django_ckeditor_5/dist/translations/az.js | 1 + .../django_ckeditor_5/dist/translations/be.js | 1 + .../django_ckeditor_5/dist/translations/bg.js | 1 + .../django_ckeditor_5/dist/translations/bn.js | 1 + .../django_ckeditor_5/dist/translations/bs.js | 1 + .../django_ckeditor_5/dist/translations/ca.js | 1 + .../django_ckeditor_5/dist/translations/cs.js | 1 + .../django_ckeditor_5/dist/translations/da.js | 1 + .../dist/translations/de-ch.js | 1 + .../django_ckeditor_5/dist/translations/de.js | 1 + .../django_ckeditor_5/dist/translations/el.js | 1 + .../dist/translations/en-au.js | 1 + .../dist/translations/en-gb.js | 1 + .../django_ckeditor_5/dist/translations/eo.js | 1 + .../dist/translations/es-co.js | 1 + .../django_ckeditor_5/dist/translations/es.js | 1 + .../django_ckeditor_5/dist/translations/et.js | 1 + .../django_ckeditor_5/dist/translations/eu.js | 1 + .../django_ckeditor_5/dist/translations/fa.js | 1 + .../django_ckeditor_5/dist/translations/fi.js | 1 + .../django_ckeditor_5/dist/translations/fr.js | 1 + .../django_ckeditor_5/dist/translations/gl.js | 1 + .../django_ckeditor_5/dist/translations/gu.js | 1 + .../django_ckeditor_5/dist/translations/he.js | 1 + .../django_ckeditor_5/dist/translations/hi.js | 1 + .../django_ckeditor_5/dist/translations/hr.js | 1 + .../django_ckeditor_5/dist/translations/hu.js | 1 + .../django_ckeditor_5/dist/translations/hy.js | 1 + .../django_ckeditor_5/dist/translations/id.js | 1 + .../django_ckeditor_5/dist/translations/it.js | 1 + .../django_ckeditor_5/dist/translations/ja.js | 1 + .../django_ckeditor_5/dist/translations/jv.js | 1 + .../django_ckeditor_5/dist/translations/kk.js | 1 + .../django_ckeditor_5/dist/translations/km.js | 1 + .../django_ckeditor_5/dist/translations/kn.js | 1 + .../django_ckeditor_5/dist/translations/ko.js | 1 + .../django_ckeditor_5/dist/translations/ku.js | 1 + .../django_ckeditor_5/dist/translations/lt.js | 1 + .../django_ckeditor_5/dist/translations/lv.js | 1 + .../django_ckeditor_5/dist/translations/ms.js | 1 + .../django_ckeditor_5/dist/translations/nb.js | 1 + .../django_ckeditor_5/dist/translations/ne.js | 1 + .../django_ckeditor_5/dist/translations/nl.js | 1 + .../django_ckeditor_5/dist/translations/no.js | 1 + .../django_ckeditor_5/dist/translations/oc.js | 1 + .../django_ckeditor_5/dist/translations/pl.js | 1 + .../dist/translations/pt-br.js | 1 + .../django_ckeditor_5/dist/translations/pt.js | 1 + .../django_ckeditor_5/dist/translations/ro.js | 1 + .../django_ckeditor_5/dist/translations/ru.js | 1 + .../django_ckeditor_5/dist/translations/si.js | 1 + .../django_ckeditor_5/dist/translations/sk.js | 1 + .../django_ckeditor_5/dist/translations/sl.js | 1 + .../django_ckeditor_5/dist/translations/sq.js | 1 + .../dist/translations/sr-latn.js | 1 + .../django_ckeditor_5/dist/translations/sr.js | 1 + .../django_ckeditor_5/dist/translations/sv.js | 1 + .../django_ckeditor_5/dist/translations/th.js | 1 + .../django_ckeditor_5/dist/translations/ti.js | 1 + .../django_ckeditor_5/dist/translations/tk.js | 1 + .../django_ckeditor_5/dist/translations/tr.js | 1 + .../django_ckeditor_5/dist/translations/tt.js | 1 + .../django_ckeditor_5/dist/translations/ug.js | 1 + .../django_ckeditor_5/dist/translations/uk.js | 1 + .../django_ckeditor_5/dist/translations/ur.js | 1 + .../django_ckeditor_5/dist/translations/uz.js | 1 + .../django_ckeditor_5/dist/translations/vi.js | 1 + .../dist/translations/zh-cn.js | 1 + .../django_ckeditor_5/dist/translations/zh.js | 1 + .../static/django_ckeditor_5/src/ckeditor.js | 116 ++ .../django_ckeditor_5/src/override-django.css | 47 + .../css/jquery.autocomplete.css | 38 + .../django_extensions/img/indicator.gif | Bin 0 -> 1553 bytes .../django_extensions/js/jquery.ajaxQueue.js | 116 ++ .../js/jquery.autocomplete.js | 1152 +++++++++++++++++ .../django_extensions/js/jquery.bgiframe.js | 39 + 85 files changed, 1957 insertions(+) create mode 100644 programmer/static/django_ckeditor_5/app.js create mode 100644 programmer/static/django_ckeditor_5/dist/bundle.js create mode 100644 programmer/static/django_ckeditor_5/dist/bundle.js.LICENSE.txt create mode 100644 programmer/static/django_ckeditor_5/dist/bundle.js.map create mode 100644 programmer/static/django_ckeditor_5/dist/styles.css create mode 100644 programmer/static/django_ckeditor_5/dist/styles.css.map create mode 100644 programmer/static/django_ckeditor_5/dist/translations/af.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/ar.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/ast.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/az.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/be.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/bg.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/bn.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/bs.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/ca.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/cs.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/da.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/de-ch.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/de.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/el.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/en-au.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/en-gb.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/eo.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/es-co.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/es.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/et.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/eu.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/fa.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/fi.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/fr.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/gl.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/gu.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/he.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/hi.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/hr.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/hu.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/hy.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/id.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/it.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/ja.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/jv.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/kk.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/km.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/kn.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/ko.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/ku.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/lt.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/lv.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/ms.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/nb.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/ne.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/nl.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/no.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/oc.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/pl.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/pt-br.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/pt.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/ro.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/ru.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/si.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/sk.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/sl.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/sq.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/sr-latn.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/sr.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/sv.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/th.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/ti.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/tk.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/tr.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/tt.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/ug.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/uk.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/ur.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/uz.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/vi.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/zh-cn.js create mode 100644 programmer/static/django_ckeditor_5/dist/translations/zh.js create mode 100644 programmer/static/django_ckeditor_5/src/ckeditor.js create mode 100644 programmer/static/django_ckeditor_5/src/override-django.css create mode 100644 programmer/static/django_extensions/css/jquery.autocomplete.css create mode 100644 programmer/static/django_extensions/img/indicator.gif create mode 100644 programmer/static/django_extensions/js/jquery.ajaxQueue.js create mode 100644 programmer/static/django_extensions/js/jquery.autocomplete.js create mode 100644 programmer/static/django_extensions/js/jquery.bgiframe.js diff --git a/programmer/static/django_ckeditor_5/app.js b/programmer/static/django_ckeditor_5/app.js new file mode 100644 index 0000000..a0b5281 --- /dev/null +++ b/programmer/static/django_ckeditor_5/app.js @@ -0,0 +1,238 @@ +import ClassicEditor from './src/ckeditor'; +import './src/override-django.css'; + +window.ClassicEditor = ClassicEditor; +window.ckeditorRegisterCallback = registerCallback; +window.ckeditorUnregisterCallback = unregisterCallback; +window.editors = {}; +let editors = {}; +let callbacks = {}; + +function getCookie(name) { + let cookieValue = null; + if (document.cookie && document.cookie !== '') { + let cookies = document.cookie.split(';'); + for (let i = 0; i < cookies.length; i++) { + let cookie = cookies[i].trim(); + if (cookie.substring(0, name.length + 1) === (name + '=')) { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); + break; + } + } + } + return cookieValue; +} + +function getCSRFToken(cookieName) { + let token = getCookie(cookieName); + if (!token) { + token = document.querySelector('input[name=csrfmiddlewaretoken]')?.value; + } + return token; +} + +/** + * Checks whether the element or its children match the query and returns + * an array with the matches. + * + * @param {!HTMLElement} element + * @param {!string} query + * + * @returns {array.} + */ +function resolveElementArray(element, query) { + return element.matches(query) ? [element] : [...element.querySelectorAll(query)]; +} + +/** + * This function initializes the CKEditor inputs within an optional element and + * assigns properties necessary for the correct operation + * + * @param {HTMLElement} [element=document.body] - The element to search for elements + * + * @returns {void} + */ +function createEditors(element = document.body) { + const allEditors = resolveElementArray(element, '.django_ckeditor_5'); + + allEditors.forEach(editorEl => { + if ( + editorEl.id.indexOf('__prefix__') !== -1 || + editorEl.getAttribute('data-processed') === '1' + ) { + return; + } + const script_id = `${editorEl.id}_script`; + // remove next sibling if it is an empty text node + if (editorEl.nextSibling.nodeType == Node.TEXT_NODE && editorEl.nextSibling.textContent.trim() === '') { + editorEl.nextSibling.remove(); + } + const upload_url = element.querySelector( + `#${script_id}-ck-editor-5-upload-url` + ).getAttribute('data-upload-url'); + const upload_file_types = JSON.parse(element.querySelector( + `#${script_id}-ck-editor-5-upload-url` + ).getAttribute('data-upload-file-types')); + const csrf_cookie_name = element.querySelector( + `#${script_id}-ck-editor-5-upload-url` + ).getAttribute('data-csrf_cookie_name'); + const labelElement = element.querySelector(`[for$="${editorEl.id}"]`); + if (labelElement) { + labelElement.style.float = 'none'; + } + + const config = JSON.parse( + element.querySelector(`#${script_id}-span`).textContent, + (key, value) => { + var match = value.toString().match(new RegExp('^/(.*?)/([gimy]*)$')); + if (match) { + var regex = new RegExp(match[1], match[2]); + return regex; + } + if (typeof value === 'string' && value.startsWith('callback:')) { + var callbackName = value.substring(9); + var callback = window[callbackName]; + if (typeof callback === 'function') { + return callback; + } + } + return value; + } + ); + config.simpleUpload = { + 'uploadUrl': upload_url, + 'headers': { + 'X-CSRFToken': getCSRFToken(csrf_cookie_name), + }, + }; + + config.fileUploader = { + 'fileTypes': upload_file_types + }; + config.licenseKey = 'GPL'; + + // Configure autosave if enabled + if (config.autosave) { + config.autosave.save = function(editor) { + return new Promise((resolve, reject) => { + const textarea = document.querySelector(`#${editorEl.id}`); + const data = editor.getData(); + textarea.value = data; + + // If save URL is provided, send to server + if (config.autosave.saveUrl) { + fetch(config.autosave.saveUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-CSRFToken': getCSRFToken(csrf_cookie_name), + }, + body: JSON.stringify({ + id: editorEl.id, + content: data + }) + }) + .then(response => response.json()) + .then(result => resolve(result)) + .catch(error => reject(error)); + } else { + // Just update textarea + resolve(); + } + }); + }; + } + + ClassicEditor.create( + editorEl, + config + ).then(editor => { + + const textarea = document.querySelector(`#${editorEl.id}`); + editor.model.document.on('change:data', () => { + textarea.value = editor.getData(); + }); + if (editor.plugins.has('WordCount')) { + const wordCountPlugin = editor.plugins.get('WordCount'); + const wordCountWrapper = element.querySelector(`#${script_id}-word-count`); + wordCountWrapper.innerHTML = ''; + wordCountWrapper.appendChild(wordCountPlugin.wordCountContainer); + } + if (editorEl.hasAttribute('disabled')) { + editor.enableReadOnlyMode('django-ckeditor-5'); + } + editors[editorEl.id] = editor; + if (callbacks[editorEl.id]) { + callbacks[editorEl.id](editor); + } + }).catch(error => { + console.error((error)); + }); + editorEl.setAttribute('data-processed', '1'); + }); + window.editors = editors; +} + +/** + * This function filters the list of mutations only by added elements, thus + * eliminates the occurrence of text nodes and tags where it does not make sense + * to try to use with `QuerySelectorAll()` and `matches()` functions. + * + * @param {MutationRecord} recordList - It is the object inside the array + * passed to the callback of a MutationObserver. + * + * @returns {Array} Array containing filtered nodes. + */ +function getAddedNodes(recordList) { + return recordList + .flatMap(({ addedNodes }) => Array.from(addedNodes)) + .filter(node => node.nodeType === 1); +} + +/** + * Register a callback for when an editor with `id` is created. + * + * @param {!string} id - the id of the ckeditor element. + * @callback callback - the callback function to be invoked. + */ +function registerCallback(id, callback) { + callbacks[id] = callback; +} + +/** + * Unregister a previously registered callback. + * + * @param {!string} id - the id of the ckeditor element. + */ +function unregisterCallback(id) { + callbacks[id] = null; +} + +document.addEventListener("DOMContentLoaded", () => { + createEditors(); + + if (typeof django === "object" && django.jQuery) { + django.jQuery(document).on("formset:added", () => {createEditors();}); + } + + const observer = new MutationObserver((mutations) => { + let addedNodes = getAddedNodes(mutations); + + addedNodes.forEach(node => { + // Initializes editors + createEditors(node); + }); + }); + + // Configure MutationObserver options + const observerOptions = { + childList: true, + subtree: true, + }; + + // Selects the parent element where the events occur + const mainContent = document.body; + + // Starts to observe the selected father element with the configured options + observer.observe(mainContent, observerOptions); +}); diff --git a/programmer/static/django_ckeditor_5/dist/bundle.js b/programmer/static/django_ckeditor_5/dist/bundle.js new file mode 100644 index 0000000..a4cca5a --- /dev/null +++ b/programmer/static/django_ckeditor_5/dist/bundle.js @@ -0,0 +1,3 @@ +/*! For license information please see bundle.js.LICENSE.txt */ +!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{"(may require Fn)":"(may require Fn)","%0 of %1":"%0 of %1",Accept:"Accept",Accessibility:"Accessibility","Accessibility help":"Accessibility help","Advanced options":"Advanced options","Align cell text to the bottom":"Align cell text to the bottom","Align cell text to the center":"Align cell text to the center","Align cell text to the left":"Align cell text to the left","Align cell text to the middle":"Align cell text to the middle","Align cell text to the right":"Align cell text to the right","Align cell text to the top":"Align cell text to the top","Align center":"Align center","Align left":"Align left","Align right":"Align right","Align table to the left":"Align table to the left","Align table to the left with no text wrapping":"Align table to the left with no text wrapping","Align table to the left with text wrapping":"Align table to the left with text wrapping","Align table to the right":"Align table to the right","Align table to the right with no text wrapping":"Align table to the right with no text wrapping","Align table to the right with text wrapping":"Align table to the right with text wrapping",Alignment:"Alignment",All:"All","Almost equal to":"Almost equal to",Angle:"Angle","Approximately equal to":"Approximately equal to",Aquamarine:"Aquamarine",Arrows:"Arrows","Asterisk operator":"Asterisk operator","Austral sign":"Austral sign",Back:"Back","back with leftwards arrow above":"back with leftwards arrow above",Background:"Background","Below, you can find a list of keyboard shortcuts that can be used in the editor.":"Below, you can find a list of keyboard shortcuts that can be used in the editor.",Big:"Big","Bitcoin sign":"Bitcoin sign",Black:"Black","Block quote":"Block quote","Block styles":"Block styles",Blue:"Blue","Blue marker":"Blue marker",Bold:"Bold","Bold text":"Bold text",Border:"Border","Break text":"Break text","Bulleted List":"Bulleted List","Bulleted list styles toolbar":"Bulleted list styles toolbar",Cancel:"Cancel","Cannot upload file:":"Cannot upload file:","Caption for image: %0":"Caption for image: %0","Caption for the image":"Caption for the image",Category:"Category","Cedi sign":"Cedi sign","Cell properties":"Cell properties","Cell type":"Cell type","Cent sign":"Cent sign","Center table":"Center table","Center table with no text wrapping":"Center table with no text wrapping","Centered image":"Centered image","Change image text alternative":"Change image text alternative","Characters: %0":"Characters: %0","Choose heading":"Choose heading","Choose table type":"Choose table type",Circle:"Circle",Clear:"Clear","Click to edit block":"Click to edit block",Close:"Close","Close contextual balloons, dropdowns, and dialogs":"Close contextual balloons, dropdowns, and dialogs",Code:"Code","Code block":"Code block","Colon sign":"Colon sign",Color:"Color","Color picker":"Color picker",Column:"Column","Contains as member":"Contains as member","Content editing keystrokes":"Content editing keystrokes","Content table":"Content table","Copy selected content":"Copy selected content","Copyright sign":"Copyright sign","Create link":"Create link","Cruzeiro sign":"Cruzeiro sign",Currency:"Currency","Currency sign":"Currency sign",Custom:"Custom","Custom image size":"Custom image size",Dashed:"Dashed","Data cell":"Data cell",Decimal:"Decimal","Decimal with leading zero":"Decimal with leading zero","Decrease indent":"Decrease indent","Decrease list item indent":"Decrease list item indent",Default:"Default","Degree sign":"Degree sign","Delete column":"Delete column","Delete row":"Delete row","Dim grey":"Dim grey",Dimensions:"Dimensions",Disc:"Disc","Displayed text":"Displayed text","Division sign":"Division sign","Document colors":"Document colors","Dollar sign":"Dollar sign","Dong sign":"Dong sign",Dotted:"Dotted",Double:"Double","Double dagger":"Double dagger","Double exclamation mark":"Double exclamation mark","Double low-9 quotation mark":"Double low-9 quotation mark","Double question mark":"Double question mark",Downloadable:"Downloadable","downwards arrow to bar":"downwards arrow to bar","downwards dashed arrow":"downwards dashed arrow","downwards double arrow":"downwards double arrow","downwards simple arrow":"downwards simple arrow","Drachma sign":"Drachma sign","Drag to move":"Drag to move","Dropdown menu":"Dropdown menu","Dropdown toolbar":"Dropdown toolbar","Edit block":"Edit block","Edit link":"Edit link","Edit source":"Edit source","Editor block content toolbar":"Editor block content toolbar","Editor contextual toolbar":"Editor contextual toolbar","Editor dialog":"Editor dialog","Editor menu bar":"Editor menu bar","Editor toolbar":"Editor toolbar","Element of":"Element of","Em dash":"Em dash","Empty set":"Empty set","Empty snippet content":"Empty snippet content","En dash":"En dash","end with leftwards arrow above":"end with leftwards arrow above","Enter image caption":"Enter image caption","Enter table caption":"Enter table caption","Entering %0 code snippet":"Entering %0 code snippet","Entering a to-do list":"Entering a to-do list","Entering code snippet":"Entering code snippet","Error during image upload":"Error during image upload","Euro sign":"Euro sign","Euro-currency sign":"Euro-currency sign","Exclamation question mark":"Exclamation question mark","Execute the currently focused button. Executing buttons that interact with the editor content moves the focus back to the content.":"Execute the currently focused button. Executing buttons that interact with the editor content moves the focus back to the content.",Find:"Find","Find and replace":"Find and replace","Find in text…":"Find in text…","Find in the document":"Find in the document","Font Background Color":"Font Background Color","Font Color":"Font Color","Font Family":"Font Family","Font Size":"Font Size","For all":"For all","Fraction slash":"Fraction slash","French franc sign":"French franc sign","From computer":"From computer","Full size image":"Full size image","German penny sign":"German penny sign","Greater-than or equal to":"Greater-than or equal to","Greater-than sign":"Greater-than sign",Green:"Green","Green marker":"Green marker","Green pen":"Green pen",Grey:"Grey",Groove:"Groove","Guarani sign":"Guarani sign","Header cell":"Header cell","Header column":"Header column","Header row":"Header row",Heading:"Heading","Heading 1":"Heading 1","Heading 2":"Heading 2","Heading 3":"Heading 3","Heading 4":"Heading 4","Heading 5":"Heading 5","Heading 6":"Heading 6",Height:"Height","Help Contents. To close this dialog press ESC.":"Help Contents. To close this dialog press ESC.",HEX:"HEX",Highlight:"Highlight","Horizontal ellipsis":"Horizontal ellipsis","Horizontal line":"Horizontal line","Horizontal text alignment toolbar":"Horizontal text alignment toolbar","Hryvnia sign":"Hryvnia sign","HTML object":"HTML object","HTML snippet":"HTML snippet",Huge:"Huge","Identical to":"Identical to",Image:"Image","Image from computer":"Image from computer","Image Resize":"Image Resize","Image resize list":"Image resize list","Image toolbar":"Image toolbar","Image upload complete":"Image upload complete","Image via URL":"Image via URL","image widget":"image widget","In line":"In line","Increase indent":"Increase indent","Increase list item indent":"Increase list item indent","Indian rupee sign":"Indian rupee sign",Infinity:"Infinity",Insert:"Insert","Insert a hard break (a new paragraph)":"Insert a hard break (a new paragraph)","Insert a new paragraph directly after a widget":"Insert a new paragraph directly after a widget","Insert a new paragraph directly before a widget":"Insert a new paragraph directly before a widget","Insert a new table row (when in the last cell of a table)":"Insert a new table row (when in the last cell of a table)","Insert a soft break (a <br> element)":"Insert a soft break (a <br> element)","Insert code block":"Insert code block","Insert column left":"Insert column left","Insert column right":"Insert column right","Insert HTML":"Insert HTML","Insert image":"Insert image","Insert image via URL":"Insert image via URL","Insert media":"Insert media","Insert paragraph after block":"Insert paragraph after block","Insert paragraph before block":"Insert paragraph before block","Insert row above":"Insert row above","Insert row below":"Insert row below","Insert table":"Insert table","Insert table layout":"Insert table layout","Insert via URL":"Insert via URL",Inset:"Inset",Integral:"Integral",Intersection:"Intersection","Invalid start index value.":"Invalid start index value.","Inverted exclamation mark":"Inverted exclamation mark","Inverted question mark":"Inverted question mark",Italic:"Italic","Italic text":"Italic text",Justify:"Justify","Justify cell text":"Justify cell text","Keystrokes that can be used in a list":"Keystrokes that can be used in a list","Keystrokes that can be used in a table cell":"Keystrokes that can be used in a table cell","Keystrokes that can be used when a widget is selected (for example: image, table, etc.)":"Keystrokes that can be used when a widget is selected (for example: image, table, etc.)","Kip sign":"Kip sign",Latin:"Latin","Latin capital letter a with breve":"Latin capital letter a with breve","Latin capital letter a with macron":"Latin capital letter a with macron","Latin capital letter a with ogonek":"Latin capital letter a with ogonek","Latin capital letter c with acute":"Latin capital letter c with acute","Latin capital letter c with caron":"Latin capital letter c with caron","Latin capital letter c with circumflex":"Latin capital letter c with circumflex","Latin capital letter c with dot above":"Latin capital letter c with dot above","Latin capital letter d with caron":"Latin capital letter d with caron","Latin capital letter d with stroke":"Latin capital letter d with stroke","Latin capital letter e with breve":"Latin capital letter e with breve","Latin capital letter e with caron":"Latin capital letter e with caron","Latin capital letter e with dot above":"Latin capital letter e with dot above","Latin capital letter e with macron":"Latin capital letter e with macron","Latin capital letter e with ogonek":"Latin capital letter e with ogonek","Latin capital letter eng":"Latin capital letter eng","Latin capital letter g with breve":"Latin capital letter g with breve","Latin capital letter g with cedilla":"Latin capital letter g with cedilla","Latin capital letter g with circumflex":"Latin capital letter g with circumflex","Latin capital letter g with dot above":"Latin capital letter g with dot above","Latin capital letter h with circumflex":"Latin capital letter h with circumflex","Latin capital letter h with stroke":"Latin capital letter h with stroke","Latin capital letter i with breve":"Latin capital letter i with breve","Latin capital letter i with dot above":"Latin capital letter i with dot above","Latin capital letter i with macron":"Latin capital letter i with macron","Latin capital letter i with ogonek":"Latin capital letter i with ogonek","Latin capital letter i with tilde":"Latin capital letter i with tilde","Latin capital letter j with circumflex":"Latin capital letter j with circumflex","Latin capital letter k with cedilla":"Latin capital letter k with cedilla","Latin capital letter l with acute":"Latin capital letter l with acute","Latin capital letter l with caron":"Latin capital letter l with caron","Latin capital letter l with cedilla":"Latin capital letter l with cedilla","Latin capital letter l with middle dot":"Latin capital letter l with middle dot","Latin capital letter l with stroke":"Latin capital letter l with stroke","Latin capital letter n with acute":"Latin capital letter n with acute","Latin capital letter n with caron":"Latin capital letter n with caron","Latin capital letter n with cedilla":"Latin capital letter n with cedilla","Latin capital letter o with breve":"Latin capital letter o with breve","Latin capital letter o with double acute":"Latin capital letter o with double acute","Latin capital letter o with macron":"Latin capital letter o with macron","Latin capital letter r with acute":"Latin capital letter r with acute","Latin capital letter r with caron":"Latin capital letter r with caron","Latin capital letter r with cedilla":"Latin capital letter r with cedilla","Latin capital letter s with acute":"Latin capital letter s with acute","Latin capital letter s with caron":"Latin capital letter s with caron","Latin capital letter s with cedilla":"Latin capital letter s with cedilla","Latin capital letter s with circumflex":"Latin capital letter s with circumflex","Latin capital letter t with caron":"Latin capital letter t with caron","Latin capital letter t with cedilla":"Latin capital letter t with cedilla","Latin capital letter t with stroke":"Latin capital letter t with stroke","Latin capital letter u with breve":"Latin capital letter u with breve","Latin capital letter u with double acute":"Latin capital letter u with double acute","Latin capital letter u with macron":"Latin capital letter u with macron","Latin capital letter u with ogonek":"Latin capital letter u with ogonek","Latin capital letter u with ring above":"Latin capital letter u with ring above","Latin capital letter u with tilde":"Latin capital letter u with tilde","Latin capital letter w with circumflex":"Latin capital letter w with circumflex","Latin capital letter y with circumflex":"Latin capital letter y with circumflex","Latin capital letter y with diaeresis":"Latin capital letter y with diaeresis","Latin capital letter z with acute":"Latin capital letter z with acute","Latin capital letter z with caron":"Latin capital letter z with caron","Latin capital letter z with dot above":"Latin capital letter z with dot above","Latin capital ligature ij":"Latin capital ligature ij","Latin capital ligature oe":"Latin capital ligature oe","Latin small letter a with breve":"Latin small letter a with breve","Latin small letter a with macron":"Latin small letter a with macron","Latin small letter a with ogonek":"Latin small letter a with ogonek","Latin small letter c with acute":"Latin small letter c with acute","Latin small letter c with caron":"Latin small letter c with caron","Latin small letter c with circumflex":"Latin small letter c with circumflex","Latin small letter c with dot above":"Latin small letter c with dot above","Latin small letter d with caron":"Latin small letter d with caron","Latin small letter d with stroke":"Latin small letter d with stroke","Latin small letter dotless i":"Latin small letter dotless i","Latin small letter e with breve":"Latin small letter e with breve","Latin small letter e with caron":"Latin small letter e with caron","Latin small letter e with dot above":"Latin small letter e with dot above","Latin small letter e with macron":"Latin small letter e with macron","Latin small letter e with ogonek":"Latin small letter e with ogonek","Latin small letter eng":"Latin small letter eng","Latin small letter f with hook":"Latin small letter f with hook","Latin small letter g with breve":"Latin small letter g with breve","Latin small letter g with cedilla":"Latin small letter g with cedilla","Latin small letter g with circumflex":"Latin small letter g with circumflex","Latin small letter g with dot above":"Latin small letter g with dot above","Latin small letter h with circumflex":"Latin small letter h with circumflex","Latin small letter h with stroke":"Latin small letter h with stroke","Latin small letter i with breve":"Latin small letter i with breve","Latin small letter i with macron":"Latin small letter i with macron","Latin small letter i with ogonek":"Latin small letter i with ogonek","Latin small letter i with tilde":"Latin small letter i with tilde","Latin small letter j with circumflex":"Latin small letter j with circumflex","Latin small letter k with cedilla":"Latin small letter k with cedilla","Latin small letter kra":"Latin small letter kra","Latin small letter l with acute":"Latin small letter l with acute","Latin small letter l with caron":"Latin small letter l with caron","Latin small letter l with cedilla":"Latin small letter l with cedilla","Latin small letter l with middle dot":"Latin small letter l with middle dot","Latin small letter l with stroke":"Latin small letter l with stroke","Latin small letter long s":"Latin small letter long s","Latin small letter n preceded by apostrophe":"Latin small letter n preceded by apostrophe","Latin small letter n with acute":"Latin small letter n with acute","Latin small letter n with caron":"Latin small letter n with caron","Latin small letter n with cedilla":"Latin small letter n with cedilla","Latin small letter o with breve":"Latin small letter o with breve","Latin small letter o with double acute":"Latin small letter o with double acute","Latin small letter o with macron":"Latin small letter o with macron","Latin small letter r with acute":"Latin small letter r with acute","Latin small letter r with caron":"Latin small letter r with caron","Latin small letter r with cedilla":"Latin small letter r with cedilla","Latin small letter s with acute":"Latin small letter s with acute","Latin small letter s with caron":"Latin small letter s with caron","Latin small letter s with cedilla":"Latin small letter s with cedilla","Latin small letter s with circumflex":"Latin small letter s with circumflex","Latin small letter t with caron":"Latin small letter t with caron","Latin small letter t with cedilla":"Latin small letter t with cedilla","Latin small letter t with stroke":"Latin small letter t with stroke","Latin small letter u with breve":"Latin small letter u with breve","Latin small letter u with double acute":"Latin small letter u with double acute","Latin small letter u with macron":"Latin small letter u with macron","Latin small letter u with ogonek":"Latin small letter u with ogonek","Latin small letter u with ring above":"Latin small letter u with ring above","Latin small letter u with tilde":"Latin small letter u with tilde","Latin small letter w with circumflex":"Latin small letter w with circumflex","Latin small letter y with circumflex":"Latin small letter y with circumflex","Latin small letter z with acute":"Latin small letter z with acute","Latin small letter z with caron":"Latin small letter z with caron","Latin small letter z with dot above":"Latin small letter z with dot above","Latin small ligature ij":"Latin small ligature ij","Latin small ligature oe":"Latin small ligature oe","Layout table":"Layout table","Leaving %0 code snippet":"Leaving %0 code snippet","Leaving a to-do list":"Leaving a to-do list","Leaving code snippet":"Leaving code snippet","Left aligned image":"Left aligned image","Left double quotation mark":"Left double quotation mark","Left single quotation mark":"Left single quotation mark","Left-pointing double angle quotation mark":"Left-pointing double angle quotation mark","leftwards arrow to bar":"leftwards arrow to bar","leftwards dashed arrow":"leftwards dashed arrow","leftwards double arrow":"leftwards double arrow","leftwards simple arrow":"leftwards simple arrow","Less-than or equal to":"Less-than or equal to","Less-than sign":"Less-than sign","Light blue":"Light blue","Light green":"Light green","Light grey":"Light grey",Link:"Link","Link image":"Link image","Link properties":"Link properties","Link URL":"Link URL","Link URL must not be empty.":"Link URL must not be empty.","Lira sign":"Lira sign","List properties":"List properties","Livre tournois sign":"Livre tournois sign","Logical and":"Logical and","Logical or":"Logical or","Lower-latin":"Lower-latin","Lower–roman":"Lower–roman",Macron:"Macron","Manat sign":"Manat sign","Match case":"Match case",Mathematical:"Mathematical",Media:"Media","Media embed":"Media embed","Media URL":"Media URL","media widget":"media widget",MENU_BAR_MENU_EDIT:"Edit",MENU_BAR_MENU_FILE:"File",MENU_BAR_MENU_FONT:"Font",MENU_BAR_MENU_FORMAT:"Format",MENU_BAR_MENU_HELP:"Help",MENU_BAR_MENU_INSERT:"Insert",MENU_BAR_MENU_TEXT:"Text",MENU_BAR_MENU_TOOLS:"Tools",MENU_BAR_MENU_VIEW:"View","Merge cell down":"Merge cell down","Merge cell left":"Merge cell left","Merge cell right":"Merge cell right","Merge cell up":"Merge cell up","Merge cells":"Merge cells","Mill sign":"Mill sign","Minus sign":"Minus sign","Move focus between form fields (inputs, buttons, etc.)":"Move focus between form fields (inputs, buttons, etc.)","Move focus from an editable area back to the parent widget":"Move focus from an editable area back to the parent widget","Move focus in and out of an active dialog window":"Move focus in and out of an active dialog window","Move focus to the menu bar, navigate between menu bars":"Move focus to the menu bar, navigate between menu bars","Move focus to the toolbar, navigate between toolbars":"Move focus to the toolbar, navigate between toolbars","Move out of a link":"Move out of a link","Move out of an inline code style":"Move out of an inline code style","Move the caret to allow typing directly after a widget":"Move the caret to allow typing directly after a widget","Move the caret to allow typing directly before a widget":"Move the caret to allow typing directly before a widget","Move the selection to the next cell":"Move the selection to the next cell","Move the selection to the previous cell":"Move the selection to the previous cell","Multiple styles":"Multiple styles","Multiplication sign":"Multiplication sign","N-ary product":"N-ary product","N-ary summation":"N-ary summation",Nabla:"Nabla","Naira sign":"Naira sign","Navigate through the table":"Navigate through the table","Navigate through the toolbar or menu bar":"Navigate through the toolbar or menu bar","New sheqel sign":"New sheqel sign",Next:"Next","Next result":"Next result","No links available":"No links available","No preview available":"No preview available","No results found":"No results found","No searchable items":"No searchable items",None:"None","Nordic mark sign":"Nordic mark sign","Not an element of":"Not an element of","Not equal to":"Not equal to","Not sign":"Not sign","Numbered List":"Numbered List","Numbered list styles toolbar":"Numbered list styles toolbar","on with exclamation mark with left right arrow above":"on with exclamation mark with left right arrow above","Open in a new tab":"Open in a new tab","Open link in new tab":"Open link in new tab","Open media in new tab":"Open media in new tab","Open the accessibility help dialog":"Open the accessibility help dialog",Orange:"Orange",Original:"Original",Outset:"Outset",Overline:"Overline",Padding:"Padding","Page break":"Page break",Paragraph:"Paragraph","Paragraph sign":"Paragraph sign","Partial differential":"Partial differential","Paste content":"Paste content","Paste content as plain text":"Paste content as plain text","Paste raw HTML here...":"Paste raw HTML here...","Paste the media URL in the input.":"Paste the media URL in the input.","Per mille sign":"Per mille sign","Per ten thousand sign":"Per ten thousand sign","Peseta sign":"Peseta sign","Peso sign":"Peso sign","Pink marker":"Pink marker","Plain text":"Plain text",'Please enter a valid color (e.g. "ff0000").':'Please enter a valid color (e.g. "ff0000").',"Plus-minus sign":"Plus-minus sign","Pound sign":"Pound sign","Press %0 for help.":"Press %0 for help.","Press Enter to type after or press Shift + Enter to type before the widget":"Press Enter to type after or press Shift + Enter to type before the widget",Previous:"Previous","Previous result":"Previous result","Proportional to":"Proportional to",Purple:"Purple","Question exclamation mark":"Question exclamation mark",Red:"Red","Red pen":"Red pen",Redo:"Redo","Registered sign":"Registered sign","Remove color":"Remove color","Remove Format":"Remove Format","Remove highlight":"Remove highlight",Replace:"Replace","Replace all":"Replace all","Replace from computer":"Replace from computer","Replace image":"Replace image","Replace image from computer":"Replace image from computer","Replace with…":"Replace with…","Resize image":"Resize image","Resize image (in %0)":"Resize image (in %0)","Resize image to %0":"Resize image to %0","Resize image to the original size":"Resize image to the original size","Restore default":"Restore default","Reversed order":"Reversed order","Reversed paragraph sign":"Reversed paragraph sign","Revert autoformatting action":"Revert autoformatting action","Rich Text Editor":"Rich Text Editor","Rich Text Editor. Editing area: %0":"Rich Text Editor. Editing area: %0",Ridge:"Ridge","Right aligned image":"Right aligned image","Right double quotation mark":"Right double quotation mark","Right single quotation mark":"Right single quotation mark","Right-pointing double angle quotation mark":"Right-pointing double angle quotation mark","rightwards arrow to bar":"rightwards arrow to bar","rightwards dashed arrow":"rightwards dashed arrow","rightwards double arrow":"rightwards double arrow","rightwards simple arrow":"rightwards simple arrow",Row:"Row","Ruble sign":"Ruble sign","Rupee sign":"Rupee sign",Save:"Save","Save changes":"Save changes","Saving changes":"Saving changes","Section sign":"Section sign","Select all":"Select all","Select column":"Select column","Select row":"Select row","Show blocks":"Show blocks","Show more items":"Show more items","Show source":"Show source","Side image":"Side image","Single left-pointing angle quotation mark":"Single left-pointing angle quotation mark","Single low-9 quotation mark":"Single low-9 quotation mark","Single right-pointing angle quotation mark":"Single right-pointing angle quotation mark",Small:"Small",Solid:"Solid","soon with rightwards arrow above":"soon with rightwards arrow above",Source:"Source","Special characters":"Special characters","Spesmilo sign":"Spesmilo sign","Split cell horizontally":"Split cell horizontally","Split cell vertically":"Split cell vertically",Square:"Square","Square root":"Square root","Start at":"Start at","Start index must be greater than 0.":"Start index must be greater than 0.",Strikethrough:"Strikethrough","Strikethrough text":"Strikethrough text",Style:"Style",Styles:"Styles",Subscript:"Subscript",Superscript:"Superscript",Table:"Table","Table Alignment":"Table Alignment","Table alignment toolbar":"Table alignment toolbar","Table cell text alignment":"Table cell text alignment","Table layout":"Table layout","Table properties":"Table properties","Table toolbar":"Table toolbar","Table type":"Table type","Table type options":"Table type options","Tenge sign":"Tenge sign",Text:"Text","Text alignment":"Text alignment","Text alignment toolbar":"Text alignment toolbar","Text alternative":"Text alternative","Text Alternative":"Text Alternative","Text highlight toolbar":"Text highlight toolbar","Text styles":"Text styles","Text to find must not be empty.":"Text to find must not be empty.",'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".':'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".',"The URL must not be empty.":"The URL must not be empty.",'The value is invalid. Try "10px" or "2em" or simply "2".':'The value is invalid. Try "10px" or "2em" or simply "2".',"The value must not be empty.":"The value must not be empty.","The value should be a plain number.":"The value should be a plain number.","There exists":"There exists","These keyboard shortcuts allow for quick access to content editing features.":"These keyboard shortcuts allow for quick access to content editing features.","This media URL is not supported.":"This media URL is not supported.","Tilde operator":"Tilde operator",Tiny:"Tiny","Tip: Find some text first in order to replace it.":"Tip: Find some text first in order to replace it.","Tip: Paste the URL into the content to embed faster.":"Tip: Paste the URL into the content to embed faster.","To-do List":"To-do List","Toggle caption off":"Toggle caption off","Toggle caption on":"Toggle caption on","Toggle the circle list style":"Toggle the circle list style","Toggle the decimal list style":"Toggle the decimal list style","Toggle the decimal with leading zero list style":"Toggle the decimal with leading zero list style","Toggle the disc list style":"Toggle the disc list style","Toggle the lower–latin list style":"Toggle the lower–latin list style","Toggle the lower–roman list style":"Toggle the lower–roman list style","Toggle the square list style":"Toggle the square list style","Toggle the upper–latin list style":"Toggle the upper–latin list style","Toggle the upper–roman list style":"Toggle the upper–roman list style","top with upwards arrow above":"top with upwards arrow above","Trade mark sign":"Trade mark sign","Tugrik sign":"Tugrik sign","Turkish lira sign":"Turkish lira sign",Turquoise:"Turquoise","Two dot leader":"Two dot leader",Underline:"Underline","Underline text":"Underline text",Undo:"Undo",Union:"Union",Unlink:"Unlink","up down arrow with base":"up down arrow with base",Update:"Update","Update image URL":"Update image URL","Upload failed":"Upload failed","Upload from computer":"Upload from computer","Upload image from computer":"Upload image from computer","Upload in progress":"Upload in progress","Uploading image":"Uploading image","Upper-latin":"Upper-latin","Upper-roman":"Upper-roman","upwards arrow to bar":"upwards arrow to bar","upwards dashed arrow":"upwards dashed arrow","upwards double arrow":"upwards double arrow","upwards simple arrow":"upwards simple arrow","Use the following keystrokes for more efficient navigation in the CKEditor 5 user interface.":"Use the following keystrokes for more efficient navigation in the CKEditor 5 user interface.","User interface and content navigation keystrokes":"User interface and content navigation keystrokes","Vertical text alignment toolbar":"Vertical text alignment toolbar","Via URL":"Via URL","Vulgar fraction one half":"Vulgar fraction one half","Vulgar fraction one quarter":"Vulgar fraction one quarter","Vulgar fraction three quarters":"Vulgar fraction three quarters",White:"White","Whole words only":"Whole words only","Widget toolbar":"Widget toolbar",Width:"Width","Won sign":"Won sign","Words: %0":"Words: %0","Wrap text":"Wrap text",Yellow:"Yellow","Yellow marker":"Yellow marker","Yen sign":"Yen sign","You have no image upload permissions.":"You have no image upload permissions."}),t.getPluralForm=function(e){return 1!=e}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),(()=>{var e={541(e,t,i){e.exports=i(341).isEqual},12(e,t){"use strict";Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t.getSymbols=function(e){return Object.getOwnPropertySymbols(e).filter((t=>Object.prototype.propertyIsEnumerable.call(e,t)))}},49(e,t){"use strict";Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t.getTag=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}},184(e,t){"use strict";Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t.argumentsTag="[object Arguments]",t.arrayBufferTag="[object ArrayBuffer]",t.arrayTag="[object Array]",t.bigInt64ArrayTag="[object BigInt64Array]",t.bigUint64ArrayTag="[object BigUint64Array]",t.booleanTag="[object Boolean]",t.dataViewTag="[object DataView]",t.dateTag="[object Date]",t.errorTag="[object Error]",t.float32ArrayTag="[object Float32Array]",t.float64ArrayTag="[object Float64Array]",t.functionTag="[object Function]",t.int16ArrayTag="[object Int16Array]",t.int32ArrayTag="[object Int32Array]",t.int8ArrayTag="[object Int8Array]",t.mapTag="[object Map]",t.numberTag="[object Number]",t.objectTag="[object Object]",t.regexpTag="[object RegExp]",t.setTag="[object Set]",t.stringTag="[object String]",t.symbolTag="[object Symbol]",t.uint16ArrayTag="[object Uint16Array]",t.uint32ArrayTag="[object Uint32Array]",t.uint8ArrayTag="[object Uint8Array]",t.uint8ClampedArrayTag="[object Uint8ClampedArray]"},761(e,t){"use strict";Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t.eq=function(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}},502(e,t){"use strict";Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t.noop=function(){}},341(e,t,i){"use strict";Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const n=i(993),o=i(502);t.isEqual=function(e,t){return n.isEqualWith(e,t,o.noop)}},993(e,t,i){"use strict";Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const n=i(74),o=i(12),s=i(49),r=i(184),a=i(761);function l(e,t,i,n,o,s,r){const a=r(e,t,i,n,o,s);if(void 0!==a)return a;if(typeof e==typeof t)switch(typeof e){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return e===t;case"number":return e===t||Object.is(e,t);case"object":return c(e,t,s,r)}return c(e,t,s,r)}function c(e,t,i,u){if(Object.is(e,t))return!0;let d=s.getTag(e),h=s.getTag(t);if(d===r.argumentsTag&&(d=r.objectTag),h===r.argumentsTag&&(h=r.objectTag),d!==h)return!1;switch(d){case r.stringTag:return e.toString()===t.toString();case r.numberTag:{const i=e.valueOf(),n=t.valueOf();return a.eq(i,n)}case r.booleanTag:case r.dateTag:case r.symbolTag:return Object.is(e.valueOf(),t.valueOf());case r.regexpTag:return e.source===t.source&&e.flags===t.flags;case r.functionTag:return e===t}const m=(i=i??new Map).get(e),g=i.get(t);if(null!=m&&null!=g)return m===t;i.set(e,t),i.set(t,e);try{switch(d){case r.mapTag:if(e.size!==t.size)return!1;for(const[n,o]of e.entries())if(!t.has(n)||!l(o,t.get(n),n,e,t,i,u))return!1;return!0;case r.setTag:{if(e.size!==t.size)return!1;const n=Array.from(e.values()),o=Array.from(t.values());for(let s=0;sl(r,n,void 0,e,t,i,u)));if(-1===a)return!1;o.splice(a,1)}return!0}case r.arrayTag:case r.uint8ArrayTag:case r.uint8ClampedArrayTag:case r.uint16ArrayTag:case r.uint32ArrayTag:case r.bigUint64ArrayTag:case r.int8ArrayTag:case r.int16ArrayTag:case r.int32ArrayTag:case r.bigInt64ArrayTag:case r.float32ArrayTag:case r.float64ArrayTag:if("undefined"!=typeof Buffer&&Buffer.isBuffer(e)!==Buffer.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(let n=0;n{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{"use strict";var e={};i.r(e),i.d(e,{attentionMarkers:()=>YI,contentInitial:()=>qI,disable:()=>QI,document:()=>$I,flow:()=>WI,flowInitial:()=>jI,insideSpan:()=>JI,string:()=>GI,text:()=>KI});var t={};let n;i.r(t),i.d(t,{boolean:()=>JV,booleanish:()=>YV,commaOrSpaceSeparated:()=>tO,commaSeparated:()=>eO,number:()=>XV,overloadedBoolean:()=>QV,spaceSeparated:()=>ZV});try{n={window,document}}catch{n={window:{},document:{}}}function o(){try{return navigator.userAgent.toLowerCase()}catch{return""}}const s=o(),r={isMac:a(s),isWindows:l(s),isGecko:c(s),isSafari:u(s),isiOS:d(s),isAndroid:h(s),isBlink:m(s),get isMediaForcedColors(){return!!n.window.matchMedia&&n.window.matchMedia("(forced-colors: active)").matches},get isMotionReduced(){return!!n.window.matchMedia&&n.window.matchMedia("(prefers-reduced-motion)").matches},features:{isRegExpUnicodePropertySupported:g()}};function a(e){return e.indexOf("macintosh")>-1}function l(e){return e.indexOf("windows")>-1}function c(e){return!!e.match(/gecko\/\d+/)}function u(e){return e.indexOf(" applewebkit/")>-1&&-1===e.indexOf("chrome")}function d(e){return!!e.match(/iphone|ipad/i)||a(e)&&navigator.maxTouchPoints>0}function h(e){return e.indexOf("android")>-1}function m(e){return e.indexOf("chrome/")>-1&&e.indexOf("edge/")<0}function g(){let e=!1;try{e=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch{}return e}function f(e,t,i,n){i=i||function(e,t){return e===t};const o=Array.isArray(e)?e:Array.prototype.slice.call(e),s=Array.isArray(t)?t:Array.prototype.slice.call(t),r=function(e,t,i){const n=p(e,t,i);if(-1===n)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const o=p(b(e,n),b(t,n),i);return{firstIndex:n,lastIndexOld:e.length-o,lastIndexNew:t.length-o}}(o,s,i),a=n?function(e,t){const{firstIndex:i,lastIndexOld:n,lastIndexNew:o}=e;if(-1===i)return Array(t).fill("equal");let s=[];return i>0&&(s=s.concat(Array(i).fill("equal"))),o-i>0&&(s=s.concat(Array(o-i).fill("insert"))),n-i>0&&(s=s.concat(Array(n-i).fill("delete"))),o0&&i.push({index:n,type:"insert",values:e.slice(n,s)}),o-n>0&&i.push({index:n+(s-n),type:"delete",howMany:o-n}),i}(s,r);return a}function p(e,t,i){for(let n=0;n200||o>200||n+o>300)return w.fastDiff(e,t,i,!0);let s,r;if(oc?-1:1;u[n+h]&&(u[n]=u[n+h].slice(0)),u[n]||(u[n]=[]),u[n].push(o>c?s:r);let m=Math.max(o,c),g=m-n;for(;gc;m--)d[m]=h(m);d[c]=h(c),g++}while(d[c]!==l);return u[c].slice(1)}w.fastDiff=f;class v{source;name;path;stop;off;return;constructor(e,t){this.source=e,this.name=t,this.path=[],this.stop=function e(){e.called=!0},this.off=function e(){e.called=!0}}}const y=new Array(256).fill("").map(((e,t)=>("0"+t.toString(16)).slice(-2)));function _(){const[e,t,i,n]=crypto.getRandomValues(new Uint32Array(4));return"e"+y[255&e]+y[e>>8&255]+y[e>>16&255]+y[e>>24&255]+y[255&t]+y[t>>8&255]+y[t>>16&255]+y[t>>24&255]+y[255&i]+y[i>>8&255]+y[i>>16&255]+y[i>>24&255]+y[255&n]+y[n>>8&255]+y[n>>16&255]+y[n>>24&255]}const k={get(e="normal"){return"number"!=typeof e?this[e]||this.normal:e},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};function C(e,t){const i=k.get(t.priority);let n=0,o=e.length;for(;n>1;k.get(e[t].priority){if("object"==typeof t&&null!==t){if(n.has(t))return`[object ${t.constructor.name}]`;n.add(t)}return t}))}`:"")+T(e)+(i?`\nOriginal error: ${i.name}: ${i.message}`:"")}(e,i,n)),this.name="CKEditorError",this.context=t,this.data=i,n&&(this.stack=n.stack)}is(e){return"CKEditorError"===e}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;throw new x("unexpected-error",t,void 0,e)}}function A(e,t){console.warn(...E(e,t))}function T(e){return`\nRead more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-${e}`}function E(e,t){const i=T(e);return t?[e,t,i]:[e,i]}const S=new Date(2026,1,11);if(globalThis.CKEDITOR_VERSION)throw new x("ckeditor-duplicated-modules",null);globalThis.CKEDITOR_VERSION="47.5.0";const P=Symbol("listeningTo"),I=Symbol("emitterId"),V=Symbol("delegations"),O=R(Object);function R(e){return e?class extends e{on(e,t,i){this.listenTo(this,e,t,i)}once(e,t,i){let n=!1;this.listenTo(this,e,((e,...i)=>{n||(n=!0,e.off(),t.call(this,e,...i))}),i)}off(e,t){this.stopListening(this,e,t)}listenTo(e,t,i,n={}){let o,s;this[P]||(this[P]={});const r=this[P];B(e)||L(e);const a=B(e);(o=r[a])||(o=r[a]={emitter:e,callbacks:{}}),(s=o.callbacks[t])||(s=o.callbacks[t]=[]),s.push(i),function(e,t,i,n,o){t._addEventListener?t._addEventListener(i,n,o):e._addEventListener.call(t,i,n,o)}(this,e,t,i,n)}stopListening(e,t,i){const n=this[P];let o=e&&B(e);const s=n&&o?n[o]:void 0,r=s&&t?s.callbacks[t]:void 0;if(!(!n||e&&!s||t&&!r))if(i)D(this,e,t,i),-1!==r.indexOf(i)&&(1===r.length?delete s.callbacks[t]:D(this,e,t,i));else if(r){for(;i=r.pop();)D(this,e,t,i);delete s.callbacks[t]}else if(s){for(t in s.callbacks)this.stopListening(e,t);delete n[o]}else{for(o in n)this.stopListening(n[o].emitter);delete this[P]}}fire(e,...t){try{const i=e instanceof v?e:new v(this,e),n=i.name;let o=function(e,t){if(!e._events)return null;let i=t;do{const t=e._events[i];if(t&&t.callbacks&&t.callbacks.length)return t.callbacks;const n=i.lastIndexOf(":");i=n>-1?i.substring(0,n):""}while(i);return null}(this,n);if(i.path.push(this),o){o=o.slice();for(let e=0;e{this[V]||(this[V]=new Map),e.forEach((e=>{const n=this[V].get(e);n?n.set(t,i):this[V].set(e,new Map([[t,i]]))}))}}}stopDelegating(e,t){if(this[V])if(e)if(t){const i=this[V].get(e);i&&i.delete(t)}else this[V].delete(e);else this[V].clear()}_addEventListener(e,t,i){!function(e,t){const i=M(e);if(i[t])return;let n=t,o=null;const s=[];for(;""!==n&&!i[n];)i[n]={callbacks:[],childEvents:[]},s.push(i[n]),o&&i[n].childEvents.push(o),o=n,n=n.substr(0,n.lastIndexOf(":"));if(""!==n){for(const e of s)e.callbacks=i[n].callbacks.slice();i[n].childEvents.push(o)}}(this,e);const n=N(this,e),o={callback:t,priority:k.get(i.priority)};for(const e of n)C(e,o)}_removeEventListener(e,t){const i=N(this,e);for(const e of i)for(let i=0;i{this.set(t,e[t])}),this);K(this);const i=this[H];if(e in this&&!i.has(e))throw new x("observable-set-cannot-override",this);Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>i.get(e),set(t){const n=i.get(e);let o=this.fire(`set:${e}`,e,t,n);void 0===o&&(o=t),n===o&&i.has(e)||(i.set(e,o),this.fire(`change:${e}`,e,o,n))}}),this[e]=t}bind(...e){if(!e.length||!Q(e))throw new x("observable-bind-wrong-properties",this);if(new Set(e).size!==e.length)throw new x("observable-bind-duplicate-properties",this);K(this);const t=this[$];e.forEach((e=>{if(t.has(e))throw new x("observable-bind-rebind",this)}));const i=new Map;return e.forEach((e=>{const n={property:e,to:[]};t.set(e,n),i.set(e,n)})),{to:J,toMany:Y,_observable:this,_bindProperties:e,_to:[],_bindings:i}}unbind(...e){if(!this[H])return;const t=this[$],i=this[U];if(e.length){if(!Q(e))throw new x("observable-unbind-wrong-properties",this);e.forEach((e=>{const n=t.get(e);n&&(n.to.forEach((([e,t])=>{const o=i.get(e),s=o[t];s.delete(n),s.size||delete o[t],Object.keys(o).length||(i.delete(e),this.stopListening(e,"change"))})),t.delete(e))}))}else i.forEach(((e,t)=>{this.stopListening(t,"change")})),i.clear(),t.clear()}decorate(e){K(this);const t=this[e];if(!t)throw new x("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:e});this.on(e,((e,i)=>{e.return=t.apply(this,i)})),this[e]=function(...t){return this.fire(e,t)},this[e][j]=t,this[q]||(this[q]=[]),this[q].push(e)}stopListening(e,t,i){if(!e&&this[q]){for(const e of this[q])this[e]=this[e][j];delete this[q]}super.stopListening(e,t,i)}[H];[q];[$];[U]}:W}function K(e){e[H]||(Object.defineProperty(e,H,{value:new Map}),Object.defineProperty(e,U,{value:new Map}),Object.defineProperty(e,$,{value:new Map}))}function J(...e){const t=function(...e){if(!e.length)throw new x("observable-bind-to-parse-error",null);const t={to:[]};let i;return"function"==typeof e[e.length-1]&&(t.callback=e.pop()),e.forEach((e=>{if("string"==typeof e)i.properties.push(e);else{if("object"!=typeof e)throw new x("observable-bind-to-parse-error",null);i={observable:e,properties:[]},t.to.push(i)}})),t}(...e),i=Array.from(this._bindings.keys()),n=i.length;if(!t.callback&&t.to.length>1)throw new x("observable-bind-to-no-callback",this);if(n>1&&t.callback)throw new x("observable-bind-to-extra-callback",this);var o;t.to.forEach((e=>{if(e.properties.length&&e.properties.length!==n)throw new x("observable-bind-to-properties-length",this);e.properties.length||(e.properties=this._bindProperties)})),this._to=t.to,t.callback&&(this._bindings.get(i[0]).callback=t.callback),o=this._observable,this._to.forEach((e=>{const t=o[U];let i;t.get(e.observable)||o.listenTo(e.observable,"change",((n,s)=>{i=t.get(e.observable)[s],i&&i.forEach((e=>{X(o,e.property)}))}))})),function(e){let t;e._bindings.forEach(((i,n)=>{e._to.forEach((o=>{t=o.properties[i.callback?0:e._bindProperties.indexOf(n)],i.to.push([o.observable,t]),function(e,t,i,n){const o=e[U],s=o.get(i),r=s||{};r[n]||(r[n]=new Set),r[n].add(t),s||o.set(i,r)}(e._observable,i,o.observable,t)}))}))}(this),this._bindProperties.forEach((e=>{X(this._observable,e)}))}function Y(e,t,i){if(this._bindings.size>1)throw new x("observable-bind-to-many-not-one-binding",this);this.to(...function(e,t){const i=e.map((e=>[e,t]));return Array.prototype.concat.apply([],i)}(e,t),i)}function Q(e){return e.every((e=>"string"==typeof e))}function X(e,t){const i=e[$].get(t);let n;i.callback?n=i.callback.apply(e,i.to.map((e=>e[0][e[1]]))):(n=i.to[0],n=n[0][n[1]]),Object.prototype.hasOwnProperty.call(e,t)?e[t]=n:e.set(t,n)}class Z{_replacedElements;constructor(){this._replacedElements=[]}replace(e,t){this._replacedElements.push({element:e,newElement:t}),e.style.display="none",t&&e.parentNode.insertBefore(t,e.nextSibling)}restore(){this._replacedElements.forEach((({element:e,newElement:t})=>{e.style.display="",t&&t.remove()})),this._replacedElements=[]}}function ee(e){let t=0;for(const i of e)t++;return t}function te(e,t){const i=Math.min(e.length,t.length);for(let n=0;nObject.prototype.propertyIsEnumerable.call(e,t)))}function ae(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const le="[object RegExp]",ce="[object String]",ue="[object Number]",de="[object Boolean]",he="[object Arguments]",me="[object Symbol]",ge="[object Date]",fe="[object Map]",pe="[object Set]",be="[object Array]",we="[object ArrayBuffer]",ve="[object Object]",ye="[object DataView]",_e="[object Uint8Array]",ke="[object Uint8ClampedArray]",Ce="[object Uint16Array]",xe="[object Uint32Array]",Ae="[object Int8Array]",Te="[object Int16Array]",Ee="[object Int32Array]",Se="[object Float32Array]",Pe="[object Float64Array]";function Ie(e){return null==e||"object"!=typeof e&&"function"!=typeof e}function Ve(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Oe(e,t,i,n=new Map,o=void 0){const s=o?.(e,t,i,n);if(null!=s)return s;if(Ie(e))return e;if(n.has(e))return n.get(e);if(Array.isArray(e)){const t=new Array(e.length);n.set(e,t);for(let s=0;s{const r=t?.(i,n,o,s);if(null!=r)return r;if("object"==typeof e)switch(Object.prototype.toString.call(e)){case ue:case ce:case de:{const t=new e.constructor(e?.valueOf());return Re(t,e),t}case he:{const t={};return Re(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}}))}function Be(e){return"object"==typeof e&&null!==e}function Me(e){return Be(e)&&1===e.nodeType&&!se(e)}class Ne{_config;constructor(e,t){this._config=Object.create(null),t&&this.define(Fe(t)),e&&this._setObjectToTarget(this._config,e)}set(e,t){this._setToTarget(this._config,e,t)}define(e,t){this._setToTarget(this._config,e,t,!0)}get(e){return this._getFromSource(this._config,e)}*names(){for(const e of Object.keys(this._config))yield e}_setToTarget(e,t,i,n=!1){if(se(t))return void this._setObjectToTarget(e,t,n);const o=t.split(".");t=o.pop();for(const t of o)se(e[t])||(e[t]=Object.create(null)),e=e[t];if(se(i))return se(e[t])||(e[t]=Object.create(null)),e=e[t],void this._setObjectToTarget(e,i,n);n&&void 0!==e[t]||(e[t]=i)}_getFromSource(e,t){const i=t.split(".");t=i.pop();for(const t of i){if(!se(e[t])){e=null;break}e=e[t]}return e?Fe(e[t]):void 0}_setObjectToTarget(e,t,i){Object.keys(t).forEach((n=>{this._setToTarget(e,n,t[n],i)}))}}function Fe(e){return Le(e,De)}function De(e){return Me(e)||"function"==typeof e?e:void 0}function ze(e){if(e){if(e.defaultView)return e instanceof e.defaultView.Document;if(e.ownerDocument&&e.ownerDocument.defaultView)return e instanceof e.ownerDocument.defaultView.Node}return!1}function He(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}const Ue=$e(R());function $e(e){return e?class extends e{listenTo(e,t,i,o={}){if(ze(e)||He(e)||e instanceof n.window.EventTarget){const n={capture:!!o.useCapture,passive:!!o.usePassive},s=this._getProxyEmitter(e,n)||new qe(e,n);this.listenTo(s,t,i,o)}else super.listenTo(e,t,i,o)}stopListening(e,t,i){if(ze(e)||He(e)||e instanceof n.window.EventTarget){const n=this._getAllProxyEmitters(e);for(const e of n)this.stopListening(e,t,i)}else super.stopListening(e,t,i)}_getProxyEmitter(e,t){return function(e,t){const i=e[P];return i&&i[t]?i[t].emitter:null}(this,je(e,t))}_getAllProxyEmitters(e){return[{capture:!1,passive:!1},{capture:!1,passive:!0},{capture:!0,passive:!1},{capture:!0,passive:!0}].map((t=>this._getProxyEmitter(e,t))).filter((e=>!!e))}}:Ue}class qe extends(R()){_domNode;_options;constructor(e,t){super(),L(this,je(e,t)),this._domNode=e,this._options=t}_domListeners;attach(e){if(this._domListeners&&this._domListeners[e])return;const t=this._createDomListener(e);this._domNode.addEventListener(e,t,this._options),this._domListeners||(this._domListeners={}),this._domListeners[e]=t}detach(e){let t;!this._domListeners[e]||(t=this._events[e])&&t.callbacks.length||this._domListeners[e].removeListener()}_addEventListener(e,t,i){this.attach(e),R().prototype._addEventListener.call(this,e,t,i)}_removeEventListener(e,t){R().prototype._removeEventListener.call(this,e,t),this.detach(e)}_createDomListener(e){const t=t=>{this.fire(e,t)};return t.removeListener=()=>{this._domNode.removeEventListener(e,t,this._options),delete this._domListeners[e]},t}}function je(e,t){let i=function(e){return e["data-ck-expando"]||(e["data-ck-expando"]=_())}(e);for(const e of Object.keys(t).sort())t[e]&&(i+="-"+e);return i}function We(e){if(!e.target)return null;const t=e.target.ownerDocument,i=e.clientX,n=e.clientY;let o=null;return t.caretRangeFromPoint&&t.caretRangeFromPoint(i,n)?o=t.caretRangeFromPoint(i,n):e.rangeParent&&(o=t.createRange(),o.setStart(e.rangeParent,e.rangeOffset),o.collapse(!0)),o}function Ge(e){return e&&e.parentNode?e.offsetParent===n.document.body?null:e.offsetParent:null}function Ke(e){return"[object Text]"==Object.prototype.toString.call(e)}function Je(e){return"[object Range]"==Object.prototype.toString.apply(e)}function Ye(e){const t=e.ownerDocument.defaultView.getComputedStyle(e);return{top:parseInt(t.borderTopWidth,10),right:parseInt(t.borderRightWidth,10),bottom:parseInt(t.borderBottomWidth,10),left:parseInt(t.borderLeftWidth,10)}}const Qe=["top","right","bottom","left","width","height"],Xe=new Set(["relative","absolute","fixed","sticky"]);class Ze{top;right;bottom;left;width;height;_source;constructor(e){const t=Je(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),it(e)||t)if(t){const t=Ze.getDomRangeRects(e);et(this,Ze.getBoundingRect(t))}else et(this,e.getBoundingClientRect());else if(He(e)){const{innerWidth:t,innerHeight:i}=e;et(this,{top:0,right:t,bottom:i,left:0,width:t,height:i})}else et(this,e)}clone(){return new Ze(this)}moveTo(e,t){return this.top=t,this.right=e+this.width,this.bottom=t+this.height,this.left=e,this}moveBy(e,t){return this.top+=t,this.right+=e,this.left+=e,this.bottom+=t,this}getIntersection(e){const t={top:Math.max(this.top,e.top),right:Math.min(this.right,e.right),bottom:Math.min(this.bottom,e.bottom),left:Math.max(this.left,e.left),width:0,height:0};if(t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0)return null;{const e=new Ze(t);return e._source=this._source,e}}getIntersectionArea(e){const t=this.getIntersection(e);return t?t.getArea():0}getArea(){return this.width*this.height}getVisible(){const e=this._source;let t=this.clone();if(tt(e))return t;let i,n=e,o=e.parentNode||e.commonAncestorContainer;for(;o&&!tt(o);){const e="visible"===((s=o)instanceof HTMLElement?s.ownerDocument.defaultView.getComputedStyle(s).overflow:"visible");if(ot(n)&&(i=n),e||i&&"absolute"===nt(i)&&!ot(o)){n=o,o=o.parentNode;continue}const r=new Ze(o),a=t.getIntersection(r);if(!a)return null;a.getArea(){for(const t of e){const e=st._getElementCallbacks(t.target);if(e)for(const i of e)i(t)}}))}}function rt(e,t){e instanceof HTMLTextAreaElement&&(e.value=t),e.innerHTML=t}function at(e){return t=>t+e}function lt(e){let t=0;for(;e.previousSibling;)e=e.previousSibling,t++;return t}function ct(e,t,i){e.insertBefore(i,e.childNodes[t]||null)}function ut(e){return e&&e.nodeType===Node.COMMENT_NODE}function dt(e){try{n.document.createAttribute(e)}catch{return!1}return!0}function ht(e){return!!e&&(Ke(e)?ht(e.parentElement):!!e.getClientRects&&!!e.getClientRects().length)}function mt(e){return"function"==typeof e}function gt({element:e,target:t,positions:i,limiter:n,fitInViewport:o,viewportOffsetConfig:s}){mt(t)&&(t=t()),mt(n)&&(n=n());const r=Ge(e),a=pt(s),l=new Ze(e),c=ft(t,a);let u;if(!c||!a.getIntersection(c))return null;const d={targetRect:c,elementRect:l,positionedElementAncestor:r,viewportRect:a};if(n||o){if(n){const e=ft(n,a);e&&(d.limiterRect=e)}u=function(e,t){const{elementRect:i}=t,n=i.getArea(),o=e.map((e=>new bt(e,t))).filter((e=>!!e.name));let s=0,r=null;for(const e of o){const{limiterIntersectionArea:t,viewportIntersectionArea:i}=e;if(t===n)return e;const o=i**2+t**2;o>s&&(s=o,r=e)}return r}(i,d)}else u=new bt(i[0],d);return u}function ft(e,t){const i=new Ze(e).getVisible();return i?i.getIntersection(t):null}function pt(e){e=Object.assign({top:0,bottom:0,left:0,right:0},e);const t=new Ze(n.window);return t.top+=e.top,t.height-=e.top,t.bottom-=e.bottom,t.height-=e.bottom,t.left+=e.left,t.right-=e.right,t.width-=e.left+e.right,t}class bt{name;config;_positioningFunctionCoordinates;_options;_cachedRect;_cachedAbsoluteRect;constructor(e,t){const i=e(t.targetRect,t.elementRect,t.viewportRect,t.limiterRect);if(!i)return;const{left:n,top:o,name:s,config:r}=i;this.name=s,this.config=r,this._positioningFunctionCoordinates={left:n,top:o},this._options=t}get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get limiterIntersectionArea(){const e=this._options.limiterRect;return e?e.getIntersectionArea(this._rect):0}get viewportIntersectionArea(){return this._options.viewportRect.getIntersectionArea(this._rect)}get _rect(){return this._cachedRect||(this._cachedRect=this._options.elementRect.clone().moveTo(this._positioningFunctionCoordinates.left,this._positioningFunctionCoordinates.top)),this._cachedRect}get _absoluteRect(){return this._cachedAbsoluteRect||(this._cachedAbsoluteRect=this._rect.toAbsoluteRect()),this._cachedAbsoluteRect}}function wt(e){const t=e.parentNode;t&&t.removeChild(e)}function vt(){const e=n.window.visualViewport;return e&&(r.isiOS||r.isSafari)?{left:Math.max(Math.round(e.offsetLeft),0),top:Math.max(Math.round(e.offsetTop),0)}:{left:0,top:0}}function yt({target:e,viewportOffset:t=0,ancestorOffset:i=0,alignToTop:n,forceScroll:o}){const s=Et(e);let r=s,a=null;for(t=function(e){return"number"==typeof e?{top:e,bottom:e,left:e,right:e}:e}(t);r;){let l;l=St(r==s?e:a),kt({parent:l,getRect:()=>Pt(e,r),alignToTop:n,ancestorOffset:i,forceScroll:o});let c=Pt(e,r);const u=Pt(l,r);if(c.height>u.height){const e=c.getIntersection(u);e&&(c=e)}if(_t({window:r,rect:c,viewportOffset:t,alignToTop:n,forceScroll:o}),r.parent!=r){if(a=r.frameElement,r=r.parent,!a)return}else r=null}}function _t({window:e,rect:t,alignToTop:i,forceScroll:n,viewportOffset:o}){const s=t.clone().moveBy(0,o.bottom),r=t.clone().moveBy(0,-o.top),a=new Ze(e).excludeScrollbarsAndBorders(),l=i&&n,c=[r,s].every((e=>a.contains(e)));let{scrollX:u,scrollY:d}=e;const h=u,m=d;l?d-=a.top-t.top+o.top:c||(xt(r,a)?d-=a.top-t.top+o.top:Ct(s,a)&&(d+=i?t.top-a.top-o.top:t.bottom-a.bottom+o.bottom)),c||(At(t,a)?u-=a.left-t.left+o.left:Tt(t,a)&&(u+=t.right-a.right+o.right)),u==h&&d===m||e.scrollTo(u,d)}function kt({parent:e,getRect:t,alignToTop:i,forceScroll:n,ancestorOffset:o=0,limiterElement:s}){const r=Et(e),a=i&&n;let l,c,u;const d=s||r.document.body;for(;e!=d;)c=t(),l=new Ze(e).excludeScrollbarsAndBorders(),u=l.contains(c),a?e.scrollTop-=l.top-c.top+o:u||(xt(c,l)?e.scrollTop-=l.top-c.top+o:Ct(c,l)&&(e.scrollTop+=i?c.top-l.top-o:c.bottom-l.bottom+o)),u||(At(c,l)?e.scrollLeft-=l.left-c.left+o:Tt(c,l)&&(e.scrollLeft+=c.right-l.right+o)),e=e.parentNode}function Ct(e,t){return e.bottom>t.bottom}function xt(e,t){return e.topt.right}function Et(e){return Je(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function St(e){if(Je(e)){let t=e.commonAncestorContainer;return Ke(t)&&(t=t.parentNode),t}return e.parentNode}function Pt(e,t){const i=Et(e),n=new Ze(e);if(i===t)return n;{let e=i;for(;e!=t;){const t=e.frameElement,i=new Ze(t).excludeScrollbarsAndBorders();n.moveBy(i.left,i.top),e=e.parent}}return n}const It={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},Vt={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},Ot={37:"←",38:"↑",39:"→",40:"↓",9:"⇥",33:"Page Up",34:"Page Down"},Rt=Dt(),Lt=Object.fromEntries(Object.entries(Rt).map((([e,t])=>{let i;return i=t in Ot?Ot[t]:e.charAt(0).toUpperCase()+e.slice(1),[t,i]})));function Bt(e){let t;if("string"==typeof e){if(t=Rt[e.toLowerCase()],!t)throw new x("keyboard-unknown-key",null,{key:e})}else t=e.keyCode+(e.altKey?Rt.alt:0)+(e.ctrlKey?Rt.ctrl:0)+(e.shiftKey?Rt.shift:0)+(e.metaKey?Rt.cmd:0);return t}function Mt(e){return"string"==typeof e&&(e=function(e){return e.split("+").map((e=>e.trim()))}(e)),e.map((e=>"string"==typeof e?function(e){if(e.endsWith("!"))return Bt(e.slice(0,-1));const t=Bt(e);return(r.isMac||r.isiOS)&&t==Rt.ctrl?Rt.cmd:t}(e):e)).reduce(((e,t)=>t+e),0)}function Nt(e,t){let i=Mt(e);const n=t?"Mac"===t:r.isMac||r.isiOS;return Object.entries(n?It:Vt).reduce(((e,[t,n])=>(i&Rt[t]&&(i&=~Rt[t],e+=n),e)),"")+(i?Lt[i]:"")}function Ft(e,t){const i="ltr"===t;switch(e){case Rt.arrowleft:return i?"left":"right";case Rt.arrowright:return i?"right":"left";case Rt.arrowup:return"up";case Rt.arrowdown:return"down"}}function Dt(){const e={pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,backspace:8,delete:46,enter:13,space:32,esc:27,tab:9,ctrl:1114112,shift:2228224,alt:4456448,cmd:8912896};for(let t=65;t<=90;t++)e[String.fromCharCode(t).toLowerCase()]=t;for(let t=48;t<=57;t++)e[t-48]=t;for(let t=112;t<=123;t++)e["f"+(t-111)]=t;return Object.assign(e,{"'":222,",":108,"-":109,".":110,"/":111,";":186,"=":187,"[":219,"\\":220,"]":221,"`":223}),e}function zt(e){return Array.isArray(e)?e:[e]}function Ht(e){return Le(e)}function Ut(e){return"__proto__"===e}function $t(e){return null!==e&&"object"==typeof e&&"[object Arguments]"===ae(e)}function qt(e){return Ve(e)}function jt(e,...t){const i=t.slice(0,-1),n=t[t.length-1];let o=e;for(let e=0;eKt(e,t))):e}(i),this.t=(e,t)=>this._t(e,t)}_t(e,t=[]){t=zt(t),"string"==typeof e&&(e={string:e});const i=e.plural?t[0]:1;return function(e,t){return e.replace(/%(\d+)/g,((e,i)=>i1===e?0:1),u=l[a];return"string"==typeof u?u:u[Number(c(i))]}(this.uiLanguage,e,i,this.translations),t)}}class Xt extends(R()){_items;_itemMap;_idProperty;_bindToCollection;_bindToExternalToInternalMap;_bindToInternalToExternalMap;_skippedIndexesFromExternal;constructor(e={},t={}){super();const i=ie(e);if(i||(t=e),this._items=[],this._itemMap=new Map,this._idProperty=t.idProperty||"id",this._bindToExternalToInternalMap=new WeakMap,this._bindToInternalToExternalMap=new WeakMap,this._skippedIndexesFromExternal=[],i)for(const t of e)this._items.push(t),this._itemMap.set(this._getItemIdBeforeAdding(t),t)}get length(){return this._items.length}get first(){return this._items[0]||null}get last(){return this._items[this.length-1]||null}add(e,t){return this.addMany([e],t)}addMany(e,t){if(void 0===t)t=this._items.length;else if(t>this._items.length||t<0)throw new x("collection-add-item-invalid-index",this);let i=0;for(const n of e){const e=this._getItemIdBeforeAdding(n),o=t+i;this._items.splice(o,0,n),this._itemMap.set(e,n),this.fire("add",n,o),i++}return this.fire("change",{added:e,removed:[],index:t}),this}get(e){let t;if("string"==typeof e)t=this._itemMap.get(e);else{if("number"!=typeof e)throw new x("collection-get-invalid-arg",this);t=this._items[e]}return t||null}has(e){if("string"==typeof e)return this._itemMap.has(e);{const t=e[this._idProperty];return t&&this._itemMap.has(t)}}getIndex(e){let t;return t="string"==typeof e?this._itemMap.get(e):e,t?this._items.indexOf(t):-1}remove(e){const[t,i]=this._remove(e);return this.fire("change",{added:[],removed:[t],index:i}),t}map(e,t){return this._items.map(e,t)}forEach(e,t){this._items.forEach(e,t)}find(e,t){return this._items.find(e,t)}filter(e,t){return this._items.filter(e,t)}clear(){this._bindToCollection&&(this.stopListening(this._bindToCollection),this._bindToCollection=null);const e=Array.from(this._items);for(;this.length;)this._remove(0);this.fire("change",{added:[],removed:e,index:0})}bindTo(e){if(this._bindToCollection)throw new x("collection-bind-to-rebind",this);return this._bindToCollection=e,{as:e=>{this._setUpBindToBinding((t=>new e(t)))},using:e=>{"function"==typeof e?this._setUpBindToBinding(e):this._setUpBindToBinding((t=>t[e]))}}}_setUpBindToBinding(e){const t=this._bindToCollection,i=(i,n,o)=>{const s=t._bindToCollection==this,r=t._bindToInternalToExternalMap.get(n);if(s&&r)this._bindToExternalToInternalMap.set(n,r),this._bindToInternalToExternalMap.set(r,n);else{const i=e(n);if(!i)return void this._skippedIndexesFromExternal.push(o);let s=o;for(const e of this._skippedIndexesFromExternal)o>e&&s--;for(const e of t._skippedIndexesFromExternal)s>=e&&s++;this._bindToExternalToInternalMap.set(n,i),this._bindToInternalToExternalMap.set(i,n),this.add(i,s);for(let e=0;e{const n=this._bindToExternalToInternalMap.get(t);n&&this.remove(n),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce(((e,t)=>(it&&e.push(t),e)),[])}))}_getItemIdBeforeAdding(e){const t=this._idProperty;let i;if(t in e){if(i=e[t],"string"!=typeof i)throw new x("collection-add-invalid-id",this);if(this.get(i))throw new x("collection-add-item-already-exists",this)}else e[t]=i=_();return i}_remove(e){let t,i,n,o=!1;const s=this._idProperty;if("string"==typeof e?(i=e,n=this._itemMap.get(i),o=!n,n&&(t=this._items.indexOf(n))):"number"==typeof e?(t=e,n=this._items[t],o=!n,n&&(i=n[s])):(n=e,i=n[s],t=this._items.indexOf(n),o=-1==t||!this._itemMap.get(i)),o)throw new x("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(i);const r=this._bindToInternalToExternalMap.get(n);return this._bindToInternalToExternalMap.delete(n),this._bindToExternalToInternalMap.delete(r),this.fire("remove",n,t),[n,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}function Zt(e){const t=e.next();return t.done?null:t.value}class ei extends($e(G())){_elements=new Set;_externalViews=new Set;_blurTimeout=null;constructor(){super(),this.set("isFocused",!1),this.set("focusedElement",null)}get elements(){return Array.from(this._elements.values())}get externalViews(){return Array.from(this._externalViews.values())}add(e){if(ii(e))this._addElement(e);else if(ti(e))this._addView(e);else{if(!e.element)throw new x("focustracker-add-view-missing-element",{focusTracker:this,view:e});this._addElement(e.element)}}remove(e){ii(e)?this._removeElement(e):ti(e)?this._removeView(e):this._removeElement(e.element)}_addElement(e){if(this._elements.has(e))throw new x("focustracker-add-element-already-exist",this);this.listenTo(e,"focus",(()=>{const t=this.externalViews.find((t=>function(e,t){return!!ni(e,t)||!!t.focusTracker.externalViews.find((t=>ni(e,t)))}(e,t)));t?this._focus(t.element):this._focus(e)}),{useCapture:!0}),this.listenTo(e,"blur",(()=>{this._blur()}),{useCapture:!0}),this._elements.add(e)}_removeElement(e){this._elements.has(e)&&(this.stopListening(e),this._elements.delete(e)),e===this.focusedElement&&this._blur()}_addView(e){e.element&&this._addElement(e.element),this.listenTo(e.focusTracker,"change:focusedElement",(()=>{e.focusTracker.focusedElement?e.element&&this._focus(e.element):this._blur()})),this._externalViews.add(e)}_removeView(e){e.element&&this._removeElement(e.element),this.stopListening(e.focusTracker),this._externalViews.delete(e)}destroy(){this.stopListening(),this._elements.clear(),this._externalViews.clear(),this.isFocused=!1,this.focusedElement=null}_focus(e){this._clearBlurTimeout(),this.focusedElement=e,this.isFocused=!0}_blur(){this.elements.find((e=>e.contains(document.activeElement)))||this.externalViews.find((e=>e.focusTracker.isFocused&&!e.focusTracker._blurTimeout))||(this._clearBlurTimeout(),this._blurTimeout=setTimeout((()=>{this.focusedElement=null,this.isFocused=!1}),0))}_clearBlurTimeout(){clearTimeout(this._blurTimeout),this._blurTimeout=null}}function ti(e){return"focusTracker"in e&&e.focusTracker instanceof ei}function ii(e){return Me(e)}function ni(e,t){return!!t.element&&t.element.contains(document.activeElement)&&e.contains(t.element)}class oi{_listener;constructor(){this._listener=new($e())}listenTo(e){this._listener.listenTo(e,"keydown",((e,t)=>{this._listener.fire("_keydown:"+Bt(t),t)}))}set(e,t,i={}){const n=Mt(e),o=i.priority;this._listener.listenTo(this._listener,"_keydown:"+n,((e,n)=>{i.filter&&!i.filter(n)||(t(n,(()=>{n.preventDefault(),n.stopPropagation(),e.stop()})),e.return=!0)}),{priority:o})}press(e){return!!this._listener.fire("_keydown:"+Bt(e),e)}stopListening(e){this._listener.stopListening(e)}destroy(){this.stopListening()}}function si(e){return ie(e)?new Map(e):function(e){const t=new Map;for(const i in e)t.set(i,e[i]);return t}(e)}function ri(e,t,i){const n=e.length,o=t.length;for(let t=n-1;t>=i;t--)e[t+o]=e[t];for(let n=0;ne(...o)),t)}return n.cancel=()=>{clearTimeout(i)},n}function li(e){try{if(!e.startsWith("ey"))return null;const t=atob(e.replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(t)}catch{return null}}function ci(e,t,i=" "){return`${i.repeat(Math.max(0,t))}${e}\n`}function ui(e,t){return!!(i=e.charAt(t-1))&&1==i.length&&/[\ud800-\udbff]/.test(i)&&function(e){return!!e&&1==e.length&&/[\udc00-\udfff]/.test(e)}(e.charAt(t));var i}function di(e,t){return!!(i=e.charAt(t))&&1==i.length&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(i);var i}const hi=gi();function mi(e,t){const i=String(e).matchAll(hi);return Array.from(i).some((e=>e.indexe.source)).join("|")+")";return new RegExp(`${e}|${t}(?:‍${t})*`,"ug")}function fi(e){if(!e)return null;const t=function(e){const t=e.split(".");return 3!=t.length?null:t[1]}(e);return t?li(t):null}class pi{editor;_components=new Map;constructor(e){this.editor=e}*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set(bi(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new x("componentfactory-item-missing",this,{name:e});return this._components.get(bi(e)).callback(this.editor.locale)}has(e){return this._components.has(bi(e))}}function bi(e){return String(e).toLowerCase()}class wi extends Xt{_parentElement;constructor(e=[]){super(e,{idProperty:"viewUid"}),this.on("add",((e,t,i)=>{this._renderViewIntoCollectionParent(t,i)})),this.on("remove",((e,t)=>{t.element&&this._parentElement&&t.element.remove()})),this._parentElement=null}destroy(){this.map((e=>e.destroy()))}setParent(e){this._parentElement=e;for(const e of this)this._renderViewIntoCollectionParent(e)}delegate(...e){if(!e.length||!e.every((e=>"string"==typeof e)))throw new x("ui-viewcollection-delegate-wrong-events",this);return{to:t=>{for(const i of this)for(const n of e)i.delegate(n).to(t);this.on("add",((i,n)=>{for(const i of e)n.delegate(i).to(t)})),this.on("remove",((i,n)=>{for(const i of e)n.stopDelegating(i,t)}))}}}_renderViewIntoCollectionParent(e,t){e.isRendered||e.render(),e.element&&this._parentElement&&this._parentElement.insertBefore(e.element,this._parentElement.children[t])}remove(e){return super.remove(e)}}class vi extends(R()){ns;tag;text;attributes;children;eventListeners;_isRendered;_revertData;constructor(e){super(),Object.assign(this,Ii(Pi(e))),this._isRendered=!1,this._revertData=null}render(){const e=this._renderNode({intoFragment:!0});return this._isRendered=!0,e}apply(e){return this._revertData={children:[],bindings:[],attributes:{}},this._renderNode({node:e,intoFragment:!1,isApplying:!0,revertData:this._revertData}),e}revert(e){if(!this._revertData)throw new x("ui-template-revert-not-applied",[this,e]);this._revertTemplateFromNode(e,this._revertData)}*getViews(){yield*function*e(t){if(t.children)for(const i of t.children)Mi(i)?yield i:Ni(i)&&(yield*e(i))}(this)}static bind(e,t){return{to:(i,n)=>new _i({eventNameOrFunction:i,attribute:i,observable:e,emitter:t,callback:n}),if:(i,n,o)=>new ki({observable:e,emitter:t,attribute:i,valueIfTrue:n,callback:o})}}static extend(e,t){if(e._isRendered)throw new x("template-extend-render",[this,e]);Li(e,Ii(Pi(t)))}_renderNode(e){let t;if(t=e.node?this.tag&&this.text:this.tag?this.text:!this.text,t)throw new x("ui-template-wrong-syntax",this);return this.text?this._renderText(e):this._renderElement(e)}_renderElement(e){let t=e.node;return t||(t=e.node=document.createElementNS(this.ns||"http://www.w3.org/1999/xhtml",this.tag)),this._renderAttributes(e),this._renderElementChildren(e),this._setUpListeners(e),t}_renderText(e){let t=e.node;return t?e.revertData.text=t.textContent:t=e.node=document.createTextNode(""),Ci(this.text)?this._bindToObservable({schema:this.text,updater:Ti(t),data:e}):t.textContent=this.text.join(""),t}_renderAttributes(e){if(!this.attributes)return;const t=e.node,i=e.revertData;for(const n in this.attributes){const o=t.getAttribute(n),s=this.attributes[n];i&&(i.attributes[n]=o);const r=Di(s)?s[0].ns:null;if(Ci(s)){const a=Di(s)?s[0].value:s;i&&zi(n)&&a.unshift(o),this._bindToObservable({schema:a,updater:Ei(t,n,r),data:e})}else if("style"==n&&"string"!=typeof s[0])this._renderStyleAttribute(s[0],e);else{i&&o&&zi(n)&&s.unshift(o);const e=s.map((e=>e&&e.value||e)).reduce(((e,t)=>e.concat(t)),[]).reduce(Oi,"");Bi(e)||t.setAttributeNS(r,n,e)}}}_renderStyleAttribute(e,t){const i=t.node;for(const n in e){const o=e[n];Ci(o)?this._bindToObservable({schema:[o],updater:Si(i,n),data:t}):xi(n)?i.style.setProperty(n,o):i.style[n]=o}}_renderElementChildren(e){const t=e.node,i=e.intoFragment?document.createDocumentFragment():t,n=e.isApplying;let o=0;for(const s of this.children)if(Fi(s)){if(!n){s.setParent(t);for(const e of s)i.appendChild(e.element)}}else if(Mi(s))n||(s.isRendered||s.render(),i.appendChild(s.element));else if(ze(s))i.appendChild(s);else if(n){const t={children:[],bindings:[],attributes:{}};e.revertData.children.push(t),s._renderNode({intoFragment:!1,node:i.childNodes[o++],isApplying:!0,revertData:t})}else i.appendChild(s.render());e.intoFragment&&t.appendChild(i)}_setUpListeners(e){if(this.eventListeners)for(const t in this.eventListeners){const i=this.eventListeners[t].map((i=>{const[n,o]=t.split("@");return i.activateDomEventListener(n,o,e)}));e.revertData&&e.revertData.bindings.push(i)}}_bindToObservable({schema:e,updater:t,data:i}){const n=i.revertData;Ai(e,t,i);const o=e.filter((e=>!Bi(e))).filter((e=>e.observable)).map((n=>n.activateAttributeListener(e,t,i)));n&&n.bindings.push(o)}_revertTemplateFromNode(e,t){for(const e of t.bindings)for(const t of e)t();if(t.text)return void(e.textContent=t.text);const i=e;for(const e in t.attributes){const n=t.attributes[e];null===n?i.removeAttribute(e):i.setAttribute(e,n)}for(let e=0;eAi(e,t,i);return this.emitter.listenTo(this.observable,`change:${this.attribute}`,n),()=>{this.emitter.stopListening(this.observable,`change:${this.attribute}`,n)}}}class _i extends yi{eventNameOrFunction;constructor(e){super(e),this.eventNameOrFunction=e.eventNameOrFunction}activateDomEventListener(e,t,i){const n=(e,i)=>{t&&!i.target.matches(t)||("function"==typeof this.eventNameOrFunction?this.eventNameOrFunction(i):this.observable.fire(this.eventNameOrFunction,i))};return this.emitter.listenTo(i.node,e,n),()=>{this.emitter.stopListening(i.node,e,n)}}}class ki extends yi{valueIfTrue;constructor(e){super(e),this.valueIfTrue=e.valueIfTrue}getValue(e){return!Bi(super.getValue(e))&&(this.valueIfTrue||!0)}}function Ci(e){return!!e&&(e.value&&(e=e.value),Array.isArray(e)?e.some(Ci):e instanceof yi)}function xi(e){return/^--[a-zA-Z_-][\w-]*$/.test(e)}function Ai(e,t,{node:i}){const n=function(e,t){return e.map((e=>e instanceof yi?e.getValue(t):e))}(e,i);let o;o=1==e.length&&e[0]instanceof ki?n[0]:n.reduce(Oi,""),Bi(o)?t.remove():t.set(o)}function Ti(e){return{set(t){e.textContent=t},remove(){e.textContent=""}}}function Ei(e,t,i){return{set(n){e.setAttributeNS(i,t,n)},remove(){e.removeAttributeNS(i,t)}}}function Si(e,t){return{set(i){xi(t)?e.style.setProperty(t,i):e.style[t]=i},remove(){xi(t)?e.style.removeProperty(t):e.style[t]=null}}}function Pi(e){return Le(e,(e=>{if(e&&(e instanceof yi||Ni(e)||Mi(e)||Fi(e)))return e}))}function Ii(e){if("string"==typeof e?e=function(e){return{text:[e]}}(e):e.text&&function(e){e.text=zt(e.text)}(e),e.on&&(e.eventListeners=function(e){for(const t in e)Vi(e,t);return e}(e.on),delete e.on),!e.text){e.attributes&&function(e){for(const t in e)e[t].value&&(e[t].value=zt(e[t].value)),Vi(e,t)}(e.attributes);const t=[];if(e.children)if(Fi(e.children))t.push(e.children);else for(const i of e.children)Ni(i)||Mi(i)||ze(i)?t.push(i):t.push(new vi(i));e.children=t}return e}function Vi(e,t){e[t]=zt(e[t])}function Oi(e,t){return Bi(t)?e:Bi(e)?t:`${e} ${t}`}function Ri(e,t){for(const i in t)e[i]?e[i].push(...t[i]):e[i]=t[i]}function Li(e,t){if(t.attributes&&(e.attributes||(e.attributes={}),Ri(e.attributes,t.attributes)),t.eventListeners&&(e.eventListeners||(e.eventListeners={}),Ri(e.eventListeners,t.eventListeners)),t.text&&e.text.push(...t.text),t.children&&t.children.length){if(e.children.length!=t.children.length)throw new x("ui-template-extend-children-mismatch",e);let i=0;for(const n of t.children)Li(e.children[i++],n)}}function Bi(e){return!e&&0!==e}function Mi(e){return e instanceof Hi}function Ni(e){return e instanceof vi}function Fi(e){return e instanceof wi}function Di(e){return z(e[0])&&e[0].ns}function zi(e){return"class"==e||"style"==e}class Hi extends($e(G())){element;isRendered;locale;t;template;_viewCollections;_unboundChildren;_bindTemplate;constructor(e){super(),this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new Xt,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",((t,i)=>{i.locale=e,i.t=e&&e.t})),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=vi.bind(this,this)}createCollection(e){const t=new wi(e);return this._viewCollections.add(t),t}registerChild(e){ie(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){ie(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new vi(e)}extendTemplate(e){vi.extend(this.template,e)}render(){if(this.isRendered)throw new x("ui-view-render-already-rendered",this);this.template&&(this.element=this.template.render(),this.registerChild(this.template.getViews())),this.isRendered=!0}destroy(){this.stopListening(),this._viewCollections.map((e=>e.destroy())),this.template&&this.template._revertData&&this.template.revert(this.element)}}const Ui=at("px"),$i={top:-99999,left:-99999,name:"arrowless",config:{withArrow:!1}};class qi extends Hi{content;_pinWhenIsVisibleCallback;_resizeObserver;constructor(e){super(e);const t=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("position","arrow_nw"),this.set("isVisible",!1),this.set("withArrow",!0),this.set("class",void 0),this._pinWhenIsVisibleCallback=null,this._resizeObserver=null,this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-panel",t.to("position",(e=>`ck-balloon-panel_${e}`)),t.if("isVisible","ck-balloon-panel_visible"),t.if("withArrow","ck-balloon-panel_with-arrow"),t.to("class")],style:{top:t.to("top",Ui),left:t.to("left",Ui)}},children:this.content})}destroy(){this.hide(),super.destroy()}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){const t=ji(e.target);if(t&&!ht(t))return!1;this.show();const i=qi.defaultPositions,o=Object.assign({},{element:this.element,positions:[i.southArrowNorth,i.southArrowNorthMiddleWest,i.southArrowNorthMiddleEast,i.southArrowNorthWest,i.southArrowNorthEast,i.northArrowSouth,i.northArrowSouthMiddleWest,i.northArrowSouthMiddleEast,i.northArrowSouthWest,i.northArrowSouthEast,i.viewportStickyNorth],limiter:n.document.body,fitInViewport:!0},e),s=qi._getOptimalPosition(o)||$i,r=parseInt(s.left),a=parseInt(s.top),l=s.name,c=s.config||{},{withArrow:u=!0}=c;return this.top=a,this.left=r,this.position=l,this.withArrow=u,!0}pin(e){this.unpin(),this._startPinning(e)&&(this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(e):this._stopPinning()},this.listenTo(this,"change:isVisible",this._pinWhenIsVisibleCallback))}unpin(){this._pinWhenIsVisibleCallback&&(this._stopPinning(),this.stopListening(this,"change:isVisible",this._pinWhenIsVisibleCallback),this._pinWhenIsVisibleCallback=null,this.hide())}_startPinning(e){if(!this.attachTo(e))return!1;let t=ji(e.target);const i=e.limiter?ji(e.limiter):n.document.body;if(this.listenTo(n.document,"scroll",((n,o)=>{const s=o.target,r=t&&s.contains(t),a=i&&s.contains(i);!r&&!a&&t&&i||this.attachTo(e)}),{useCapture:!0}),this.listenTo(n.window,"resize",(()=>{this.attachTo(e)})),!this._resizeObserver&&(t&&Ke(t)&&(t=t.parentElement),t)){const e=()=>{ht(t)||this.unpin()};this._resizeObserver=new st(t,e)}return!0}_stopPinning(){this.stopListening(n.document,"scroll"),this.stopListening(n.window,"resize"),this._resizeObserver&&(this._resizeObserver.destroy(),this._resizeObserver=null)}static generatePositions(e={}){const{sideOffset:t=qi.arrowSideOffset,heightOffset:i=qi.arrowHeightOffset,stickyVerticalOffset:o=qi.stickyVerticalOffset,config:s}=e;return{northWestArrowSouthWest:(e,i)=>({top:r(e,i),left:e.left-t,name:"arrow_sw",...s&&{config:s}}),northWestArrowSouthMiddleWest:(e,i)=>({top:r(e,i),left:e.left-.25*i.width-t,name:"arrow_smw",...s&&{config:s}}),northWestArrowSouth:(e,t)=>({top:r(e,t),left:e.left-t.width/2,name:"arrow_s",...s&&{config:s}}),northWestArrowSouthMiddleEast:(e,i)=>({top:r(e,i),left:e.left-.75*i.width+t,name:"arrow_sme",...s&&{config:s}}),northWestArrowSouthEast:(e,i)=>({top:r(e,i),left:e.left-i.width+t,name:"arrow_se",...s&&{config:s}}),northArrowSouthWest:(e,i)=>({top:r(e,i),left:e.left+e.width/2-t,name:"arrow_sw",...s&&{config:s}}),northArrowSouthMiddleWest:(e,i)=>({top:r(e,i),left:e.left+e.width/2-.25*i.width-t,name:"arrow_smw",...s&&{config:s}}),northArrowSouth:(e,t)=>({top:r(e,t),left:e.left+e.width/2-t.width/2,name:"arrow_s",...s&&{config:s}}),northArrowSouthMiddleEast:(e,i)=>({top:r(e,i),left:e.left+e.width/2-.75*i.width+t,name:"arrow_sme",...s&&{config:s}}),northArrowSouthEast:(e,i)=>({top:r(e,i),left:e.left+e.width/2-i.width+t,name:"arrow_se",...s&&{config:s}}),northEastArrowSouthWest:(e,i)=>({top:r(e,i),left:e.right-t,name:"arrow_sw",...s&&{config:s}}),northEastArrowSouthMiddleWest:(e,i)=>({top:r(e,i),left:e.right-.25*i.width-t,name:"arrow_smw",...s&&{config:s}}),northEastArrowSouth:(e,t)=>({top:r(e,t),left:e.right-t.width/2,name:"arrow_s",...s&&{config:s}}),northEastArrowSouthMiddleEast:(e,i)=>({top:r(e,i),left:e.right-.75*i.width+t,name:"arrow_sme",...s&&{config:s}}),northEastArrowSouthEast:(e,i)=>({top:r(e,i),left:e.right-i.width+t,name:"arrow_se",...s&&{config:s}}),southWestArrowNorthWest:e=>({top:a(e),left:e.left-t,name:"arrow_nw",...s&&{config:s}}),southWestArrowNorthMiddleWest:(e,i)=>({top:a(e),left:e.left-.25*i.width-t,name:"arrow_nmw",...s&&{config:s}}),southWestArrowNorth:(e,t)=>({top:a(e),left:e.left-t.width/2,name:"arrow_n",...s&&{config:s}}),southWestArrowNorthMiddleEast:(e,i)=>({top:a(e),left:e.left-.75*i.width+t,name:"arrow_nme",...s&&{config:s}}),southWestArrowNorthEast:(e,i)=>({top:a(e),left:e.left-i.width+t,name:"arrow_ne",...s&&{config:s}}),southArrowNorthWest:e=>({top:a(e),left:e.left+e.width/2-t,name:"arrow_nw",...s&&{config:s}}),southArrowNorthMiddleWest:(e,i)=>({top:a(e),left:e.left+e.width/2-.25*i.width-t,name:"arrow_nmw",...s&&{config:s}}),southArrowNorth:(e,t)=>({top:a(e),left:e.left+e.width/2-t.width/2,name:"arrow_n",...s&&{config:s}}),southArrowNorthMiddleEast:(e,i)=>({top:a(e),left:e.left+e.width/2-.75*i.width+t,name:"arrow_nme",...s&&{config:s}}),southArrowNorthEast:(e,i)=>({top:a(e),left:e.left+e.width/2-i.width+t,name:"arrow_ne",...s&&{config:s}}),southEastArrowNorthWest:e=>({top:a(e),left:e.right-t,name:"arrow_nw",...s&&{config:s}}),southEastArrowNorthMiddleWest:(e,i)=>({top:a(e),left:e.right-.25*i.width-t,name:"arrow_nmw",...s&&{config:s}}),southEastArrowNorth:(e,t)=>({top:a(e),left:e.right-t.width/2,name:"arrow_n",...s&&{config:s}}),southEastArrowNorthMiddleEast:(e,i)=>({top:a(e),left:e.right-.75*i.width+t,name:"arrow_nme",...s&&{config:s}}),southEastArrowNorthEast:(e,i)=>({top:a(e),left:e.right-i.width+t,name:"arrow_ne",...s&&{config:s}}),westArrowEast:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.left-t.width-i,name:"arrow_e",...s&&{config:s}}),eastArrowWest:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.right+i,name:"arrow_w",...s&&{config:s}}),viewportStickyNorth:(e,t,i)=>{const r=new Ze(n.document.body).getIntersection(i.getVisible());if(!r)return null;const a=r.getVisible();return e.getIntersection(a)&&a.top-e.top-o{null!==s&&(e.apply(o,s),o=void 0,s=null)};let c=null;const u=()=>{null!=c&&clearTimeout(c),c=setTimeout((()=>{c=null,a&&l(),h()}),t)},d=()=>{null!==c&&(clearTimeout(c),c=null)},h=()=>{d(),o=void 0,s=null},m=function(...e){if(i?.aborted)return;o=this,s=e;const t=null==c;u(),r&&t&&l()};return m.schedule=u,m.cancel=h,m.flush=()=>{d(),l()},i?.addEventListener("abort",h,{once:!0}),m}((function(...t){a=e.apply(this,t),l=null}),t,{edges:r}),u=function(...t){return null!=s&&(null===l&&(l=Date.now()),Date.now()-l>=s)?(a=e.apply(this,t),l=Date.now(),c.cancel(),c.schedule(),a):(c.apply(this,t),a)};return u.cancel=c.cancel,u.flush=()=>(c.flush(),a),u}const Gi="ck-tooltip";class Ki extends($e()){tooltipTextView;balloonPanelView;static defaultBalloonPositions=qi.generatePositions({heightOffset:5,sideOffset:13});_currentElementWithTooltip=null;_currentTooltipPosition=null;_mutationObserver=null;_pinTooltipDebounced;_unpinTooltipDebounced;_watchdogExcluded;static _editors=new Set;static _instance=null;constructor(e){if(super(),Ki._editors.add(e),Ki._instance)return Ki._instance;Ki._instance=this,this.tooltipTextView=new Hi(e.locale),this.tooltipTextView.set("text",""),this.tooltipTextView.setTemplate({tag:"span",attributes:{class:["ck","ck-tooltip__text"]},children:[{text:this.tooltipTextView.bindTemplate.to("text")}]}),this.balloonPanelView=new qi(e.locale),this.balloonPanelView.class=Gi,this.balloonPanelView.content.add(this.tooltipTextView),this._mutationObserver=function(e){const t=new MutationObserver((()=>{e()}));return{attach(e){t.observe(e,{attributes:!0,attributeFilter:["data-cke-tooltip-text","data-cke-tooltip-position"]})},detach(){t.disconnect()}}}((()=>{this._updateTooltipPosition()})),this._pinTooltipDebounced=Wi(this._pinTooltip,600),this._unpinTooltipDebounced=Wi(this._unpinTooltip,400),this.listenTo(n.document,"keydown",this._onKeyDown.bind(this),{useCapture:!0}),this.listenTo(n.document,"mouseenter",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(n.document,"mouseleave",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(n.document,"focus",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(n.document,"blur",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(n.document,"scroll",this._onScroll.bind(this),{useCapture:!0}),this._watchdogExcluded=!0}destroy(e){const t=e.ui.view&&e.ui.view.body;Ki._editors.delete(e),this.stopListening(e.ui),t&&t.has(this.balloonPanelView)&&t.remove(this.balloonPanelView),Ki._editors.size||(this._unpinTooltip(),this.balloonPanelView.destroy(),this.stopListening(),Ki._instance=null)}static getPositioningFunctions(e){const t=Ki.defaultBalloonPositions;return{s:[t.southArrowNorth,t.southArrowNorthEast,t.southArrowNorthWest],n:[t.northArrowSouth],e:[t.eastArrowWest],w:[t.westArrowEast],sw:[t.southArrowNorthEast],se:[t.southArrowNorthWest]}[e]}_onKeyDown(e,t){"Escape"===t.key&&this._currentElementWithTooltip&&(this._unpinTooltip(),t.stopPropagation())}_onEnterOrFocus(e,{target:t}){const i=Ji(t);i?i!==this._currentElementWithTooltip?(this._unpinTooltip(),"focus"===e.name&&!i.matches(":hover")||i.matches("[data-cke-tooltip-instant]")?this._pinTooltip(i,Yi(i)):this._pinTooltipDebounced(i,Yi(i))):this._unpinTooltipDebounced.cancel():"focus"===e.name&&this._unpinTooltip()}_onLeaveOrBlur(e,{target:t,relatedTarget:i}){if("mouseleave"===e.name){if(!Me(t))return;const e=this.balloonPanelView.element,n=e&&(e===i||e.contains(i)),o=!n&&t===e;if(n)return void this._unpinTooltipDebounced.cancel();if(!o&&this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;const s=Ji(t),r=Ji(i);(o||s&&s!==r)&&(this._pinTooltipDebounced.cancel(),this._currentElementWithTooltip&&this._currentElementWithTooltip.matches("[data-cke-tooltip-instant]")||s&&s.matches("[data-cke-tooltip-instant]")?this._unpinTooltip():this._unpinTooltipDebounced())}else{if(this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;this._pinTooltipDebounced.cancel(),this._unpinTooltipDebounced()}}_onScroll(e,{target:t}){this._currentElementWithTooltip&&(t.contains(this.balloonPanelView.element)&&t.contains(this._currentElementWithTooltip)||this._unpinTooltip())}_pinTooltip(e,{text:t,position:i,cssClass:n}){this._unpinTooltip();const o=Zt(Ki._editors.values()).ui.view.body;o.has(this.balloonPanelView)||o.add(this.balloonPanelView),this.tooltipTextView.text=t,this.balloonPanelView.class=[Gi,n].filter((e=>e)).join(" "),this.balloonPanelView.pin({target:e,positions:Ki.getPositioningFunctions(i)}),this._mutationObserver.attach(e);for(const e of Ki._editors)this.listenTo(e.ui,"update",this._updateTooltipPosition.bind(this),{priority:"low"});this._currentElementWithTooltip=e,this._currentTooltipPosition=i}_unpinTooltip(){this._unpinTooltipDebounced.cancel(),this._pinTooltipDebounced.cancel(),this.balloonPanelView.unpin();for(const e of Ki._editors)this.stopListening(e.ui,"update");this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this.tooltipTextView.text="",this._mutationObserver.detach()}_updateTooltipPosition(){if(!this._currentElementWithTooltip)return;const e=Yi(this._currentElementWithTooltip);ht(this._currentElementWithTooltip)&&e.text?this.balloonPanelView.pin({target:this._currentElementWithTooltip,positions:Ki.getPositioningFunctions(e.position)}):this._unpinTooltip()}}function Ji(e){return Me(e)?e.closest("[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])"):null}function Yi(e){return{text:e.dataset.ckeTooltipText,position:e.dataset.ckeTooltipPosition||"s",cssClass:e.dataset.ckeTooltipClass||""}}function Qi(e,t=0,i={}){"object"!=typeof i&&(i={});const{leading:n=!0,trailing:o=!0}=i;return Wi(e,t,{leading:n,trailing:o,maxWait:t})}class Xi extends($e()){editor;_balloonView=null;_showBalloonThrottled=Qi((()=>this._showBalloon()),50,{leading:!0});_lastFocusedEditableElement=null;_balloonClass;constructor(e,t={}){super(),this.editor=e,this._balloonClass=t.balloonClass,e.on("ready",(()=>this._handleEditorReady()))}destroy(){const e=this._balloonView;e&&(e.unpin(),this._balloonView=null),this._showBalloonThrottled.cancel(),this.stopListening()}_handleEditorReady(){const e=this.editor;this._isEnabled()&&e.ui.view&&(e.ui.focusTracker.on("change:isFocused",((e,t,i)=>{this._updateLastFocusedEditableElement(),i?this._showBalloon():this._hideBalloon()})),e.ui.focusTracker.on("change:focusedElement",((e,t,i)=>{this._updateLastFocusedEditableElement(),i&&this._showBalloon()})),e.ui.on("update",(()=>{this._showBalloonThrottled()})))}_getNormalizedConfig(){return{side:"ltr"===this.editor.locale.contentLanguageDirection?"right":"left",position:"border",verticalOffset:0,horizontalOffset:5}}_showBalloon(){const e=this._getBalloonAttachOptions();e&&(this._balloonView||(this._balloonView=this._createBalloonView()),this._balloonView.pin(e))}_hideBalloon(){this._balloonView&&this._balloonView.unpin()}_createBalloonView(){const e=this.editor,t=new qi,i=this._createBadgeContent();return t.content.add(i),this._balloonClass&&(t.class=this._balloonClass),e.ui.view.body.add(t),t}_getBalloonAttachOptions(){if(!this._lastFocusedEditableElement)return null;const e=this._getNormalizedConfig(),t="right"===e.side?Zi(this._lastFocusedEditableElement,i=e,((e,t)=>e.left+e.width-t.width-i.horizontalOffset)):function(e,t){return Zi(e,t,(e=>e.left+t.horizontalOffset))}(this._lastFocusedEditableElement,e);var i;return{target:this._lastFocusedEditableElement,positions:[t]}}_updateLastFocusedEditableElement(){const e=this.editor,t=e.ui.focusTracker.isFocused,i=e.ui.focusTracker.focusedElement;if(!t||!i)return void(this._lastFocusedEditableElement=null);const n=Array.from(e.ui.getEditableElementsNames()).map((t=>e.ui.getEditableElement(t)));n.includes(i)?this._lastFocusedEditableElement=i:this._lastFocusedEditableElement=n[0]}}function Zi(e,t,i){return(n,o)=>{const s=new Ze(e);if(s.width<350||s.height<50)return null;let r;r="inside"===t.position?s.bottom-o.height:s.bottom-o.height/2,r-=t.verticalOffset;const a=i(s,o),l=n.clone().moveTo(a,r).getIntersection(o.clone().moveTo(a,r)).getVisible();return!l||l.getArea()!e)),"ck-reset_all-excluded",e.if("isColorInherited","ck-icon_inherit-color")],viewBox:e.to("viewBox"),"aria-hidden":!0}})}render(){super.render(),this._updateXMLContent(),this._colorFillPaths(),this.on("change:content",(()=>{this._updateXMLContent(),this._colorFillPaths()})),this.on("change:fillColor",(()=>{this._colorFillPaths()}))}_updateXMLContent(){if(this.content){const e=(new DOMParser).parseFromString(this.content.trim(),"image/svg+xml").querySelector("svg");if(!e)throw new x("ui-iconview-invalid-svg",this);const t=e.getAttribute("viewBox");t&&(this.viewBox=t);for(const{name:t,value:i}of Array.from(e.attributes))en.presentationalAttributeNames.includes(t)&&this.element.setAttribute(t,i);for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);for(;e.childNodes.length>0;)this.element.appendChild(e.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(".ck-icon__fill").forEach((e=>{e.style.fill=this.fillColor}))}}class tn extends Xi{constructor(e){super(e,{balloonClass:"ck-powered-by-balloon"})}_isEnabled(){const e=this.editor;if(e.config.get("ui.poweredBy.forceVisible"))return!0;const t=e.config.get("licenseKey");if("GPL"==t)return!0;const i=li(t.split(".")[1]);return!i||!i.whiteLabel}_createBadgeContent(){return new nn(this.editor.locale,this._getNormalizedConfig().label)}_getNormalizedConfig(){const e=super._getNormalizedConfig(),t=this.editor.config.get("ui.poweredBy")||{},i=t.position||e.position,n="inside"===i?5:e.verticalOffset;return{position:i,side:t.side||e.side,label:void 0===t.label?"Powered by":t.label,verticalOffset:void 0!==t.verticalOffset?t.verticalOffset:n,horizontalOffset:void 0!==t.horizontalOffset?t.horizontalOffset:e.horizontalOffset,forceVisible:!!t.forceVisible}}}class nn extends Hi{constructor(e,t){super(e);const i=new en,n=this.bindTemplate;i.set({content:'\n',isColorInherited:!1}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-powered-by"],"aria-hidden":!0},children:[{tag:"a",attributes:{href:"https://ckeditor.com/powered-by-ckeditor/?utm_source=ckeditor&utm_medium=referral&utm_campaign=701Dn000000hVgmIAE_powered_by_ckeditor_logo",target:"_blank",tabindex:"-1"},children:[...t?[{tag:"span",attributes:{class:["ck","ck-powered-by__label"]},children:[t]}]:[],i],on:{dragstart:n.to((e=>e.preventDefault()))}}]})}}class on extends Xi{licenseTypeMessage={evaluation:"For evaluation purposes only",trial:"For evaluation purposes only",development:"For development purposes only"};constructor(e){super(e,{balloonClass:"ck-evaluation-badge-balloon"})}_isEnabled(){const e=rn(this.editor.config.get("licenseKey"));return Boolean(e&&this.licenseTypeMessage[e])}_createBadgeContent(){const e=rn(this.editor.config.get("licenseKey"));return new sn(this.editor.locale,this.licenseTypeMessage[e])}_getNormalizedConfig(){const e=super._getNormalizedConfig(),t=this.editor.config.get("ui.poweredBy")||{};return{position:t.position||e.position,side:"left"===(t.side||e.side)?"right":"left",verticalOffset:e.verticalOffset,horizontalOffset:e.horizontalOffset}}}class sn extends Hi{constructor(e,t){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-evaluation-badge"],"aria-hidden":!0},children:[{tag:"span",attributes:{class:["ck","ck-evaluation-badge__label"]},children:[t]}]})}}function rn(e){if("GPL"==e)return"GPL";const t=li(e.split(".")[1]);return t?t.licenseType||"production":null}const an={POLITE:"polite",ASSERTIVE:"assertive"};class ln{editor;view;constructor(e){this.editor=e,e.once("ready",(()=>{for(const e of Object.values(an))this.announce("",e)}))}announce(e,t=an.POLITE){const i=this.editor;if(!i.ui.view)return;this.view||(this.view=new cn(i.locale),i.ui.view.body.add(this.view));const{politeness:n,isUnsafeHTML:o}="string"==typeof t?{politeness:t}:t;let s=this.view.regionViews.find((e=>e.politeness===n));s||(s=new un(i,n),this.view.regionViews.add(s)),s.announce({announcement:e,isUnsafeHTML:o})}}class cn extends Hi{regionViews;constructor(e){super(e),this.regionViews=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-aria-live-announcer"]},children:this.regionViews})}}class un extends Hi{politeness;_domConverter;_pruneAnnouncementsInterval;constructor(e,t){super(e.locale),this.setTemplate({tag:"div",attributes:{"aria-live":t,"aria-relevant":"additions"},children:[{tag:"ul",attributes:{class:["ck","ck-aria-live-region-list"]}}]}),e.on("destroy",(()=>{null!==this._pruneAnnouncementsInterval&&(clearInterval(this._pruneAnnouncementsInterval),this._pruneAnnouncementsInterval=null)})),this.politeness=t,this._domConverter=e.data.htmlProcessor.domConverter,this._pruneAnnouncementsInterval=setInterval((()=>{this.element&&this._listElement.firstChild&&this._listElement.firstChild.remove()}),5e3)}announce({announcement:e,isUnsafeHTML:t}){if(!e.trim().length)return;const i=document.createElement("li");t?this._domConverter.setContentOf(i,e):i.innerText=e,this._listElement.appendChild(i)}get _listElement(){return this.element.querySelector("ul")}}class dn extends Hi{children;constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!0),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item",t.if("isVisible","ck-hidden",(e=>!e))],role:"presentation"},children:this.children})}focus(){this.children.first&&this.children.first.focus()}}class hn extends dn{constructor(e,t){super(e);const i=this.bindTemplate;this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item"]},on:{mouseenter:i.to("mouseenter")}}),this.delegate("mouseenter").to(t)}}function mn({emitter:e,activator:t,callback:i,contextElements:n,listenerOptions:o}){e.listenTo(document,"mousedown",((e,o)=>{if(!t())return;const s="function"==typeof o.composedPath?o.composedPath():[],r="function"==typeof n?n():n;for(const e of r)if(e.contains(o.target)||s.includes(e))return;i()}),o)}const gn={toggleMenusAndFocusItemsOnHover(e){e.on("menu:mouseenter",(t=>{if(e.isFocusBorderEnabled||e.isOpen){if(e.isOpen)for(const i of e.menus){const e=t.path[0],n=e instanceof hn&&e.children.first===i;i.isOpen=(t.path.includes(i)||n)&&i.isEnabled}t.source.focus()}}))},focusCycleMenusOnArrows(e){const t="rtl"===e.locale.uiLanguageDirection;function i(t,i){const n=e.children.getIndex(t),o=t.isOpen,s=e.children.length,r=e.children.get((n+s+i)%s);t.isOpen=!1,o&&(r.isOpen=!0),r.buttonView.focus()}e.on("menu:arrowright",(e=>{i(e.source,t?-1:1)})),e.on("menu:arrowleft",(e=>{i(e.source,t?1:-1)}))},closeMenusWhenTheBarCloses(e){e.on("change:isOpen",(()=>{e.isOpen||e.menus.forEach((e=>{e.isOpen=!1}))}))},closeMenuWhenAnotherOnTheSameLevelOpens(e){e.on("menu:change:isOpen",((t,i,n)=>{n&&e.menus.filter((e=>t.source.parentMenuView===e.parentMenuView&&t.source!==e&&e.isOpen)).forEach((e=>{e.isOpen=!1}))}))},closeOnClickOutside(e){mn({emitter:e,activator:()=>e.isOpen,callback:()=>e.close(),contextElements:()=>e.children.map((e=>e.element))})},enableFocusHighlightOnInteraction(e){let t=!1;e.on("change:isOpen",((i,n,o)=>{o||(t||(e.isFocusBorderEnabled=!1),t=!1)})),e.listenTo(e.element,"keydown",(()=>{t=!0}),{useCapture:!0}),e.listenTo(e.element,"keyup",(()=>{t=!1}),{useCapture:!0}),e.listenTo(e.element,"focus",(()=>{t&&(e.isFocusBorderEnabled=!0)}),{useCapture:!0})}},fn={openAndFocusPanelOnArrowDownKey(e){e.keystrokes.set("arrowdown",((t,i)=>{e.isEnabled&&e.focusTracker.focusedElement===e.buttonView.element&&(e.isOpen||(e.isOpen=!0),e.panelView.focus(),i())}))},openOnArrowRightKey(e){const t="rtl"===e.locale.uiLanguageDirection?"arrowleft":"arrowright";e.keystrokes.set(t,((t,i)=>{e.focusTracker.focusedElement===e.buttonView.element&&e.isEnabled&&(e.isOpen||(e.isOpen=!0),e.panelView.focus(),i())}))},openOnButtonClick(e){e.buttonView.on("execute",(()=>{e.isOpen=!0}))},toggleOnButtonClick(e){e.buttonView.on("execute",(()=>{e.isOpen=!e.isOpen}))},openAndFocusOnEnterKeyPress(e){e.keystrokes.set("enter",((t,i)=>{e.focusTracker.focusedElement===e.buttonView.element&&(e.isOpen=!0,e.panelView.focus(),i())}))},closeOnArrowLeftKey(e){const t="rtl"===e.locale.uiLanguageDirection?"arrowright":"arrowleft";e.keystrokes.set(t,((t,i)=>{e.isOpen&&(e.isOpen=!1,e.focus(),i())}))},closeOnEscKey(e){e.keystrokes.set("esc",((t,i)=>{e.isOpen&&(e.isOpen=!1,e.focus(),i())}))},closeOnParentClose(e){e.parentMenuView.on("change:isOpen",((t,i,n)=>{n||t.source!==e.parentMenuView||(e.isOpen=!1)}))}},pn={southEast:e=>({top:e.bottom,left:e.left,name:"se"}),southWest:(e,t)=>({top:e.bottom,left:e.left-t.width+e.width,name:"sw"}),northEast:(e,t)=>({top:e.top-t.height,left:e.left,name:"ne"}),northWest:(e,t)=>({top:e.top-t.height,left:e.left-t.width+e.width,name:"nw"}),eastSouth:e=>({top:e.top,left:e.right-5,name:"es"}),eastNorth:(e,t)=>({top:e.top-t.height,left:e.right-5,name:"en"}),westSouth:(e,t)=>({top:e.top,left:e.left-t.width+5,name:"ws"}),westNorth:(e,t)=>({top:e.top-t.height,left:e.left-t.width+5,name:"wn"})},bn=[{menuId:"file",label:"File",groups:[{groupId:"export",items:["menuBar:exportPdf","menuBar:exportWord"]},{groupId:"import",items:["menuBar:importWord"]},{groupId:"revisionHistory",items:["menuBar:revisionHistory"]}]},{menuId:"edit",label:"Edit",groups:[{groupId:"undo",items:["menuBar:undo","menuBar:redo"]},{groupId:"selectAll",items:["menuBar:selectAll"]},{groupId:"findAndReplace",items:["menuBar:findAndReplace"]}]},{menuId:"view",label:"View",groups:[{groupId:"sourceEditingEnhanced",items:["menuBar:sourceEditingEnhanced"]},{groupId:"sourceEditing",items:["menuBar:sourceEditing"]},{groupId:"showBlocks",items:["menuBar:showBlocks"]},{groupId:"previewMergeFields",items:["menuBar:previewMergeFields"]},{groupId:"fullscreen",items:["menuBar:fullscreen"]},{groupId:"restrictedEditing",items:["menuBar:restrictedEditing"]}]},{menuId:"insert",label:"Insert",groups:[{groupId:"insertMainWidgets",items:["menuBar:insertImage","menuBar:ckbox","menuBar:ckfinder","menuBar:insertTable","menuBar:insertTableLayout"]},{groupId:"insertInline",items:["menuBar:link","menuBar:insertFootnote","menuBar:bookmark","menuBar:comment","menuBar:insertMergeField","menuBar:emoji"]},{groupId:"insertMinorWidgets",items:["menuBar:mediaEmbed","menuBar:insertTemplate","menuBar:specialCharacters","menuBar:blockQuote","menuBar:codeBlock","menuBar:htmlEmbed"]},{groupId:"insertStructureWidgets",items:["menuBar:horizontalLine","menuBar:pageBreak","menuBar:tableOfContents"]},{groupId:"restrictedEditingException",items:["menuBar:restrictedEditingException:inline","menuBar:restrictedEditingException:block"]}]},{menuId:"format",label:"Format",groups:[{groupId:"textAndFont",items:[{menuId:"text",label:"Text",groups:[{groupId:"basicStyles",items:["menuBar:bold","menuBar:italic","menuBar:underline","menuBar:strikethrough","menuBar:superscript","menuBar:subscript","menuBar:code"]},{groupId:"textPartLanguage",items:["menuBar:textPartLanguage"]}]},{menuId:"font",label:"Font",groups:[{groupId:"fontProperties",items:["menuBar:fontSize","menuBar:fontFamily"]},{groupId:"fontColors",items:["menuBar:fontColor","menuBar:fontBackgroundColor"]},{groupId:"highlight",items:["menuBar:highlight"]}]},"menuBar:heading"]},{groupId:"list",items:["menuBar:bulletedList","menuBar:numberedList","menuBar:multiLevelList","menuBar:todoList"]},{groupId:"indent",items:["menuBar:alignment","menuBar:lineHeight","menuBar:indent","menuBar:outdent"]},{groupId:"caseChange",items:["menuBar:caseChange"]},{groupId:"removeFormat",items:["menuBar:removeFormat"]}]},{menuId:"tools",label:"Tools",groups:[{groupId:"aiTools",items:["menuBar:aiAssistant","menuBar:aiCommands","menuBar:toggleAi","menuBar:aiQuickActions"]},{groupId:"tools",items:["menuBar:trackChanges","menuBar:commentsArchive"]}]},{menuId:"help",label:"Help",groups:[{groupId:"help",items:["menuBar:accessibilityHelp"]}]}];function wn({normalizedConfig:e,locale:t,componentFactory:i,extraItems:n}){const o=Ht(e);return vn(e,o,n),function(e,t){const i=t.removeItems,n=[];t.items=t.items.filter((({menuId:e})=>!i.includes(e)||(n.push(e),!1))),Cn(t.items,(e=>{e.groups=e.groups.filter((({groupId:e})=>!i.includes(e)||(n.push(e),!1)));for(const t of e.groups)t.items=t.items.filter((e=>{const t=En(e);return!i.includes(t)||(n.push(t),!1)}))}));for(const t of i)n.includes(t)||A("menu-bar-item-could-not-be-removed",{menuBarConfig:e,itemName:t})}(e,o),vn(e,o,o.addItems),function(e,t,i){Cn(t.items,(n=>{for(const o of n.groups)o.items=o.items.filter((o=>{const s="string"==typeof o&&!i.has(o);return s&&!t.isUsingDefaultConfig&&A("menu-bar-item-unavailable",{menuBarConfig:e,parentMenuConfig:Ht(n),componentName:o}),!s}))}))}(e,o,i),_n(e,o),function(e,t){const i=t.t,n={File:i({string:"File",id:"MENU_BAR_MENU_FILE"}),Edit:i({string:"Edit",id:"MENU_BAR_MENU_EDIT"}),View:i({string:"View",id:"MENU_BAR_MENU_VIEW"}),Insert:i({string:"Insert",id:"MENU_BAR_MENU_INSERT"}),Format:i({string:"Format",id:"MENU_BAR_MENU_FORMAT"}),Tools:i({string:"Tools",id:"MENU_BAR_MENU_TOOLS"}),Help:i({string:"Help",id:"MENU_BAR_MENU_HELP"}),Text:i({string:"Text",id:"MENU_BAR_MENU_TEXT"}),Font:i({string:"Font",id:"MENU_BAR_MENU_FONT"})};Cn(e.items,(e=>{e.label in n&&(e.label=n[e.label])}))}(o,t),o}function vn(e,t,i){const n=[];if(0!=i.length){for(const e of i){const i=An(e.position),s=Tn(e.position);if("object"==typeof(o=e)&&"menu"in o)if(s){const o=t.items.findIndex((e=>e.menuId===s));-1!=o?"before"===i?(t.items.splice(o,0,e.menu),n.push(e)):"after"===i&&(t.items.splice(o+1,0,e.menu),n.push(e)):yn(t,e.menu,s,i)&&n.push(e)}else"start"===i?(t.items.unshift(e.menu),n.push(e)):"end"===i&&(t.items.push(e.menu),n.push(e));else xn(e)?Cn(t.items,(t=>{if(t.menuId===s)"start"===i?(t.groups.unshift(e.group),n.push(e)):"end"===i&&(t.groups.push(e.group),n.push(e));else{const o=t.groups.findIndex((e=>e.groupId===s));-1!==o&&("before"===i?(t.groups.splice(o,0,e.group),n.push(e)):"after"===i&&(t.groups.splice(o+1,0,e.group),n.push(e)))}})):yn(t,e.item,s,i)&&n.push(e)}for(const t of i)n.includes(t)||A("menu-bar-item-could-not-be-added",{menuBarConfig:e,addedItemConfig:t})}var o}function yn(e,t,i,n){let o=!1;return Cn(e.items,(e=>{for(const{groupId:s,items:r}of e.groups){if(o)return;if(s===i)"start"===n?(r.unshift(t),o=!0):"end"===n&&(r.push(t),o=!0);else{const e=r.findIndex((e=>En(e)===i));-1!==e&&("before"===n?(r.splice(e,0,t),o=!0):"after"===n&&(r.splice(e+1,0,t),o=!0))}}})),o}function _n(e,t){const i=t.isUsingDefaultConfig;let n=!1;t.items=t.items.filter((t=>!!t.groups.length||(kn(e,t,i),!1))),t.items.length?(Cn(t.items,(t=>{t.groups=t.groups.filter((e=>!!e.items.length||(n=!0,!1)));for(const o of t.groups)o.items=o.items.filter((t=>!(Sn(t)&&!t.groups.length&&(kn(e,t,i),n=!0,1))))})),n&&_n(e,t)):kn(e,e,i)}function kn(e,t,i){i||A("menu-bar-menu-empty",{menuBarConfig:e,emptyMenuConfig:t})}function Cn(e,t){if(Array.isArray(e))for(const t of e)i(t);function i(e){t(e);for(const t of e.groups)for(const e of t.items)Sn(e)&&i(e)}}function xn(e){return"object"==typeof e&&"group"in e}function An(e){return e.startsWith("start")?"start":e.startsWith("end")?"end":e.startsWith("after")?"after":"before"}function Tn(e){const t=e.match(/^[^:]+:(.+)/);return t?t[1]:null}function En(e){return"string"==typeof e?e:e.menuId}function Sn(e){return"object"==typeof e&&"menuId"in e}class Pn extends(G()){editor;componentFactory;focusTracker;tooltipManager;poweredBy;evaluationBadge;ariaLiveAnnouncer;isReady=!1;_editableElementsMap=new Map;_focusableToolbarDefinitions=[];_extraMenuBarElements=[];_lastFocusedForeignElement=null;_domEmitter;constructor(e){super();const t=e.editing.view;this.editor=e,this.componentFactory=new pi(e),this.focusTracker=new ei,this.tooltipManager=new Ki(e),this.poweredBy=new tn(e),this.evaluationBadge=new on(e),this.ariaLiveAnnouncer=new ln(e),this._initViewportOffset(this._readViewportOffsetFromConfig()),this.once("ready",(()=>{this._bindBodyCollectionWithFocusTracker(),this.isReady=!0})),this.listenTo(t.document,"layoutChanged",this.update.bind(this)),this.listenTo(t,"scrollToTheSelection",this._handleScrollToTheSelection.bind(this)),this._initFocusTracking(),this._initVisualViewportSupport()}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy(),this.tooltipManager.destroy(this.editor),this.poweredBy.destroy(),this.evaluationBadge.destroy();for(const e of this._editableElementsMap.values())e.ckeditorInstance=null,this.editor.keystrokes.stopListening(e);this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[],this._domEmitter&&this._domEmitter.stopListening()}setEditableElement(e,t){this._editableElementsMap.set(e,t),t.ckeditorInstance||(t.ckeditorInstance=this.editor),this.focusTracker.add(t);const i=()=>{this.editor.editing.view.getDomRoot(e)||this.editor.keystrokes.listenTo(t)};this.isReady?i():this.once("ready",i)}removeEditableElement(e){const t=this._editableElementsMap.get(e);t&&(this._editableElementsMap.delete(e),this.editor.keystrokes.stopListening(t),this.focusTracker.remove(t),t.ckeditorInstance=null)}getEditableElement(e="main"){return this._editableElementsMap.get(e)}getEditableElementsNames(){return this._editableElementsMap.keys()}addToolbar(e,t={}){e.isRendered?(this.focusTracker.add(e),this.editor.keystrokes.listenTo(e.element)):e.once("render",(()=>{this.focusTracker.add(e),this.editor.keystrokes.listenTo(e.element)})),this._focusableToolbarDefinitions.push({toolbarView:e,options:t})}extendMenuBar(e){this._extraMenuBarElements.push(e)}initMenuBar(e){const t=e.element;this.focusTracker.add(t),this.editor.keystrokes.listenTo(t);const i=function(e){let t;return t="items"in e&&e.items?{items:e.items,removeItems:[],addItems:[],isVisible:!0,isUsingDefaultConfig:!1,...e}:{items:Ht(bn),addItems:[],removeItems:[],isVisible:!0,isUsingDefaultConfig:!0,...e},t}(this.editor.config.get("menuBar")||{});e.fillFromConfig(i,this.componentFactory,this._extraMenuBarElements),this.editor.keystrokes.set("Esc",((e,i)=>{t.contains(this.editor.ui.focusTracker.focusedElement)&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):this.editor.editing.view.focus(),i())})),this.editor.keystrokes.set("Alt+F9",((i,n)=>{t.contains(this.editor.ui.focusTracker.focusedElement)||(this._saveLastFocusedForeignElement(),e.isFocusBorderEnabled=!0,e.focus(),n())}))}_readViewportOffsetFromConfig(){const e=this.editor,t=e.config.get("ui.viewportOffset");if(t)return t;const i=e.config.get("toolbar.viewportTopOffset");return i?(console.warn("editor-ui-deprecated-viewport-offset-config: The `toolbar.vieportTopOffset` configuration option is deprecated. It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead."),{top:i}):{top:0}}_initFocusTracking(){const e=this.editor;let t;e.keystrokes.set("Alt+F10",((e,i)=>{this._saveLastFocusedForeignElement();const n=this._getCurrentFocusedToolbarDefinition();n&&t||(t=this._getFocusableCandidateToolbarDefinitions());for(let e=0;e{const n=this._getCurrentFocusedToolbarDefinition();n&&(this._lastFocusedForeignElement?(this._lastFocusedForeignElement.focus(),this._lastFocusedForeignElement=null):e.editing.view.focus(),n.options.afterBlur&&n.options.afterBlur(),i())}))}_saveLastFocusedForeignElement(){const e=this.focusTracker.focusedElement;Array.from(this._editableElementsMap.values()).includes(e)&&!Array.from(this.editor.editing.view.domRoots.values()).includes(e)&&(this._lastFocusedForeignElement=e)}_getFocusableCandidateToolbarDefinitions(){const e=[];for(const t of this._focusableToolbarDefinitions){const{toolbarView:i,options:n}=t;(ht(i.element)||n.beforeFocus)&&e.push(t)}return e.sort(((e,t)=>In(e)-In(t))),e}_getCurrentFocusedToolbarDefinition(){for(const e of this._focusableToolbarDefinitions)if(e.toolbarView.element&&e.toolbarView.element.contains(this.focusTracker.focusedElement))return e;return null}_focusFocusableCandidateToolbar(e){const{toolbarView:t,options:{beforeFocus:i}}=e;return i&&i(),!!ht(t.element)&&(t.focus(),!0)}_handleScrollToTheSelection(e,t){const i={top:0,bottom:0,left:0,right:0,...this.viewportOffset};t.viewportOffset.top+=i.top,t.viewportOffset.bottom+=i.bottom,t.viewportOffset.left+=i.left,t.viewportOffset.right+=i.right}_bindBodyCollectionWithFocusTracker(){const e=this.view.body;for(const t of e)this.focusTracker.add(t.element);e.on("add",((e,t)=>{this.focusTracker.add(t.element)})),e.on("remove",((e,t)=>{this.focusTracker.remove(t.element)}))}_initViewportOffset(e){this.on("set:viewportOffset",((e,t,i)=>{const n=this._getVisualViewportTopOffset(i);i.visualTop!==n&&(e.return={...i,visualTop:n})})),this.set("viewportOffset",e)}_initVisualViewportSupport(){if(!n.window.visualViewport)return;const e=()=>{const e=this._getVisualViewportTopOffset(this.viewportOffset);this.viewportOffset.visualTop!==e&&(this.viewportOffset={...this.viewportOffset,visualTop:e})};this._domEmitter=new($e()),this._domEmitter.listenTo(n.window.visualViewport,"scroll",e),this._domEmitter.listenTo(n.window.visualViewport,"resize",e)}_getVisualViewportTopOffset(e){const t=vt().top,i=e.top||0;return t>i?0:i-t}}function In(e){const{toolbarView:t,options:i}=e;let n=10;return ht(t.element)&&n--,i.isContextual&&(n-=2),n}function Vn(e){if(Array.isArray(e))return{items:e,removeItems:[]};const t={items:[],removeItems:[]};return e?{...t,...e}:t}const On='';class Rn extends Hi{children;iconView;constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("label",t.label||""),this.set("class",t.class||null),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__header",i.to("class")]},children:this.children}),t.icon&&(this.iconView=new en,this.iconView.content=t.icon,this.children.add(this.iconView));const n=new Hi(e);n.setTemplate({tag:"h2",attributes:{class:["ck","ck-form__header__label"],role:"presentation"},children:[{text:i.to("label")}]}),this.children.add(n)}}class Ln extends Hi{constructor(){super(),this.set({style:void 0,text:void 0,id:void 0});const e=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:e.to("style"),id:e.to("id")},children:[{text:e.to("text")}]})}}class Bn extends Hi{children;labelView;iconView;keystrokeView;_focusDelayed=null;constructor(e,t=new Ln){super(e);const i=this.bindTemplate,n=_();this.set("_ariaPressed",!1),this.set("_ariaChecked",!1),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",`ck-editor__aria-label_${n}`),this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isVisible",!0),this.set("isToggleable",!1),this.set("keystroke",void 0),this.set("label",void 0),this.set("role",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.set("withKeystroke",!1),this.children=this.createCollection(),this.labelView=this._setupLabelView(t),this.iconView=new en,this.iconView.extendTemplate({attributes:{class:"ck-button__icon"}}),this.iconView.bind("content").to(this,"icon"),this.keystrokeView=this._createKeystrokeView(),this.bind("_tooltipString").to(this,"tooltip",this,"label",this,"keystroke",this._getTooltipString.bind(this));const o={tag:"button",attributes:{class:["ck","ck-button",i.to("class"),i.if("isEnabled","ck-disabled",(e=>!e)),i.if("isVisible","ck-hidden",(e=>!e)),i.to("isOn",(e=>e?"ck-on":"ck-off")),i.if("withText","ck-button_with-text"),i.if("withKeystroke","ck-button_with-keystroke")],role:i.to("role"),type:i.to("type",(e=>e||"button")),tabindex:i.to("tabindex"),"aria-checked":i.to("_ariaChecked"),"aria-pressed":i.to("_ariaPressed"),"aria-label":i.to("ariaLabel"),"aria-labelledby":i.to("ariaLabelledBy"),"aria-disabled":i.if("isEnabled",!0,(e=>!e)),"data-cke-tooltip-text":i.to("_tooltipString"),"data-cke-tooltip-position":i.to("tooltipPosition")},children:this.children,on:{click:i.to((e=>{this.isEnabled?this.fire("execute"):e.preventDefault()}))}};this.bind("_ariaPressed").to(this,"isOn",this,"isToggleable",this,"role",((e,t,i)=>!(!t||Mn(i))&&String(!!e))),this.bind("_ariaChecked").to(this,"isOn",this,"isToggleable",this,"role",((e,t,i)=>!(!t||!Mn(i))&&String(!!e))),r.isSafari&&(this._focusDelayed||(this._focusDelayed=ai((()=>this.focus()),0)),o.on.mousedown=i.to((()=>{this._focusDelayed()})),o.on.mouseup=i.to((()=>{this._focusDelayed.cancel()}))),this.setTemplate(o)}render(){super.render(),this.icon&&this.children.add(this.iconView),this.on("change:icon",((e,t,i,n)=>{i&&!n?this.children.add(this.iconView,0):!i&&n&&this.children.remove(this.iconView)})),this.children.add(this.labelView),this.withKeystroke&&this.keystroke&&this.children.add(this.keystrokeView)}focus(){this.element.focus()}destroy(){this._focusDelayed&&this._focusDelayed.cancel(),super.destroy()}_setupLabelView(e){return e.bind("text","style","id").to(this,"label","labelStyle","ariaLabelledBy"),e}_createKeystrokeView(){const e=new Hi;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",(e=>Nt(e)))}]}),e}_getTooltipString(e,t,i){return e?"string"==typeof e?e:(i&&(i=Nt(i)),e instanceof Function?e(t,i):`${t}${i?` (${i})`:""}`):""}}function Mn(e){switch(e){case"radio":case"checkbox":case"option":case"switch":case"menuitemcheckbox":case"menuitemradio":return!0;default:return!1}}class Nn extends(R()){focusables;focusTracker;keystrokeHandler;actions;constructor(e){if(super(),this.focusables=e.focusables,this.focusTracker=e.focusTracker,this.keystrokeHandler=e.keystrokeHandler,this.actions=e.actions,e.actions&&e.keystrokeHandler)for(const t in e.actions){let i=e.actions[t];"string"==typeof i&&(i=[i]);for(const n of i)e.keystrokeHandler.set(n,((e,i)=>{this[t](),i()}),e.keystrokeHandlerOptions)}this.on("forwardCycle",(()=>this.focusFirst()),{priority:"low"}),this.on("backwardCycle",(()=>this.focusLast()),{priority:"low"})}get first(){return this.focusables.find(Fn)||null}get last(){return this.focusables.filter(Fn).slice(-1)[0]||null}get next(){return this._getDomFocusableItem(1)}get previous(){return this._getDomFocusableItem(-1)}get current(){let e=null;return null===this.focusTracker.focusedElement?null:(this.focusables.find(((t,i)=>{const n=t.element===this.focusTracker.focusedElement;return n&&(e=i),n})),e)}focusFirst(){this._focus(this.first,1)}focusLast(){this._focus(this.last,-1)}focusNext(){const e=this.next;e&&this.focusables.getIndex(e)===this.current||e===this.first?this.fire("forwardCycle"):this._focus(e,1)}focusPrevious(){const e=this.previous;e&&this.focusables.getIndex(e)===this.current||e===this.last?this.fire("backwardCycle"):this._focus(e,-1)}chain(e){const t=()=>null===this.current?null:this.focusables.get(this.current);this.listenTo(e,"forwardCycle",(e=>{const i=t();this.focusNext(),i!==t()&&e.stop()}),{priority:"low"}),this.listenTo(e,"backwardCycle",(e=>{const i=t();this.focusPrevious(),i!==t()&&e.stop()}),{priority:"low"})}unchain(e){this.stopListening(e)}_focus(e,t){e&&this.focusTracker.focusedElement!==e.element&&e.focus(t)}_getDomFocusableItem(e){const t=this.focusables.length;if(!t)return null;const i=this.current;if(null===i)return this[1===e?"first":"last"];let n=this.focusables.get(i),o=(i+t+e)%t;do{const i=this.focusables.get(o);if(Fn(i)){n=i;break}o=(o+t+e)%t}while(o!==i);return n}}function Fn(e){return Dn(e)&&ht(e.element)}function Dn(e){return!(!("focus"in e)||"function"!=typeof e.focus)}function zn(e){return class extends e{_onDragBound=this._onDrag.bind(this);_onDragEndBound=this._onDragEnd.bind(this);_lastDraggingCoordinates={x:0,y:0};constructor(...e){super(...e),this.on("render",(()=>{this._attachListeners()})),this.set("isDragging",!1)}_attachListeners(){this.listenTo(this.element,"mousedown",this._onDragStart.bind(this)),this.listenTo(this.element,"touchstart",this._onDragStart.bind(this))}_attachDragListeners(){this.listenTo(n.document,"mouseup",this._onDragEndBound),this.listenTo(n.document,"touchend",this._onDragEndBound),this.listenTo(n.document,"mousemove",this._onDragBound),this.listenTo(n.document,"touchmove",this._onDragBound)}_detachDragListeners(){this.stopListening(n.document,"mouseup",this._onDragEndBound),this.stopListening(n.document,"touchend",this._onDragEndBound),this.stopListening(n.document,"mousemove",this._onDragBound),this.stopListening(n.document,"touchmove",this._onDragBound)}_onDragStart(e,t){if(!this._isHandleElementPressed(t))return;this._attachDragListeners();let i=0,n=0;t instanceof MouseEvent?(i=t.clientX,n=t.clientY):(i=t.touches[0].clientX,n=t.touches[0].clientY),this._lastDraggingCoordinates={x:i,y:n},this.isDragging=!0}_onDrag(e,t){if(!this.isDragging)return void this._detachDragListeners();let i=0,n=0;t instanceof MouseEvent?(i=t.clientX,n=t.clientY):(i=t.touches[0].clientX,n=t.touches[0].clientY),t.preventDefault(),this.fire("drag",{deltaX:Math.round(i-this._lastDraggingCoordinates.x),deltaY:Math.round(n-this._lastDraggingCoordinates.y)}),this._lastDraggingCoordinates={x:i,y:n}}_onDragEnd(){this._detachDragListeners(),this.isDragging=!1}_isHandleElementPressed(e){return!!this.dragHandleElement&&(this.dragHandleElement===e.target||e.target instanceof HTMLElement&&this.dragHandleElement.contains(e.target))}}}class Hn extends Hi{children;keystrokes;focusCycler;_focusTracker;_focusables;constructor(e){super(e),this.children=this.createCollection(),this.keystrokes=new oi,this._focusTracker=new ei,this._focusables=new wi,this.focusCycler=new Nn({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__actions"]},children:this.children})}render(){super.render(),this.keystrokes.listenTo(this.element)}setButtons(e){for(const t of e){const e=new Bn(this.locale);let i;for(i in e.on("execute",(()=>t.onExecute())),t.onCreate&&t.onCreate(e),t)"onExecute"!=i&&"onCreate"!=i&&e.set(i,t[i]);this.children.add(e)}this._updateFocusCyclableItems()}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}_updateFocusCyclableItems(){Array.from(this.children).forEach((e=>{this._focusables.add(e),this._focusTracker.add(e.element)}))}}class Un extends Hi{children;constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog__content"]},children:this.children})}reset(){for(;this.children.length;)this.children.remove(0)}}const $n="screen-center",qn="editor-center",jn="editor-top-side",Wn=at("px");class Gn extends(zn(Hi)){parts;headerView;closeButtonView;actionsView;static defaultOffset=15;contentView;keystrokes;focusTracker;wasMoved=!1;_getCurrentDomRoot;_getViewportOffset;_focusables;_focusCycler;constructor(e,{getCurrentDomRoot:t,getViewportOffset:i,keystrokeHandlerOptions:n}){super(e);const o=this.bindTemplate,s=e.t;this.set("className",""),this.set("ariaLabel",s("Editor dialog")),this.set("isModal",!1),this.set("position",$n),this.set("_isVisible",!1),this.set("_isTransparent",!1),this.set("_top",0),this.set("_left",0),this._getCurrentDomRoot=t,this._getViewportOffset=i,this.decorate("moveTo"),this.parts=this.createCollection(),this.keystrokes=new oi,this.focusTracker=new ei,this._focusables=new wi,this._focusCycler=new Nn({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"},keystrokeHandlerOptions:n}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-dialog-overlay",o.if("isModal","ck-dialog-overlay__transparent",(e=>!e)),o.if("_isVisible","ck-hidden",(e=>!e))],tabindex:"-1"},children:[{tag:"div",attributes:{tabindex:"-1",class:["ck","ck-dialog",o.if("isModal","ck-dialog_modal"),o.to("className")],role:"dialog","aria-label":o.to("ariaLabel"),style:{top:o.to("_top",(e=>Wn(e))),left:o.to("_left",(e=>Wn(e))),visibility:o.if("_isTransparent","hidden")}},children:this.parts}]})}render(){super.render(),this.keystrokes.set("Esc",((e,t)=>{e.defaultPrevented||(this.fire("close",{source:"escKeyPress"}),t())})),this.on("drag",((e,{deltaX:t,deltaY:i})=>{this.wasMoved=!0,this.moveBy(t,i)})),this.listenTo(n.window,"resize",(()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()})),this.listenTo(n.document,"scroll",(()=>{this._isVisible&&!this.wasMoved&&this.updatePosition()})),this.on("change:_isVisible",((e,t,i)=>{i&&(this._isTransparent=!0,setTimeout((()=>{this.updatePosition(),this._isTransparent=!1,this.focus()}),10))})),this.keystrokes.listenTo(this.element)}get dragHandleElement(){return this.headerView&&!this.isModal?this.headerView.element:null}setupParts({icon:e,title:t,hasCloseButton:i=!0,content:n,actionButtons:o}){t&&(this.headerView=new Rn(this.locale,{icon:e}),i&&(this.closeButtonView=this._createCloseButton(),this.headerView.children.add(this.closeButtonView)),this.headerView.label=t,this.ariaLabel=t,this.parts.add(this.headerView,0)),n&&(n instanceof Hi&&(n=[n]),this.contentView=new Un(this.locale),this.contentView.children.addMany(n),this.parts.add(this.contentView)),o&&(this.actionsView=new Hn(this.locale),this.actionsView.setButtons(o),this.parts.add(this.actionsView)),this._updateFocusCyclableItems()}focus(){this._focusCycler.focusFirst()}moveTo(e,t){const i=this._getViewportRect(),n=this._getDialogRect();e+n.width>i.right&&(e=i.right-n.width),e{var t;this._focusables.add(e),this.focusTracker.add(e.element),Dn(t=e)&&"focusCycler"in t&&t.focusCycler instanceof Nn&&this._focusCycler.chain(e.focusCycler)}))}_createCloseButton(){const e=new Bn(this.locale),t=this.locale.t;return e.set({label:t("Close"),tooltip:!0,icon:On}),e.on("execute",(()=>this.fire("close",{source:"closeButton"}))),e}}const Kn=new WeakMap;let Jn=!1;function Yn({view:e,element:t,text:i,isDirectHost:n=!0,keepOnFocus:o=!1}){const s=e.document;function r(i){const r={text:i,isDirectHost:n,keepOnFocus:o,hostElement:n?t:null};Kn.get(s).set(t,r),e.change((e=>Xn([[t,r]],e)))}Kn.has(s)||(Kn.set(s,new Map),s.registerPostFixer((e=>Xn(Kn.get(s),e))),s.on("change:isComposing",(()=>{e.change((e=>Xn(Kn.get(s),e)))}),{priority:"high"})),t.is("editableElement")&&t.on("change:placeholder",((e,t,i)=>r(i))),t.placeholder?r(t.placeholder):i&&r(i),i&&(Jn||A("enableViewPlaceholder-deprecated-text-option"),Jn=!0)}function Qn(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function Xn(e,t){const i=[];let n=!1;for(const[o,s]of e)s.isDirectHost&&(i.push(o),Zn(t,o,s)&&(n=!0));for(const[o,s]of e){if(s.isDirectHost)continue;const e=eo(o);e!==s.hostElement&&s.hostElement&&(t.removeAttribute("data-placeholder",s.hostElement),Qn(t,s.hostElement),s.hostElement=null,n=!0),e&&(i.includes(e)||(s.hostElement=e,Zn(t,o,s)&&(n=!0)))}return n}function Zn(e,t,i){const{text:n,isDirectHost:o,hostElement:s}=i;let r=!1;return s.getAttribute("data-placeholder")!==n&&(e.setAttribute("data-placeholder",n,s),r=!0),(o||1==t.childCount)&&function(e,t){if(!e.isAttached())return!1;if(function(e){for(const t of e.getChildren())if(!t.is("uiElement"))return!0;return!1}(e))return!1;const i=e.document,n=i.selection.anchor;return!(i.isComposing&&n&&n.parent===e||!t&&i.isFocused&&(!n||n.parent===e))}(s,i.keepOnFocus)?function(e,t){return!t.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",t),!0)}(e,s)&&(r=!0):Qn(e,s)&&(r=!0),r}function eo(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}class to{is(){throw new Error("is() method is abstract")}}class io extends(R(to)){document;parent;constructor(e){super(),this.document=e,this.parent=null}get index(){let e;if(!this.parent)return null;if(-1==(e=this.parent.getChildIndex(this)))throw new x("view-node-not-found-in-parent",this);return e}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&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 i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let o=0;for(;i[o]==n[o]&&i[o];)o++;return 0===o?null:i[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=te(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n]e.data.length)throw new x("view-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.data.length)throw new x("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),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 i=e.includeSelf?this.textNode:this.parent;for(;null!==i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}}oo.prototype.is=function(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e};class so{_consumables=new Map;add(e,t){let i;e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):(this._consumables.has(e)?i=this._consumables.get(e):(i=new ro(e),this._consumables.set(e,i)),i.add(t?ao(t):e._getConsumables()))}test(e,t){const i=this._consumables.get(e);return void 0===i?null:e.is("$text")||e.is("documentFragment")?i:i.test(ao(t))}consume(e,t){if(e.is("$text")||e.is("documentFragment"))return!!this.test(e,t)&&(this._consumables.set(e,!1),!0);const i=this._consumables.get(e);return void 0!==i&&i.consume(ao(t))}revert(e,t){const i=this._consumables.get(e);void 0!==i&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):i.revert(ao(t)))}static createFrom(e,t){if(t||(t=new so),e.is("$text"))t.add(e);else if(e.is("element")||e.is("documentFragment")){t.add(e);for(const i of e.getChildren())so.createFrom(i,t)}return t}}class ro{element;_canConsumeName=null;_attributes=new Map;constructor(e){this.element=e}add(e){e.name&&(this._canConsumeName=!0);for(const[t,i]of e.attributes)if(i){let e=this._attributes.get(t);e&&"boolean"!=typeof e||(e=new Map,this._attributes.set(t,e)),e.set(i,!0)}else{if("style"==t||"class"==t)throw new x("viewconsumable-invalid-attribute",this);this._attributes.set(t,!0)}}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const[t,i]of e.attributes){const e=this._attributes.get(t);if(void 0===e)return null;if(!1===e)return!1;if(!0!==e)if(i){const t=e.get(i);if(void 0===t)return null;if(!t)return!1}else for(const t of e.values())if(!t)return!1}return!0}consume(e){if(!this.test(e))return!1;e.name&&(this._canConsumeName=!1);for(const[t,i]of e.attributes){const e=this._attributes.get(t);if("boolean"==typeof e)for(const[e]of this.element._getConsumables(t,i).attributes)this._attributes.set(e,!1);else if(i)for(const[,n]of this.element._getConsumables(t,i).attributes)e.set(n,!1);else for(const t of e.keys())e.set(t,!1)}return!0}revert(e){e.name&&(this._canConsumeName=!0);for(const[t,i]of e.attributes){const e=this._attributes.get(t);if(!1!==e){if(void 0!==e&&!0!==e)if(i)!1===e.get(i)&&e.set(i,!0);else for(const t of e.keys())e.set(t,!0)}else this._attributes.set(t,!0)}}}function ao(e){const t=[];return"attributes"in e&&e.attributes&&lo(t,e.attributes),"classes"in e&&e.classes&&lo(t,e.classes,"class"),"styles"in e&&e.styles&&lo(t,e.styles,"style"),{name:e.name||!1,attributes:t}}function lo(e,t,i){if("string"!=typeof t)for(const n of t)Array.isArray(n)?e.push(n):e.push(i?[i,n]:[n]);else e.push(i?[i,t]:[t])}class co{_patterns=[];constructor(...e){this.add(...e)}add(...e){for(let t of e)("string"==typeof t||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(const t of e)for(const e of this._patterns){const i=this._isElementMatching(t,e);if(i)return{element:t,pattern:e,match:i}}return null}matchAll(...e){const t=[];for(const i of e)for(const e of this._patterns){const n=this._isElementMatching(i,e);n&&t.push({element:i,pattern:e,match:n})}return t.length>0?t:null}getElementName(){if(1!==this._patterns.length)return null;const e=this._patterns[0],t=e.name;return"function"==typeof e||!t||t instanceof RegExp?null:t}_isElementMatching(e,t){if("function"==typeof t){const i=t(e);return i&&"object"==typeof i?ao(i):i}const i={};if(t.name&&(i.name=function(e,t){return e instanceof RegExp?!!t.match(e):e===t}(t.name,e.name),!i.name))return null;const n=[];return t.attributes&&!function(e,t,i){let n;return"object"!=typeof e||e instanceof RegExp||Array.isArray(e)?n=["class","style"]:(void 0!==e.style&&A("matcher-pattern-deprecated-attributes-style-key",e),void 0!==e.class&&A("matcher-pattern-deprecated-attributes-class-key",e)),t._collectAttributesMatch(ho(e),i,n)}(t.attributes,e,n)||t.classes&&!function(e,t,i){return t._collectAttributesMatch(ho(e,"class"),i)}(t.classes,e,n)||t.styles&&!function(e,t,i){return t._collectAttributesMatch(ho(e,"style"),i)}(t.styles,e,n)?null:(n.length&&(i.attributes=n),i)}}function uo(e,t){return!0===e||e===t||e instanceof RegExp&&!!String(t).match(e)}function ho(e,t){if(Array.isArray(e))return e.map((e=>"object"!=typeof e||e instanceof RegExp?t?[t,e,!0]:[e,!0]:(void 0!==e.key&&void 0!==e.value||A("matcher-pattern-missing-key-or-value",e),t?[t,e.key,e.value]:[e.key,e.value])));if("object"!=typeof e||e instanceof RegExp)return[t?[t,e,!0]:[e,!0]];const i=[];for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&i.push(t?[t,n,e[n]]:[n,e[n]]);return i}function mo(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function go(e){return"string"==typeof e||"symbol"==typeof e?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function fo(e){const t=[],i=e.length;if(0===i)return t;let n=0,o="",s="",r=!1;for(46===e.charCodeAt(0)&&(t.push(""),n++);n{const n=e[t];Object.hasOwn(e,t)&&bo(n,i)&&(void 0!==i||t in e)||(e[t]=i)},vo=/^(?:0|[1-9]\d*)$/;function yo(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&ei),(()=>{}))}class Ao{_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=function(e){let t=null,i=0,n=0,o=null;const s=new Map;if(""===e)return s;";"!=e.charAt(e.length-1)&&(e+=";");for(let r=0;rt===e));return Array.isArray(t)}set(e,t){if(this._cachedStyleNames=null,this._cachedExpandedStyleNames=null,z(e))for(const[t,i]of Object.entries(e))this._styleProcessor.toNormalizedForm(t,i,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t={};for(const i of zt(e)){const e=Eo(i),n=po(this._styles,e);if(n)So(t,e,n);else{const e=this.getAsString(i);void 0!==e&&this._styleProcessor.toNormalizedForm(i,e,t)}}Object.keys(t).length&&(Po(this._styles,t),this._cachedStyleNames=null,this._cachedExpandedStyleNames=null)}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]&&!z(this._styles[e]))return this._styles[e];const t=this._styleProcessor.getReducedForm(e,this._styles).find((([t])=>t===e));return Array.isArray(t)?t[1]:void 0}getStyleNames(e=!1){return this.isEmpty?[]:e?(this._cachedExpandedStyleNames||=this._styleProcessor.getStyleNames(this._styles),this._cachedExpandedStyleNames):(this._cachedStyleNames||=this.getStylesEntries().map((([e])=>e)),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 i of t)e.push(...this._styleProcessor.getReducedForm(i,this._styles));return e}_clone(){const e=new this.constructor(this._styleProcessor);return e.set(this.getNormalized()),e}_getTokensMatch(e,t){const i=[];for(const n of this.getStyleNames(!0))if(uo(e,n)){if(!0===t){i.push(n);continue}uo(t,this.getAsString(n))&&i.push(n)}return i.length?i:void 0}_getConsumables(e){const t=[];if(e){t.push(e);for(const i of this._styleProcessor.getRelatedStyles(e))t.push(i)}else for(const e of this.getStyleNames()){for(const i of this._styleProcessor.getRelatedStyles(e))t.push(i);t.push(e)}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}}class To{_normalizers;_extractors;_reducers;_consumables;constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,i){if(z(t))So(i,Eo(e),t);else if(this._normalizers.has(e)){const n=this._normalizers.get(e),{path:o,value:s}=n(t);So(i,o,s)}else So(i,e,t)}getNormalized(e,t){if(!e)return Kt({},t);if(void 0!==t[e])return t[e];if(this._extractors.has(e)){const i=this._extractors.get(e);if("string"==typeof i)return po(t,i);const n=i(e,t);if(n)return n}return po(t,Eo(e))}getReducedForm(e,t){const i=this.getNormalized(e,t);return void 0===i?[]:this._reducers.has(e)?this._reducers.get(e)(i):[[e,i]]}getStyleNames(e){const t=new Set;for(const i of this._consumables.keys()){const n=this.getNormalized(i,e);n&&("object"!=typeof n||Object.keys(n).length)&&t.add(i)}for(const i of Object.keys(e))t.add(i);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 i of t)this._mapStyleNames(i,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function Eo(e){return e.replace("-",".")}function So(e,t,i){let n=i;z(i)&&(n=Kt({},po(e,t),i)),xo(e,t,n)}function Po(e,t){for(const i of Object.keys(t))null===e[i]||Array.isArray(e[i])||"object"!=typeof e[i]||"object"!=typeof t[i]?delete e[i]:(Po(e[i],t[i]),Object.keys(e[i]).length||delete e[i])}class Io{_set=new Set;get isEmpty(){return 0==this._set.size}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 zt(e))t&&this._set.add(t)}remove(e){for(const t of zt(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(!0===e){for(const e of this._set.keys())t.push(e);return t}if("string"==typeof e){for(const i of e.split(/\s+/)){if(!this._set.has(i))return;t.push(i)}return t}for(const i of this._set.keys())i.match(e)&&t.push(i);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}}class Vo extends io{name;_unsafeAttributesToRender=[];_attrs;_children;_customProperties=new Map;get _classes(){return this._attrs.get("class")}get _styles(){return this._attrs.get("style")}constructor(e,t,i,n){super(e),this.name=t,this._attrs=this._parseAttributes(i),this._children=[],n&&this._insertChild(0,n)}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}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())"class"!=e&&"style"!=e&&(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)&&(void 0===t||(Ro(this.name,e)||Oo(this.name,e)?this._attrs.get(e).has(t):this._attrs.get(e)===t))}isSimilar(e){if(!(e instanceof Vo))return!1;if(this===e)return!0;if(this.name!=e.name)return!1;if(this._attrs.size!==e._attrs.size)return!1;for(const[t,i]of this._attrs){const n=e._attrs.get(t);if(void 0===n)return!1;if("string"==typeof i||"string"==typeof n){if(n!==i)return!1}else if(!i.isSimilar(n))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 co(...e);let i=this.parent;for(;i&&!i.is("documentFragment");){if(t.match(i))return i;i=i.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),i=Array.from(this._attrs).filter((([e])=>"style"!=e&&"class"!=e)).map((e=>`${e[0]}="${e[1]}"`)).sort().join(" ");return this.name+(""==e?"":` class="${e}"`)+(t?` style="${t}"`:"")+(""==i?"":` ${i}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}toJSON(){const e=super.toJSON();if(e.name=this.name,e.type="Element",this._attrs.size&&(e.attributes=Object.fromEntries(this.getAttributes())),this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=[];if(e)for(const i of this.getChildren())t.push(i._clone(e));const i=new this.constructor(this.document,this.name,this._attrs,t);return i._customProperties=new Map(this._customProperties),i.getFillerOffset=this.getFillerOffset,i._unsafeAttributesToRender=this._unsafeAttributesToRender,i}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this,{index:e});let i=0;const n=function(e,t){if("string"==typeof t)return[new no(e,t)];ie(t)||(t=[t]);const i=[];for(const n of t)"string"==typeof n?i.push(new no(e,n)):n instanceof oo?i.push(new no(e,n.data)):i.push(n);return i}(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,t.document=this.document,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let i=e;it&&e.selection.editableElement==this)),this.listenTo(e.selection,"change",(()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this}))}destroy(){this.stopListening()}toJSON(){const e=super.toJSON();return e.type="EditableElement",e.isReadOnly=this.isReadOnly,e.isFocused=this.isFocused,e}}Mo.prototype.is=function(e,t){return t?t===this.name&&("editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};const No=Symbol("rootName");class Fo extends Mo{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(No)}set rootName(e){this._setCustomProperty(No,e)}toJSON(){return this.rootName}set _name(e){this.name=e}}Fo.prototype.is=function(e,t){return t?t===this.name&&("rootElement"===e||"view:rootElement"===e||"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"rootElement"===e||"view:rootElement"===e||"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class Do{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new x("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new x("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=zo._createAt(e.startPosition):this._position=zo._createAt(e.boundaries["backward"==e.direction?"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,i;do{i=this.position,t=this.next()}while(!t.done&&e(t.value));t.done||(this._position=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()}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&e.offset===i.childCount)return{done:!0,value:void 0};if(i===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let n;if(i&&i.is("view:$text")){if(e.isAtEnd)return this._position=zo._createAfter(i),this._next();n=i.data[e.offset]}else n=i.getChild(e.offset);if("string"==typeof n){let n;n=this.singleCharacters?1:(i===this._boundaryEndParent?this.boundaries.end.offset:i.data.length)-e.offset;const o=new oo(i,e.offset,n);return e.offset+=n,this._position=e,this._formatReturnValue("text",o,t,e,n)}if(n&&n.is("view:element")){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}else e=new zo(n,0);return this._position=e,this._formatReturnValue("elementStart",n,t,e,1)}if(n&&n.is("view:$text")){if(this.singleCharacters)return e=new zo(n,0),this._position=e,this._next();let i,o=n.data.length;return n==this._boundaryEndParent?(o=this.boundaries.end.offset,i=new oo(n,0,o),e=zo._createAfter(i)):(i=new oo(n,0,n.data.length),e.offset++),this._position=e,this._formatReturnValue("text",i,t,e,o)}return e=zo._createAfter(i),this._position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",i,t,e)}_previous(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&0===e.offset)return{done:!0,value:void 0};if(i==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let n;if(i.is("view:$text")){if(e.isAtStart)return this._position=zo._createBefore(i),this._previous();n=i.data[e.offset-1]}else n=i.getChild(e.offset-1);if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{const t=i===this._boundaryStartParent?this.boundaries.start.offset:0;n=e.offset-t}e.offset-=n;const o=new oo(i,e.offset,n);return this._position=e,this._formatReturnValue("text",o,t,e,n)}if(n&&n.is("view:element"))return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",n,t,e,1)):(e=new zo(n,n.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",n,t,e));if(n&&n.is("view:$text")){if(this.singleCharacters)return e=new zo(n,n.data.length),this._position=e,this._previous();let i,o=n.data.length;if(n==this._boundaryStartParent){const t=this.boundaries.start.offset;i=new oo(n,t,n.data.length-t),o=i.data.length,e=zo._createBefore(i)}else i=new oo(n,0,n.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",i,t,e,o)}return e=zo._createBefore(i),this._position=e,this._formatReturnValue("elementStart",i,t,e,1)}_formatReturnValue(e,t,i,n,o){return t.is("view:$textProxy")&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?i=zo._createAfter(t.textNode):(n=zo._createAfter(t.textNode),this._position=n)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?i=zo._createBefore(t.textNode):(n=zo._createBefore(t.textNode),this._position=n))),{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:o}}}}class zo extends to{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 0===this.offset}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 Mo);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(e){const t=zo._createAt(this),i=t.offset+e;return t.offset=i<0?0:i,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new Do(t);return i.skip(e),i.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),i=e.getAncestors();let n=0;for(;t[n]==i[n]&&t[n];)n++;return 0===n?null:t[n-1]}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return"before"==this.compareWith(e)}isAfter(e){return"after"==this.compareWith(e)}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";const t=this.parent.is("node")?this.parent.getPath():[],i=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),i.push(e.offset);const n=te(t,i);switch(n){case"prefix":return"before";case"extension":return"after";default:return t[n]0?new this(i,n):new this(n,i)}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(zo._createBefore(e),t)}}function Uo(e){return!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))}Ho.prototype.is=function(e){return"range"===e||"view:range"===e};class $o extends(R(to)){_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 1===this.rangeCount&&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)return!1;if(this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel)return!1;if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=ee(this.getRanges());if(t!=ee(e.getRanges()))return!1;if(0==t)return!0;for(let t of this.getRanges()){t=t.getTrimmed();let i=!1;for(let n of e.getRanges())if(n=n.getTrimmed(),t.start.isEqual(n.start)&&t.end.isEqual(n.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,i,n]=e;if("object"==typeof i&&(n=i,i=void 0),null===t)this._setRanges([]),this._setFakeOptions(n);else if(t instanceof $o||t instanceof qo)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof Ho)this._setRanges([t],n&&n.backward),this._setFakeOptions(n);else if(t instanceof zo)this._setRanges([new Ho(t)]),this._setFakeOptions(n);else if(t instanceof io){const e=!!n&&!!n.backward;let o;if(void 0===i)throw new x("view-selection-setto-required-second-parameter",this);o="in"==i?Ho._createIn(t):"on"==i?Ho._createOn(t):new Ho(zo._createAt(t,i)),this._setRanges([o],e),this._setFakeOptions(n)}else{if(!ie(t))throw new x("view-selection-setto-not-selectable",this);this._setRanges(t,n&&n.backward),this._setFakeOptions(n)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new x("view-selection-setfocus-no-ranges",this);const i=zo._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.pop(),"before"==i.compareWith(n)?this._addRange(new Ho(i,n),!0):this._addRange(new Ho(n,i)),this.fire("change")}toJSON(){const e={ranges:Array.from(this.getRanges()).map((e=>e.toJSON()))};return this.isBackward&&(e.isBackward=!0),this.isFake&&(e.isFake=!0),e}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(const t of e)this._addRange(t);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,t=!1){if(!(e instanceof Ho))throw new x("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 x("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new Ho(e.start,e.end))}}$o.prototype.is=function(e){return"selection"===e||"view:selection"===e};class qo extends(R(to)){_selection;constructor(...e){super(),this._selection=new $o,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)}toJSON(){return this._selection.toJSON()}_setTo(...e){this._selection.setTo(...e)}_setFocus(e,t){this._selection.setFocus(e,t)}}qo.prototype.is=function(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e};class jo extends v{startRange;_eventPhase;_currentTarget;constructor(e,t,i){super(e,t),this.startRange=i,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const Wo=Symbol("bubblingEmitter"),Go=Symbol("bubblingCallbacks"),Ko=Symbol("bubblingContexts");function Jo(e){return class extends e{fire(e,...t){try{const i=e instanceof v?e:new v(this,e),n=Xo(this),o=es(this);if(Yo(i,"capturing",this),Qo(n,"$capture",i,...t))return i.return;const s=i.startRange||this.selection.getFirstRange(),r=s?s.getContainedElement():null,a=!!r&&function(e,t){for(const i of e)if(i(t))return!0;return!1}(o,r);let l=r||function(e){if(!e)return null;const t=e.start.parent,i=e.end.parent,n=t.getPath(),o=i.getPath();return n.length>o.length?t:i}(s);if(Yo(i,"atTarget",l),!a){if(Qo(n,"$text",i,...t))return i.return;Yo(i,"bubbling",l)}for(;l;){if(l.is("element")&&Qo(n,l,i,...t))return i.return;l=l.parent,Yo(i,"bubbling",l)}return Yo(i,"bubbling",this),Qo(n,"$document",i,...t),i.return}catch(e){x.rethrowUnexpectedError(e,this)}}_addEventListener(e,t,i){const n=zt(i.context||"$document"),o=Xo(this),s=Zo(this);for(const e of n)"function"==typeof e&&es(this).add(e);const r=function(e,t,i){return function(n,o){const{currentTarget:s,eventArgs:r}=o;if("string"!=typeof s){if(s.is("rootElement")&&t.includes("$root"))i.call(e,n,...r);else if(t.includes(s.name))i.call(e,n,...r);else for(const o of t)if("function"==typeof o&&o(s))return void i.call(e,n,...r)}else t.includes(s)&&i.call(e,n,...r)}}(this,n,t);s.set(t,r),this.listenTo(o,e,r,i)}_removeEventListener(e,t){const i=Xo(this),n=Zo(this),o=n.get(t);o&&(n.delete(t),this.stopListening(i,e,o))}}}function Yo(e,t,i){e instanceof jo&&(e._eventPhase=t,e._currentTarget=i)}function Qo(e,t,i,...n){return e.fire(i,{currentTarget:t,eventArgs:n}),!!i.stop.called}function Xo(e){return e[Wo]||(e[Wo]=new(R())),e[Wo]}function Zo(e){return e[Go]||(e[Go]=new Map),e[Go]}function es(e){return e[Ko]||(e[Ko]=new Set),e[Ko]}class ts extends(Jo(G())){selection;roots;stylesProcessor;_postFixers=new Set;constructor(e){super(),this.selection=new qo,this.roots=new Xt({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 i of this._postFixers)if(t=i(e),t)break}while(t)}}class is extends Vo{static DEFAULT_PRIORITY=10;_priority=10;_id=null;_clonesGroup=null;constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=ns}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new x("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}isSimilar(e){return null!==this.id||null!==e.id?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}toJSON(){const e=super.toJSON();return e.type="AttributeElement",e}_clone(e=!1){const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}_canMergeAttributesFrom(e){return null===this.id&&null===e.id&&this.priority===e.priority&&super._canMergeAttributesFrom(e)}_canSubtractAttributesOf(e){return null===this.id&&null===e.id&&this.priority===e.priority&&super._canSubtractAttributesOf(e)}}function ns(){if(os(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(os(e)>1)return null;e=e.parent}return!e||os(e)>1?null:this.childCount}function os(e){return Array.from(e.getChildren()).filter((e=>!e.is("uiElement"))).length}is.prototype.is=function(e,t){return t?t===this.name&&("attributeElement"===e||"view:attributeElement"===e||"element"===e||"view:element"===e):"attributeElement"===e||"view:attributeElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class ss extends Vo{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=rs}toJSON(){const e=super.toJSON();return e.type="EmptyElement",e}_insertChild(e,t){if(t&&(t instanceof io||Array.from(t).length>0))throw new x("view-emptyelement-cannot-add",[this,t]);return 0}}function rs(){return null}ss.prototype.is=function(e,t){return t?t===this.name&&("emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e):"emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class as extends Vo{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=ls}_insertChild(e,t){if(t&&(t instanceof io||Array.from(t).length>0))throw new x("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 e of this.getAttributeKeys())t.setAttribute(e,this.getAttribute(e));return t}toJSON(){const e=super.toJSON();return e.type="UIElement",e}}function ls(){return null}as.prototype.is=function(e,t){return t?t===this.name&&("uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e):"uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class cs extends Vo{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=us}toJSON(){const e=super.toJSON();return e.type="RawElement",e}_insertChild(e,t){if(t&&(t instanceof io||Array.from(t).length>0))throw new x("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}function us(){return null}cs.prototype.is=function(e,t){return t?t===this.name&&("rawElement"===e||"view:rawElement"===e||"element"===e||"view:element"===e):"rawElement"===e||"view:rawElement"===e||e===this.name||e==="view:"+this.name||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class ds extends(R(to)){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 0===this.childCount}get root(){return this}get parent(){return null}get name(){}get getFillerOffset(){}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}_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 i=0;const n=function(e,t){return"string"==typeof t?[new no(e,t)]:(ie(t)||(t=[t]),Array.from(t).map((t=>"string"==typeof t?new no(e,t):t instanceof oo?new no(e,t.data):t)))}(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let i=e;i{const i=e[e.length-1],n=!t.is("uiElement");return i&&i.breakAttributes==n?i.nodes.push(t):e.push({breakAttributes:n,nodes:[t]}),e}),[]);let n=null,o=e;for(const{nodes:e,breakAttributes:t}of i){const i=this._insertNodes(o,e,t);n||(n=i.start),o=i.end}return n?new Ho(n,o):new Ho(e)}remove(e){const t=e instanceof Ho?e:Ho._createOn(e);if(ys(t,this.document),t.isCollapsed)return new ds(this.document);const{start:i,end:n}=this._breakAttributesRange(t,!0),o=i.parent,s=n.offset-i.offset,r=o._removeChildren(i.offset,s);for(const e of r)this._removeFromClonedElementsGroup(e);const a=this.mergeAttributes(i);return t.start=a,t.end=a.clone(),new ds(this.document,r)}clear(e,t){ys(e,this.document);const i=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const n of i){const i=n.item;let o;if(i.is("element")&&t.isSimilar(i))o=Ho._createOn(i);else if(!n.nextPosition.isAfter(e.start)&&i.is("$textProxy")){const e=i.getAncestors().find((e=>e.is("element")&&t.isSimilar(e)));e&&(o=Ho._createIn(e))}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 i;if(t.isAfter(e.end)){const n=(t=this._breakAttributes(t,!0)).parent,o=n.childCount;e=this._breakAttributesRange(e,!0),i=this.remove(e),t.offset+=n.childCount-o}else i=this.remove(e);return this.insert(t,i)}wrap(e,t){if(!(t instanceof is))throw new x("view-writer-wrap-invalid-attribute",this.document);if(ys(e,this.document),e.isCollapsed){let n=e.start;n.parent.is("element")&&(i=n.parent,!Array.from(i.getChildren()).some((e=>!e.is("uiElement"))))&&(n=n.getLastMatchingPosition((e=>e.item.is("uiElement")))),n=this._wrapPosition(n,t);const o=this.document.selection;return o.isCollapsed&&o.getFirstPosition().isEqual(e.start)&&this.setSelection(n),new Ho(n)}return this._wrapRange(e,t);var i}unwrap(e,t){if(!(t instanceof is))throw new x("view-writer-unwrap-invalid-attribute",this.document);if(ys(e,this.document),e.isCollapsed)return e;const{start:i,end:n}=this._breakAttributesRange(e,!0),o=i.parent,s=this._unwrapChildren(o,i.offset,n.offset,t),r=this.mergeAttributes(s.start);r.isEqual(s.start)||s.end.offset--;const a=this.mergeAttributes(s.end);return new Ho(r,a)}rename(e,t){const i=new Lo(this.document,e,t.getAttributes());return this.insert(zo._createAfter(t),i),this.move(Ho._createIn(t),zo._createAt(i,0)),this.remove(Ho._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return zo._createAt(e,t)}createPositionAfter(e){return zo._createAfter(e)}createPositionBefore(e){return zo._createBefore(e)}createRange(e,t){return new Ho(e,t)}createRangeOn(e){return Ho._createOn(e)}createRangeIn(e){return Ho._createIn(e)}createSelection(...e){return new $o(...e)}createSlot(e="children"){if(!this._slotFactory)throw new x("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,i){let n,o;if(n=i?ms(e):e.parent.is("$text")?e.parent.parent:e.parent,!n)throw new x("view-writer-invalid-position-container",this.document);o=i?this._breakAttributes(e,!0):e.parent.is("$text")?fs(e):e;const s=n._insertChild(o.offset,t);for(const e of t)this._addToClonedElementsGroup(e);const r=o.getShiftedBy(s),a=this.mergeAttributes(o);a.isEqual(o)||r.offset--;const l=this.mergeAttributes(r);return new Ho(a,l)}_wrapChildren(e,t,i,n){let o=t;const s=[];for(;oa.priority)&&r.getIdentity()!1,e.parent._insertChild(e.offset,i);const n=new Ho(e,e.getShiftedBy(1));this.wrap(n,t);const o=new zo(i.parent,i.index);i._remove();const s=o.nodeBefore,r=o.nodeAfter;return s&&s.is("view:$text")&&r&&r.is("view:$text")?ps(s,r):gs(o)}_breakAttributesRange(e,t=!1){const i=e.start,n=e.end;if(ys(e,this.document),e.isCollapsed){const i=this._breakAttributes(e.start,t);return new Ho(i,i)}const o=this._breakAttributes(n,t),s=o.parent.childCount,r=this._breakAttributes(i,t);return o.offset+=o.parent.childCount-s,new Ho(r,o)}_breakAttributes(e,t=!1){const i=e.offset,n=e.parent;if(e.parent.is("emptyElement"))throw new x("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new x("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new x("view-writer-cannot-break-raw-element",this.document);if(!t&&n.is("$text")&&vs(n.parent))return e.clone();if(vs(n))return e.clone();if(n.is("$text"))return this._breakAttributes(fs(e),t);if(i==n.childCount){const e=new zo(n.parent,n.index+1);return this._breakAttributes(e,t)}if(0===i){const e=new zo(n.parent,n.index);return this._breakAttributes(e,t)}{const e=n.index+1,o=n._clone();n.parent._insertChild(e,o),this._addToClonedElementsGroup(o);const s=n.childCount-i,r=n._removeChildren(i,s);o._appendChild(r);const a=new zo(n.parent,e);return this._breakAttributes(a,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const t of e.getChildren())this._addToClonedElementsGroup(t);const t=e.id;if(!t)return;let i=this._cloneGroups.get(t);i||(i=new Set,this._cloneGroups.set(t,i)),i.add(e),e._clonesGroup=i}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const t of e.getChildren())this._removeFromClonedElementsGroup(t);const t=e.id;if(!t)return;const i=this._cloneGroups.get(t);i&&i.delete(e)}}function ms(e){let t=e.parent;for(;!vs(t);){if(!t)return;t=t.parent}return t}function gs(e){const t=e.nodeBefore;if(t&&t.is("$text"))return new zo(t,t.data.length);const i=e.nodeAfter;return i&&i.is("$text")?new zo(i,0):e}function fs(e){if(e.offset==e.parent.data.length)return new zo(e.parent.parent,e.parent.index+1);if(0===e.offset)return new zo(e.parent.parent,e.parent.index);const t=e.parent.data.slice(e.offset);return e.parent._data=e.parent.data.slice(0,e.offset),e.parent.parent._insertChild(e.parent.index+1,new no(e.root.document,t)),new zo(e.parent.parent,e.parent.index+1)}function ps(e,t){const i=e.data.length;return e._data+=t.data,t._remove(),new zo(e,i)}const bs=[no,is,Lo,ss,cs,as];function ws(e,t){for(const i of e){if(!bs.some((e=>i instanceof e)))throw new x("view-writer-insert-invalid-node-type",t);i.is("$text")||ws(i.getChildren(),t)}}function vs(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function ys(e,t){const i=ms(e.start),n=ms(e.end);if(!i||!n||i!==n)throw new x("view-writer-invalid-range-container",t)}const _s=e=>e.createTextNode(" "),ks=e=>{const t=e.createElement("span");return t.dataset.ckeFiller="true",t.innerText=" ",t},Cs=e=>{const t=e.createElement("br");return t.dataset.ckeFiller="true",t},xs="⁠".repeat(7);function As(e){return"string"==typeof e?e.substr(0,7)===xs:Ke(e)&&e.data.substr(0,7)===xs}function Ts(e){return 7==e.data.length&&As(e)}function Es(e){const t="string"==typeof e?e:e.data;return As(e)?t.slice(7):t}function Ss(e,t){if(t.keyCode==Rt.arrowleft){const e=t.domTarget.ownerDocument.defaultView.getSelection();if(1==e.rangeCount&&e.getRangeAt(0).collapsed){const t=e.getRangeAt(0).startContainer,i=e.getRangeAt(0).startOffset;As(t)&&i<=7&&e.collapse(t,0)}}}class Ps extends(G()){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),r.isBlink&&!r.isAndroid&&this.on("change:isSelecting",(()=>{this.isSelecting||this.render()}))}markToSync(e,t){if("text"===e)this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if("attributes"===e)this.markedAttributes.add(t);else{if("children"!==e)throw new x("view-renderer-unknown-type",this);this.markedChildren.add(t)}}}render(){if(this.isComposing&&!r.isAndroid)return;let e=null;const t=!(r.isBlink&&!r.isAndroid&&this.isSelecting);for(const e of this.markedChildren)this._updateChildrenMappings(e);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=zo._createBefore(e.parent)));for(const e of this.markedAttributes)this._updateAttrs(e);for(const t of this.markedChildren)this._updateChildren(t,{inlineFillerPosition:e});for(const t of this.markedTexts)!this.markedChildren.has(t.parent)&&this.domConverter.mapViewToDom(t.parent)&&this._updateText(t,{inlineFillerPosition:e});if(t)if(e){const t=this.domConverter.viewPositionToDom(e),i=t.parent.ownerDocument;As(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=Is(i,t.parent,t.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 i=Array.from(t.childNodes),n=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),o=this._diffNodeLists(i,n),s=this._findUpdateActions(o,i,n,Vs);if(-1!==s.indexOf("update")){const t={equal:0,insert:0,delete:0};for(const o of s)if("update"===o){const o=t.equal+t.insert,s=t.equal+t.delete,r=e.getChild(o);!r||r.is("uiElement")||r.is("rawElement")||this._updateElementMappings(r,i[s]),wt(n[o]),t.equal++}else t[o]++}}_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")?zo._createBefore(e.parent):e}_isSelectionInInlineFiller(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=this.domConverter.viewPositionToDom(e);return!!(t&&Ke(t.parent)&&As(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!As(e))throw new x("view-renderer-filler-was-lost",this);Ts(e)?e.remove():e.data=e.data.substr(7),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,i=e.offset;if(!this.domConverter.mapViewToDom(t.root))return!1;if(!t.is("element"))return!1;if(!function(e){if("false"==e.getAttribute("contenteditable"))return!1;const t=e.findAncestor((e=>e.hasAttribute("contenteditable")));return!t||"true"==t.getAttribute("contenteditable")}(t))return!1;const n=e.nodeBefore,o=e.nodeAfter;return!(n instanceof no||o instanceof no||!(i!==t.getFillerOffset()||n&&n.is("element","br"))||r.isAndroid&&(n||o))}_updateText(e,t){const i=this.domConverter.findCorrespondingDomText(e);let n=this.domConverter.viewToDom(e).data;const o=t.inlineFillerPosition;o&&o.parent==e.parent&&o.offset==e.index&&(n=xs+n),this._updateTextNode(i,n)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(t){for(const i of Array.from(t.attributes)){const n=i.name;e.hasAttribute(n)||this.domConverter.removeDomElementAttribute(t,n)}for(const i of e.getAttributeKeys())this.domConverter.setDomElementAttribute(t,i,e.getAttribute(i),e)}}_updateChildren(e,t){const i=this.domConverter.mapViewToDom(e);if(!i)return;if(r.isAndroid){let e=null;for(const t of Array.from(i.childNodes)){if(e&&Ke(e)&&Ke(t)){i.normalize();break}e=t}}const n=t.inlineFillerPosition,o=i.childNodes,s=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));n&&n.parent===e&&Is(i.ownerDocument,s,n.offset);const a=this._diffNodeLists(o,s),l=this._findUpdateActions(a,o,s,Os);let c=0;const u=new Set;for(const e of l)"delete"===e?(u.add(o[c]),wt(o[c])):"equal"!==e&&"update"!==e||c++;c=0;for(const e of l)"insert"===e?(ct(i,c,s[c]),c++):"update"===e?(this._updateTextNode(o[c],s[c].data),c++):"equal"===e&&(this._markDescendantTextToSync(this.domConverter.domToView(s[c])),c++);for(const e of u)e.parentNode||this.domConverter.unbindDomElement(e)}_diffNodeLists(e,t){return w(e=function(e,t){const i=Array.from(e);return 0!=i.length&&t?(i[i.length-1]==t&&i.pop(),i):i}(e,this._fakeSelectionContainer),t,Rs.bind(null,this.domConverter))}_findUpdateActions(e,t,i,n){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let o=[],s=[],r=[];const a={equal:0,insert:0,delete:0};for(const l of e)"insert"===l?r.push(i[a.equal+a.insert]):"delete"===l?s.push(t[a.equal+a.delete]):(o=o.concat(w(s,r,n).map((e=>"equal"===e?"update":e))),o.push("equal"),s=[],r=[]),a[l]++;return o.concat(w(s,r,n).map((e=>"equal"===e?"update":e)))}_updateTextNode(e,t){const i=e.data;i!=t&&(r.isAndroid&&this.isComposing&&i.replace(/\u00A0/g," ")==t.replace(/\u00A0/g," ")||this._updateTextNodeInternal(e,t))}_updateTextNodeInternal(e,t){const i=f(e.data,t);for(const t of i)"insert"===t.type?e.insertData(t.index,t.values.join("")):e.deleteData(t.index,t.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(r.isBlink&&!r.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(0===this.selection.rangeCount)return this._removeDomSelection(),void this._removeFakeSelection();const e=this.domConverter.mapViewToDom(this.selection.editableElement);this.isFocused&&e?this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&r.isAndroid||this._updateDomSelection(e):!this.selection.isFake&&this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected&&this._removeFakeSelection()}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=function(e){const t=e.createElement("div");return t.className="ck-fake-selection-container",Object.assign(t.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),t.textContent=" ",t}(t));const i=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(i,this.selection),!this._fakeSelectionNeedsUpdate(e))return;i.parentElement&&i.parentElement==e||e.appendChild(i),i.textContent=this.selection.fakeSelectionLabel||" ";const n=t.getSelection(),o=t.createRange();n.removeAllRanges(),o.selectNodeContents(i),n.addRange(o)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const i=this.domConverter.viewPositionToDom(this.selection.anchor),n=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(i.parent,i.offset,n.parent,n.offset),r.isGecko&&function(e,t){let i=e.parent,n=e.offset;if(Ke(i)&&Ts(i)&&(n=lt(i)+1,i=i.parentNode),i.nodeType!=Node.ELEMENT_NODE||n!=i.childNodes.length-1)return;const o=i.childNodes[n];o&&"BR"==o.tagName&&t.addRange(t.getRangeAt(0))}(n,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,i=e.ownerDocument.getSelection();return!t||t.parentElement!==e||i.anchorNode!==t&&!t.contains(i.anchorNode)||t.textContent!==this.selection.fakeSelectionLabel}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const i=e.activeElement,n=this.domConverter.mapDomToView(i);i&&n&&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 Is(e,t,i){const n=t instanceof Array?t:t.childNodes,o=n[i];if(Ke(o))return o.data=xs+o.data,o;{const o=e.createTextNode(xs);return Array.isArray(t)?n.splice(i,0,o):ct(t,i,o),o}}function Vs(e,t){return ze(e)&&ze(t)&&!Ke(e)&&!Ke(t)&&!ut(e)&&!ut(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function Os(e,t){return ze(e)&&ze(t)&&Ke(e)&&Ke(t)}function Rs(e,t,i){return t===i||(Ke(t)&&Ke(i)?t.data===i.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(i)))}const Ls=Cs(n.document),Bs=_s(n.document),Ms=ks(n.document),Ns="data-ck-unsafe-attribute-",Fs="data-ck-unsafe-element";class Ds{document;renderingMode;blockFillerMode;preElements;blockElements;inlineObjectElements;unsafeElements;_domDocument;_domToViewMapping=new WeakMap;_viewToDomMapping=new WeakMap;_fakeSelectionMapping=new WeakMap;_rawContentElementMatcher=new co;_inlineObjectElementMatcher=new co;_elementsWithTemporaryCustomProperties=new Set;constructor(e,{blockFillerMode:t,renderingMode:i="editing"}={}){this.document=e,this.renderingMode=i,this.blockFillerMode=t||("editing"===i?"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="editing"===this.renderingMode?n.document:n.document.implementation.createHTMLDocument("")}get domDocument(){return this._domDocument}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new $o(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 t of e.children)this.unbindDomElement(t)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,i){return"data"===this.renderingMode||!(e=e.toLowerCase()).startsWith("on")&&("srcdoc"!==e||!t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i))&&("img"===i&&("src"===e||"srcset"===e)||"source"===i&&"srcset"===e||!t.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))}setContentOf(e,t){if("data"===this.renderingMode)return void(e.innerHTML=t);const i=(new DOMParser).parseFromString(t,"text/html"),n=i.createDocumentFragment(),o=i.body.childNodes;for(;o.length>0;)n.appendChild(o[0]);const s=i.createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r=[];let a;for(;a=s.nextNode();)r.push(a);for(const e of r){for(const t of e.getAttributeNames())this.setDomElementAttribute(e,t,e.getAttribute(t));const t=e.tagName.toLowerCase();this._shouldRenameElement(t)&&(Ws(t),e.replaceWith(this._createReplacementDomElement(t,e)))}for(;e.firstChild;)e.firstChild.remove();e.append(n)}viewToDom(e,t={}){if(e.is("$text")){const t=this._processDataFromViewText(e);return this._domDocument.createTextNode(t)}{const i=e;if(this.mapViewToDom(i)){if(!i.getCustomProperty("editingPipeline:doNotReuseOnce"))return this.mapViewToDom(i);this._elementsWithTemporaryCustomProperties.add(i)}let n;if(i.is("documentFragment"))n=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(n,i);else{if(i.is("uiElement"))return n="$comment"===i.name?this._domDocument.createComment(i.getCustomProperty("$rawContent")):i.render(this._domDocument,this),t.bind&&this.bindElements(n,i),n;this._shouldRenameElement(i.name)?(Ws(i.name),n=this._createReplacementDomElement(i.name)):n=i.hasAttribute("xmlns")?this._domDocument.createElementNS(i.getAttribute("xmlns"),i.name):this._domDocument.createElement(i.name),i.is("rawElement")&&i.render(n,this),t.bind&&this.bindElements(n,i);for(const e of i.getAttributeKeys())this.setDomElementAttribute(n,e,i.getAttribute(e),i)}if(!1!==t.withChildren)for(const e of this.viewChildrenToDom(i,t))n instanceof HTMLTemplateElement?n.content.appendChild(e):n.appendChild(e);return n}}setDomElementAttribute(e,t,i,n){const o=this.shouldRenderAttribute(t,i,e.tagName.toLowerCase())||n&&n.shouldRenderUnsafeAttribute(t);o||A("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:i}),dt(t)?(e.hasAttribute(t)&&!o?e.removeAttribute(t):e.hasAttribute(Ns+t)&&o&&e.removeAttribute(Ns+t),e.setAttribute(o?t:Ns+t,i)):A("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:i})}removeDomElementAttribute(e,t){t!=Fs&&(e.removeAttribute(t),e.removeAttribute(Ns+t))}*viewChildrenToDom(e,t={}){const i=e.getFillerOffset&&e.getFillerOffset();let n=0;for(const o of e.getChildren()){i===n&&(yield this._getBlockFiller());const e=o.is("element")&&!!o.getCustomProperty("dataPipeline:transparentRendering")&&!Zt(o.getAttributes());if(e&&"data"==this.renderingMode)if(o.is("rawElement")){const e=this._domDocument.createElement(o.name);o.render(e,this),yield*[...e.childNodes]}else yield*this.viewChildrenToDom(o,t);else e&&A("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:o}),yield this.viewToDom(o,t);n++}i===n&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),i=this.viewPositionToDom(e.end),n=this._domDocument.createRange();return n.setStart(t.parent,t.offset),n.setEnd(i.parent,i.offset),n}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const i=this.findCorrespondingDomText(t);if(!i)return null;let n=e.offset;return As(i)&&(n+=7),i.data&&n>i.data.length&&(n=i.data.length),{parent:i,offset:n}}{let i,n,o;if(0===e.offset){if(i=this.mapViewToDom(t),!i)return null;o=i.childNodes[0]}else{const t=e.nodeBefore;if(n=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(t),!n)return null;i=n.parentNode,o=n.nextSibling}return Ke(o)&&As(o)?{parent:o,offset:7}:{parent:i,offset:n?lt(n)+1:0}}}domToView(e,t={}){const i=[],n=this._domToView(e,t,i),o=n.next().value;return o?(n.next(),this._processDomInlineNodes(null,i,t),"br"==this.blockFillerMode&&qs(o)||o.is("$text")&&0==o.data.length?null:o):null}*domChildrenToView(e,t={},i=[]){let n=[];n=e instanceof HTMLTemplateElement?[...e.content.childNodes]:[...e.childNodes];for(let o=0;o{const{scrollLeft:t,scrollTop:i}=e;s.push([t,i])})),t.focus({preventScroll:!0}),zs(t,(e=>{const[t,i]=s.shift();e.scrollLeft=t,e.scrollTop=i})),n.window.scrollTo(i,o)}_clearDomSelection(){const e=this.mapViewToDom(this.document.selection.editableElement);if(!e)return;const t=e.ownerDocument.defaultView.getSelection(),i=this.domSelectionToView(t);i&&i.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"br"==this.blockFillerMode?e.isEqualNode(Ls):!!js(e,this.blockElements)||e.isEqualNode(Ms)||function(e,t){return e.isEqualNode(Bs)&&Hs(e,t)&&1===e.parentNode.childNodes.length}(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 i=t.collapsed;return t.detach(),i}getHostViewElement(e){const t=function(e){const t=[];let i=e;for(;i&&i.nodeType!=Node.DOCUMENT_NODE;)t.unshift(i),i=i.parentNode;return t}(e);for(t.pop();t.length;){const e=t.pop(),i=this._domToViewMapping.get(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return i}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 _s(this._domDocument);case"markedNbsp":return ks(this._domDocument);case"br":return Cs(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(Ke(e)&&As(e)&&t<7)return!1;if(this.isElement(e)&&As(e.childNodes[t]))return!1;const i=this.mapDomToView(e);return!i||!i.is("uiElement")&&!i.is("rawElement")}*_domToView(e,t,i){if("br"!=this.blockFillerMode&&js(e,this.blockElements))return null;const n=this.getHostViewElement(e);if(n)return n;if(ut(e)&&t.skipComments)return null;if(Ke(e)){if(Ts(e))return null;{const t=e.data;if(""===t)return null;const n=new no(this.document,t);return i.push(n),n}}{let n=this.mapDomToView(e);if(n)return this._isInlineObjectElement(n)&&i.push(n),n;if(this.isDocumentFragment(e))n=new ds(this.document),t.bind&&this.bindDocumentFragments(e,n);else{n=this._createViewElement(e,t),t.bind&&this.bindElements(e,n);const o=e.attributes;if(o)for(let e=o.length,t=0;t0?t[e-1]:null,l=e+1e.is("element")&&t.includes(e.name)))}(e,this.preElements))return!0;for(const t of e.getAncestors({parentFirst:!0}))if(t.is("element")&&t.hasStyle("white-space")&&"inherit"!==t.getStyle("white-space"))return["pre","pre-wrap","break-spaces"].includes(t.getStyle("white-space"));return!1}_getTouchingInlineViewNode(e,t){const i=new Do({startPosition:t?zo._createAfter(e):zo._createBefore(e),direction:t?"forward":"backward"});for(const{item:e}of i){if(e.is("$textProxy"))return e;if(!e.is("element")||!e.getCustomProperty("dataPipeline:transparentRendering")){if(e.is("element","br"))return null;if(this._isInlineObjectElement(e))return e;if(e.is("containerElement")||this._isBlockViewElement(e))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")&&("br"==e.name||this.inlineObjectElements.includes(e.name)||!!this._inlineObjectElementMatcher.match(e))}_createViewElement(e,t){if(ut(e))return new as(this.document,"$comment");const i=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new Vo(this.document,i)}_isViewElementWithRawContent(e,t){return!1!==t.withChildren&&e.is("element")&&!!this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return"editing"===this.renderingMode&&this.unsafeElements.includes(t)}_createReplacementDomElement(e,t){const i=this._domDocument.createElement("span");if(i.setAttribute(Fs,e),t){for(;t.firstChild;)i.appendChild(t.firstChild);for(const e of t.getAttributeNames())i.setAttribute(e,t.getAttribute(e))}return i}}function zs(e,t){let i=e;for(;i;)t(i),i=i.parentElement}function Hs(e,t){const i=e.parentNode;return!!i&&!!i.tagName&&t.includes(i.tagName.toLowerCase())}function Us(e,t,i){return" "==t&&e&&e.is("element")&&1==e.childCount&&i.includes(e.name)}function $s(e,t){return" "==t&&e&&e.is("element","span")&&1==e.childCount&&e.hasAttribute("data-cke-filler")}function qs(e){return e.is("element","br")&&e.hasAttribute("data-cke-filler")}function js(e,t){return"BR"===e.tagName&&Hs(e,t)&&1===e.parentNode.childNodes.length}function Ws(e){"script"===e&&A("domconverter-unsafe-script-element-detected"),"style"===e&&A("domconverter-unsafe-style-element-detected")}class Gs extends($e()){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&&3===e.nodeType&&(e=e.parentNode),!(!e||1!==e.nodeType)&&e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}function Ks(e,t){if((e=function(e){const t=function(e){return e?(e=function(e){return _o(e)?NaN:Number(e)}(e))===1/0||e===-1/0?(e<0?-1:1)*Number.MAX_VALUE:e==e?e:0:0===e?e:0}(e),i=t%1;return i?t-i:t}(e))<1||!Number.isSafeInteger(e))return[];const i=new Array(e);for(let n=0;n=0}(t.length)?function(e){const t=Ks(e.length,(e=>`${e}`)),i=new Set(t);var n;return n=e,"undefined"!=typeof Buffer&&Buffer.isBuffer(n)&&(i.add("offset"),i.add("parent")),qt(e)&&(i.add("buffer"),i.add("byteLength"),i.add("byteOffset")),[...t,...Ys(e).filter((e=>!i.has(e)))]}(e):function(e){const t=e?.constructor;return e===("function"==typeof t?t.prototype:Object.prototype)}(e)?function(e){return Ys(e).filter((e=>"constructor"!==e))}(e):Ys(e);default:return Ys(Object(e))}var t}function Ys(e){const t=[];for(const i in e)t.push(i);return t}function Qs(e,...t){for(let i=0;i{this.listenTo(e,t,((e,t)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(t.target)&&this.onDomEvent(t)}),{useCapture:this.useCapture,usePassive:this.usePassive})}))}stopObserving(e){this.stopListening(e)}fire(e,t,i){this.isEnabled&&this.document.fire(e,new Zs(this.view,t,i))}}class tr extends er{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 Bt(this)}};this.fire(e.type,e,t)}}class ir extends Gs{_fireSelectionChangeDoneDebounced;constructor(e){super(e),this._fireSelectionChangeDoneDebounced=Wi((e=>{this.document.fire("selectionChangeDone",e)}),200)}observe(){const e=this.document;e.on("arrowKey",((t,i)=>{e.selection.isFake&&this.isEnabled&&i.preventDefault()}),{context:"$capture"}),e.on("arrowKey",((t,i)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(i.keyCode)}),{priority:"lowest"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,i=new $o(t.getRanges(),{backward:t.isBackward,fake:!1});e!=Rt.arrowleft&&e!=Rt.arrowup||i.setTo(i.getFirstPosition()),e!=Rt.arrowright&&e!=Rt.arrowdown||i.setTo(i.getLastPosition());const n={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",n),this._fireSelectionChangeDoneDebounced(n)}}function nr(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t))&&"[object Object]"===Object.prototype.toString.call(e)}function or(e,t,i){return sr(e,t,void 0,void 0,void 0,void 0,i)}function sr(e,t,i,n,o,s,r){const a=r(e,t,i,n,o,s);if(void 0!==a)return a;if(typeof e==typeof t)switch(typeof e){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return e===t;case"number":return e===t||Object.is(e,t);case"object":return rr(e,t,s,r)}return rr(e,t,s,r)}function rr(e,t,i,n){if(Object.is(e,t))return!0;let o=ae(e),s=ae(t);if(o===he&&(o=ve),s===he&&(s=ve),o!==s)return!1;switch(o){case ce:return e.toString()===t.toString();case ue:return bo(e.valueOf(),t.valueOf());case de:case ge:case me:return Object.is(e.valueOf(),t.valueOf());case le:return e.source===t.source&&e.flags===t.flags;case"[object Function]":return e===t}const r=(i=i??new Map).get(e),a=i.get(t);if(null!=r&&null!=a)return r===t;i.set(e,t),i.set(t,e);try{switch(o){case fe:if(e.size!==t.size)return!1;for(const[o,s]of e.entries())if(!t.has(o)||!sr(s,t.get(o),o,e,t,i,n))return!1;return!0;case pe:{if(e.size!==t.size)return!1;const o=Array.from(e.values()),s=Array.from(t.values());for(let r=0;rsr(a,o,void 0,e,t,i,n)));if(-1===l)return!1;s.splice(l,1)}return!0}case be:case _e:case ke:case Ce:case xe:case"[object BigUint64Array]":case Ae:case Te:case Ee:case"[object BigInt64Array]":case Se:case Pe:if("undefined"!=typeof Buffer&&Buffer.isBuffer(e)!==Buffer.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(let o=0;o{}),or(e,t,((...n)=>{const o=i(...n);return void 0!==o?Boolean(o):e instanceof Map&&t instanceof Map||e instanceof Set&&t instanceof Set?ar(Array.from(e),Array.from(t),function(e,t){if(!Number.isInteger(e)||e<0)throw new Error("n must be a non-negative integer.");let i=0;return(...n)=>{if(++i>=e)return t(...n)}}(2,i)):void 0}))}class lr extends Gs{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 e of this._domElements)this._mutationObserver.observe(e,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(0===e.length)return;const t=this.domConverter,i=new Set,n=new Set;for(const i of e){const e=t.mapDomToView(i.target);e&&(e.is("uiElement")||e.is("rawElement")||"childList"!==i.type||this._isBogusBrMutation(i)||n.add(e))}for(const o of e){const e=t.mapDomToView(o.target);if((!e||!e.is("uiElement")&&!e.is("rawElement"))&&"characterData"===o.type){const e=t.findCorrespondingViewText(o.target);e&&!n.has(e.parent)?i.add(e):!e&&As(o.target)&&n.add(t.mapDomToView(o.target.parentNode))}}const o=[];for(const e of i)o.push({type:"text",node:e});for(const e of n){const i=t.mapViewToDom(e);ar(Array.from(e.getChildren()),Array.from(t.domChildrenToView(i,{withChildren:!1})),cr)||o.push({type:"children",node:e})}o.length&&this.document.fire("mutations",{mutations:o})}_isBogusBrMutation(e){let t=null;return null===e.nextSibling&&0===e.removedNodes.length&&1==e.addedNodes.length&&(t=this.domConverter.domToView(e.addedNodes[0],{withChildren:!1})),t&&t.is("element","br")}}function cr(e,t){if(!Array.isArray(e))return e===t||!(!e.is("$text")||!t.is("$text"))&&e.data===t.data}class ur extends er{_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",((e,t)=>this._handleBlur(t))),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;null!==t&&t!==e.target||(this.document.isFocused=!1,this._isFocusChanging=!1,this.view.change((()=>{})))}_clearTimeout(){this._renderTimeoutId&&(clearTimeout(this._renderTimeoutId),this._renderTimeoutId=null)}}class dr extends Gs{mutationObserver;focusObserver;selection;domConverter;_documents=new WeakSet;_fireSelectionChangeDoneDebounced;_clearInfiniteLoopInterval;_documentIsSelectingInactivityTimeoutDebounced;_loopbackCounter=0;_pendingSelectionChange=new Set;constructor(e){super(e),this.mutationObserver=e.getObserver(lr),this.focusObserver=e.getObserver(ur),this.selection=this.document.selection,this.domConverter=e.domConverter,this._fireSelectionChangeDoneDebounced=Wi((e=>{this.document.fire("selectionChangeDone",e)}),200),this._clearInfiniteLoopInterval=setInterval((()=>this._clearInfiniteLoop()),1e3),this._documentIsSelectingInactivityTimeoutDebounced=Wi((()=>this.document.isSelecting=!1),5e3),this.view.document.on("change:isFocused",((e,t,i)=>{if(i&&this._pendingSelectionChange.size){for(const e of Array.from(this._pendingSelectionChange))this._handleSelectionChange(e);this._pendingSelectionChange.clear()}}))}observe(e){const t=e.ownerDocument,i=()=>{this.document.isSelecting&&(this._handleSelectionChange(t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",(()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()}),{priority:"highest"}),this.listenTo(e,"keydown",i,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",i,{priority:"highest",useCapture:!0}),this._documents.has(t)||(this.listenTo(t,"mouseup",i,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",(()=>{this.document.isComposing&&!r.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 i=this.domConverter.domSelectionToView(t);var n;if(0!=i.rangeCount)if(this.view.hasDomSelection=!0,this.focusObserver.flush(),this.view.document.isFocused||this.view.document.isReadOnly){if(this._pendingSelectionChange.delete(e),!this.selection.isEqual(i)||!this.domConverter.isDomSelectionCorrect(t))if(++this._loopbackCounter>60)this._reportInfiniteLoop();else if(n=i,Array.from(n.getRanges()).flatMap((e=>[e.start.root,e.end.root])).every((e=>e&&e.is("rootElement"))))if(this.selection.isSimilar(i))this.view.forceRender();else{const e={oldSelection:this.selection,newSelection:i,domSelection:t};this.document.fire("selectionChange",e),this._fireSelectionChangeDoneDebounced(e)}else this.view.forceRender()}else this._pendingSelectionChange.add(e);else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}}class hr extends er{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})}}class mr{_files;_native;constructor(e,t={}){this._files=t.cacheFiles?gr(e):null,this._native=e}get files(){return this._files||(this._files=gr(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,i){this._native.setDragImage(e,t,i)}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}function gr(e){const t=Array.from(e.files||[]),i=Array.from(e.items||[]);return t.length?t:i.filter((e=>"file"===e.kind)).map((e=>e.getAsFile()))}class fr extends er{domEventType="beforeinput";onDomEvent(e){const t=e.getTargetRanges(),i=this.view,n=i.document;let o=null,s=null,a=[];if(e.dataTransfer&&(o=new mr(e.dataTransfer)),null!==e.data?s=e.data:o&&(s=o.getData("text/plain")),n.selection.isFake)a=Array.from(n.selection.getRanges()),e.preventDefault();else if(t.length)a=t.map((t=>{let n=i.domConverter.domPositionToView(t.startContainer,t.startOffset);const o=i.domConverter.domPositionToView(t.endContainer,t.endOffset);if(n&&As(t.startContainer)&&t.startOffset<7){e.preventDefault();let i=7-t.startOffset;n=n.getLastMatchingPosition((e=>!!(e.item.is("attributeElement")||e.item.is("uiElement")||e.item.is("$textProxy")&&i--)),{direction:"backward",singleCharacters:!0})}return function(e,t){for(;e.parentNode;){if(Ke(e)){if(t!=e.data.length)return!1}else if(t!=e.childNodes.length)return!1;if((t=lt(e)+1)<(e=e.parentNode).childNodes.length&&As(e.childNodes[t]))return!0}return!1}(t.endContainer,t.endOffset)&&e.preventDefault(),n?i.createRange(n,o):o?i.createRange(o):void 0})).filter((e=>!!e));else if(r.isAndroid){const t=e.target.ownerDocument.defaultView.getSelection();a=Array.from(i.domConverter.domSelectionToView(t).getRanges())}if(r.isAndroid&&"insertCompositionText"==e.inputType&&s&&s.endsWith("\n"))this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[i.createRange(a[0].end)]});else if(["insertText","insertReplacementText"].includes(e.inputType)&&s&&s.includes("\n")){const t=s.split(/\n{1,2}/g);let i=a;e.preventDefault();for(let s=0;s{if(this.isEnabled&&((i=t.keyCode)==Rt.arrowright||i==Rt.arrowleft||i==Rt.arrowup||i==Rt.arrowdown)){const i=new jo(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(i,t),i.stop.called&&e.stop()}var i}))}observe(){}stopObserving(){}}class br extends Gs{constructor(e){super(e);const t=this.document;t.on("keydown",((e,i)=>{if(!this.isEnabled||i.keyCode!=Rt.tab||i.ctrlKey)return;const n=new jo(t,"tab",t.selection.getFirstRange());t.fire(n,i),n.stop.called&&e.stop()}))}observe(){}stopObserving(){}}class wr extends(G()){document;domConverter;domRoots=new Map;_renderer;_initialDomRootAttributes=new WeakMap;_observers=new Map;_writer;_ongoingChange=!1;_postFixersInProgress=!1;_renderingDisabled=!1;_hasChangedSinceTheLastRendering=!1;constructor(e){var t;super(),this.document=new ts(e),this.domConverter=new Ds(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new Ps(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new hs(this.document),this.addObserver(lr),this.addObserver(ur),this.addObserver(dr),this.addObserver(tr),this.addObserver(ir),this.addObserver(hr),this.addObserver(pr),this.addObserver(fr),this.addObserver(br),this.document.on("arrowKey",Ss,{priority:"low"}),(t=this).document.on("arrowKey",((e,i)=>function(e,t,i){if(t.keyCode==Rt.arrowright){const e=t.domTarget.ownerDocument.defaultView.getSelection(),n=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(n||t.shiftKey){const t=e.focusNode,o=e.focusOffset,s=i.domPositionToView(t,o);if(null===s)return;let r=!1;const a=s.getLastMatchingPosition((e=>(e.item.is("uiElement")&&(r=!0),!(!e.item.is("uiElement")&&!e.item.is("attributeElement")))));if(r){const t=i.viewPositionToDom(a);n?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}}(0,i,t.domConverter)),{priority:"low"}),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})),r.isiOS&&this.listenTo(this.document,"blur",((e,t)=>{this.domConverter.mapDomToView(t.domEvent.relatedTarget)||this.domConverter._clearDomSelection()})),this.listenTo(this.document,"mutations",((e,{mutations:t})=>{t.forEach((e=>this._renderer.markToSync(e.type,e.node)))}),{priority:"low"}),this.listenTo(this.document,"mutations",(()=>{this.forceRender()}),{priority:"lowest"})}attachDomRoot(e,t="main"){const i=this.document.getRoot(t);i._name=e.tagName.toLowerCase();const n={};for(const{name:t,value:o}of Array.from(e.attributes))n[t]=o,"class"===t?this._writer.addClass(o.split(" "),i):i.hasAttribute(t)||this._writer.setAttribute(t,o,i);this._initialDomRootAttributes.set(e,n);const o=()=>{this._writer.setAttribute("contenteditable",(!i.isReadOnly).toString(),i),i.isReadOnly?this._writer.addClass("ck-read-only",i):this._writer.removeClass("ck-read-only",i)};o(),this.domRoots.set(t,e),this.domConverter.bindElements(e,i),this._renderer.markToSync("children",i),this._renderer.markToSync("attributes",i),this._renderer.domDocuments.add(e.ownerDocument),i.on("change:children",((e,t)=>this._renderer.markToSync("children",t))),i.on("change:attributes",((e,t)=>this._renderer.markToSync("attributes",t))),i.on("change:text",((e,t)=>this._renderer.markToSync("text",t))),i.on("change:isReadOnly",(()=>this.change(o))),i.on("change",(()=>{this._hasChangedSinceTheLastRendering=!0}));for(const i of this._observers.values())i.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach((({name:e})=>t.removeAttribute(e)));const i=this._initialDomRootAttributes.get(t);for(const e in i)t.setAttribute(e,i[e]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t);for(const e of this._observers.values())e.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[e,i]of this.domRoots)t.observe(i,e);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:i=20,ancestorOffset:n=20}={}){const o=this.document.selection.getFirstRange();if(!o)return;const s=Ht({alignToTop:e,forceScroll:t,viewportOffset:i,ancestorOffset:n});"number"==typeof i&&(i={top:i,bottom:i,left:i,right:i});const r={target:this.domConverter.viewRangeToDom(o),viewportOffset:i,ancestorOffset:n,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",r,s),yt(r)}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 x("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(e){x.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(ur).flush(),this.change((()=>{}))}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return zo._createAt(e,t)}createPositionAfter(e){return zo._createAfter(e)}createPositionBefore(e){return zo._createBefore(e)}createRange(e,t){return new Ho(e,t)}createRangeOn(e){return Ho._createOn(e)}createRangeIn(e){return Ho._createIn(e)}createSelection(...e){return new $o(...e)}_disableRendering(e){this._renderingDisabled=e,0==e&&this.change((()=>{}))}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}class vr{is(){throw new Error("is() method is abstract")}}class yr extends vr{textNode;data;offsetInText;constructor(e,t,i){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new x("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new x("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get startOffset(){return null!==this.textNode.startOffset?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return null!==this.startOffset?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 i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.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()}}yr.prototype.is=function(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e};class _r{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;_visitedParent;constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new x("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new x("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=Cr._createAt(this.boundaries["backward"==this.direction?"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,i,n,o;do{n=this.position,o=this._visitedParent,({done:t,value:i}=this.next())}while(!t&&e(i));t||(this._position=n,this._visitedParent=o)}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"forward"==this.direction?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(null===i.parent&&t.offset===i.maxOffset)return{done:!0,value:void 0};if(i===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const n=xr(t,i),o=n||Ar(t,i,n);if(o&&o.is("model:element")){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}else t.path.push(0),this._visitedParent=o;return this._position=t,kr("elementStart",o,e,t,1)}if(o&&o.is("model:$text")){let n;if(this.singleCharacters)n=1;else{let e=o.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offsete&&(e=this.boundaries.start.offset),n=t.offset-e}const o=t.offset-s.startOffset,r=new yr(s,o-n,n);return t.offset-=n,this._position=t,kr("text",r,e,t,n)}return t.path.pop(),this._position=t,this._visitedParent=i.parent,kr("elementStart",i,e,t,1)}}function kr(e,t,i,n,o){return{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:o}}}class Cr extends vr{root;path;stickiness;constructor(e,t,i="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new x("model-position-root-invalid",e);if(!Array.isArray(t)||0===t.length)throw new x("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=i}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;t1)return!1;if(1===t)return Er(e,this,i);if(-1===t)return Er(this,e,i)}return this.path.length===e.path.length||(this.path.length>e.path.length?Sr(this.path,t):Sr(e.path,t))}hasSameParentAs(e){return this.root===e.root&&"same"==te(this.getParentPath(),e.getParentPath())}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=Cr._createAt(this)}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)&&"toNext"==this.stickiness?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;let i;return t.containsPosition(this)||t.start.isEqual(this)?(i=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(i=i._getTransformedByDeletion(e.deletionPosition,1))):i=this.isEqual(e.deletionPosition)?Cr._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),i}_getTransformedByDeletion(e,t){const i=Cr._createAt(this);if(this.root!=e.root)return i;if("same"==te(e.getParentPath(),this.getParentPath())){if(e.offsetthis.offset)return null;i.offset-=t}}else if("prefix"==te(e.getParentPath(),this.getParentPath())){const n=e.path.length-1;if(e.offset<=this.path[n]){if(e.offset+t>this.path[n])return null;i.path[n]-=t}}return i}_getTransformedByInsertion(e,t){const i=Cr._createAt(this);if(this.root!=e.root)return i;if("same"==te(e.getParentPath(),this.getParentPath()))(e.offset=t;){if(e.path[n]+o!==i.maxOffset)return!1;o=1,n--,i=i.parent}return!0}(e,i+1)}function Sr(e,t){for(;tt+1;){const t=n.maxOffset-i.offset;0!==t&&e.push(new Pr(i,i.getShiftedBy(t))),i.path=i.path.slice(0,-1),i.offset++,n=n.parent}for(;i.path.length<=this.end.path.length;){const t=this.end.path[i.path.length-1],n=t-i.offset;0!==n&&e.push(new Pr(i,i.getShiftedBy(n))),i.offset=t,i.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new _r(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new _r(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new _r(e);yield t.position;for(const e of t)yield e.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 Pr(this.start,this.end)]}getTransformedByOperations(e){const t=[new Pr(this.start,this.end)];for(const i of e)for(let e=0;e0?new this(i,n):new this(n,i)}static _createIn(e){return new this(Cr._createAt(e,0),Cr._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(Cr._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new x("range-create-from-ranges-empty-array",null);if(1==e.length)return e[0].clone();const t=e[0];e.sort(((e,t)=>e.start.isAfter(t.start)?1:-1));const i=e.indexOf(t),n=new this(t.start,t.end);for(let t=i-1;t>=0&&e[t].end.isEqual(n.start);t--)n.start=Cr._createAt(e[t].start);for(let t=i+1;t{if(t.viewPosition)return;const i=this._modelToViewMapping.get(t.modelPosition.parent);if(!i)throw new x("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(i,t.modelPosition.offset)}),{priority:"low"}),this.on("viewToModelPosition",((e,t)=>{if(t.modelPosition)return;const i=this.findMappedViewAncestor(t.viewPosition),n=this._viewToModelMapping.get(i),o=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,i);t.modelPosition=Cr._createAt(n,o)}),{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const i=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const t of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(t);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e)&&this._cache.stopTracking(e),this._modelToViewMapping.get(i)==e&&this._modelToViewMapping.delete(i))}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 i=this._markerNameToElements.get(t)||new Set;i.add(e);const n=this._elementToMarkerNames.get(e)||new Set;n.add(t),this._markerNameToElements.set(t,i),this._elementToMarkerNames.set(e,n)}unbindElementFromMarkerName(e,t){const i=this._markerNameToElements.get(t);i&&(i.delete(e),0==i.size&&this._markerNameToElements.delete(t));const n=this._elementToMarkerNames.get(e);n&&(n.delete(t),0==n.size&&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 Pr(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new Ho(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 i={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",i),i.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const i=new Set;for(const e of t)if(e.is("attributeElement"))for(const t of e.getElementsWithSameId())i.add(t);else i.add(e);return i}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,i){if(i!=e)return this._toModelOffset(e.parent,e.index,i)+this._toModelOffset(e,t,e);if(e.is("$text"))return t;let n=0;for(let i=0;i0;){const e=t.pop(),n=e.name&&this._viewToModelLengthCallbacks.size>0&&this._viewToModelLengthCallbacks.get(e.name);if(n)i+=n(e);else if(this._viewToModelMapping.has(e))i+=1;else if(e.is("$text"))i+=e.data.length;else{if(e.is("uiElement"))continue;for(const i of e.getChildren())t.push(i)}}return i}findPositionIn(e,t){if(0===t)return this._moveViewPositionToTextNode(new zo(e,0));if(0==this._viewToModelLengthCallbacks.size&&this._viewToModelMapping.has(e)){const i=this._cache.getClosest(e,t);return this._findPositionStartingFrom(i.viewPosition,i.modelOffset,t,e,!0)}return this._findPositionStartingFrom(new zo(e,0),0,t,e,!1)}_findPositionStartingFrom(e,t,i,n,o){let s,r=e.parent,a=e.offset;if(r.is("$text"))return new zo(r,i-t);let l=t,c=0;for(;l{this._clearCacheInsideParent(t,i.index)};_invalidateOnTextChangeCallback=(e,t)=>{this._clearCacheAfter(t)};save(e,t,i,n){const o=this._cachedMapping.get(i),s=o.cacheMap.get(n);if(s){const i=e.getChild(t-1),n=s.viewPosition.nodeBefore?this._nodeToCacheListIndex.get(s.viewPosition.nodeBefore):0;return void this._nodeToCacheListIndex.set(i,n)}const r={viewPosition:new zo(e,t),modelOffset:n};o.maxModelOffset=n>o.maxModelOffset?n:o.maxModelOffset,o.cacheMap.set(n,r);let a=o.cacheList.length-1;for(;a>=0&&o.cacheList[a].modelOffset>n;)a--;if(o.cacheList.splice(a+1,0,r),t>0){const i=e.getChild(t-1);this._nodeToCacheListIndex.set(i,a+1)}}getClosest(e,t){const i=this._cachedMapping.get(e);let n;if(i)if(t>i.maxModelOffset)n=i.cacheList[i.cacheList.length-1];else{n=i.cacheMap.get(t)||this._findInCacheList(i.cacheList,t)}else n=this.startTracking(e);return{modelOffset:n.modelOffset,viewPosition:n.viewPosition.clone()}}startTracking(e){const t={viewPosition:new zo(e,0),modelOffset:0},i={maxModelOffset:0,cacheList:[t],cacheMap:new Map([[0,t]])};return this._cachedMapping.set(e,i),e.on("change:children",this._invalidateOnChildrenChangeCallback),e.on("change:text",this._invalidateOnTextChangeCallback),t}stopTracking(e){e.off("change:children",this._invalidateOnChildrenChangeCallback),e.off("change:text",this._invalidateOnTextChangeCallback),this._cachedMapping.delete(e)}_clearCacheInsideParent(e,t){if(0==t)this._cachedMapping.has(e)?this._clearCacheAll(e):this._clearCacheInsideParent(e.parent,e.index);else{const i=e.getChild(t-1);this._clearCacheAfter(i)}}_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(void 0===t){const t=e.parent;return void(this._cachedMapping.has(t)||this._clearCacheInsideParent(t.parent,t.index))}let i=e.parent;for(;!this._cachedMapping.has(i);)i=i.parent;this._clearCacheFromCacheIndex(i,t)}_clearCacheFromCacheIndex(e,t){0===t&&(t=1);const i=this._cachedMapping.get(e),n=i.cacheList[t-1];if(!n)return;i.maxModelOffset=n.modelOffset;const o=i.cacheList.splice(t);for(const e of o){i.cacheMap.delete(e.modelOffset);const t=e.viewPosition.nodeBefore;this._nodeToCacheListIndex.delete(t)}}_findInCacheList(e,t){let i=0,n=e.length-1,o=n-i>>1,s=e[o];for(;i>1),s=e[o];return s.modelOffset<=t?s:e[o-1]}}class Or{_consumable=new Map;_textProxyRegistry=new Map;add(e,t){t=Rr(t),e instanceof yr&&(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=Rr(t),e instanceof yr&&(e=this._getSymbolForTextProxy(e)),!!this.test(e,t)&&(this._consumable.get(e).set(t,!1),!0)}test(e,t){t=Rr(t),e instanceof yr&&(e=this._getSymbolForTextProxy(e));const i=this._consumable.get(e);if(void 0===i)return null;const n=i.get(t);return void 0===n?null:n}revert(e,t){t=Rr(t),e instanceof yr&&(e=this._getSymbolForTextProxy(e));const i=this.test(e,t);return!1===i?(this._consumable.get(e).set(t,!0),!0):!0!==i&&null}verifyAllConsumed(e){const t=[];for(const[i,n]of this._consumable)for(const[o,s]of n){const n=o.split(":")[0];s&&e==n&&t.push({event:o,item:i.name||i.description})}if(t.length)throw new x("conversion-model-consumable-not-consumed",null,{items:t})}_getSymbolForTextProxy(e){let t=null;const i=this._textProxyRegistry.get(e.startOffset);if(i){const n=i.get(e.endOffset);n&&(t=n.get(e.parent))}return t||(t=this._addSymbolForTextProxy(e)),t}_addSymbolForTextProxy(e){const t=e.startOffset,i=e.endOffset,n=e.parent,o=Symbol("$textProxy:"+e.data);let s,r;return s=this._textProxyRegistry.get(t),s||(s=new Map,this._textProxyRegistry.set(t,s)),r=s.get(i),r||(r=new Map,s.set(i,r)),r.set(n,o),o}}function Rr(e){const t=e.split(":");return"insert"==t[0]?t[0]:"addMarker"==t[0]||"removeMarker"==t[0]?e:t.length>1?t[0]+":"+t[1]:t[0]}class Lr extends(R()){_conversionApi;_firedEventsMap;constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,i){const n=e.getRefreshedItems(),o=this._createConversionApi(i,n);for(const t of e.getMarkersToRemove())this._convertMarkerRemove(t.name,t.range,o);const s=this._reduceChanges(e.getChanges(),n);for(const e of s)"insert"===e.type?this._convertInsert(Pr._createFromPositionAndShift(e.position,e.length),o):"reinsert"===e.type?this._convertReinsert(Pr._createFromPositionAndShift(e.position,e.length),o):"remove"===e.type?this._convertRemove(e.position,e.length,e.name,o):this._convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,o);o.mapper.flushDeferredBindings();for(const e of o.mapper.flushUnboundMarkerNames()){const i=t.get(e).getRange();this._convertMarkerRemove(e,i,o),this._convertMarkerAdd(e,i,o)}for(const t of e.getMarkersToAdd())this._convertMarkerAdd(t.name,t.range,o);o.consumable.verifyAllConsumed("insert")}convert(e,t,i,n={}){const o=this._createConversionApi(i,void 0,n);this._convertInsert(e,o);for(const[e,i]of t)this._convertMarkerAdd(e,i,o);o.consumable.verifyAllConsumed("insert")}convertSelection(e,t,i){const n=this._createConversionApi(i);this.fire("cleanSelection",{selection:e},n);const o=e.getFirstPosition().root;if(!n.mapper.toViewElement(o))return;const s=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(n.consumable,e,s),this.fire("selection",{selection:e},n),e.isCollapsed){for(const t of s)if(n.consumable.test(e,"addMarker:"+t.name)){const i=t.getRange();if(!Br(e.getFirstPosition(),t,n.mapper))continue;const o={item:e,markerName:t.name,markerRange:i};this.fire(`addMarker:${t.name}`,o,n)}for(const t of e.getAttributeKeys())if(n.consumable.test(e,"attribute:"+t)){const i={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};this.fire(`attribute:${t}:$text`,i,n)}}}_convertInsert(e,t,i={}){i.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,e);for(const i of e.getWalker({shallow:!0}))this._testAndFire("insert",Mr(i),t)}_convertRemove(e,t,i,n){this.fire(`remove:${i}`,{position:e,length:t},n)}_convertAttribute(e,t,i,n,o){this._addConsumablesForRange(o.consumable,e,`attribute:${t}`);for(const s of e){const e={item:s.item,range:Pr._createFromPositionAndShift(s.previousPosition,s.length),attributeKey:t,attributeOldValue:i,attributeNewValue:n};this._testAndFire(`attribute:${t}`,e,o)}}_convertReinsert(e,t){const i=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,i);for(const e of i.map(Mr))this.fire(`remove:${e.item.is("element")?e.item.name:"$text"}`,{position:e.range.start,length:e.item.offsetSize,reconversion:!0},t),this._testAndFire("insert",{...e,reconversion:!0},t)}_convertMarkerAdd(e,t,i){if("$graveyard"==t.root.rootName)return;const n=`addMarker:${e}`;if(i.consumable.add(t,n),this.fire(n,{markerName:e,markerRange:t},i),i.consumable.consume(t,n)){this._addConsumablesForRange(i.consumable,t,n);for(const o of t.getItems()){if(!i.consumable.test(o,n))continue;const s={item:o,range:Pr._createOn(o),markerName:e,markerRange:t};this.fire(n,s,i)}}}_convertMarkerRemove(e,t,i){"$graveyard"!=t.root.rootName&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},i)}_reduceChanges(e,t){const i={changes:e,refreshedItems:t};return this.fire("reduceChanges",i),i.changes}_addConsumablesForInsert(e,t){for(const i of t){const t=i.item;if(null===e.test(t,"insert")){e.add(t,"insert");for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i)}}return e}_addConsumablesForRange(e,t,i){for(const n of t.getItems())e.add(n,i);return e}_addConsumablesForSelection(e,t,i){e.add(t,"selection");for(const n of i)e.add(t,"addMarker:"+n.name);for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i);return e}_testAndFire(e,t,i){const n=function(e,t){return`${e}:${t.item.is("element")?t.item.name:"$text"}`}(e,t),o=t.item.is("$textProxy")?i.consumable._getSymbolForTextProxy(t.item):t.item,s=this._firedEventsMap.get(i),r=s.get(o);if(r){if(r.has(n))return;r.add(n)}else s.set(o,new Set([n]));this.fire(n,t,i)}_testAndFireAddAttributes(e,t){const i={item:e,range:Pr._createOn(e)};for(const e of i.item.getAttributeKeys())i.attributeKey=e,i.attributeOldValue=null,i.attributeNewValue=i.item.getAttribute(e),this._testAndFire(`attribute:${e}`,i,t)}_createConversionApi(e,t=new Set,i={}){const n={...this._conversionApi,consumable:new Or,writer:e,options:i,convertItem:e=>this._convertInsert(Pr._createOn(e),n),convertChildren:e=>this._convertInsert(Pr._createIn(e),n,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,n),canReuseView:e=>!t.has(n.mapper.toModelElement(e))};return this._firedEventsMap.set(n,new Map),n}}function Br(e,t,i){const n=t.getRange(),o=Array.from(e.getAncestors());return o.shift(),o.reverse(),!o.some((e=>{if(n.containsItem(e))return!!i.toViewElement(e).getCustomProperty("addHighlight")}))}function Mr(e){return{item:e.item,range:Pr._createFromPositionAndShift(e.previousPosition,e.length)}}class Nr extends vr{parent=null;_attrs;_index=null;_startOffset=null;constructor(e){super(),this._attrs=si(e)}get document(){return null}get index(){return this._index}get startOffset(){return this._startOffset}get offsetSize(){return 1}get endOffset(){return null===this.startOffset?null:this.startOffset+this.offsetSize}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return null!==this.parent&&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 i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let o=0;for(;i[o]==n[o]&&i[o];)o++;return 0===o?null:i[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=te(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n](e[t[0]]=t[1],e)),{})),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=si(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}Nr.prototype.is=function(e){return"node"===e||"model:node"===e};class Fr extends(R(vr)){_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 1===this._ranges.length&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new Pr(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 Pr(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 Pr(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,i,n]=e;if("object"==typeof i&&(n=i,i=void 0),null===t)this._setRanges([]);else if(t instanceof Fr)this._setRanges(t.getRanges(),t.isBackward);else if(t&&"function"==typeof t.getRanges)this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof Pr)this._setRanges([t],!!n&&!!n.backward);else if(t instanceof Cr)this._setRanges([new Pr(t)]);else if(t instanceof Nr){const e=!!n&&!!n.backward;let o;if("in"==i)o=Pr._createIn(t);else if("on"==i)o=Pr._createOn(t);else{if(void 0===i)throw new x("model-selection-setto-required-second-parameter",[this,t]);o=new Pr(Cr._createAt(t,i))}this._setRanges([o],e)}else{if(!ie(t))throw new x("model-selection-setto-not-selectable",[this,t]);this._setRanges(t,n&&!!n.backward)}}_setRanges(e,t=!1){const i=Array.from(e),n=i.some((t=>{if(!(t instanceof Pr))throw new x("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every((e=>!e.isEqual(t)))}));(i.length!==this._ranges.length||n)&&(this._replaceAllRanges(i),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(null===this.anchor)throw new x("model-selection-setfocus-no-ranges",[this,e]);const i=Cr._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.length&&this._popRange(),"before"==i.compareWith(n)?(this._pushRange(new Pr(i,n)),this._lastRangeBackward=!0):(this._pushRange(new Pr(n,i)),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 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const i=Hr(t.start,e);$r(i,t)&&(yield i);const n=t.getWalker();for(const i of n){const o=i.item;"elementEnd"==i.type&&zr(o,e,t)?yield o:"elementStart"==i.type&&o.is("model:element")&&o.root.document.model.schema.isBlock(o)&&n.jumpTo(Cr._createAt(o,"end"))}const o=Hr(t.end,e);qr(o,t)&&(yield o)}}containsEntireContent(e=this.anchor.root){const t=Cr._createAt(e,0),i=Cr._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}toJSON(){const e={ranges:Array.from(this.getRanges()).map((e=>e.toJSON()))},t=Object.fromEntries(this.getAttributes());return Object.keys(t).length&&(e.attributes=t),this.isBackward&&(e.isBackward=!0),e}_pushRange(e){this._checkRange(e),this._ranges.push(new Pr(e.start,e.end))}_checkRange(e){for(let t=0;t0;)this._popRange()}_popRange(){this._ranges.pop()}}function Dr(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&!!e.parent)}function zr(e,t,i){return Dr(e,t)&&Ur(e,i)}function Hr(e,t){const i=e.parent.root.document.model.schema,n=e.parent.getAncestors({parentFirst:!0,includeSelf:!0});let o=!1;const s=n.find((e=>!o&&(o=i.isLimit(e),!o&&Dr(e,t))));return n.forEach((e=>t.add(e))),s}function Ur(e,t){const i=function(e){const t=e.root.document.model.schema;let i=e.parent;for(;i;){if(t.isBlock(i))return i;i=i.parent}}(e);return!i||!t.containsRange(Pr._createOn(i),!0)}function $r(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.start.isTouching(Cr._createAt(e,e.maxOffset))&&Ur(e,t))}function qr(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.end.isTouching(Cr._createAt(e,0))&&Ur(e,t))}Fr.prototype.is=function(e){return"selection"===e||"model:selection"===e};class jr extends(R(Pr)){constructor(e,t){super(e,t),Wr.call(this)}detach(){this.stopListening()}toRange(){return new Pr(this.start,this.end)}static fromRange(e){return new jr(e.start,e.end)}}function Wr(){this.listenTo(this.root.document.model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&Gr.call(this,i)}),{priority:"low"})}function Gr(e){const t=this.getTransformedByOperation(e),i=Pr._createFromRanges(t),n=!i.isEqual(this),o=function(e,t){switch(t.type){case"insert":return e.containsPosition(t.position);case"move":case"remove":case"reinsert":case"merge":return e.containsPosition(t.sourcePosition)||e.start.isEqual(t.sourcePosition)||e.containsPosition(t.targetPosition);case"split":return e.containsPosition(t.splitPosition)||e.containsPosition(t.insertionPosition)}return!1}(this,e);let s=null;if(n){"$graveyard"==i.root.rootName&&(s="remove"==e.type?e.sourcePosition:e.deletionPosition);const t=this.toRange();this.start=i.start,this.end=i.end,this.fire("change:range",t,{deletionPosition:s})}else o&&this.fire("change:content",this.toRange(),{deletionPosition:s})}jr.prototype.is=function(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e};class Kr extends Nr{_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 Kr(this.data,this.getAttributes())}static fromJSON(e){return new Kr(e.data,e.attributes)}}Kr.prototype.is=function(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e};const Jr="selection:";class Yr extends(R(vr)){_selection;constructor(e){super(),this._selection=new Qr(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)}toJSON(){return this._selection.toJSON()}_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 Jr+e}static _isStoreAttributeKey(e){return e.startsWith(Jr)}}Yr.prototype.is=function(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e};class Qr extends Fr{markers=new Xt({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",((e,t)=>{const i=t[0];i.isDocumentOperation&&"marker"!=i.type&&"rename"!=i.type&&"noop"!=i.type&&(0==this._ranges.length&&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",((e,t,i,n)=>{this._updateMarker(t,n)})),this.listenTo(this._document,"change",((e,t)=>{!function(e,t){const i=e.document.differ;for(const n of i.getChanges()){if("insert"!=n.type)continue;const i=n.position.parent;n.length===i.maxOffset&&e.enqueueChange(t,(e=>{const t=Array.from(i.getAttributeKeys()).filter((e=>e.startsWith(Jr)));for(const n of t)e.removeAttribute(n,i)}))}}(this._model,t)}))}get isCollapsed(){return 0===this._ranges.length?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;ee.toJSON()))),e}_validateSelectionRanges(e){for(const t of e)if(!this._document._validateSelectionRange(t))throw new x("document-selection-wrong-position",this,{range:t})}_prepareRange(e){if(this._checkRange(e),e.root==this._document.graveyard)return;const t=jr.fromRange(e);return t.on("change:range",((e,i,n)=>{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=n.deletionPosition;const e=this._ranges.indexOf(t);this._ranges.splice(e,1),t.detach()}})),t}updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const t of this._model.markers){const i=t.name.split(":",1)[0];if(!this._observedMarkers.has(i))continue;const n=t.getRange();for(const i of this.getRanges())n.containsRange(i,!i.isCollapsed)&&e.push(t)}const i=Array.from(this.markers);for(const i of e)this.markers.has(i)||(this.markers.add(i),t=!0);for(const i of Array.from(this.markers))e.includes(i)||(this.markers.remove(i),t=!0);t&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateMarker(e,t){const i=e.name.split(":",1)[0];if(!this._observedMarkers.has(i))return;let n=!1;const o=Array.from(this.markers),s=this.markers.has(e);if(t){let i=!1;for(const e of this.getRanges())if(t.containsRange(e,!e.isCollapsed)){i=!0;break}i&&!s?(this.markers.add(e),n=!0):!i&&s&&(this.markers.remove(e),n=!0)}else s&&(this.markers.remove(e),n=!0);n&&this.fire("change:marker",{oldMarkers:o,directChange:!1})}_updateAttributes(e){const t=si(this._getSurroundingAttributes()),i=si(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[e,t]of this._attributePriority)"low"==t&&(this._attrs.delete(e),this._attributePriority.delete(e));this._setAttributesTo(t);const n=[];for(const[e,t]of this.getAttributes())i.has(e)&&i.get(e)===t||n.push(e);for(const[e]of i)this.hasAttribute(e)||n.push(e);n.length>0&&this.fire("change:attribute",{attributeKeys:n,directChange:!1})}_setAttribute(e,t,i=!0){const n=i?"normal":"low";return("low"!=n||"normal"!=this._attributePriority.get(e))&&(super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,n),!0))}_removeAttribute(e,t=!0){const i=t?"normal":"low";return!("low"==i&&"normal"==this._attributePriority.get(e)||(this._attributePriority.set(e,i),!super.hasAttribute(e)||(this._attrs.delete(e),0)))}_setAttributesTo(e){const t=new Set;for(const[t,i]of this.getAttributes())e.get(t)!==i&&this._removeAttribute(t,!1);for(const[i,n]of e)this._setAttribute(i,n,!1)&&t.add(i);return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())if(t.startsWith(Jr)){const i=t.substr(10);yield[i,e.getAttribute(t)]}}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;if("$graveyard"==e.root.rootName)return null;let i=null;if(this.isCollapsed){const n=e.textNode?e.textNode:e.nodeBefore,o=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(i=Xr(n,t)),i||(i=Xr(o,t)),!this.isGravityOverridden&&!i){let e=n;for(;e&&!i;)e=e.previousSibling,i=Xr(e,t)}if(!i){let e=o;for(;e&&!i;)e=e.nextSibling,i=Xr(e,t)}i||(i=this.getStoredAttributes())}else{const e=this.getFirstRange();for(const n of e){if(n.item.is("element")&&t.isObject(n.item)){i=Xr(n.item,t);break}if("text"==n.type){i=n.item.getAttributes();break}}}return i}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function Xr(e,t){if(!e)return null;if(e instanceof yr||e instanceof Kr)return e.getAttributes();if(!t.isInline(e))return null;if(!t.isObject(e))return[];const i=[];for(const[n,o]of e.getAttributes())t.checkAttribute("$text",n)&&!1!==t.getAttributeProperties(n).copyFromObject&&i.push([n,o]);return i}class Zr{_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 x("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 x("model-nodelist-offset-out-of-bounds",this,{offset:e,nodeList:this});return this.getNodeIndex(t)}_insertNodes(e,t){const i=[];for(const e of t){if(!(e instanceof Nr))throw new x("model-nodelist-insertnodes-not-node",this);i.push(e)}let n=this.indexToOffset(e);ri(this._nodes,i,e),ri(this._offsetToNode,function(e){const t=[];let i=0;for(const n of e)for(let e=0;enull!==e.index)),this._offsetToNode=this._offsetToNode.filter((e=>null!==e.index));let t=0;for(let e=0;ee.toJSON()))}}class ea extends Nr{name;_children=new Zr;constructor(e,t,i){super(t),this.name=e,i&&this._insertChild(0,i)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}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 i of e)t=t.getChildAtOffset(i);return t}findAncestor(e,t={}){let i=t.includeSelf?this:this.parent;for(;i;){if(i.name===e)return i;i=i.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?function(e){const t=[];for(const i of e)t.push(i._clone(!0));return t}(this._children):void 0;return new ea(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new Kr(e)];ie(e)||(e=[e]);const t=[];for(const i of e)"string"==typeof i?t.push(new Kr(i)):i instanceof yr?t.push(new Kr(i.data,i.getAttributes())):t.push(i);return t}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}_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 i of e.children)i.name?t.push(ea.fromJSON(i)):t.push(Kr.fromJSON(i))}return new ea(e.name,e.attributes,t)}}ea.prototype.is=function(e,t){return t?t===this.name&&("element"===e||"model:element"===e):"element"===e||"model:element"===e||"node"===e||"model:node"===e};class ta{_dispatchers;constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}class ia extends ta{elementToElement(e){return this.add(function(e){const t=aa(e.model),i=la(e.view,"container");return t.attributes.length&&(t.children=!0),n=>{n.on(`insert:${t.name}`,function(e,t=pa){return(i,n,o)=>{if(!t(n.item,o.consumable,{preflight:!0}))return;const s=e(n.item,o,n);if(!s)return;t(n.item,o.consumable);const r=n.reconversion&&sa(n.item,o)||o.mapper.toViewPosition(n.range.start);o.mapper.bindElements(n.item,s),o.writer.insert(r,s),o.convertAttributes(n.item),ga(s,n.item.getChildren(),o,{reconversion:n.reconversion})}}(i,ma(t)),{priority:e.converterPriority||"normal"}),(t.children||t.attributes.length)&&n.on("reduceChanges",ha(t),{priority:"low"})}}(e))}elementToStructure(e){return this.add(function(e){const t=aa(e.model),i=la(e.view,"container");return t.children=!0,n=>{if(n._conversionApi.schema.checkChild(t.name,"$text"))throw new x("conversion-element-to-structure-disallowed-text",n,{elementName:t.name});var o,s;n.on(`insert:${t.name}`,(o=i,s=ma(t),(e,t,i)=>{if(!s(t.item,i.consumable,{preflight:!0}))return;const n=new Map;i.writer._registerSlotFactory(function(e,t,i){return(n,o)=>{const s=n.createContainerElement("$slot");let r=null;if("children"===o)r=Array.from(e.getChildren());else{if("function"!=typeof o)throw new x("conversion-slot-mode-unknown",i.dispatcher,{modeOrFilter:o});r=Array.from(e.getChildren()).filter((e=>o(e)))}return t.set(s,r),s}}(t.item,n,i));const r=o(t.item,i,t);if(i.writer._clearSlotFactory(),!r)return;!function(e,t,i){const n=Array.from(t.values()).flat(),o=new Set(n);if(o.size!=n.length)throw new x("conversion-slot-filter-overlap",i.dispatcher,{element:e});if(o.size!=e.childCount)throw new x("conversion-slot-filter-incomplete",i.dispatcher,{element:e})}(t.item,n,i),s(t.item,i.consumable);const a=t.reconversion&&sa(t.item,i)||i.mapper.toViewPosition(t.range.start);i.mapper.bindElements(t.item,r),i.writer.insert(a,r),i.convertAttributes(t.item),function(e,t,i,n){i.mapper.on("modelToViewPosition",r,{priority:"highest"});let o=null,s=null;for([o,s]of t)ga(e,s,i,n),i.writer.setCustomProperty("$structureSlotParent",!0,o.parent),i.writer.move(i.writer.createRangeIn(o),i.writer.createPositionBefore(o)),i.writer.remove(o);function r(e,t){const i=t.modelPosition.nodeAfter,n=s.indexOf(i);n<0||(t.viewPosition=t.mapper.findPositionIn(o,n))}i.mapper.off("modelToViewPosition",r)}(r,n,i,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),n.on("reduceChanges",ha(t),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){let t=(e=Ht(e)).model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;if(t.name&&(i+=":"+t.name),t.values)for(const i of t.values)e.view[i]=la(e.view[i],"attribute");else e.view=la(e.view,"attribute");const n=ca(e);return t=>{t.on(i,function(e){return(t,i,n)=>{if(!n.consumable.test(i.item,t.name))return;const o=e(i.attributeOldValue,n,i),s=e(i.attributeNewValue,n,i);if(!o&&!s)return;n.consumable.consume(i.item,t.name);const r=n.writer,a=r.document.selection;if(i.item instanceof Fr||i.item instanceof Yr)r.wrap(a.getFirstRange(),s);else{let e=n.mapper.toViewRange(i.range);null!==i.attributeOldValue&&o&&(e=r.unwrap(e,o)),null!==i.attributeNewValue&&s&&r.wrap(e,s)}}}(n),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){let t=(e=Ht(e)).model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;if(t.name&&(i+=":"+t.name),t.values)for(const i of t.values)e.view[i]=ua(e.view[i]);else e.view=ua(e.view);const n=ca(e);return t=>{var o;t.on(i,(o=n,(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=o(t.attributeOldValue,i,t),s=o(t.attributeNewValue,i,t);if(!n&&!s)return;i.consumable.consume(t.item,e.name);const r=i.mapper.toViewElement(t.item),a=i.writer;if(!r)throw new x("conversion-attribute-to-attribute-on-text",i.dispatcher,t);if(null!==t.attributeOldValue&&n){let e=n.value;"style"==n.key&&(e="string"==typeof n.value?new Ao(a.document.stylesProcessor).setTo(n.value).getStylesEntries().map((([e])=>e)):Object.keys(n.value)),a.removeAttribute(n.key,e,r)}if(null!==t.attributeNewValue&&s){let e=s.value;"style"==s.key&&"string"==typeof s.value&&(e=Object.fromEntries(new Ao(a.document.stylesProcessor).setTo(s.value).getStylesEntries())),a.setAttribute(s.key,e,!1,r)}}),{priority:e.converterPriority||"normal"})}}(e))}markerToElement(e){return this.add(function(e){const t=la(e.view,"ui");return i=>{var n;i.on(`addMarker:${e.model}`,(n=t,(e,t,i)=>{t.isOpening=!0;const o=n(t,i);t.isOpening=!1;const s=n(t,i);if(!o||!s)return;const r=t.markerRange;if(r.isCollapsed&&!i.consumable.consume(r,e.name))return;for(const t of r)if(!i.consumable.consume(t.item,e.name))return;const a=i.mapper,l=i.writer;l.insert(a.toViewPosition(r.start),o),i.mapper.bindElementToMarker(o,t.markerName),r.isCollapsed||(l.insert(a.toViewPosition(r.end),s),i.mapper.bindElementToMarker(s,t.markerName)),e.stop()}),{priority:e.converterPriority||"normal"}),i.on(`removeMarker:${e.model}`,((e,t,i)=>{const n=i.mapper.markerNameToElements(t.markerName);if(n){for(const e of n)i.mapper.unbindElementFromMarkerName(e,t.markerName),i.writer.clear(i.writer.createRangeOn(e),e);i.writer.clearClonedElementsGroup(t.markerName),e.stop()}}),{priority:e.converterPriority||"normal"})}}(e))}markerToHighlight(e){return this.add(function(e){return t=>{var i;t.on(`addMarker:${e.model}`,(i=e.view,(e,t,n)=>{if(!t.item)return;if(!(t.item instanceof Fr||t.item instanceof Yr||t.item.is("$textProxy")))return;const o=da(i,t,n);if(!o)return;if(!n.consumable.consume(t.item,e.name))return;const s=n.writer,r=na(s,o),a=s.document.selection;if(t.item instanceof Fr||t.item instanceof Yr)s.wrap(a.getFirstRange(),r);else{const e=n.mapper.toViewRange(t.range),i=s.wrap(e,r);for(const e of i.getItems())if(e.is("attributeElement")&&e.isSimilar(r)){n.mapper.bindElementToMarker(e,t.markerName);break}}}),{priority:e.converterPriority||"normal"}),t.on(`addMarker:${e.model}`,function(e){return(t,i,n)=>{if(!i.item)return;if(!(i.item instanceof ea))return;const o=da(e,i,n);if(!o)return;if(!n.consumable.test(i.item,t.name))return;const s=n.mapper.toViewElement(i.item);if(s&&s.getCustomProperty("addHighlight")){n.consumable.consume(i.item,t.name);for(const e of Pr._createIn(i.item))n.consumable.consume(e.item,t.name);s.getCustomProperty("addHighlight")(s,o,n.writer),n.mapper.bindElementToMarker(s,i.markerName)}}}(e.view),{priority:e.converterPriority||"normal"}),t.on(`removeMarker:${e.model}`,function(e){return(t,i,n)=>{if(i.markerRange.isCollapsed)return;const o=da(e,i,n);if(!o)return;const s=na(n.writer,o),r=n.mapper.markerNameToElements(i.markerName);if(r){for(const e of r)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("attributeElement")?n.writer.unwrap(n.writer.createRangeOn(e),s):e.getCustomProperty("removeHighlight")(e,o.id,n.writer);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}markerToData(e){return this.add(function(e){const t=(e=Ht(e)).model;let i=e.view;return i||(i=i=>({group:t,name:i.substr(e.model.length+1)})),n=>{var o;n.on(`addMarker:${t}`,(o=i,(e,t,i)=>{const n=o(t.markerName,i);if(!n)return;const s=t.markerRange;i.consumable.consume(s,e.name)&&(ra(s,!1,i,t,n),ra(s,!0,i,t,n),e.stop())}),{priority:e.converterPriority||"normal"}),n.on(`removeMarker:${t}`,function(e){return(t,i,n)=>{const o=e(i.markerName,n);if(!o)return;const s=n.mapper.markerNameToElements(i.markerName);if(s){for(const e of s)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("containerElement")?(r(`data-${o.group}-start-before`,e),r(`data-${o.group}-start-after`,e),r(`data-${o.group}-end-before`,e),r(`data-${o.group}-end-after`,e)):n.writer.clear(n.writer.createRangeOn(e),e);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}function r(e,t){if(t.hasAttribute(e)){const i=new Set(t.getAttribute(e).split(","));i.delete(o.name),0==i.size?n.writer.removeAttribute(e,t):n.writer.setAttribute(e,Array.from(i).join(","),t)}}}}(i),{priority:e.converterPriority||"normal"})}}(e))}}function na(e,t){const i=e.createAttributeElement("span",t.attributes);return t.classes&&i._addClass(t.classes),"number"==typeof t.priority&&(i._priority=t.priority),i._id=t.id,i}function oa(e,t){const i=t.writer.remove(e);for(const e of t.writer.createRangeIn(i).getItems())t.mapper.unbindViewElement(e,{defer:!0});return e.start}function sa(e,t){const i=t.mapper.toViewElement(e);return i&&oa(t.writer.createRangeOn(i),t)}function ra(e,t,i,n,o){const s=t?e.start:e.end,r=s.nodeAfter&&s.nodeAfter.is("element")?s.nodeAfter:null,a=s.nodeBefore&&s.nodeBefore.is("element")?s.nodeBefore:null;if(r||a){let e,s;t&&r||!t&&!a?(e=r,s=!0):(e=a,s=!1);const l=i.mapper.toViewElement(e);if(l)return void function(e,t,i,n,o,s){const r=`data-${s.group}-${t?"start":"end"}-${i?"before":"after"}`,a=e.hasAttribute(r)?e.getAttribute(r).split(","):[];a.unshift(s.name),n.writer.setAttribute(r,a.join(","),e),n.mapper.bindElementToMarker(e,o.markerName)}(l,t,s,i,n,o)}!function(e,t,i,n,o){const s=`${o.group}-${t?"start":"end"}`,r=o.name?{name:o.name}:null,a=i.writer.createUIElement(s,r);i.writer.insert(e,a),i.mapper.bindElementToMarker(a,n.markerName)}(i.mapper.toViewPosition(s),t,i,n,o)}function aa(e){return"string"==typeof e&&(e={name:e}),{name:e.name,attributes:e.attributes?zt(e.attributes):[],children:!!e.children}}function la(e,t){return"function"==typeof e?e:(i,n)=>function(e,t,i){let n;"string"==typeof e&&(e={name:e});const o=t.writer,s=Object.assign({},e.attributes);if("container"==i)n=o.createContainerElement(e.name,s);else if("attribute"==i){const t={priority:e.priority||is.DEFAULT_PRIORITY};n=o.createAttributeElement(e.name,s,t)}else n=o.createUIElement(e.name,s);if(e.styles){const t=Object.keys(e.styles);for(const i of t)o.setStyle(i,e.styles[i],n)}if(e.classes){const t=e.classes;if("string"==typeof t)o.addClass(t,n);else for(const e of t)o.addClass(e,n)}return n}(e,n,t)}function ca(e){return e.model.values?(t,i,n)=>{const o=e.view[t];return o?o(t,i,n):null}:e.view}function ua(e){return"string"==typeof e?t=>({key:e,value:t}):"object"==typeof e?e.value?()=>e:t=>({key:e.key,value:t}):e}function da(e,t,i){const n="function"==typeof e?e(t,i):{...e};return n?(n.priority||(n.priority=10),n.id||(n.id=t.markerName),n):null}function ha(e){const t=function(e){return(t,i)=>{if(!t.is("element",e.name))return!1;if("attribute"==i.type){if(e.attributes.includes(i.attributeKey))return!0}else if(e.children)return!0;return!1}}(e);return(e,i)=>{const n=[];i.reconvertedElements||(i.reconvertedElements=new Set);for(const e of i.changes){const o="attribute"==e.type?e.range.start.nodeAfter:e.position.parent;if(o&&t(o,e)&&"reinsert"!=e.type){if("insert"==e.type&&"rename"==e.action&&i.refreshedItems.add(e.position.nodeAfter),!i.reconvertedElements.has(o)){i.reconvertedElements.add(o);const e=Cr._createBefore(o);let t=n.length;for(let i=n.length-1;i>=0;i--){const o=n[i],s=("attribute"==o.type?o.range.start:o.position).compareWith(e);if("before"==s||"remove"==o.type&&"same"==s)break;t=i}n.splice(t,0,{type:"reinsert",name:o.name,position:e,length:1})}}else n.push(e)}i.changes=n}}function ma(e){return(t,i,n={})=>{const o=["insert"];for(const i of e.attributes)t.hasAttribute(i)&&o.push(`attribute:${i}`);return!!o.every((e=>i.test(t,e)))&&(n.preflight||o.forEach((e=>i.consume(t,e))),!0)}}function ga(e,t,i,n){for(const o of t)fa(e.root,o,i,n)||i.convertItem(o)}function fa(e,t,i,n){const{writer:o,mapper:s}=i;if(!n.reconversion)return!1;const r=s.toViewElement(t);return!(!r||r.root==e||!i.canReuseView(r)||(o.move(o.createRangeOn(r),s.toViewPosition(Cr._createBefore(t))),0))}function pa(e,t,{preflight:i}={}){return i?t.test(e,"insert"):t.consume(e,"insert")}function ba(e){const{schema:t,document:i}=e.model;for(const n of i.getRoots())if(n.isEmpty&&!t.checkChild(n,"$text")&&t.checkChild(n,"paragraph"))return e.insertElement("paragraph",n),!0;return!1}function wa(e,t,i){const n=i.createContext(e);return!!i.checkChild(n,"paragraph")&&!!i.checkChild(n.push("paragraph"),t)}function va(e,t){const i=t.createElement("paragraph");return t.insert(i,e),t.createPositionAt(i,0)}class ya extends ta{elementToElement(e){return this.add(_a(e))}elementToAttribute(e){return this.add(function(e){xa(e=Ht(e));const t=Aa(e,!1),i=ka(e.view),n=i?`element:${i}`:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){let t=null;("string"==typeof(e=Ht(e)).view||e.view.key)&&(t=function(e){"string"==typeof e.view&&(e.view={key:e.view});const t=e.view.key,i=void 0===e.view.value?/[\s\S]*/:e.view.value;let n;if("class"==t||"style"==t){const e="class"==t?"classes":"styles";n={[e]:i}}else n={attributes:{[t]:i}};return e.view.name&&(n.name=e.view.name),e.view=n,t}(e)),xa(e,t);const i=Aa(e,!0);return t=>{t.on("element",i,{priority:e.converterPriority||"low"})}}(e))}elementToMarker(e){return this.add(function(e){const t=function(e){return(t,i)=>{const n="string"==typeof e?e:e(t,i);return i.writer.createElement("$marker",{"data-name":n})}}(e.model);return _a({...e,model:t})}(e))}dataToMarker(e){return this.add(function(e){(e=Ht(e)).model||(e.model=t=>t?e.view+":"+t:e.view);const t={view:e.view,model:e.model},i=Ca(Ta(t,"start")),n=Ca(Ta(t,"end"));return o=>{o.on(`element:${e.view}-start`,i,{priority:e.converterPriority||"normal"}),o.on(`element:${e.view}-end`,n,{priority:e.converterPriority||"normal"});const s=k.low,r=k.highest,a=k.get(e.converterPriority)/r;o.on("element",function(e){return(t,i,n)=>{const o=`data-${e.view}`;function s(t,o){for(const s of o){const o=e.model(s,n),r=n.writer.createElement("$marker",{"data-name":o});n.writer.insert(r,t),i.modelCursor.isEqual(t)?i.modelCursor=i.modelCursor.getShiftedBy(1):i.modelCursor=i.modelCursor._getTransformedByInsertion(t,1),i.modelRange=i.modelRange._getTransformedByInsertion(t,1)[0]}}(n.consumable.test(i.viewItem,{attributes:o+"-end-after"})||n.consumable.test(i.viewItem,{attributes:o+"-start-after"})||n.consumable.test(i.viewItem,{attributes:o+"-end-before"})||n.consumable.test(i.viewItem,{attributes:o+"-start-before"}))&&(i.modelRange||Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor)),n.consumable.consume(i.viewItem,{attributes:o+"-end-after"})&&s(i.modelRange.end,i.viewItem.getAttribute(o+"-end-after").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-start-after"})&&s(i.modelRange.end,i.viewItem.getAttribute(o+"-start-after").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-end-before"})&&s(i.modelRange.start,i.viewItem.getAttribute(o+"-end-before").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-start-before"})&&s(i.modelRange.start,i.viewItem.getAttribute(o+"-start-before").split(",")))}}(t),{priority:s+a})}}(e))}}function _a(e){const t=Ca(e=Ht(e)),i=ka(e.view),n=i?`element:${i}`:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"normal"})}}function ka(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}function Ca(e){const t=new co(e.view);return(i,n,o)=>{const s=t.match(n.viewItem);if(!s)return;const r=s.match;if(r.name=!0,!o.consumable.test(n.viewItem,r))return;const a=function(e,t,i){return e instanceof Function?e(t,i):i.writer.createElement(e)}(e.model,n.viewItem,o);a&&o.safeInsert(a,n.modelCursor)&&(o.consumable.consume(n.viewItem,r),o.convertChildren(n.viewItem,a),o.updateConversionResult(a,n))}}function xa(e,t=null){const i=null===t||(e=>e.getAttribute(t)),n="object"!=typeof e.model?e.model:e.model.key,o="object"!=typeof e.model||void 0===e.model.value?i:e.model.value;e.model={key:n,value:o}}function Aa(e,t){const i=new co(e.view);return(n,o,s)=>{if(!o.modelRange&&t)return;const r=i.match(o.viewItem);if(!r)return;if(function(e,t){const i="function"==typeof e?e(t):e;return!("object"==typeof i&&!ka(i))&&(!i.classes&&!i.attributes&&!i.styles)}(e.view,o.viewItem)?r.match.name=!0:delete r.match.name,!s.consumable.test(o.viewItem,r.match))return;const a=e.model.key,l="function"==typeof e.model.value?e.model.value(o.viewItem,s,o):e.model.value;if(null==l)return;o.modelRange||Object.assign(o,s.convertChildren(o.viewItem,o.modelCursor));const c=function(e,t,i,n){let o=!1;for(const s of Array.from(e.getItems({shallow:i})))n.schema.checkAttribute(s,t.key)&&(o=!0,s.hasAttribute(t.key)||n.writer.setAttribute(t.key,t.value,s));return o}(o.modelRange,{key:a,value:l},t,s);c&&(s.consumable.test(o.viewItem,{name:!0})&&(r.match.name=!0),s.consumable.consume(o.viewItem,r.match))}}function Ta(e,t){return{view:`${e.view}-${t}`,model:(t,i)=>{const n=t.getAttribute("name"),o=e.model(n,i);return i.writer.createElement("$marker",{"data-name":o})}}}class Ea extends(G()){model;view;mapper;downcastDispatcher;constructor(e,t){super(),this.model=e,this.view=new wr(t),this.mapper=new Ir,this.downcastDispatcher=new Lr({mapper:this.mapper,schema:e.schema});const i=this.model.document,n=i.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(i,"change",(()=>{this.view.change((e=>{this.downcastDispatcher.convertChanges(i.differ,o,e),this.downcastDispatcher.convertSelection(n,o,e)}))}),{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(i,n)=>{const o=n.newSelection,s=[];for(const e of o.getRanges())s.push(t.toModelRange(e));const r=e.createSelection(s,{backward:o.isBackward});r.isEqual(e.document.selection)||e.change((e=>{e.setSelection(r)}))}}(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewPosition(t.range.start),s=n.createText(t.item.data);n.insert(o,s)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)}),{priority:"lowest"}),this.downcastDispatcher.on("remove",((e,t,i)=>{if(t.reconversion)return;const n=i.mapper.toViewPosition(t.position),o=t.position.getShiftedBy(t.length),s=i.mapper.toViewPosition(o,{isPhantom:!0});oa(i.writer.createRange(n,s).getTrimmed(),i)}),{priority:"low"}),this.downcastDispatcher.on("cleanSelection",((e,t,i)=>{const n=i.writer,o=n.document.selection;for(const e of o.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&i.writer.mergeAttributes(e.start);n.setSelection(null)})),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=t.selection;if(n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const o=[];for(const e of n.getRanges())o.push(i.mapper.toViewRange(e));i.writer.setSelection(o,{backward:n.isBackward})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=t.selection;if(!n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const o=i.writer,s=n.getFirstPosition(),r=i.mapper.toViewPosition(s),a=o.breakAttributes(r);o.setSelection(a)}),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using((e=>{if("$graveyard"==e.rootName)return null;const t=new Fo(this.view.document,e.name);return t.rootName=e.rootName,this.mapper.bindElements(e,t),t}))}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const t="string"==typeof e?e:e.name,i=this.model.markers.get(t);if(!i)throw new x("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change((()=>{this.model.markers._refresh(i)}))}reconvertItem(e){this.model.change((()=>{this.model.document.differ._refreshItem(e)}))}}class Sa extends(G()){_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 Pa(t[0])}),{priority:"highest"}),this.on("checkChild",((e,t)=>{t[0]=new Pa(t[0]),t[1]=this.getDefinition(t[1])}),{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new x("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 x("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 t="string"==typeof e?e:"is"in e&&(e.is("$text")||e.is("$textProxy"))?"$text":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)}isObject(e){const t=this.getDefinition(e);return!!t&&!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent)}isInline(e){const t=this.getDefinition(e);return!(!t||!t.isInline)}isSelectable(e){const t=this.getDefinition(e);return!(!t||!t.isSelectable&&!t.isObject)}isContent(e){const t=this.getDefinition(e);return!(!t||!t.isContent&&!t.isObject)}checkChild(e,t){return!!t&&this._checkContextMatch(e,t)}checkAttribute(e,t){const i=this.getDefinition(e.last);if(!i)return!1;const n=this._evaluateAttributeChecks(e,t);return void 0!==n?n:i.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof Cr){const t=e.nodeBefore,i=e.nodeAfter;if(!(t instanceof ea))throw new x("schema-check-merge-no-element-before",this);if(!(i instanceof ea))throw new x("schema-check-merge-no-element-after",this);return this.checkMerge(t,i)}if(this.isLimit(e)||this.isLimit(t))return!1;for(const i of t.getChildren())if(!this.checkChild(e,i))return!1;return!0}addChildCheck(e,t){const i=void 0!==t?t:this._genericCheckSymbol,n=this._customChildChecks.get(i)||[];n.push(e),this._customChildChecks.set(i,n)}addAttributeCheck(e,t){const i=void 0!==t?t:this._genericCheckSymbol,n=this._customAttributeChecks.get(i)||[];n.push(e),this._customAttributeChecks.set(i,n)}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(t=e instanceof Cr?e.parent:(e instanceof Pr?[e]:Array.from(e.getRanges())).reduce(((e,t)=>{const i=t.getCommonAncestor();return e?e.getCommonAncestor(i,{includeSelf:!0}):i}),null);!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const i=[...e.getFirstPosition().getAncestors(),new Kr("",e.getAttributes())];return this.checkAttribute(i,t)}{const i=e.getRanges();for(const e of i)for(const i of e)if(this.checkAttribute(i.item,t))return!0}return!1}*getValidRanges(e,t,i={}){e=function*(e){for(const t of e)yield*t.getMinimalFlatRanges()}(e);for(const n of e)yield*this._getValidRangesForRange(n,t,i)}getNearestSelectionRange(e,t="both"){if("$graveyard"==e.root.rootName)return null;if(this.checkChild(e,"$text"))return new Pr(e);let i,n;const o=e.getAncestors().reverse().find((e=>this.isLimit(e)))||e.root;"both"!=t&&"backward"!=t||(i=new _r({boundaries:Pr._createIn(o),startPosition:e,direction:"backward"})),"both"!=t&&"forward"!=t||(n=new _r({boundaries:Pr._createIn(o),startPosition:e}));for(const e of function*(e,t){let i=!1;for(;!i;){if(i=!0,e){const t=e.next();t.done||(i=!1,yield{walker:e,value:t.value})}if(t){const e=t.next();e.done||(i=!1,yield{walker:t,value:e.value})}}}(i,n)){const t=e.walker==i?"elementEnd":"elementStart",n=e.value;if(n.type==t&&this.isObject(n.item))return Pr._createOn(n.item);if(this.checkChild(n.nextPosition,"$text"))return new Pr(n.nextPosition)}return null}findAllowedParent(e,t){let i=e.parent;for(;i;){if(this.checkChild(i,t))return i;if(this.isLimit(i))return null;i=i.parent}return null}setAllowedAttributes(e,t,i){const n=i.model;for(const[o,s]of Object.entries(t))n.schema.checkAttribute(e,o)&&i.setAttribute(o,s,e)}removeDisallowedAttributes(e,t){for(const i of e)if(i.is("$text"))Ua(this,i,t);else{const e=Pr._createIn(i).getPositions();for(const i of e)Ua(this,i.nodeBefore||i.parent,t)}}getAttributesWithProperty(e,t,i){const n={};for(const[o,s]of e.getAttributes()){const e=this.getAttributeProperties(o);void 0!==e[t]&&(void 0!==i&&i!==e[t]||(n[o]=s))}return n}createContext(e){return new Pa(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,i=Object.keys(t);for(const n of i)e[n]=Ia(t[n],n);const n=Object.values(e);for(const t of n)Va(e,t),Oa(e,t),Ra(e,t),La(e,t);for(const e of n)Ba(0,e);for(const t of n)Ma(e,t);for(const t of n)Na(e,t);for(const t of n)Fa(e,t);for(const t of n)Da(e,t);this._compiledDefinitions=function(e){const t={};for(const i of Object.values(e))t[i.name]={name:i.name,isBlock:!!i.isBlock,isContent:!!i.isContent,isInline:!!i.isInline,isLimit:!!i.isLimit,isObject:!!i.isObject,isSelectable:!!i.isSelectable,allowIn:Array.from(i.allowIn).filter((t=>!!e[t])),allowChildren:Array.from(i.allowChildren).filter((t=>!!e[t])),allowAttributes:Array.from(i.allowAttributes)};return t}(e)}_checkContextMatch(e,t){const i=e.last;let n=this._evaluateChildChecks(e,t);if(n=void 0!==n?n:t.allowIn.includes(i.name),!n)return!1;const o=this.getDefinition(i),s=e.trimLast();return!!o&&(0==s.length||this._checkContextMatch(s,o))}_evaluateChildChecks(e,t){const i=this._customChildChecks.get(this._genericCheckSymbol)||[],n=this._customChildChecks.get(t.name)||[];for(const o of[...i,...n]){const i=o(e,t);if(void 0!==i)return i}}_evaluateAttributeChecks(e,t){const i=this._customAttributeChecks.get(this._genericCheckSymbol)||[],n=this._customAttributeChecks.get(t)||[];for(const o of[...i,...n]){const i=o(e,t);if(void 0!==i)return i}}*_getValidRangesForRange(e,t,i){let n=e.start,o=e.start;for(const s of e.getItems({shallow:!0})){if(s.is("element"))if(i.includeEmptyRanges&&s.isEmpty){const e=this.createContext(s);this.checkChild(e,"$text")&&this.checkAttribute(e.push("$text"),t)&&(yield Pr._createIn(s))}else yield*this._getValidRangesForRange(Pr._createIn(s),t,i);this.checkAttribute(s,t)||(n.isEqual(o)||(yield new Pr(n,o)),n=Cr._createAfter(s)),o=Cr._createAfter(s)}n.isEqual(o)||(yield new Pr(n,o))}findOptimalInsertionRange(e,t){const i=e.getSelectedElement();if(i&&this.isObject(i)&&!this.isInline(i))return"before"==t||"after"==t?new Pr(Cr._createAt(i,t)):Pr._createOn(i);const n=Zt(e.getSelectedBlocks());if(!n)return new Pr(e.focus);if(n.isEmpty)return new Pr(Cr._createAt(n,0));const o=Cr._createAfter(n);return e.focus.isTouching(o)?new Pr(o):new Pr(Cr._createBefore(n))}}class Pa{_items;constructor(e){if(e instanceof Pa)return e;let t;t="string"==typeof e?[e]:Array.isArray(e)?e:e.getAncestors({includeSelf:!0}),this._items=t.map(Ha)}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 Pa([e]);return t._items=[...this._items,...t._items],t}trimLast(){const e=new Pa([]);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 Ia(e,t){const i={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 function(e,t){for(const i of e){const e=Object.keys(i).filter((e=>e.startsWith("is")));for(const n of e)t[n]=!!i[n]}}(e,i),za(e,i,"allowIn"),za(e,i,"allowChildren"),za(e,i,"disallowIn"),za(e,i,"disallowChildren"),za(e,i,"allowContentOf"),za(e,i,"allowWhere"),za(e,i,"allowAttributes"),za(e,i,"disallowAttributes"),za(e,i,"allowAttributesOf"),za(e,i,"inheritTypesFrom"),function(e,t){for(const i of e){const e=i.inheritAllFrom;e&&(t.allowContentOf.add(e),t.allowWhere.add(e),t.allowAttributesOf.add(e),t.inheritTypesFrom.add(e))}}(e,i),i}function Va(e,t){for(const i of t.allowIn){const n=e[i];n?n.allowChildren.add(t.name):t.allowIn.delete(i)}}function Oa(e,t){for(const i of t.allowChildren){const n=e[i];n?n.allowIn.add(t.name):t.allowChildren.delete(i)}}function Ra(e,t){for(const i of t.disallowIn){const n=e[i];n?n.disallowChildren.add(t.name):t.disallowIn.delete(i)}}function La(e,t){for(const i of t.disallowChildren){const n=e[i];n?n.disallowIn.add(t.name):t.disallowChildren.delete(i)}}function Ba(e,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 Ma(e,t){for(const i of t.allowContentOf){const n=e[i];n&&(n.disallowChildren.forEach((i=>{t.allowChildren.has(i)||(t.disallowChildren.add(i),e[i].disallowIn.add(t.name))})),n.allowChildren.forEach((i=>{t.disallowChildren.has(i)||(t.allowChildren.add(i),e[i].allowIn.add(t.name))})))}}function Na(e,t){for(const i of t.allowWhere){const n=e[i];n&&(n.disallowIn.forEach((i=>{t.allowIn.has(i)||(t.disallowIn.add(i),e[i].disallowChildren.add(t.name))})),n.allowIn.forEach((i=>{t.disallowIn.has(i)||(t.allowIn.add(i),e[i].allowChildren.add(t.name))})))}}function Fa(e,t){for(const i of t.allowAttributesOf){const n=e[i];if(!n)return;n.allowAttributes.forEach((e=>{t.disallowAttributes.has(e)||t.allowAttributes.add(e)}))}}function Da(e,t){for(const i of t.inheritTypesFrom){const n=e[i];if(n){const e=Object.keys(n).filter((e=>e.startsWith("is")));for(const i of e)i in t||(t[i]=n[i])}}}function za(e,t,i){for(const n of e){let e=n[i];"string"==typeof e&&(e=[e]),Array.isArray(e)&&e.forEach((e=>t[i].add(e)))}}function Ha(e){return"string"==typeof e||e.is("documentFragment")?{name:"string"==typeof e?e:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:e.is("element")?e.name:"$text",*getAttributeKeys(){yield*e.getAttributeKeys()},getAttribute:t=>e.getAttribute(t)}}function Ua(e,t,i){for(const n of t.getAttributeKeys())e.checkAttribute(t,n)||i.removeAttribute(n,t)}class $a extends(R()){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:(e,t)=>this._convertItem(e,t),convertChildren:(e,t)=>this._convertChildren(e,t),safeInsert:(e,t)=>this._safeInsert(e,t),updateConversionResult:(e,t)=>this._updateConversionResult(e,t),splitToAllowedParent:(e,t)=>this._splitToAllowedParent(e,t),getSplitParts:e=>this._getSplitParts(e),keepEmptyElement:e=>this._keepEmptyElement(e)}}convert(e,t,i=["$root"]){this.fire("viewCleanup",e),this._modelCursor=function(e,t){let i;for(const n of new Pa(e)){const e={};for(const t of n.getAttributeKeys())e[t]=n.getAttribute(t);const o=t.createElement(n.name,e);i&&t.insert(o,i),i=Cr._createAt(o,0)}return i}(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=so.createFrom(e),this.conversionApi.store={};const{modelRange:n}=this._convertItem(e,this._modelCursor),o=t.createDocumentFragment();if(n){this._removeEmptyElements();const e=this._modelCursor.parent,i=e._removeChildren(0,e.childCount);o._insertChild(0,i),o.markers=function(e,t){const i=new Set,n=new Map,o=Pr._createIn(e).getItems();for(const e of o)e.is("element","$marker")&&i.add(e);for(const e of i){const i=e.getAttribute("data-name"),o=t.createPositionBefore(e);n.has(i)?n.get(i).end=o.clone():n.set(i,new Pr(o.clone())),t.remove(e)}return n}(o,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,o}_convertItem(e,t){const i={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,i,this.conversionApi):e.is("$text")?this.fire("text",i,this.conversionApi):this.fire("documentFragment",i,this.conversionApi),i.modelRange&&!(i.modelRange instanceof Pr))throw new x("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:Cr._createAt(t,0);const n=new Pr(i);for(const t of Array.from(e.getChildren())){const e=this._convertItem(t,i);e.modelRange instanceof Pr&&(n.end=e.modelRange.end,i=e.modelCursor)}return{modelRange:n,modelCursor:i}}_safeInsert(e,t){const i=this._splitToAllowedParent(e,t);return!!i&&(this.conversionApi.writer.insert(e,i.position),!0)}_updateConversionResult(e,t){const i=this._getSplitParts(e),n=this.conversionApi.writer;t.modelRange||(t.modelRange=n.createRange(n.createPositionBefore(e),n.createPositionAfter(i[i.length-1])));const o=this._cursorParents.get(e);t.modelCursor=o?n.createPositionAt(o,0):t.modelRange.end}_splitToAllowedParent(e,t){const{schema:i,writer:n}=this.conversionApi;let o=i.findAllowedParent(t,e);if(o){if(o===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(o)&&(o=null)}if(!o)return wa(t,e,i)?{position:va(t,n)}:null;const s=this.conversionApi.writer.split(t,o),r=[];for(const e of s.range.getWalker())if("elementEnd"==e.type)r.push(e.item);else{const t=r.pop(),i=e.item;this._registerSplitPair(t,i)}const a=s.range.end.parent;return this._cursorParents.set(e,a),{position:s.position,cursorParent:a}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);const i=this._splitParts.get(e);this._splitParts.set(t,i),i.push(t)}_getSplitParts(e){let t;return t=this._splitParts.has(e)?this._splitParts.get(e):[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 i=e.get(t.parent)||[];i.push(t),this._splitParts.delete(t),e.set(t.parent,i)}for(const[t,i]of e)t._removeChildrenArray(i);e.size&&this._removeEmptyElements()}}class qa{getHtml(e){const t=n.document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class ja{domParser;domConverter;htmlWriter;skipComments=!0;constructor(e){this.domParser=new DOMParser,this.domConverter=new Ds(e,{renderingMode:"data"}),this.htmlWriter=new qa}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="marked"==e?"markedNbsp":"nbsp"}_toDom(e){/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(e.trim().slice(0,1e4))||(e=`${e}`);const t=this.domParser.parseFromString(e,"text/html"),i=t.createDocumentFragment(),n=t.body.childNodes;for(;n.length>0;)i.appendChild(n[0]);return i}}class Wa extends(R()){model;mapper;downcastDispatcher;upcastDispatcher;viewDocument;stylesProcessor;htmlProcessor;processor;_viewWriter;constructor(e,t){super(),this.model=e,this.mapper=new Ir,this.downcastDispatcher=new Lr({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewPosition(t.range.start),s=n.createText(t.item.data);n.insert(o,s)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)}),{priority:"lowest"}),this.upcastDispatcher=new $a({schema:e.schema}),this.viewDocument=new ts(t),this.stylesProcessor=t,this.htmlProcessor=new ja(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new hs(this.viewDocument),this.upcastDispatcher.on("text",((e,t,{schema:i,consumable:n,writer:o})=>{let s=t.modelCursor;if(!n.test(t.viewItem))return;if(!i.checkChild(s,"$text")){if(!wa(s,"$text",i))return;if(0==t.viewItem.data.trim().length)return;s=va(s,o)}n.consume(t.viewItem);const r=o.createText(t.viewItem.data);o.insert(r,s),t.modelRange=o.createRange(s,s.getShiftedBy(r.offsetSize)),t.modelCursor=t.modelRange.end}),{priority:"lowest"}),this.upcastDispatcher.on("element",((e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}}),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",((e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}}),{priority:"lowest"}),G().prototype.decorate.call(this,"init"),G().prototype.decorate.call(this,"set"),G().prototype.decorate.call(this,"get"),G().prototype.decorate.call(this,"toView"),G().prototype.decorate.call(this,"toModel"),this.on("init",(()=>{this.fire("ready")}),{priority:"lowest"}),this.on("ready",(()=>{this.model.enqueueChange({isUndoable:!1},ba)}),{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new x("datacontroller-get-non-existent-root",this);const n=this.model.document.getRoot(t);return n.isAttached()||A("datacontroller-get-detached-root",this),"empty"!==i||this.model.hasContent(n,{ignoreWhitespaces:!0})?this.stringify(n,e):""}stringify(e,t={}){const i=this.toView(e,t);return this.processor.toData(i)}toView(e,t={}){const i=this.viewDocument,n=this._viewWriter;this.mapper.clearBindings();const o=Pr._createIn(e),s=new ds(i);this.mapper.bindElements(e,s);const r=e.is("documentFragment")?e.markers:function(e){const t=[],i=e.root.document;if(!i)return new Map;const n=Pr._createIn(e);for(const e of i.model.markers){const i=e.getRange(),o=i.isCollapsed,s=i.start.isEqual(n.start)||i.end.isEqual(n.end);if(o&&s)t.push([e.name,i]);else{const o=n.getIntersection(i);o&&t.push([e.name,o])}}return t.sort((([e,t],[i,n])=>{if("after"!==t.end.compareWith(n.start))return 1;if("before"!==t.start.compareWith(n.end))return-1;switch(t.start.compareWith(n.start)){case"before":return 1;case"after":return-1;default:switch(t.end.compareWith(n.end)){case"before":return 1;case"after":return-1;default:return i.localeCompare(e)}}})),new Map(t)}(e);return this.downcastDispatcher.convert(o,r,n,t),s}init(e){if(this.model.document.version)throw new x("datacontroller-init-document-not-empty",this);let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new x("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},(e=>{for(const i of Object.keys(t)){const n=this.model.document.getRoot(i);e.insert(this.parse(t[i],n),n,0)}})),Promise.resolve()}set(e,t={}){let i={};if("string"==typeof e?i.main=e:i=e,!this._checkIfRootsExists(Object.keys(i)))throw new x("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},(e=>{e.setSelection(null),e.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const t of Object.keys(i)){const n=this.model.document.getRoot(t);e.remove(e.createRangeIn(n)),e.insert(this.parse(i[t],n),n,0)}}))}parse(e,t="$root"){const i=this.processor.toView(e);return this.toModel(i,t)}toModel(e,t="$root"){return this.model.change((i=>this.upcastDispatcher.convert(e,i,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}}class Ga{_helpers=new Map;_downcast;_upcast;constructor(e,t){this._downcast=zt(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=zt(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const i=this._downcast.includes(t);if(!this._upcast.includes(t)&&!i)throw new x("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new x("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:i}of Ka(e))this.for("upcast").elementToElement({model:t,view:i,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:i}of Ka(e))this.for("upcast").elementToAttribute({view:i,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:i}of Ka(e))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:i}){if(this._helpers.has(e))throw new x("conversion-group-exists",this);const n=i?new ia(t):new ya(t);this._helpers.set(e,n)}}function*Ka(e){if(e.model.values)for(const t of e.model.values){const i={key:e.model.key,value:t},n=e.view[t],o=e.upcastAlso?e.upcastAlso[t]:void 0;yield*Ja(i,n,o)}else yield*Ja(e.model,e.view,e.upcastAlso)}function*Ja(e,t,i){if(yield{model:e,view:t},i)for(const t of zt(i))yield{model:e,view:t}}class Ya{baseVersion;isDocumentOperation;batch;constructor(e){this.baseVersion=e,this.isDocumentOperation=null!==this.baseVersion,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 Qa(e,t){const i=el(t),n=i.reduce(((e,t)=>e+t.offsetSize),0),o=e.parent;il(e);const s=e.index;return o._insertChild(s,i),tl(o,s+i.length),tl(o,s),new Pr(e,e.getShiftedBy(n))}function Xa(e){if(!e.isFlat)throw new x("operation-utils-remove-range-not-flat",this);const t=e.start.parent;il(e.start),il(e.end);const i=t._removeChildren(e.start.index,e.end.index-e.start.index);return tl(t,e.start.index),i}function Za(e,t){if(!e.isFlat)throw new x("operation-utils-move-range-not-flat",this);const i=Xa(e);return Qa(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),i)}function el(e){const t=[];!function e(i){if("string"==typeof i)t.push(new Kr(i));else if(i instanceof yr)t.push(new Kr(i.data,i.getAttributes()));else if(i instanceof Nr)t.push(i);else if(ie(i))for(const t of i)e(t)}(e);for(let e=1;ee.maxOffset)throw new x("move-operation-nodes-do-not-exist",this);if(e===t&&i=i&&this.targetPosition.path[e]e._clone(!0)))),t=new sl(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new Cr(e,[0]);return new ol(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffsete._clone(!0)))),Qa(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 i=[];for(const t of e.nodes)t.name?i.push(ea.fromJSON(t)):i.push(Kr.fromJSON(t));const n=new sl(Cr.fromJSON(e.position,t),i,e.baseVersion);return n.shouldReceiveAttributes=e.shouldReceiveAttributes,n}}class rl extends Ya{splitPosition;howMany;insertionPosition;graveyardPosition;constructor(e,t,i,n,o){super(o),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=i,this.graveyardPosition=n?n.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 Cr(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new Pr(this.splitPosition,e)}get affectedSelectable(){const e=[Pr._createFromPositionAndShift(this.splitPosition,0),Pr._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(Pr._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new rl(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new Cr(e,[0]);return new al(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset1&&e.sourcePosition.isEqual(t.deletionPosition)?this._setRelation(e,t,"firstToMoveMerged"):e.howMany>1&&e.sourcePosition.getShiftedBy(e.howMany-1).isEqual(t.deletionPosition)&&this._setRelation(e,t,"lastToMoveMerged"):t instanceof ol&&(e.targetPosition.isEqual(t.sourcePosition)||e.targetPosition.isBefore(t.sourcePosition)?this._setRelation(e,t,"insertBefore"):this._setRelation(e,t,"insertAfter"));else if(e instanceof rl){if(t instanceof al)e.splitPosition.isBefore(t.sourcePosition)&&this._setRelation(e,t,"splitBefore");else if(t instanceof ol)if(e.splitPosition.isEqual(t.sourcePosition)||e.splitPosition.isBefore(t.sourcePosition))this._setRelation(e,t,"splitBefore");else{const i=Pr._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.splitPosition)){const n=i.end.offset-e.splitPosition.offset,o=e.splitPosition.offset-i.start.offset;this._setRelation(e,t,{howMany:n,offset:o})}}}else if(e instanceof al)t instanceof al?(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 rl?e.sourcePosition.isEqual(t.splitPosition)&&this._setRelation(e,t,"splitAtSource"):t instanceof ol&&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 ll){const i=e.newRange;if(!i)return;if(t instanceof al){const n=i.start.isEqual(t.targetPosition),o=i.start.isEqual(t.deletionPosition),s=i.end.isEqual(t.deletionPosition),r=i.end.isEqual(t.sourcePosition);(n||o||s||r)&&this._setRelation(e,t,{wasInLeftElement:n,wasStartBeforeMergedElement:o,wasEndBeforeMergedElement:s,wasInRightElement:r})}}}getContext(e,t,i){return{aIsStrong:i,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 i=this.originalOperations.get(t),n=this._history.getUndoneOperation(i);if(!n)return null;const o=this.originalOperations.get(e),s=this._relations.get(o);return s&&s.get(n)||null}_setRelation(e,t,i){const n=this.originalOperations.get(e),o=this.originalOperations.get(t);let s=this._relations.get(n);s||(s=new Map,this._relations.set(n,s)),s.set(o,i)}}function Cl(e,t){for(const i of e)i.baseVersion=t++}function xl(e,t){for(let i=0;i{if(e.key===t.key&&e.range.start.hasSameParentAs(t.range.start)){const n=e.range.getDifference(t.range).map((t=>new ul(t,e.key,e.oldValue,e.newValue,0))),o=e.range.getIntersection(t.range);return o&&i.aIsStrong&&n.push(new ul(o,t.key,t.newValue,e.newValue,0)),0==n.length?[new dl(0)]:n}return[e]})),wl(ul,sl,((e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){const i=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map((t=>new ul(t,e.key,e.oldValue,e.newValue,e.baseVersion)));if(t.shouldReceiveAttributes){const n=Tl(t,e.key,e.oldValue);n&&i.unshift(n)}return i}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]})),wl(ul,al,((e,t)=>{const i=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&i.push(Pr._createFromPositionAndShift(t.graveyardPosition,1));const n=e.range._getTransformedByMergeOperation(t);return n.isCollapsed||i.push(n),i.map((t=>new ul(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),wl(ul,ol,((e,t)=>{const i=function(e,t){const i=Pr._createFromPositionAndShift(t.sourcePosition,t.howMany);let n=null,o=[];i.containsRange(e,!0)?n=e:e.start.hasSameParentAs(i.start)?(o=e.getDifference(i),n=e.getIntersection(i)):o=[e];const s=[];for(let e of o){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const i=t.getMovedRangeStart(),n=e.start.hasSameParentAs(i),o=e._getTransformedByInsertion(i,t.howMany,n);s.push(...o)}return n&&s.push(n._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]),s}(e.range,t);return i.map((t=>new ul(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),wl(ul,rl,((e,t)=>{if(e.range.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.range.end.offset++,[e];if(e.range.start.hasSameParentAs(t.splitPosition)&&e.range.containsPosition(t.splitPosition)){const i=e.clone();return i.range=new Pr(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness="toPrevious",[e,i]}return e.range=e.range._getTransformedBySplitOperation(t),[e]})),wl(sl,ul,((e,t)=>{const i=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const n=Tl(e,t.key,t.newValue);n&&i.push(n)}return i})),wl(sl,sl,((e,t,i)=>(e.position.isEqual(t.position)&&i.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e]))),wl(sl,ol,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),wl(sl,rl,((e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e]))),wl(sl,al,((e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e]))),wl(ll,sl,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e]))),wl(ll,ll,((e,t,i)=>{if(e.name==t.name){if(!i.aIsStrong)return[new dl(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]})),wl(ll,al,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e]))),wl(ll,ol,((e,t)=>{const i=[e];if(e.oldRange&&(e.oldRange=Pr._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){const n=e.newRange._getTransformedByMoveOperation(t);e.newRange=n[0];for(let t=1;t{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(i.abRelation){const n=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)?i.abRelation.wasStartBeforeMergedElement?e.newRange.start=Cr._createAt(t.insertionPosition):i.abRelation.wasInLeftElement?e.newRange.start=Cr._createAt(e.newRange.start):e.newRange.start=Cr._createAt(t.moveTargetPosition):e.newRange.start=n.start,e.newRange.end.isEqual(t.splitPosition)?e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?e.newRange.end=Cr._createAt(t.insertionPosition):i.abRelation.wasInRightElement?e.newRange.end=Cr._createAt(t.moveTargetPosition):e.newRange.end=Cr._createAt(e.newRange.end):e.newRange.end=n.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]})),wl(al,sl,((e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e]))),wl(al,al,((e,t,i)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition)){if(i.bWasUndone){const i=t.graveyardPosition.path.slice();return i.push(0),e.sourcePosition=new Cr(t.graveyardPosition.root,i),e.howMany=0,[e]}return[new dl(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!i.bWasUndone&&"splitAtSource"!=i.abRelation){const n="$graveyard"==e.targetPosition.root.rootName,o="$graveyard"==t.targetPosition.root.rootName;if(o&&!n||(!n||o)&&i.aIsStrong){const i=t.targetPosition._getTransformedByMergeOperation(t),n=e.targetPosition._getTransformedByMergeOperation(t);return[new ol(i,e.howMany,n,0)]}return[new dl(0)]}return e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMergeOperation(t),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),e.graveyardPosition.isEqual(t.graveyardPosition)&&i.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),wl(al,ol,((e,t,i)=>{const n=Pr._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!i.bWasUndone&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.sourcePosition)?[new dl(0)]:(t.sourcePosition.getShiftedBy(t.howMany).isEqual(e.sourcePosition)?e.sourcePosition.stickiness="toNone":t.targetPosition.isEqual(e.sourcePosition)&&"mergeSourceAffected"==i.abRelation?e.sourcePosition.stickiness="toNext":t.sourcePosition.isEqual(e.targetPosition)?(e.targetPosition.stickiness="toNone",e.howMany-=t.howMany):t.targetPosition.isEqual(e.targetPosition)&&"mergeTargetWasBefore"==i.abRelation?(e.targetPosition.stickiness="toPrevious",e.howMany+=t.howMany):(e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition.hasSameParentAs(t.sourcePosition)&&(e.howMany-=t.howMany)),e.sourcePosition=e.sourcePosition._getTransformedByMoveOperation(t),e.targetPosition=e.targetPosition._getTransformedByMoveOperation(t),e.sourcePosition.stickiness="toPrevious",e.targetPosition.stickiness="toNext",e.graveyardPosition.isEqual(t.targetPosition)||(e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)),[e])})),wl(al,rl,((e,t,i)=>{if(t.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByDeletion(t.graveyardPosition,1),e.deletionPosition.isEqual(t.graveyardPosition)&&(e.howMany=t.howMany)),e.targetPosition.isEqual(t.splitPosition)&&(t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition)||"mergeTargetNotMoved"==i.abRelation))return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e];if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==i.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==i.abRelation||e.sourcePosition.offset>0)return e.sourcePosition=t.moveTargetPosition.clone(),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}return e.sourcePosition.hasSameParentAs(t.splitPosition)&&(e.howMany=t.splitPosition.offset),e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]})),wl(ol,sl,((e,t)=>{const i=Pr._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=i.start,e.howMany=i.end.offset-i.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]})),wl(ol,ol,((e,t,i)=>{const n=Pr._createFromPositionAndShift(e.sourcePosition,e.howMany),o=Pr._createFromPositionAndShift(t.sourcePosition,t.howMany);let s,r=i.aIsStrong,a=!i.aIsStrong;if("insertBefore"==i.abRelation||"insertAfter"==i.baRelation?a=!0:"insertAfter"!=i.abRelation&&"insertBefore"!=i.baRelation||(a=!1),s=e.targetPosition.isEqual(t.targetPosition)&&a?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),El(e,t)&&El(t,e))return[t.getReversed()];if(n.containsPosition(t.targetPosition)&&n.containsRange(o,!0))return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Sl([n],s);if(o.containsPosition(e.targetPosition)&&o.containsRange(n,!0))return n.start=n.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),n.end=n.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),Sl([n],s);const l=te(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==l||"extension"==l)return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Sl([n],s);"remove"!=e.type||"remove"==t.type||i.aWasUndone||i.forceWeakRemove?"remove"==e.type||"remove"!=t.type||i.bWasUndone||i.forceWeakRemove||(r=!1):r=!0;const c=[],u=n.getDifference(o);for(const e of u){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const i="same"==te(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),n=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,i);c.push(...n)}const d=n.getIntersection(o);return null!==d&&r&&(d.start=d.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),d.end=d.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===c.length?c.push(d):1==c.length?o.start.isBefore(n.start)||o.start.isEqual(n.start)?c.unshift(d):c.push(d):c.splice(1,0,d)),0===c.length?[new dl(e.baseVersion)]:Sl(c,s)})),wl(ol,rl,((e,t,i)=>{let n=e.targetPosition.clone();if(e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=i.abRelation||(n=e.targetPosition._getTransformedBySplitOperation(t)),e.sourcePosition.isEqual(t.insertionPosition)&&"firstToMoveMerged"==i.abRelation)return e.howMany++,e.targetPosition=n,[e];const o=Pr._createFromPositionAndShift(e.sourcePosition,e.howMany);if(o.end.isEqual(t.insertionPosition))return t.graveyardPosition&&"lastToMoveMerged"!=i.abRelation||e.howMany++,e.targetPosition=n,[e];if(o.start.hasSameParentAs(t.splitPosition)&&o.containsPosition(t.splitPosition)){let e=new Pr(t.splitPosition,o.end);return e=e._getTransformedBySplitOperation(t),Sl([new Pr(o.start,t.splitPosition),e],n)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==i.abRelation&&(n=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==i.abRelation&&(n=e.targetPosition);const s=[o._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const n=o.start.isEqual(t.graveyardPosition)||o.containsPosition(t.graveyardPosition);e.howMany>1&&n&&!i.aWasUndone&&s.push(Pr._createFromPositionAndShift(t.insertionPosition,1))}return Sl(s,n)})),wl(ol,al,((e,t,i)=>{const n=Pr._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(t.sourcePosition))if("remove"!=e.type||i.forceWeakRemove){if(1==e.howMany)return i.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new dl(0)]}else if(!i.aWasUndone){const i=[];let n=t.graveyardPosition.clone(),o=t.targetPosition._getTransformedByMergeOperation(t);const s=e.targetPosition.getTransformedByOperation(t);e.howMany>1&&(i.push(new ol(e.sourcePosition,e.howMany-1,s,0)),n=n._getTransformedByMove(e.sourcePosition,s,e.howMany-1),o=o._getTransformedByMove(e.sourcePosition,s,e.howMany-1));const r=t.deletionPosition._getCombined(e.sourcePosition,s),a=new ol(n,1,r,0),l=a.getMovedRangeStart().path.slice();l.push(0);const c=new Cr(a.targetPosition.root,l);o=o._getTransformedByMove(n,r,1);const u=new ol(o,t.howMany,c,0);return i.push(a),i.push(u),i}const o=Pr._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByMergeOperation(t);return e.sourcePosition=o.start,e.howMany=o.end.offset-o.start.offset,e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]})),wl(hl,sl,((e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e]))),wl(hl,al,((e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e]))),wl(hl,ol,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),wl(hl,hl,((e,t,i)=>{if(e.position.isEqual(t.position)){if(!i.aIsStrong)return[new dl(0)];e.oldName=t.newName}return[e]})),wl(hl,rl,((e,t)=>{if("same"==te(e.position.path,t.splitPosition.getParentPath())&&!t.graveyardPosition){const t=new hl(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]})),wl(ml,ml,((e,t,i)=>{if(e.root===t.root&&e.key===t.key){if(!i.aIsStrong)return[new dl(0)];e.oldValue=t.newValue}return[e]})),wl(gl,gl,((e,t)=>e.rootName===t.rootName&&e.isAdd===t.isAdd?[new dl(0)]:[e])),wl(rl,sl,((e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset{if(!e.graveyardPosition&&!i.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const i=t.graveyardPosition.path.slice();i.push(0);const n=new Cr(t.graveyardPosition.root,i),o=rl.getInsertionPosition(new Cr(t.graveyardPosition.root,i)),s=new rl(n,0,o,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=rl.getInsertionPosition(e.splitPosition),e.graveyardPosition=s.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[s,e]}return e.splitPosition.hasSameParentAs(t.deletionPosition)&&!e.splitPosition.isAfter(t.deletionPosition)&&e.howMany--,e.splitPosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=rl.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),wl(rl,ol,((e,t,i)=>{const n=Pr._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const o=n.start.isEqual(e.graveyardPosition)||n.containsPosition(e.graveyardPosition);if(!i.bWasUndone&&o){const i=e.splitPosition._getTransformedByMoveOperation(t),n=e.graveyardPosition._getTransformedByMoveOperation(t),o=n.path.slice();o.push(0);const s=new Cr(n.root,o);return[new ol(i,e.howMany,s,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const o=e.splitPosition.isEqual(t.targetPosition);if(o&&("insertAtSource"==i.baRelation||"splitBefore"==i.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=rl.getInsertionPosition(e.splitPosition),[e];if(o&&i.abRelation&&i.abRelation.howMany){const{howMany:t,offset:n}=i.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(n),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.splitPosition)){const i=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=i,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new dl(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new dl(0)];if("splitBefore"==i.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){const n="$graveyard"==e.splitPosition.root.rootName,o="$graveyard"==t.splitPosition.root.rootName;if(o&&!n||(!n||o)&&i.aIsStrong){const i=[];return t.howMany&&i.push(new ol(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&i.push(new ol(e.splitPosition,e.howMany,e.moveTargetPosition,0)),i}return[new dl(0)]}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==i.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==i.baRelation){const i=t.insertionPosition.path.slice();i.push(0);const n=new Cr(t.insertionPosition.root,i);return[e,new ol(e.insertionPosition,1,n,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset{const i=t[0];i.isDocumentOperation&&Vl.call(this,i)}),{priority:"low"})}function Vl(e){const t=this.getTransformedByOperation(e);if(!this.isEqual(t)){const e=this.toPosition();this.path=t.path,this.root=t.root,this.fire("change",e)}}Pl.prototype.is=function(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e};class Ol{operations;isUndoable;isLocal;isUndo;isTyping;constructor(e={}){"string"==typeof e&&(e="transparent"===e?{isUndoable:!1}:{},A("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:i=!0,isUndo:n=!1,isTyping:o=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=i,this.isUndo=n,this.isTyping=o}get baseVersion(){for(const e of this.operations)if(null!==e.baseVersion)return e.baseVersion;return null}addOperation(e){return e.isDocumentOperation&&(e.batch=this,this.operations.push(e)),e}}class Rl{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 0==this._changesInElement.size&&0==this._changedMarkers.size&&0==this._changedRoots.size}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 e of t.range.getItems({shallow:!0}))this._isInInsertedElement(e.parent)||this._markAttribute(e);break;case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const e=this._isInInsertedElement(t.sourcePosition.parent),i=this._isInInsertedElement(t.targetPosition.parent);e||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),i||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);const n=Pr._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const e of n.getItems({shallow:!0}))this._setElementState(e,"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 e=Pr._createFromPositionAndShift(t.position,1);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getData();this.bufferMarkerChange(t.name,e,e)}this._setElementState(t.position.nodeAfter,"rename");break}case"split":{const e=t.splitPosition.parent;if(!this._isInInsertedElement(e)){this._markRemove(e,t.splitPosition.offset,t.howMany);const i=Pr._createFromPositionAndShift(t.splitPosition,t.howMany);for(const e of i.getItems({shallow:!0}))this._setElementState(e,"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 e=t.sourcePosition.parent;this._isInInsertedElement(e.parent)||this._markRemove(e.parent,e.startOffset,1);const i=t.graveyardPosition.parent;this._markInsert(i,t.graveyardPosition.offset,1),this._setElementState(e,"move");const n=t.targetPosition.parent;if(!this._isInInsertedElement(n)){this._markInsert(n,t.targetPosition.offset,e.maxOffset);const i=Pr._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const e of i.getItems({shallow:!0}))this._setElementState(e,"move")}break}case"detachRoot":case"addRoot":{const e=t.affectedSelectable;if(!e._isLoaded)return;if(e.isAttached()==t.isAdd)return;this._bufferRootStateChange(t.rootName,t.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!t.root._isLoaded)return;const e=t.root.rootName;this._bufferRootAttributeChange(e,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,i){t.range&&t.range.root.is("rootElement")&&!t.range.root._isLoaded&&(t.range=null),i.range&&i.range.root.is("rootElement")&&!i.range.root._isLoaded&&(i.range=null);let n=this._changedMarkers.get(e);n?n.newMarkerData=i:(n={newMarkerData:i,oldMarkerData:t},this._changedMarkers.set(e,n)),null==n.oldMarkerData.range&&null==i.range&&this._changedMarkers.delete(e)}getMarkersToRemove(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.oldMarkerData.range&&e.push({name:t,range:i.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.newMarkerData.range&&e.push({name:t,range:i.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)return!0;if(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 i=e.range&&!t.range,n=!e.range&&t.range,o=e.range&&t.range&&!e.range.isEqual(t.range);if(i||n||o)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const e of this._changesInElement.keys()){const i=this._changesInElement.get(e).sort(((e,t)=>e.offset===t.offset?e.type!=t.type?"remove"==e.type?-1:1:0:e.offsete.position.root!=t.position.root?e.position.root.rootNamee));for(const e of t)delete e.changeCount,"attribute"==e.type&&(delete e.position,delete e.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(Nl),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getChangedRoots(){return Array.from(this._changedRoots.values()).map((e=>{const t={...e};return void 0!==t.state&&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=Pr._createOn(e);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getData();this.bufferMarkerChange(e.name,t,t)}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 e=t.getData();this.bufferMarkerChange(t.name,{...e,range:null},e)}}}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e))return void this._changedRoots.set(e,{name:e,state:t?"attached":"detached"});const i=this._changedRoots.get(e);void 0!==i.state?(delete i.state,void 0===i.attributes&&this._changedRoots.delete(e)):i.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,i,n){const o=this._changedRoots.get(e)||{name:e},s=o.attributes||{};if(s[t]){const e=s[t];n===e.oldValue?delete s[t]:e.newValue=n}else s[t]={oldValue:i,newValue:n};0===Object.entries(s).length?(delete o.attributes,void 0===o.state&&this._changedRoots.delete(e)):(o.attributes=s,this._changedRoots.set(e,o))}_markInsert(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n)}_markRemove(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n),this._removeAllNestedChanges(e,t,i)}_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 i=this._getChangesForElement(e);this._handleChange(t,i),i.push(t);for(let e=0;ei&&this._elementState.set(e,t)}_getDiffActionForNode(e,t){if(!e.is("element"))return t;if(!this._elementsSnapshots.has(e))return t;const i=this._elementState.get(e);return i&&"move"!=i?i:t}_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=Bl(e.getChildren());this._elementChildrenSnapshots.set(e,t);for(const e of t)this._elementsSnapshots.set(e.node,e)}_handleChange(e,t){e.nodesToHandle=e.howMany;for(const i of t){const n=e.offset+e.howMany,o=i.offset+i.howMany;if("insert"==e.type&&("insert"==i.type&&(e.offset<=i.offset?i.offset+=e.howMany:e.offseti.offset){if(n>o){const e={type:"attribute",offset:o,howMany:n-o,count:this._changeCount++};this._handleChange(e,t),t.push(e)}e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=i.offset&&e.offseto?(e.nodesToHandle=n-o,e.offset=o):e.nodesToHandle=0);if("remove"==i.type&&e.offseti.offset){const o={type:"attribute",offset:i.offset,howMany:n-i.offset,count:this._changeCount++};this._handleChange(o,t),t.push(o),e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==i.type&&(e.offset>=i.offset&&n<=o?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=i.offset&&n>=o&&(i.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,i,n,o){const s={type:"insert",position:Cr._createAt(e,t),name:n.name,attributes:new Map(n.attributes),length:1,changeCount:this._changeCount++,action:i};return"insert"!=i&&o&&(s.before={name:o.name,attributes:new Map(o.attributes)}),s}_getRemoveDiff(e,t,i,n){return{type:"remove",action:i,position:Cr._createAt(e,t),name:n.name,attributes:new Map(n.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,i){const n=[];i=new Map(i);for(const[o,s]of t){const t=i.has(o)?i.get(o):null;t!==s&&n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:o,attributeOldValue:s,attributeNewValue:t,changeCount:this._changeCount++}),i.delete(o)}for(const[t,o]of i)n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:o,changeCount:this._changeCount++});return n}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const i=this._changesInElement.get(t),n=e.startOffset;if(i)for(const e of i)if("insert"==e.type&&n>=e.offset&&nn){for(let t=0;t1500)for(let t=0;tthis._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 x("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 i=this._operations[0];void 0===e&&(e=i.baseVersion);let n=t-1;for(const[t,i]of this._gaps)e>t&&et&&nthis.lastOperation.baseVersion)return[];let o=this._baseVersionToOperationIndex.get(e);void 0===o&&(o=0);let s=this._baseVersionToOperationIndex.get(n);return void 0===s&&(s=this._operations.length-1),this._operations.slice(o,s+1)}getOperation(e){const t=this._baseVersionToOperationIndex.get(e);if(void 0!==t)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 Dl extends ea{rootName;_document;_isAttached=!0;_isLoaded=!0;constructor(e,t,i="main"){super(t),this._document=e,this.rootName=i}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}function zl(e,t){for(const i in t)Object.hasOwn(t,i)&&(e[i]=t[i])}Dl.prototype.is=function(e,t){return t?t===this.name&&("rootElement"===e||"model:rootElement"===e||"element"===e||"model:element"===e):"rootElement"===e||"model:rootElement"===e||"element"===e||"model:element"===e||"node"===e||"model:node"===e};const Hl="$graveyard";class Ul extends(R()){model;history;selection;roots;differ;isReadOnly;_postFixers;_hasSelectionChangedFromTheLastChangeBlock;constructor(e){super(),this.model=e,this.history=new Fl,this.selection=new Yr(this),this.roots=new Xt({idProperty:"rootName"}),this.differ=new Rl(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",Hl),this.listenTo(e,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&this.differ.bufferOperation(i)}),{priority:"high"}),this.listenTo(e,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&this.history.addOperation(i)}),{priority:"low"}),this.listenTo(this.selection,"change",(()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0})),this.listenTo(e.markers,"update",((e,t,i,n,o)=>{const s={...t.getData(),range:n};this.differ.bufferMarkerChange(t.name,o,s),null===i&&t.on("change",((e,i)=>{const n=t.getData();this.differ.bufferMarkerChange(t.name,{...n,range:i},n)}))})),this.registerPostFixer((e=>{let t=!1;for(const i of this.roots)i.isAttached()||i.isEmpty||(e.remove(e.createRangeIn(i)),t=!0);for(const i of this.model.markers)i.getRange().root.isAttached()||(e.removeMarker(i),t=!0);return t}))}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(Hl)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new x("model-document-createroot-name-exists",this,{name:t});const i=new Dl(this,e,t);return this.roots.add(i),i}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map((e=>e.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=function(e){if(Ie(e))return e;const t=ae(e);if(!function(e){switch(ae(e)){case he:case be:case we:case ye:case de:case ge:case Se:case Pe:case Ae:case Te:case Ee:case fe:case ue:case ve:case le:case pe:case ce:case me:case _e:case ke:case Ce:case xe:return!0;default:return!1}}(e))return{};if(i=e,Array.isArray(i)){const t=Array.from(e);return e.length>0&&"string"==typeof e[0]&&Object.hasOwn(e,"index")&&(t.index=e.index,t.input=e.input),t}var i;if(qt(e)){const t=e;return new(0,t.constructor)(t.buffer,t.byteOffset,t.length)}if(t===we)return new ArrayBuffer(e.byteLength);if(t===ye){const t=e,i=t.buffer,n=t.byteOffset,o=t.byteLength,s=new ArrayBuffer(o),r=new Uint8Array(i,n,o);return new Uint8Array(s).set(r),new DataView(s)}if(t===de||t===ue||t===ce){const i=new(0,e.constructor)(e.valueOf());return t===ce?function(e,t){const i=t.valueOf().length;for(const n in t)Object.hasOwn(t,n)&&(Number.isNaN(Number(n))||Number(n)>=i)&&(e[n]=t[n])}(i,e):zl(i,e),i}if(t===ge)return new Date(Number(e));if(t===le){const t=e,i=new RegExp(t.source,t.flags);return i.lastIndex=t.lastIndex,i}if(t===me)return Object(Symbol.prototype.valueOf.call(e));if(t===fe){const t=e,i=new Map;return t.forEach(((e,t)=>{i.set(t,e)})),i}if(t===pe){const t=e,i=new Set;return t.forEach((e=>{i.add(e)})),i}if(t===he){const t=e,i={};return zl(i,t),i.length=t.length,i[Symbol.iterator]=t[Symbol.iterator],i}const n={};return function(e,t){const i=Object.getPrototypeOf(t);null!==i&&"function"==typeof t.constructor&&Object.setPrototypeOf(e,i)}(n,e),zl(n,e),function(e,t){const i=Object.getOwnPropertySymbols(t);for(let n=0;n"string"==typeof e?new Kr(e):e instanceof yr?new Kr(e.data,e.getAttributes()):e)))}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}}Gl.prototype.is=function(e){return"documentFragment"===e||"model:documentFragment"===e};class Kl{model;batch;constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new Kr(e,t)}createElement(e,t){return new ea(e,t)}createDocumentFragment(){return new Gl}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,i=0){if(this._assertWriterUsedCorrectly(),e instanceof Kr&&""==e.data)return;const n=Cr._createAt(t,i);if(e.parent){if(Zl(e.root,n.root))return void this.move(Pr._createOn(e),n);if(e.root.document)throw new x("model-writer-insert-forbidden-move",this);this.remove(e)}const o=n.root.document?n.root.document.version:null,s=e instanceof Gl?e._removeChildren(0,e.childCount):e,r=new sl(n,s,o);if(e instanceof Kr&&(r.shouldReceiveAttributes=!0),this.batch.addOperation(r),this.model.applyOperation(r),e instanceof Gl)for(const[t,i]of e.markers){const e=Cr._createAt(i.root,0),o={range:new Pr(i.start._getCombined(e,n),i.end._getCombined(e,n)),usingOperation:!0,affectsData:!0};this.model.markers.has(t)?this.updateMarker(t,o):this.addMarker(t,o)}}insertText(e,t,i,n){t instanceof Gl||t instanceof ea||t instanceof Cr?this.insert(this.createText(e),t,i):this.insert(this.createText(e,t),i,n)}insertElement(e,t,i,n){t instanceof Gl||t instanceof ea||t instanceof Cr?this.insert(this.createElement(e),t,i):this.insert(this.createElement(e,t),i,n)}append(e,t){this.insert(e,t,"end")}appendText(e,t,i){t instanceof Gl||t instanceof ea?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),i,"end")}appendElement(e,t,i){t instanceof Gl||t instanceof ea?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),i,"end")}setAttribute(e,t,i){if(this._assertWriterUsedCorrectly(),i instanceof Pr){const n=i.getMinimalFlatRanges();for(const i of n)Jl(this,e,t,i)}else Yl(this,e,t,i)}setAttributes(e,t){for(const[i,n]of si(e))this.setAttribute(i,n,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof Pr){const i=t.getMinimalFlatRanges();for(const t of i)Jl(this,e,null,t)}else Yl(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=e=>{for(const t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof Pr)for(const i of e.getItems())t(i);else t(e)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof Pr))throw new x("writer-move-invalid-range",this);if(!e.isFlat)throw new x("writer-move-range-not-flat",this);const n=Cr._createAt(t,i);if(n.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!Zl(e.root,n.root))throw new x("writer-move-different-document",this);const o=e.root.document?e.root.document.version:null,s=new ol(e.start,e.end.offset-e.start.offset,n,o);this.batch.addOperation(s),this.model.applyOperation(s)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof Pr?e:Pr._createOn(e)).getMinimalFlatRanges().reverse();for(const e of t)this._addOperationForAffectedMarkers("move",e),Xl(e.start,e.end.offset-e.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,i=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof ea))throw new x("writer-merge-no-element-before",this);if(!(i instanceof ea))throw new x("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,i){return this.model.createPositionFromPath(e,t,i)}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,i=e.nodeAfter;this.move(Pr._createIn(i),Cr._createAt(t,"end")),this.remove(i)}_merge(e){const t=Cr._createAt(e.nodeBefore,"end"),i=Cr._createAt(e.nodeAfter,0),n=e.root.document.graveyard,o=new Cr(n,[0]),s=e.root.document.version,r=new al(i,e.nodeAfter.maxOffset,t,o,s);this.batch.addOperation(r),this.model.applyOperation(r)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof ea))throw new x("writer-rename-not-element-instance",this);const i=e.root.document?e.root.document.version:null,n=new hl(Cr._createBefore(e),e.name,t,i);this.batch.addOperation(n),this.model.applyOperation(n)}split(e,t){this._assertWriterUsedCorrectly();let i,n,o=e.parent;if(!o.parent)throw new x("writer-split-element-no-parent",this);if(t||(t=o.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new x("writer-split-invalid-limit-element",this);do{const t=o.root.document?o.root.document.version:null,s=o.maxOffset-e.offset,r=rl.getInsertionPosition(e),a=new rl(e,s,r,null,t);this.batch.addOperation(a),this.model.applyOperation(a),i||n||(i=o,n=e.parent.nextSibling),o=(e=this.createPositionAfter(e.parent)).parent}while(o!==t);return{position:e,range:new Pr(Cr._createAt(i,"end"),Cr._createAt(n,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new x("writer-wrap-range-not-flat",this);const i=t instanceof ea?t:new ea(t);if(i.childCount>0)throw new x("writer-wrap-element-not-empty",this);if(null!==i.parent)throw new x("writer-wrap-element-attached",this);this.insert(i,e.start);const n=new Pr(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(n,Cr._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new x("writer-unwrap-element-no-parent",this);this.move(Pr._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new x("writer-addmarker-no-usingoperation",this);const i=t.usingOperation,n=t.range,o=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new x("writer-addmarker-marker-exists",this);if(!n)throw new x("writer-addmarker-no-range",this);return i?(Ql(this,e,null,n,o),this.model.markers.get(e)):this.model.markers._set(e,n,i,o)}updateMarker(e,t){this._assertWriterUsedCorrectly();const i="string"==typeof e?e:e.name,n=this.model.markers.get(i);if(!n)throw new x("writer-updatemarker-marker-not-exists",this);if(!t)return A("writer-updatemarker-reconvert-using-editingcontroller",{markerName:i}),void this.model.markers._refresh(n);const o="boolean"==typeof t.usingOperation,s="boolean"==typeof t.affectsData,r=s?t.affectsData:n.affectsData;if(!o&&!t.range&&!s)throw new x("writer-updatemarker-wrong-options",this);const a=n.getRange(),l=t.range?t.range:a;o&&t.usingOperation!==n.managedUsingOperations?t.usingOperation?Ql(this,i,null,l,r):(Ql(this,i,a,null,r),this.model.markers._set(i,l,void 0,r)):n.managedUsingOperations?Ql(this,i,a,l,r):this.model.markers._set(i,l,void 0,r)}removeMarker(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new x("writer-removemarker-no-marker",this);const i=this.model.markers.get(t);i.managedUsingOperations?Ql(this,t,i.getRange(),null,i.affectsData):this.model.markers._remove(t)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const i=this.model.document.getRoot(e);if(i&&i.isAttached())throw new x("writer-addroot-root-exists",this);const n=this.model.document,o=new gl(e,t,!0,n,n.version);return this.batch.addOperation(o),this.model.applyOperation(o),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new x("writer-detachroot-no-root",this);for(const e of this.model.markers)e.getRange().root===t&&this.removeMarker(e);for(const e of t.getAttributeKeys())this.removeAttribute(e,t);this.remove(this.createRangeIn(t));const i=this.model.document,n=new gl(t.rootName,t.name,!1,i,i.version);this.batch.addOperation(n),this.model.applyOperation(n)}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(),"string"==typeof e)this._setSelectionAttribute(e,t);else for(const[t,i]of si(e))this._setSelectionAttribute(t,i)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),"string"==typeof e)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 i=this.model.document.selection;if(i.isCollapsed&&i.anchor.parent.isEmpty){const n=Yr._getStoreAttributeKey(e);this.setAttribute(n,t,i.anchor.parent)}i._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const i=Yr._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new x("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const i of this.model.markers){if(!i.managedUsingOperations)continue;const n=i.getRange();let o=!1;if("move"===e){const e=t;o=e.containsPosition(n.start)||e.start.isEqual(n.start)||e.containsPosition(n.end)||e.end.isEqual(n.end)}else{const e=t,i=e.nodeBefore,s=e.nodeAfter,r=n.start.parent==i&&n.start.isAtEnd,a=n.end.parent==s&&0==n.end.offset,l=n.end.nodeAfter==s,c=n.start.nodeAfter==s;o=r||a||l||c}o&&this.updateMarker(i.name,{range:n})}}}function Jl(e,t,i,n){const o=e.model,s=o.document;let r,a,l,c=n.start;for(const e of n.getWalker({shallow:!0}))l=e.item.getAttribute(t),r&&a!=l&&(a!=i&&u(),c=r),r=e.nextPosition,a=l;function u(){const n=new Pr(c,r),l=n.root.document?s.version:null,u=new ul(n,t,a,i,l);e.batch.addOperation(u),o.applyOperation(u)}r instanceof Cr&&r!=c&&a!=i&&u()}function Yl(e,t,i,n){const o=e.model,s=o.document,r=n.getAttribute(t);let a,l;if(r!=i){if(n.root===n){const e=n.document?s.version:null;l=new ml(n,t,r,i,e)}else{a=new Pr(Cr._createBefore(n),e.createPositionAfter(n));const o=a.root.document?s.version:null;l=new ul(a,t,r,i,o)}e.batch.addOperation(l),o.applyOperation(l)}}function Ql(e,t,i,n,o){const s=e.model,r=s.document,a=new ll(t,i,n,s.markers,!!o,r.version);e.batch.addOperation(a),s.applyOperation(a)}function Xl(e,t,i,n){let o;if(e.root.document){const i=n.document,s=new Cr(i.graveyard,[0]);o=new ol(e,t,s,i.version)}else o=new Wl(e,t);i.addOperation(o),n.applyOperation(o)}function Zl(e,t){return e===t||e instanceof Dl&&t instanceof Dl}function ec(e,t){return e.isCollapsed?function(e,t){const i=e.start,n=t.getNearestSelectionRange(i);if(!n){const e=i.getAncestors().reverse().find((e=>t.isObject(e)));return e?Pr._createOn(e):null}if(!n.isCollapsed)return n;const o=n.start;return i.isEqual(o)?null:new Pr(o)}(e,t):function(e,t){const{start:i,end:n}=e,o=t.checkChild(i,"$text"),s=t.checkChild(n,"$text"),r=t.getLimitElement(i),a=t.getLimitElement(n);if(r===a){if(o&&s)return null;if(function(e,t,i){const n=e.nodeAfter&&!i.isLimit(e.nodeAfter)||i.checkChild(e,"$text"),o=t.nodeBefore&&!i.isLimit(t.nodeBefore)||i.checkChild(t,"$text");return n||o}(i,n,t)){const e=i.nodeAfter&&t.isSelectable(i.nodeAfter)?null:t.getNearestSelectionRange(i,"forward"),o=n.nodeBefore&&t.isSelectable(n.nodeBefore)?null:t.getNearestSelectionRange(n,"backward"),s=e?e.start:i,r=o?o.end:n;return new Pr(s,r)}}const l=r&&!r.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const e=i.nodeAfter&&n.nodeBefore&&i.nodeAfter.parent===n.nodeBefore.parent,o=l&&(!e||!ic(i.nodeAfter,t)),s=c&&(!e||!ic(n.nodeBefore,t));let u=i,d=n;return o&&(u=Cr._createBefore(tc(r,t))),s&&(d=Cr._createAfter(tc(a,t))),new Pr(u,d)}return null}(e,t)}function tc(e,t){let i=e,n=i;for(;t.isLimit(n)&&n.parent;)i=n,n=n.parent;return i}function ic(e,t){return e&&t.isSelectable(e)}function nc(e,t,i={}){if(t.isCollapsed)return;const n=t.getFirstRange();if("$graveyard"==n.root.rootName)return;const o=e.schema;e.change((e=>{if(!i.doNotResetEntireContent&&function(e,t){const i=e.getLimitElement(t);if(!t.containsEntireContent(i))return!1;const n=t.getFirstRange();return n.start.parent!=n.end.parent&&e.checkChild(i,"paragraph")}(o,t))return void function(e,t){const i=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(i)),ac(e,e.createPositionAt(i,0),t)}(e,t);const s={};if(!i.doNotAutoparagraph){const e=t.getSelectedElement();e&&Object.assign(s,o.getAttributesWithProperty(e,"copyOnReplace",!0))}let r,a;i.doNotFixSelection?(r=Pl.fromPosition(n.start,"toPrevious"),a=Pl.fromPosition(n.end,"toNext")):[r,a]=function(e){const t=e.root.document.model,i=e.start;let n=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){const i=function(e){const t=e.parent,i=t.root.document.model.schema,n=t.getAncestors({parentFirst:!0,includeSelf:!0});for(const e of n){if(i.isLimit(e))return null;if(i.isBlock(e))return e}}(n);if(i&&n.isTouching(t.createPositionAt(i,0))){const i=t.createSelection(e);t.modifySelection(i,{direction:"backward"});const o=i.getLastPosition(),s=t.createRange(o,n);t.hasContent(s,{ignoreMarkers:!0})||(n=o)}}return[Pl.fromPosition(i,"toPrevious"),Pl.fromPosition(n,"toNext")]}(n),r.isTouching(a)||e.remove(e.createRange(r,a)),i.leaveUnmerged||(function(e,t,i){const n=e.model;if(!rc(e.model.schema,t,i))return;const[o,s]=function(e,t){const i=e.getAncestors(),n=t.getAncestors();let o=0;for(;i[o]&&i[o]==n[o];)o++;return[i[o],n[o]]}(t,i);o&&s&&(!n.hasContent(o,{ignoreMarkers:!0})&&n.hasContent(s,{ignoreMarkers:!0})?sc(e,t,i,o.parent):oc(e,t,i,o.parent))}(e,r,a),o.removeDisallowedAttributes(r.parent.getChildren(),e)),lc(e,t,r),!i.doNotAutoparagraph&&function(e,t){const i=e.checkChild(t,"$text"),n=e.checkChild(t,"paragraph");return!i&&n}(o,r)&&ac(e,r,t,s),r.detach(),a.detach()}))}function oc(e,t,i,n){const o=t.parent,s=i.parent;if(o!=n&&s!=n){for(t=e.createPositionAfter(o),(i=e.createPositionBefore(s)).isEqual(t)||e.insert(s,t),e.merge(t);i.parent.isEmpty;){const t=i.parent;i=e.createPositionBefore(t),e.remove(t)}rc(e.model.schema,t,i)&&oc(e,t,i,n)}}function sc(e,t,i,n){const o=t.parent,s=i.parent;if(o!=n&&s!=n){for(t=e.createPositionAfter(o),(i=e.createPositionBefore(s)).isEqual(t)||e.insert(o,i);t.parent.isEmpty;){const i=t.parent;t=e.createPositionBefore(i),e.remove(i)}i=e.createPositionBefore(s),function(e,t){const i=t.nodeBefore,n=t.nodeAfter;i.name!=n.name&&e.rename(i,n.name),e.clearAttributes(i),e.setAttributes(Object.fromEntries(n.getAttributes()),i),e.merge(t)}(e,i),rc(e.model.schema,t,i)&&sc(e,t,i,n)}}function rc(e,t,i){const n=t.parent,o=i.parent;return n!=o&&!e.isLimit(n)&&!e.isLimit(o)&&function(e,t,i){const n=new Pr(e,t);for(const e of n.getWalker())if(i.isLimit(e.item))return!1;return!0}(t,i,e)}function ac(e,t,i,n={}){const o=e.createElement("paragraph");e.model.schema.setAllowedAttributes(o,n,e),e.insert(o,t),lc(e,i,e.createPositionAt(o,0))}function lc(e,t,i){t instanceof Yr?e.setSelection(i):t.setTo(i)}function cc(e,t){const i=[];Array.from(e.getItems({direction:"backward"})).map((e=>t.createRangeOn(e))).filter((t=>(t.start.isAfter(e.start)||t.start.isEqual(e.start))&&(t.end.isBefore(e.end)||t.end.isEqual(e.end)))).forEach((e=>{i.push(e.start.parent),t.remove(e)})),i.forEach((e=>{let i=e;for(;i.parent&&i.isEmpty;){const e=t.createRangeOn(i);i=i.parent,t.remove(e)}}))}class uc{model;writer;position;canMergeWith;schema;_documentFragment;_documentFragmentPosition;_firstNode=null;_lastNode=null;_lastAutoParagraph=null;_filterAttributesAndChildrenOf=[];_affectedStart=null;_affectedEnd=null;_nodeToSelect=null;constructor(e,t,i){this.model=e,this.writer=t,this.position=i,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))t.offsetSize>0&&this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesAndChildrenOf,this.writer),this.model._config?.get("experimentalFlags.modelInsertContentDeepSchemaVerification")&&this._removeDisallowedChildren(this._filterAttributesAndChildrenOf),this._filterAttributesAndChildrenOf=[]}_removeDisallowedChildren(e){const t=Array.from(e);for(const e of t){if(!e.is("element"))continue;const i=[],n=[],o=this.writer.createRangeIn(e).getWalker({ignoreElementEnd:!0});for(const{item:e}of o){const s=e.parent;this.schema.checkChild(s,e)||(e.is("element")&&!this.schema.isObject(e)?(n.push(e),t.push(s)):i.push(e),o.jumpTo(this.writer.createPositionAfter(e)))}for(const e of n)this.writer.unwrap(e);for(const e of i)this.writer.remove(e)}}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),i=this.writer.createPositionAfter(e);if(i.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new x("insertcontent-invalid-insertion-position",this);this.position=i,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?Pr._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new Pr(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(e){this._checkAndSplitToAllowedPosition(e)?(e=this._appendToFragment(e),this._firstNode||(this._firstNode=e),this._lastNode=e):this.schema.isObject(e)||this._handleDisallowedNode(e)}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const e=Pl.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){if(!this.schema.checkChild(this.position,e))throw new x("insertcontent-wrong-position",this,{node:e,position:this.position});return this.writer.insert(e,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(e.offsetSize),e.parent||(e=this._documentFragmentPosition.nodeBefore),this.schema.isObject(e)&&!this.schema.checkChild(this.position,"$text")?this._nodeToSelect=e:this._nodeToSelect=null,this._filterAttributesAndChildrenOf.push(e),e}_setAffectedBoundaries(e){this._affectedStart||(this._affectedStart=Pl.fromPosition(e,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(e)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=Pl.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof ea))return;if(!this._canMergeLeft(e))return;const t=Pl._createBefore(e);t.stickiness="toNext";const i=Pl.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=Pl._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=Pl._createAt(t.nodeBefore,"end","toNext")),this.position=i.toPosition(),i.detach(),this._filterAttributesAndChildrenOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof ea))return;if(!this._canMergeRight(e))return;const t=Pl._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new x("insertcontent-invalid-insertion-position",this);this.position=Cr._createAt(t.nodeBefore,"end");const i=Pl.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=Pl._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=Pl._createAt(t.nodeBefore,0,"toPrevious")),this.position=i.toPosition(),i.detach(),this._filterAttributesAndChildrenOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof ea&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof ea&&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 e=this.position.parent;this.position=this.writer.createPositionBefore(e),e.isEmpty&&e.parent===t&&this.writer.remove(e)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const e=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=e,this.canMergeWith.add(this.position.nodeAfter)}return this.schema.checkChild(this.position.parent,e)||this._insertAutoParagraph(),!0}_getAllowedIn(e,t){const i=this.schema.createContext(e);return this.schema.checkChild(i,t)||this.schema.checkChild(i,"paragraph")&&this.schema.checkChild(i.push("paragraph"),t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}}function dc(e,t){const{isForward:i,walker:n,unit:o,schema:s,treatEmojiAsSingleUnit:r}=e,{type:a,item:l,nextPosition:c}=t;if("text"==a)return"word"===e.unit?function(e,t){let i=e.position.textNode;for(i||(i=t?e.position.nodeAfter:e.position.nodeBefore);i&&i.is("$text");){const n=e.position.offset-i.startOffset;if(gc(i,n,t))i=t?e.position.nodeAfter:e.position.nodeBefore;else{if(mc(i.data,n,t))break;e.next()}}return e.position}(n,i):function(e,t,i){const n=e.position.textNode;if(n){const o=n.data;let s=e.position.offset-n.startOffset;for(;ui(o,s)||"character"==t&&di(o,s)||i&&mi(o,s);)e.next(),s=e.position.offset-n.startOffset}return e.position}(n,o,r);if(a==(i?"elementStart":"elementEnd")){if(s.isSelectable(l))return Cr._createAt(l,i?"after":"before");if(s.checkChild(c,"$text"))return c}else{if(s.isLimit(l))return void n.skip((()=>!0));if(s.checkChild(c,"$text"))return c}}function hc(e,t){const i=e.root,n=Cr._createAt(i,t?"end":0);return t?new Pr(e,n):new Pr(n,e)}function mc(e,t,i){const n=t+(i?0:-1);return' ,.?!:;"-()'.includes(e.charAt(n))}function gc(e,t,i){return t===(i?e.offsetSize:0)}class fc extends(G()){markers;document;schema;_config;_pendingChanges;_currentWriter;constructor(e){var t;super(),this.markers=new ql,this.document=new Ul(this),this.schema=new Sa,this._config=e,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"),(t=this).document.registerPostFixer((e=>function(e,t){const i=t.document.selection,n=t.schema,o=[];let s=!1;for(const e of i.getRanges()){const t=ec(e,n);t&&!t.isEqual(e)?(o.push(t),s=!0):o.push(e)}return s&&e.setSelection(function(e){const t=[...e],i=new Set;let n=1;for(;n!i.has(t)));return o}(o),{backward:i.isBackward}),!1}(e,t))),this.document.registerPostFixer(ba),this.on("insertContent",((e,[t,i])=>{e.return=function(e,t,i){return e.change((n=>{const o=i||e.document.selection;o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0});const s=new uc(e,n,o.anchor),r=[];let a;if(t.is("documentFragment")){if(t.markers.size){const e=[];for(const[i,n]of t.markers){const{start:t,end:o}=n,s=t.isEqual(o);e.push({position:t,name:i,isCollapsed:s},{position:o,name:i,isCollapsed:s})}e.sort((({position:e},{position:t})=>e.isBefore(t)?1:-1));for(const{position:i,name:o,isCollapsed:s}of e){let e=null,a=null;const l=i.parent===t&&i.isAtStart,c=i.parent===t&&i.isAtEnd;l||c?s&&(a=l?"start":"end"):(e=n.createElement("$marker"),n.insert(e,i)),r.push({name:o,element:e,collapsed:a})}}a=t.getChildren()}else a=[t];s.handleNodes(a);let l=s.getSelectionRange();if(t.is("documentFragment")&&r.length){const e=l?jr.fromRange(l):null,t={};for(let e=r.length-1;e>=0;e--){const{name:i,element:o,collapsed:a}=r[e],l=!t[i];if(l&&(t[i]=[]),o){const e=n.createPositionAt(o,"before");t[i].push(e),n.remove(o)}else{const e=s.getAffectedRange();if(!e){a&&t[i].push(s.position);continue}a?t[i].push(e[a]):t[i].push(l?e.start:e.end)}}for(const[e,[i,o]]of Object.entries(t))i&&o&&i.root===o.root&&i.root.document&&!n.model.markers.has(e)&&n.addMarker(e,{usingOperation:!0,affectsData:!0,range:new Pr(i,o)});e&&(l=e.toRange(),e.detach())}l&&(o instanceof Yr?n.setSelection(l):o.setTo(l));const c=s.getAffectedRange()||e.createRange(o.anchor);return s.destroy(),c}))}(this,t,i)})),this.on("insertObject",((e,[t,i,n])=>{e.return=function(e,t,i,n={}){if(!e.schema.isObject(t))throw new x("insertobject-element-not-an-object",e,{object:t});const o=i||e.document.selection;let s=o;n.findOptimalPosition&&e.schema.isBlock(t)&&(s=e.createSelection(e.schema.findOptimalInsertionRange(o,n.findOptimalPosition)));const r=Zt(o.getSelectedBlocks()),a={};return r&&Object.assign(a,e.schema.getAttributesWithProperty(r,"copyOnReplace",!0)),e.change((i=>{s.isCollapsed||e.deleteContent(s,{doNotAutoparagraph:!0});let o=t;const r=s.anchor.parent,l=e.schema.createContext(r);!e.schema.checkChild(l,t)&&e.schema.checkChild(l,"paragraph")&&e.schema.checkChild(l.push("paragraph"),t)&&(o=i.createElement("paragraph"),i.insert(t,o)),e.schema.setAllowedAttributes(o,a,i);const c=e.insertContent(o,s);return c.isCollapsed||n.setSelection&&function(e,t,i,n){const o=e.model;if("on"==i)return void e.setSelection(t,"on");if("after"!=i)throw new x("insertobject-invalid-place-parameter-value",o);let s=t.nextSibling;o.schema.isInline(t)?e.setSelection(t,"after"):(!(s&&o.schema.checkChild(s,"$text"))&&o.schema.checkChild(t.parent,"paragraph")&&(s=e.createElement("paragraph"),o.schema.setAllowedAttributes(s,n,e),o.insertContent(s,e.createPositionAfter(t))),s&&e.setSelection(s,0))}(i,t,n.setSelection,a),c}))}(this,t,i,n)})),this.on("canEditAt",(e=>{const t=!this.document.isReadOnly;e.return=t,t||e.stop()}))}change(e){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new Ol,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(e){x.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{e?"function"==typeof e?(t=e,e=new Ol):e instanceof Ol||(e=new Ol(e)):e=new Ol,this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(e){x.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,i,...n){const o=pc(t,i);return this.fire("insertContent",[e,o,i,...n])}insertObject(e,t,i,n,...o){const s=pc(t,i);return this.fire("insertObject",[e,s,n,n,...o])}deleteContent(e,t){nc(this,e,t)}modifySelection(e,t){!function(e,t,i={}){const n=e.schema,o="backward"!=i.direction,s=i.unit?i.unit:"character",r=!!i.treatEmojiAsSingleUnit,a=t.focus,l=new _r({boundaries:hc(a,o),singleCharacters:!0,direction:o?"forward":"backward"}),c={walker:l,schema:n,isForward:o,unit:s,treatEmojiAsSingleUnit:r};let u;for(;u=l.next();){if(u.done)return;const i=dc(c,u.value);if(i)return void(t instanceof Yr?e.change((e=>{e.setSelectionFocus(i)})):t.setFocus(i))}}(this,e,t)}getSelectedContent(e){return function(e,t){return e.change((e=>{const i=e.createDocumentFragment(),n=t.getFirstRange();if(!n||n.isCollapsed)return i;const o=n.start.root,s=n.start.getCommonPath(n.end),r=o.getNodeByPath(s);let a;a=n.start.parent==n.end.parent?n:e.createRange(e.createPositionAt(r,n.start.path[s.length]),e.createPositionAt(r,n.end.path[s.length]+1));const l=a.end.offset-a.start.offset;for(const t of a.getItems({shallow:!0}))t.is("$textProxy")?e.appendText(t.data,t.getAttributes(),i):e.append(e.cloneElement(t,!0),i);if(a!=n){const t=n._getTransformedByMove(a.start,e.createPositionAt(i,0),l)[0],o=e.createRange(e.createPositionAt(i,0),t.start);cc(e.createRange(t.end,e.createPositionAt(i,"end")),e),cc(o,e)}return i}))}(this,e)}hasContent(e,t={}){const i=e instanceof Pr?e:Pr._createIn(e);if(i.isCollapsed)return!1;const{ignoreWhitespaces:n=!1,ignoreMarkers:o=!1}=t;if(!o)for(const e of this.markers.getMarkersIntersectingRange(i))if(e.affectsData)return!0;for(const e of i.getItems())if(this.schema.isContent(e)){if(!e.is("$textProxy"))return!0;if(!n)return!0;if(-1!==e.data.search(/\S/))return!0}return!1}canEditAt(e){const t=pc(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,i){return new Cr(e,t,i)}createPositionAt(e,t){return Cr._createAt(e,t)}createPositionAfter(e){return Cr._createAfter(e)}createPositionBefore(e){return Cr._createBefore(e)}createRange(e,t){return new Pr(e,t)}createRangeIn(e){return Pr._createIn(e)}createRangeOn(e){return Pr._createOn(e)}createSelection(...e){return new Fr(...e)}createBatch(e){return new Ol(e)}createOperationFromJSON(e){return pl.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 Kl(this,t);const i=this._pendingChanges[0].callback(this._currentWriter);e.push(i),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 pc(e,t){if(e)return e instanceof Fr||e instanceof Yr?e:e instanceof Nr?t||0===t?new Fr(e,t):e.is("rootElement")?new Fr(e,"in"):new Fr(e,"on"):new Fr(e)}class bc extends er{domEventType="click";onDomEvent(e){this.fire(e.type,e)}}class wc extends er{domEventType=["mousedown","mouseup","mouseover","mouseout"];onDomEvent(e){this.fire(e.type,e)}}class vc extends er{domEventType=["touchstart","touchend","touchmove"];onDomEvent(e){this.fire(e.type,e)}}class yc extends er{domEventType=["pointerdown","pointerup","pointermove"];onDomEvent(e){this.fire(e.type,e)}}class _c{document;constructor(e){this.document=e}createDocumentFragment(e){return new ds(this.document,e)}createElement(e,t,i){return new Vo(this.document,e,t,i)}createText(e){return new no(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,i){return i._insertChild(e,t)}removeChildren(e,t,i){return i._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const i=e.parent;if(i){const n=i.getChildIndex(e);return this.removeChildren(n,1,i),this.insertChild(n,t,i),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const i=t.getChildIndex(e);this.remove(e),this.insertChild(i,e.getChildren(),t)}}rename(e,t){const i=new Vo(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,i)?i:null}setAttribute(e,t,i){i._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){se(e)&&void 0===i?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return zo._createAt(e,t)}createPositionAfter(e){return zo._createAfter(e)}createPositionBefore(e){return zo._createBefore(e)}createRange(e,t){return new Ho(e,t)}createRangeOn(e){return Ho._createOn(e)}createRangeIn(e){return Ho._createIn(e)}createSelection(...e){return new $o(...e)}}const kc=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Cc=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,xc=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Ac=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,Tc=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Ec=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,Sc=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 Pc(e){return e.startsWith("#")?kc.test(e):e.startsWith("rgb")?Cc.test(e)||xc.test(e):e.startsWith("hsl")?Ac.test(e)||Tc.test(e):Sc.has(e.toLowerCase())}const Ic=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];function Vc(e){return Ic.includes(e)}const Oc=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function Rc(e){return Oc.test(e)}const Lc=/^[+-]?[0-9]*([.][0-9]+)?%$/;function Bc(e){return Lc.test(e)}const Mc=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function Nc(e){return Mc.includes(e)}const Fc=["center","top","bottom","left","right"];function Dc(e){return Fc.includes(e)}const zc=["fixed","scroll","local"];function Hc(e){return zc.includes(e)}const Uc=/^url\(/;function $c(e){return Uc.test(e)}function qc(e=""){if(""===e)return{top:void 0,right:void 0,bottom:void 0,left:void 0};const t=Kc(e),i=t[0],n=t[2]||i,o=t[1]||i;return{top:i,bottom:n,right:o,left:t[3]||o}}function jc(e){return t=>{const{top:i,right:n,bottom:o,left:s}=t,r=[];return[i,n,s,o].every((e=>!!e))?r.push([e,Wc(t)]):(i&&r.push([e+"-top",i]),n&&r.push([e+"-right",n]),o&&r.push([e+"-bottom",o]),s&&r.push([e+"-left",s])),r}}function Wc({top:e,right:t,bottom:i,left:n}){const o=[];return n!==t?o.push(e,t,i,n):i!==e?o.push(e,t,i):t!==e?o.push(e,t):o.push(e),o.join(" ")}function Gc(e){return t=>({path:e,value:qc(t)})}function Kc(e){const t=e.trim().slice(0,1500).matchAll(Ec);return Array.from(t).map((e=>e[0]))}function Jc(e){e.setNormalizer("background",(e=>{const t={},i=Kc(e);for(const e of i)Nc(e)?(t.repeat=t.repeat||[],t.repeat.push(e)):Dc(e)?(t.position=t.position||[],t.position.push(e)):Hc(e)?t.attachment=e:Pc(e)?t.color=e:$c(e)&&(t.image=e);return{path:"background",value:t}})),e.setNormalizer("background-color",(e=>({path:"background.color",value:e}))),e.setReducer("background",(e=>{const t=[];return t.push(["background-color",e.color]),t})),e.setStyleRelation("background",["background-color"])}function Yc(e){e.setNormalizer("border",(e=>{const{color:t,style:i,width:n}=nu(e);return{path:"border",value:{color:qc(t),style:qc(i),width:qc(n)}}})),e.setNormalizer("border-top",Qc("top")),e.setNormalizer("border-right",Qc("right")),e.setNormalizer("border-bottom",Qc("bottom")),e.setNormalizer("border-left",Qc("left")),e.setNormalizer("border-color",Xc("color")),e.setNormalizer("border-width",Xc("width")),e.setNormalizer("border-style",Xc("style")),e.setNormalizer("border-top-color",eu("color","top")),e.setNormalizer("border-top-style",eu("style","top")),e.setNormalizer("border-top-width",eu("width","top")),e.setNormalizer("border-right-color",eu("color","right")),e.setNormalizer("border-right-style",eu("style","right")),e.setNormalizer("border-right-width",eu("width","right")),e.setNormalizer("border-bottom-color",eu("color","bottom")),e.setNormalizer("border-bottom-style",eu("style","bottom")),e.setNormalizer("border-bottom-width",eu("width","bottom")),e.setNormalizer("border-left-color",eu("color","left")),e.setNormalizer("border-left-style",eu("style","left")),e.setNormalizer("border-left-width",eu("width","left")),e.setExtractor("border-top",tu("top")),e.setExtractor("border-right",tu("right")),e.setExtractor("border-bottom",tu("bottom")),e.setExtractor("border-left",tu("left")),e.setExtractor("border-top-color","border.color.top"),e.setExtractor("border-right-color","border.color.right"),e.setExtractor("border-bottom-color","border.color.bottom"),e.setExtractor("border-left-color","border.color.left"),e.setExtractor("border-top-width","border.width.top"),e.setExtractor("border-right-width","border.width.right"),e.setExtractor("border-bottom-width","border.width.bottom"),e.setExtractor("border-left-width","border.width.left"),e.setExtractor("border-top-style","border.style.top"),e.setExtractor("border-right-style","border.style.right"),e.setExtractor("border-bottom-style","border.style.bottom"),e.setExtractor("border-left-style","border.style.left"),e.setReducer("border-color",jc("border-color")),e.setReducer("border-style",jc("border-style")),e.setReducer("border-width",jc("border-width")),e.setReducer("border-top",ou("top")),e.setReducer("border-right",ou("right")),e.setReducer("border-bottom",ou("bottom")),e.setReducer("border-left",ou("left")),e.setReducer("border",function(){return t=>{const i=iu(t,"top"),n=iu(t,"right"),o=iu(t,"bottom"),s=iu(t,"left"),r=[i,n,o,s],a={width:e(r,"width"),style:e(r,"style"),color:e(r,"color")},l=su(a,"all");if(l.length)return l;const c=Object.entries(a).reduce(((e,[t,i])=>(i&&(e.push([`border-${t}`,i]),r.forEach((e=>delete e[t]))),e)),[]);return[...c,...su(i,"top"),...su(n,"right"),...su(o,"bottom"),...su(s,"left")]};function e(e,t){return e.map((e=>e[t])).reduce(((e,t)=>e==t?e:null))}}()),e.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"]),e.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),e.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),e.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),e.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),e.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),e.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function Qc(e){return t=>{const{color:i,style:n,width:o}=nu(t),s={};return void 0!==i&&(s.color={[e]:i}),void 0!==n&&(s.style={[e]:n}),void 0!==o&&(s.width={[e]:o}),{path:"border",value:s}}}function Xc(e){return t=>({path:"border",value:Zc(t,e)})}function Zc(e,t){return{[t]:qc(e)}}function eu(e,t){return i=>({path:"border",value:{[e]:{[t]:i}}})}function tu(e){return(t,i)=>{if(i.border)return iu(i.border,e)}}function iu(e,t){const i={};return e.width&&e.width[t]&&(i.width=e.width[t]),e.style&&e.style[t]&&(i.style=e.style[t]),e.color&&e.color[t]&&(i.color=e.color[t]),i}function nu(e){const t={},i=Kc(e);for(const e of i)Rc(e)||/thin|medium|thick/.test(e)?t.width=e:Vc(e)?t.style=e:t.color=e;return t}function ou(e){return t=>su(t,e)}function su(e,t){const i=[];if(e&&e.width&&i.push("width"),e&&e.style&&i.push("style"),e&&e.color&&i.push("color"),3==i.length){const n=i.map((t=>e[t])).join(" ");return["all"==t?["border",n]:[`border-${t}`,n]]}return"all"==t?[]:i.map((i=>[`border-${t}-${i}`,e[i]]))}function ru(e){e.setNormalizer("margin",Gc("margin")),e.setNormalizer("margin-top",(e=>({path:"margin.top",value:e}))),e.setNormalizer("margin-right",(e=>({path:"margin.right",value:e}))),e.setNormalizer("margin-bottom",(e=>({path:"margin.bottom",value:e}))),e.setNormalizer("margin-left",(e=>({path:"margin.left",value:e}))),e.setReducer("margin",jc("margin")),e.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}function au(e){e.setNormalizer("padding",Gc("padding")),e.setNormalizer("padding-top",(e=>({path:"padding.top",value:e}))),e.setNormalizer("padding-right",(e=>({path:"padding.right",value:e}))),e.setNormalizer("padding-bottom",(e=>({path:"padding.bottom",value:e}))),e.setNormalizer("padding-left",(e=>({path:"padding.left",value:e}))),e.setReducer("padding",jc("padding")),e.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}Symbol("_treeDump");class lu extends Pn{view;_toolbarConfig;_elementReplacer;constructor(e,t){super(e),this.view=t,this._toolbarConfig=Vn(e.config.get("toolbar")),this._elementReplacer=new Z,this.listenTo(e.editing.view,"scrollToTheSelection",this._handleScrollToTheSelectionWithStickyPanel.bind(this))}get element(){return this.view.element}init(e){const t=this.editor,i=this.view,n=t.editing.view,o=i.editable,s=n.document.getRoot();o.name=s.rootName,i.render();const r=o.element;this.setEditableElement(o.name,r),i.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),i.menuBarView&&this.initMenuBar(i.menuBarView),this._initDialogPluginIntegration(),this._initContextualBalloonIntegration(),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),t.getDomRoot(e.editable.name)&&t.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.view;e.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),e.stickyPanel.limiterElement=e.element,e.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",(({visualTop:e})=>e||0)),e.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(e.toolbar)}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.sourceElement;let o;const s=e.config.get("placeholder");s&&(o="string"==typeof s?s:s[this.view.editable.name]),!o&&n&&"textarea"===n.tagName.toLowerCase()&&(o=n.getAttribute("placeholder")),o&&(i.placeholder=o),Yn({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}_initContextualBalloonIntegration(){if(!this.editor.plugins.has("ContextualBalloon"))return;const{stickyPanel:e}=this.view,t=this.editor.plugins.get("ContextualBalloon");t.on("getPositionOptions",(t=>{const i=t.return;if(!i||!e.isSticky||!e.element)return;const n=new Ze(e.element).height,o="function"==typeof i.target?i.target():i.target,s="function"==typeof i.limiter?i.limiter():i.limiter;if(o&&s&&new Ze(o).height>=new Ze(s).height-n)return;const r={...i.viewportOffsetConfig},a=(r.top||0)+n;t.return={...i,viewportOffsetConfig:{...r,top:a}}}),{priority:"low"});const i=()=>{t.visibleView&&t.updatePosition()};this.listenTo(e,"change:isSticky",i),this.listenTo(this.editor.ui,"change:viewportOffset",i)}_handleScrollToTheSelectionWithStickyPanel(e,t,i){const n=this.view.stickyPanel;if(n.isSticky){const e=new Ze(n.element).height;t.viewportOffset.top+=e}else{const e=()=>{this.editor.editing.view.scrollToTheSelection(i)};this.listenTo(n,"change:isSticky",e),setTimeout((()=>{this.stopListening(n,"change:isSticky",e)}),20)}}_initDialogPluginIntegration(){if(!this.editor.plugins.has("Dialog"))return;const e=this.view.stickyPanel,t=this.editor.plugins.get("Dialog");t.on("show",(()=>{const i=t.view;i.on("moveTo",((t,n)=>{if(!e.isSticky||i.wasMoved||i.isModal)return;const o=new Ze(e.contentPanelElement);n[1]e?"block":"none")),height:t.to("isSticky",(e=>e?mu(this._contentPanelRect.height):null))}}}).render(),this.contentPanelElement=new vi({tag:"div",attributes:{class:["ck","ck-sticky-panel__content",t.if("isSticky","ck-sticky-panel__content_sticky"),t.if("_isStickyToTheBottomOfLimiter","ck-sticky-panel__content_sticky_bottom-limit")],style:{width:t.to("isSticky",(e=>e?mu(this._contentPanelPlaceholder.getBoundingClientRect().width):null)),top:t.to("_stickyTopOffset",(e=>e?mu(e):e)),bottom:t.to("_stickyBottomOffset",(e=>e?mu(e):e)),marginLeft:t.to("_marginLeft")}},children:this.content}).render(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-sticky-panel"]},children:[this._contentPanelPlaceholder,this.contentPanelElement]})}render(){super.render(),this.checkIfShouldBeSticky(),this.listenTo(n.document,"scroll",(()=>{this.checkIfShouldBeSticky()}),{useCapture:!0}),this.listenTo(this,"change:isActive",(()=>{this.checkIfShouldBeSticky()})),n.window.visualViewport&&(this.listenTo(n.window.visualViewport,"scroll",(()=>{this.checkIfShouldBeSticky()})),this.listenTo(n.window.visualViewport,"resize",(()=>{this.checkIfShouldBeSticky()})))}checkIfShouldBeSticky(){if(!this.limiterElement||!this.isActive)return void this._unstick();const e=new Ze(this.limiterElement);let t=e.getVisible();if(t){const e=new Ze(n.window);e.top+=this.viewportTopOffset,e.height-=this.viewportTopOffset,t=t.getIntersection(e)}const{left:i,top:o}=vt();if(e.moveBy(i,o),t&&t.moveBy(i,o),t&&e.topt.height){const i=Math.max(e.bottom-t.bottom,0)+this.limiterBottomOffset;this._contentPanelRect.height+i+1`ck-dropdown__panel_${e}`)),t.if("isVisible","ck-dropdown__panel-visible")],tabindex:"-1"},children:this.children,on:{selectstart:t.to((e=>{const t=e.target;t instanceof Element&&"input"===t.tagName.toLocaleLowerCase()||e.preventDefault()}))}})}focus(){if(this.children.length){const e=this.children.first;"function"==typeof e.focus?e.focus():A("ui-dropdown-panel-focus-child-missing-focus",{childView:this.children.first,dropdownPanel:this})}}focusLast(){if(this.children.length){const e=this.children.last;"function"==typeof e.focusLast?e.focusLast():e.focus()}}}class wu extends Hi{buttonView;panelView;focusTracker;keystrokes;listView;toolbarView;menuView;constructor(e,t,i){super(e);const n=this.bindTemplate;this.buttonView=t,this.panelView=i,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class",void 0),this.set("id",void 0),this.set("panelPosition","auto"),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new oi,this.focusTracker=new ei,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",n.to("class"),n.if("isEnabled","ck-disabled",(e=>!e))],id:n.to("id"),"aria-describedby":n.to("ariaDescribedById")},children:[t,i]}),t.extendTemplate({attributes:{class:["ck-dropdown__button"],"data-cke-tooltip-disabled":n.to("isOpen")}})}render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.listenTo(this.buttonView,"open",(()=>{this.isOpen=!this.isOpen})),this.on("change:isOpen",((e,t,i)=>{if(i)if("auto"===this.panelPosition){const e=wu._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=e?e.name:this._defaultPanelPositionName}else this.panelView.position=this.panelPosition})),this.keystrokes.listenTo(this.element);const e=(e,t)=>{this.isOpen&&(this.isOpen=!1,t())};this.keystrokes.set("arrowdown",((e,t)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,t())})),this.keystrokes.set("arrowright",((e,t)=>{this.isOpen&&t()})),this.keystrokes.set("arrowleft",e),this.keystrokes.set("esc",e)}focus(){this.buttonView.focus()}get _panelPositions(){const{south:e,north:t,southEast:i,southWest:n,northEast:o,northWest:s,southMiddleEast:r,southMiddleWest:a,northMiddleEast:l,northMiddleWest:c}=wu.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[i,n,r,a,e,o,s,l,c,t]:[n,i,a,r,e,s,o,c,l,t]}get _defaultPanelPositionName(){return"rtl"===this.locale.uiLanguageDirection?"sw":"se"}static defaultPanelPositions={south:(e,t)=>({top:e.bottom,left:e.left-(t.width-e.width)/2,name:"s"}),southEast:e=>({top:e.bottom,left:e.left,name:"se"}),southWest:(e,t)=>({top:e.bottom,left:e.left-t.width+e.width,name:"sw"}),southMiddleEast:(e,t)=>({top:e.bottom,left:e.left-(t.width-e.width)/4,name:"sme"}),southMiddleWest:(e,t)=>({top:e.bottom,left:e.left-3*(t.width-e.width)/4,name:"smw"}),north:(e,t)=>({top:e.top-t.height,left:e.left-(t.width-e.width)/2,name:"n"}),northEast:(e,t)=>({top:e.top-t.height,left:e.left,name:"ne"}),northWest:(e,t)=>({top:e.top-t.height,left:e.left-t.width+e.width,name:"nw"}),northMiddleEast:(e,t)=>({top:e.top-t.height,left:e.left-(t.width-e.width)/4,name:"nme"}),northMiddleWest:(e,t)=>({top:e.top-t.height,left:e.left-3*(t.width-e.width)/4,name:"nmw"})};static _getOptimalPosition=gt}const vu='';class yu extends Bn{arrowView;constructor(e){super(e),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",(e=>String(e)))}}),this.delegate("execute").to(this,"open")}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new en;return e.content=vu,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}}class _u extends Hi{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}class ku extends Hi{labelView;items;children;constructor(e,t=new du){super(e);const i=this.bindTemplate,n=new Cu(e);this.set({label:"",isVisible:!0}),this.labelView=t,this.labelView.bind("text").to(this,"label"),this.children=this.createCollection(),this.children.addMany([this.labelView,n]),n.set({role:"group",ariaLabelledBy:t.id}),n.focusTracker.destroy(),n.keystrokes.destroy(),this.items=n.items,this.setTemplate({tag:"li",attributes:{role:"presentation",class:["ck","ck-list__group",i.if("isVisible","ck-hidden",(e=>!e))]},children:this.children})}focus(){if(this.items){const e=this.items.find((e=>!(e instanceof _u)));e&&e.focus()}}}class Cu extends Hi{focusables;items;focusTracker;keystrokes;_focusCycler;_listItemGroupToChangeListeners=new WeakMap;constructor(e){super(e);const t=this.bindTemplate;this.focusables=new wi,this.items=this.createCollection(),this.focusTracker=new ei,this.keystrokes=new oi,this._focusCycler=new Nn({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.set("ariaLabel",void 0),this.set("ariaLabelledBy",void 0),this.set("role",void 0),this.setTemplate({tag:"ul",attributes:{class:["ck","ck-reset","ck-list"],role:t.to("role"),"aria-label":t.to("ariaLabel"),"aria-labelledby":t.to("ariaLabelledBy")},children:this.items})}render(){super.render();for(const e of this.items)e instanceof ku?this._registerFocusableItemsGroup(e):e instanceof dn&&this._registerFocusableListItem(e);this.items.on("change",((e,t)=>{for(const e of t.removed)e instanceof ku?this._deregisterFocusableItemsGroup(e):e instanceof dn&&this._deregisterFocusableListItem(e);for(const e of Array.from(t.added).reverse())e instanceof ku?this._registerFocusableItemsGroup(e,t.index):this._registerFocusableListItem(e,t.index)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}focusFirst(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_registerFocusableListItem(e,t){this.focusTracker.add(e.element),this.focusables.add(e,t)}_deregisterFocusableListItem(e){this.focusTracker.remove(e.element),this.focusables.remove(e)}_getOnGroupItemsChangeCallback(e){return(t,i)=>{for(const e of i.removed)this._deregisterFocusableListItem(e);for(const t of Array.from(i.added).reverse())this._registerFocusableListItem(t,this.items.getIndex(e)+i.index)}}_registerFocusableItemsGroup(e,t){Array.from(e.items).forEach(((e,i)=>{const n=void 0!==t?t+i:void 0;this._registerFocusableListItem(e,n)}));const i=this._getOnGroupItemsChangeCallback(e);this._listItemGroupToChangeListeners.set(e,i),e.items.on("change",i)}_deregisterFocusableItemsGroup(e){for(const t of e.items)this._deregisterFocusableListItem(t);e.items.off("change",this._listItemGroupToChangeListeners.get(e)),this._listItemGroupToChangeListeners.delete(e)}}class xu extends Hi{children;actionView;arrowView;keystrokes;focusTracker;constructor(e,t){super(e);const i=this.bindTemplate;this.set("class",void 0),this.set("labelStyle",void 0),this.set("icon",void 0),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isToggleable",!1),this.set("isVisible",!0),this.set("keystroke",void 0),this.set("withKeystroke",!1),this.set("label",void 0),this.set("tabindex",-1),this.set("tooltip",!1),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.children=this.createCollection(),this.actionView=this._createActionView(t),this.arrowView=this._createArrowView(),this.keystrokes=new oi,this.focusTracker=new ei,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",i.to("class"),i.if("isVisible","ck-hidden",(e=>!e)),this.arrowView.bindTemplate.if("isOn","ck-splitbutton_open")]},children:this.children})}render(){super.render(),this.children.add(this.actionView),this.children.add(this.arrowView),this.focusTracker.add(this.actionView.element),this.focusTracker.add(this.arrowView.element),this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",((e,t)=>{this.focusTracker.focusedElement===this.actionView.element&&(this.arrowView.focus(),t())})),this.keystrokes.set("arrowleft",((e,t)=>{this.focusTracker.focusedElement===this.arrowView.element&&(this.actionView.focus(),t())}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.actionView.focus()}_createActionView(e){const t=e||new Bn;return e||t.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),t.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),t.delegate("execute").to(this),t}_createArrowView(){const e=new Bn,t=e.bindTemplate;return e.icon=vu,e.extendTemplate({attributes:{class:["ck-splitbutton__arrow"],"data-cke-tooltip-disabled":t.to("isOn"),"aria-haspopup":!0,"aria-expanded":t.to("isOn",(e=>String(e)))}}),e.bind("isEnabled").to(this),e.bind("label").to(this),e.bind("tooltip").to(this),e.delegate("execute").to(this,"open"),e}}class Au extends Bn{toggleSwitchView;constructor(e){super(e),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:"ck-switchbutton"}})}render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){const e=new Hi;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}}const Tu='';class Eu extends Bn{_checkIconHolderView=new Su;constructor(e,t=new Ln){super(e,t),this.set({hasCheckSpace:!1,_hasCheck:this.isToggleable});const i=this.bindTemplate;this.extendTemplate({attributes:{class:["ck-list-item-button",i.if("isToggleable","ck-list-item-button_toggleable")]}}),this.bind("_hasCheck").to(this,"hasCheckSpace",this,"isToggleable",((e,t)=>e||t))}render(){super.render(),this._hasCheck&&this.children.add(this._checkIconHolderView,0),this._watchCheckIconHolderMount()}_watchCheckIconHolderMount(){this._checkIconHolderView.bind("isOn").to(this,"isOn",(e=>this.isToggleable&&e)),this.on("change:_hasCheck",((e,t,i)=>{const{children:n,_checkIconHolderView:o}=this;i?n.add(o,0):n.remove(o)}))}}class Su extends Hi{children;_checkIconView=this._createCheckIconView();constructor(){super();const e=this.bindTemplate;this.children=this.createCollection(),this.set("isOn",!1),this.setTemplate({tag:"span",children:this.children,attributes:{class:["ck","ck-list-item-button__check-holder",e.to("isOn",(e=>e?"ck-on":"ck-off"))]}})}render(){super.render(),this.isOn&&this.children.add(this._checkIconView,0),this._watchCheckIconMount()}_watchCheckIconMount(){this.on("change:isOn",((e,t,i)=>{const{children:n,_checkIconView:o}=this;i&&!n.has(o)?n.add(o):!i&&n.has(o)&&n.remove(o)}))}_createCheckIconView(){const e=new en;return e.content=Tu,e.extendTemplate({attributes:{class:"ck-list-item-button__check-icon"}}),e}}function Pu(e,t=yu){const i="function"==typeof t?new t(e):t,o=new bu(e),s=new wu(e,i,o);return i.bind("isEnabled").to(s),i instanceof xu?i.arrowView.bind("isOn").to(s,"isOpen"):i.bind("isOn").to(s,"isOpen"),function(e){(function(e){mn({emitter:e,activator:()=>e.isRendered&&e.isOpen,callback:()=>{e.isOpen=!1},contextElements:()=>[e.element,...Bu(e.focusTracker).filter((t=>!e.element.contains(t)))]})})(e),function(e){e.on("execute",(t=>{t.source instanceof Au||(e.isOpen=!1)}))}(e),function(e){e.focusTracker.on("change:isFocused",((t,i,n)=>{!n&&e.isOpen&&(e.isOpen=!1)}))}(e),function(e){e.keystrokes.set("arrowdown",((t,i)=>{e.isOpen&&(e.panelView.focus(),i())})),e.keystrokes.set("arrowup",((t,i)=>{e.isOpen&&(e.panelView.focusLast(),i())}))}(e),function(e){e.on("change:isOpen",((t,i,o)=>{o||e.focusTracker.elements.some((e=>e.contains(n.document.activeElement)))&&e.buttonView.focus()}))}(e),function(e){e.on("change:isOpen",((t,i,n)=>{n&&e.panelView.focus()}),{priority:"low"})}(e)}(s),s}function Iu(e,t,i={}){e.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),e.isOpen?Vu(e,t,i):e.once("change:isOpen",(()=>Vu(e,t,i)),{priority:"highest"}),i.enableActiveItemFocusOnDropdownOpen&&Lu(e,(()=>e.toolbarView.items.find((e=>e.isOn))))}function Vu(e,t,i){const n=e.locale,o=n.t,s=e.toolbarView=new Hu(n),r="function"==typeof t?t():t;s.ariaLabel=i.ariaLabel||o("Dropdown toolbar"),i.maxWidth&&(s.maxWidth=i.maxWidth),i.class&&(s.class=i.class),i.isCompact&&(s.isCompact=i.isCompact),i.isVertical&&(s.isVertical=!0),r instanceof wi?s.items.bindTo(r).using((e=>e)):s.items.addMany(r),e.panelView.children.add(s),e.focusTracker.add(s),s.items.delegate("execute").to(e)}function Ou(e,t,i={}){e.isOpen?Ru(e,t,i):e.once("change:isOpen",(()=>Ru(e,t,i)),{priority:"highest"}),Lu(e,(()=>e.listView.items.find((e=>e instanceof dn&&e.children.first.isOn))))}function Ru(e,t,i){const n=e.locale,o=e.listView=new Cu(n),s="function"==typeof t?t():t;o.ariaLabel=i.ariaLabel,o.role=i.role,Mu(e,o.items,s,n),e.panelView.children.add(o),o.items.delegate("execute").to(e)}function Lu(e,t){e.on("change:isOpen",(()=>{if(!e.isOpen)return;const i=t();i&&("function"==typeof i.focus?i.focus():A("ui-dropdown-focus-child-on-open-child-missing-focus",{view:i}))}),{priority:k.low-10})}function Bu(e){return[...e.elements,...e.externalViews.flatMap((e=>Bu(e.focusTracker)))]}function Mu(e,t,i,n){!function(e){let t=0;const i=e=>e instanceof dn&&e.children.first instanceof Eu?e.children.first:null,n=e=>{const t=i(e);return t&&t.isToggleable?t:null};e.on("change",((o,s)=>{const r=t>0;for(const e of s.removed)n(e)&&t--;for(const e of s.added){const n=i(e);n&&(n.isToggleable&&t++,n.hasCheckSpace=t>0)}const a=t>0;r!==a&&(t=>{for(const n of e){const e=i(n);e&&(e.hasCheckSpace=t)}})(a)}))}(t),t.bindTo(i).using((t=>{if("separator"===t.type)return new _u(n);if("group"===t.type){const i=new ku(n);return i.set({label:t.label}),Mu(e,i.items,t.items,n),i.items.delegate("execute").to(e),i}if("button"===t.type||"switchbutton"===t.type){const e="menuitemcheckbox"===t.model.role||"menuitemradio"===t.model.role,i=new dn(n);let o;return"button"===t.type?(o=new Eu(n,t.labelView),o.set({isToggleable:e})):o=new Au(n),o.bind(...Object.keys(t.model)).to(t.model),o.delegate("execute").to(i),i.children.add(o),i}return null}))}const Nu='',Fu='',Du='',zu=(()=>({alignLeft:Nu,bold:Fu,importExport:'',paragraph:'',plus:'',text:'',threeVerticalDots:Du,pilcrow:'',dragIndicator:''}))();class Hu extends Hi{options;items;focusTracker;keystrokes;itemsView;children;focusables;_focusCycler;_behavior;constructor(e,t){super(e);const i=this.bindTemplate,n=this.t;this.options=t||{},this.set("ariaLabel",n("Editor toolbar")),this.set("maxWidth","auto"),this.set("role","toolbar"),this.set("isGrouping",!!this.options.shouldGroupWhenFull),this.items=this.createCollection(),this.focusTracker=new ei,this.keystrokes=new oi,this.set("class",void 0),this.set("isCompact",!1),this.set("isVertical",!1),this.itemsView=new Uu(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const o="rtl"===e.uiLanguageDirection;this._focusCycler=new Nn({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[o?"arrowright":"arrowleft","arrowup"],focusNext:[o?"arrowleft":"arrowright","arrowdown"]}});const s=["ck","ck-toolbar",i.to("class"),i.if("isCompact","ck-toolbar_compact"),i.if("isGrouping","ck-toolbar_grouping"),i.if("isVertical","ck-toolbar_vertical")];var r;this.options.shouldGroupWhenFull&&this.options.isFloating&&s.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:s,role:i.to("role"),"aria-label":i.to("ariaLabel"),style:{maxWidth:i.to("maxWidth")},tabindex:-1},children:this.children,on:{mousedown:(r=this,r.bindTemplate.to((e=>{e.target===r.element&&e.preventDefault()})))}}),this._behavior=this.options.shouldGroupWhenFull?new qu(this):new $u(this)}render(){super.render(),this.focusTracker.add(this.element);for(const e of this.items)this.focusTracker.add(e);this.items.on("add",((e,t)=>{this.focusTracker.add(t)})),this.items.on("remove",((e,t)=>{this.focusTracker.remove(t)})),this.keystrokes.listenTo(this.element),this._behavior.render(this)}destroy(){return this._behavior.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy(),super.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}fillFromConfig(e,t,i){this.items.addMany(this._buildItemsFromConfig(e,t,i))}switchBehavior(e){this._behavior.type!==e&&(this._behavior.destroy(),this.itemsView.children.clear(),this.focusables.clear(),"dynamic"===e?(this._behavior=new qu(this),this._behavior.render(this),this._behavior.refreshItems()):(this._behavior=new $u(this),this._behavior.render(this)))}_buildItemsFromConfig(e,t,i){const n=Vn(e),o=i||n.removeItems;return this._cleanItemsConfiguration(n.items,t,o).map((e=>z(e)?this._createNestedToolbarDropdown(e,t,o):"|"===e?new fu:"-"===e?new pu:t.create(e))).filter((e=>!!e))}_cleanItemsConfiguration(e,t,i){const n=e.filter(((e,n,o)=>"|"===e||-1===i.indexOf(e)&&("-"===e?!this.options.shouldGroupWhenFull||(A("toolbarview-line-break-ignored-when-grouping-items",o),!1):!(!z(e)&&!t.has(e)&&(A("toolbarview-item-unavailable",{item:e}),1)))));return this._cleanSeparatorsAndLineBreaks(n)}_cleanSeparatorsAndLineBreaks(e){const t=e=>"-"!==e&&"|"!==e,i=e.length,n=e.findIndex(t);if(-1===n)return[];const o=i-e.slice().reverse().findIndex(t);return e.slice(n,o).filter(((e,i,n)=>!!t(e)||!(i>0&&n[i-1]===e)))}_createNestedToolbarDropdown(e,t,i){let{label:n,icon:o,items:s,tooltip:r=!0,withText:a=!1}=e;if(s=this._cleanItemsConfiguration(s,t,i),!s.length)return null;const l=Pu(this.locale);return n||A("toolbarview-nested-toolbar-dropdown-missing-label",e),l.class="ck-toolbar__nested-toolbar-dropdown",l.buttonView.set({label:n,tooltip:r,withText:!!a}),!1!==o?l.buttonView.icon=zu[o]||o||Du:l.buttonView.withText=!0,Iu(l,(()=>l.toolbarView._buildItemsFromConfig(s,t,i))),l}}class Uu extends Hi{children;constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class $u{type="static";constructor(e){e.isGrouping=!1,e.itemsView.children.bindTo(e.items).using((e=>e)),e.focusables.bindTo(e.items).using((e=>Dn(e)?e:null))}render(){}destroy(){}}class qu{type="dynamic";view;viewChildren;viewFocusables;viewItemsView;viewFocusTracker;viewLocale;ungroupedItems;groupedItems;groupedItemsDropdown;resizeObserver=null;cachedPadding=null;shouldUpdateGroupingOnNextResize=!1;viewElement;constructor(e){this.view=e,this.viewChildren=e.children,this.viewFocusables=e.focusables,this.viewItemsView=e.itemsView,this.viewFocusTracker=e.focusTracker,this.viewLocale=e.locale,this.view.isGrouping=!0,this.ungroupedItems=e.createCollection(),this.groupedItems=e.createCollection(),this.groupedItemsDropdown=this._createGroupedItemsDropdown(),e.itemsView.children.bindTo(this.ungroupedItems).using((e=>e)),this.ungroupedItems.on("change",this._updateFocusCyclableItems.bind(this)),e.children.on("change",this._updateFocusCyclableItems.bind(this)),e.items.on("change",((e,t)=>{const i=t.index,n=Array.from(t.added);for(const e of t.removed)i>=this.ungroupedItems.length?this.groupedItems.remove(e):this.ungroupedItems.remove(e);for(let e=i;ethis.ungroupedItems.length?this.groupedItems.add(t,e-this.ungroupedItems.length):this.ungroupedItems.add(t,e)}this._updateGrouping()}))}render(e){this.viewElement=e.element,this._enableGroupingOnResize(),this._enableGroupingOnMaxWidthChange(e)}destroy(){this.groupedItemsDropdown.destroy(),this.viewChildren.length>1&&(this.viewChildren.remove(this.groupedItemsDropdown),this.viewChildren.remove(this.viewChildren.last)),this.resizeObserver.destroy()}refreshItems(){const e=this.view;if(e.items.length){for(let t=0;to.right-this.cachedPadding:i.left{e&&e===t.contentRect.width&&!this.shouldUpdateGroupingOnNextResize||(this.shouldUpdateGroupingOnNextResize=!1,this._updateGrouping(),e=t.contentRect.width)})),this._updateGrouping()}_enableGroupingOnMaxWidthChange(e){e.on("change:maxWidth",(()=>{this._updateGrouping()}))}_groupLastItem(){this.groupedItems.length||(this.viewChildren.add(new fu),this.viewChildren.add(this.groupedItemsDropdown),this.viewFocusTracker.add(this.groupedItemsDropdown.element)),this.groupedItems.add(this.ungroupedItems.remove(this.ungroupedItems.last),0)}_ungroupFirstItem(){this.ungroupedItems.add(this.groupedItems.remove(this.groupedItems.first)),this.groupedItems.length||(this.viewChildren.remove(this.groupedItemsDropdown),this.viewChildren.remove(this.viewChildren.last),this.viewFocusTracker.remove(this.groupedItemsDropdown.element))}_createGroupedItemsDropdown(){const e=this.viewLocale,t=e.t,i=Pu(e);return i.class="ck-toolbar__grouped-dropdown",i.panelPosition="ltr"===e.uiLanguageDirection?"sw":"se",Iu(i,this.groupedItems),i.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:"rtl"===e.uiLanguageDirection?"se":"sw",icon:Du}),i}_updateFocusCyclableItems(){this.viewFocusables.clear(),this.ungroupedItems.map((e=>{Dn(e)&&this.viewFocusables.add(e)})),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}class ju extends Eu{arrowView;constructor(e){super(e);const t=this.bindTemplate;this.set({withText:!0,role:"menuitem"}),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__button"],"aria-haspopup":!0,"aria-expanded":this.bindTemplate.to("isOn",(e=>String(e))),"data-cke-tooltip-disabled":t.to("isOn")},on:{mouseenter:t.to("mouseenter")}})}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new en;return e.content=vu,e.extendTemplate({attributes:{class:"ck-menu-bar__menu__button__arrow"}}),e}}class Wu extends Hi{children;constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!1),this.set("position","se"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-menu-bar__menu__panel",t.to("position",(e=>`ck-menu-bar__menu__panel_position_${e}`)),t.if("isVisible","ck-hidden",(e=>!e))],tabindex:"-1"},children:this.children,on:{selectstart:t.to((e=>{"input"!==e.target.tagName.toLocaleLowerCase()&&e.preventDefault()}))}})}focus(e=1){this.children.length&&(1===e?this.children.first.focus():this.children.last.focus())}}class Gu extends Hi{buttonView;panelView;focusTracker;keystrokes;constructor(e){super(e);const t=this.bindTemplate;this.buttonView=new ju(e),this.buttonView.delegate("mouseenter").to(this),this.buttonView.bind("isOn","isEnabled").to(this,"isOpen","isEnabled"),this.panelView=new Wu(e),this.panelView.bind("isVisible").to(this,"isOpen"),this.keystrokes=new oi,this.focusTracker=new ei,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("panelPosition","w"),this.set("class",void 0),this.set("parentMenuView",null),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar__menu",t.to("class"),t.if("isEnabled","ck-disabled",(e=>!e)),t.if("parentMenuView","ck-menu-bar__menu_top-level",(e=>!e))]},children:[this.buttonView,this.panelView]})}render(){super.render(),this.focusTracker.add(this.buttonView.element),this.focusTracker.add(this.panelView.element),this.keystrokes.listenTo(this.element),fn.closeOnEscKey(this),this._repositionPanelOnOpen()}_attachBehaviors(){this.parentMenuView?(fn.openOnButtonClick(this),fn.openOnArrowRightKey(this),fn.closeOnArrowLeftKey(this),fn.openAndFocusOnEnterKeyPress(this),fn.closeOnParentClose(this)):(this._propagateArrowKeystrokeEvents(),fn.openAndFocusPanelOnArrowDownKey(this),fn.toggleOnButtonClick(this))}_propagateArrowKeystrokeEvents(){this.keystrokes.set("arrowright",((e,t)=>{this.fire("arrowright"),t()})),this.keystrokes.set("arrowleft",((e,t)=>{this.fire("arrowleft"),t()}))}_repositionPanelOnOpen(){this.on("change:isOpen",((e,t,i)=>{if(!i)return;const n=Gu._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=n?n.name:this._defaultMenuPositionName}))}focus(){this.buttonView.focus()}get _panelPositions(){const{southEast:e,southWest:t,northEast:i,northWest:n,westSouth:o,eastSouth:s,westNorth:r,eastNorth:a}=pn;return"ltr"===this.locale.uiLanguageDirection?this.parentMenuView?[s,a,o,r]:[e,t,i,n]:this.parentMenuView?[o,r,s,a]:[t,e,n,i]}get _defaultMenuPositionName(){return"ltr"===this.locale.uiLanguageDirection?this.parentMenuView?"es":"se":this.parentMenuView?"ws":"sw"}static _getOptimalPosition=gt}class Ku extends Cu{constructor(e){super(e),this.role="menu",this.items.on("change",this._setItemsCheckSpace.bind(this))}_setItemsCheckSpace(){const e=Array.from(this.items).some((e=>{const t=Ju(e);return t&&t.isToggleable}));this.items.forEach((t=>{const i=Ju(t);i&&(i.hasCheckSpace=e)}))}}function Ju(e){return e instanceof dn?e.children.map((e=>function(e){return"object"==typeof e&&"buttonView"in e&&e.buttonView instanceof Bn}(e)?e.buttonView:e)).find((e=>e instanceof Eu)):null}class Yu extends Eu{constructor(e){super(e),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}class Qu extends(Zu(Bn)){}class Xu extends(Zu(Eu)){}function Zu(e){return class extends e{_fileInputView;constructor(...e){super(...e),this._fileInputView=new ed(this.locale),this._fileInputView.bind("acceptedType").to(this),this._fileInputView.bind("allowMultipleFiles").to(this),this._fileInputView.delegate("done").to(this),this.on("execute",(()=>{this._fileInputView.open()})),this.extendTemplate({attributes:{class:"ck-file-dialog-button"}})}render(){super.render(),this.children.add(this._fileInputView)}}}class ed extends Hi{constructor(e){super(e),this.set("acceptedType",void 0),this.set("allowMultipleFiles",!1);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:t.to("acceptedType"),multiple:t.to("allowMultipleFiles")},on:{change:t.to((()=>{this.element?.files?.length&&this.fire("done",this.element.files),this.element.value=""}))}})}open(){this.element.click()}}class td extends Xu{constructor(e){super(e),this.set({withText:!0,withKeystroke:!0,tooltip:!1,role:"menuitem"}),this.extendTemplate({attributes:{class:["ck-menu-bar__menu__item__button"]}})}}const id=["mouseenter","arrowleft","arrowright","change:isOpen"];class nd extends Hi{children;menus=[];constructor(e){super(e);const t=e.t,i=this.bindTemplate;this.set({isOpen:!1,isFocusBorderEnabled:!1}),this._setupIsOpenUpdater(),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-menu-bar",i.if("isFocusBorderEnabled","ck-menu-bar_focus-border-enabled")],"aria-label":t("Editor menu bar"),role:"menubar"},children:this.children})}fillFromConfig(e,t,i=[]){const n=wn({normalizedConfig:e,locale:this.locale,componentFactory:t,extraItems:i}).items.map((e=>this._createMenu({componentFactory:t,menuDefinition:e})));this.children.addMany(n)}render(){super.render(),gn.toggleMenusAndFocusItemsOnHover(this),gn.closeMenusWhenTheBarCloses(this),gn.closeMenuWhenAnotherOnTheSameLevelOpens(this),gn.focusCycleMenusOnArrows(this),gn.closeOnClickOutside(this),gn.enableFocusHighlightOnInteraction(this)}focus(){this.children.first&&this.children.first.focus()}close(){for(const e of this.children)e.isOpen=!1}disable(){for(const e of this.children)e.isEnabled=!1}enable(){for(const e of this.children)e.isEnabled=!0}registerMenu(e,t=null){t?(e.delegate(...id).to(t),e.parentMenuView=t):e.delegate(...id).to(this,(e=>"menu:"+e)),e._attachBehaviors(),this.menus.push(e)}_createMenu({componentFactory:e,menuDefinition:t,parentMenuView:i}){const n=this.locale,o=new Gu(n);return this.registerMenu(o,i),o.buttonView.set({label:t.label}),o.once("change:isOpen",(()=>{const i=new Ku(n);i.ariaLabel=t.label,o.panelView.children.add(i),i.items.addMany(this._createMenuItems({menuDefinition:t,parentMenuView:o,componentFactory:e}))})),o}_createMenuItems({menuDefinition:e,parentMenuView:t,componentFactory:i}){const n=this.locale,o=[];for(const s of e.groups){for(const e of s.items){const s=new hn(n,t);if(z(e))s.children.add(this._createMenu({componentFactory:i,menuDefinition:e,parentMenuView:t}));else{const n=this._createMenuItemContentFromFactory({componentName:e,componentFactory:i,parentMenuView:t});if(!n)continue;s.children.add(n)}o.push(s)}s!==e.groups[e.groups.length-1]&&o.push(new _u(n))}return o}_createMenuItemContentFromFactory({componentName:e,parentMenuView:t,componentFactory:i}){const n=i.create(e);return n instanceof Gu||n instanceof Yu||n instanceof td?(this._registerMenuTree(n,t),n.on("execute",(()=>{this.close()})),n):(A("menu-bar-component-unsupported",{componentName:e,componentView:n}),null)}_registerMenuTree(e,t){if(!(e instanceof Gu))return void e.delegate("mouseenter").to(t);this.registerMenu(e,t);const i=e.panelView.children.filter((e=>e instanceof Ku))[0];if(!i)return void e.delegate("mouseenter").to(t);const n=i.items.filter((e=>e instanceof dn));for(const t of n)this._registerMenuTree(t.children.get(0),e)}_setupIsOpenUpdater(){let e;this.on("menu:change:isOpen",((t,i,n)=>{clearTimeout(e),n?this.isOpen=!0:e=setTimeout((()=>{this.isOpen=Array.from(this.children).some((e=>e.isOpen))}),0)}))}}class od extends Hi{name=null;_editingView;_editableElement;_hasExternalElement;constructor(e,t,i){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:e.contentLanguage,dir:e.contentLanguageDirection}}),this.set("isFocused",!1),this._editableElement=i,this._hasExternalElement=!!this._editableElement,this._editingView=t}render(){super.render(),this._hasExternalElement?this.template.apply(this.element=this._editableElement):this._editableElement=this.element,this.on("change:isFocused",(()=>this._updateIsFocusedClasses())),this._updateIsFocusedClasses()}destroy(){this._hasExternalElement&&this.template.revert(this._editableElement),super.destroy()}get hasExternalElement(){return this._hasExternalElement}_updateIsFocusedClasses(){const e=this._editingView;function t(t){e.change((i=>{const n=e.document.getRoot(t.name);i.addClass(t.isFocused?"ck-focused":"ck-blurred",n),i.removeClass(t.isFocused?"ck-blurred":"ck-focused",n)}))}e.isRenderingInProgress?function i(n){e.once("change:isRenderingInProgress",((e,o,s)=>{s?i(n):t(n)}))}(this):t(this)}}class sd extends od{_options;constructor(e,t,i,n={}){super(e,t,i),this._options=n,this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}})}render(){super.render();const e=this._editingView;e.change((t=>{const i=e.document.getRoot(this.name);t.setAttribute("aria-label",this.getEditableAriaLabel(),i)}))}getEditableAriaLabel(){const e=this.locale.t,t=this._options.label,i=this._editableElement,n=this.name;if("string"==typeof t)return t;if("object"==typeof t)return t[n];if("function"==typeof t)return t(this);if(i){const e=i.getAttribute("aria-label");if(e)return e}return e("Rich Text Editor. Editing area: %0",n)}}class rd extends hu{stickyPanel;toolbar;editable;constructor(e,t,i={}){super(e),this.stickyPanel=new gu(e),this.toolbar=new Hu(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),i.useMenuBar&&(this.menuBarView=new nd(e)),this.editable=new sd(e,t,void 0,{label:i.label})}render(){super.render(),this.menuBarView?this.stickyPanel.content.addMany([this.menuBarView,this.toolbar]):this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}class ad extends(G()){editor;_disableStack=new Set;constructor(e){super(),this.editor=e,this.set("isEnabled",!0)}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",ld,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",ld),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}function ld(e){e.return=!1,e.stop()}class cd extends(G()){editor;_isEnabledBasedOnSelection;_affectsData;_disableStack;static get _throwErrorWhenUsedAsAPlugin(){return!0}constructor(e){super(),this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._affectsData=!0,this._isEnabledBasedOnSelection=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",(()=>{this.refresh()})),this.listenTo(e,"change:isReadOnly",(()=>{this.refresh()})),this.on("set:isEnabled",(t=>{if(!this.affectsData)return;const i=e.model.document.selection,n=!("$graveyard"==i.getFirstPosition().root.rootName)&&e.model.canEditAt(i);(e.isReadOnly||this._isEnabledBasedOnSelection&&!n)&&(t.return=!1,t.stop())}),{priority:"highest"}),this.on("execute",(e=>{this.isEnabled||e.stop()}),{priority:"high"})}get affectsData(){return this._affectsData}set affectsData(e){this._affectsData=e}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",ud,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",ud),this.refresh())}execute(...e){}destroy(){this.stopListening()}}function ud(e){e.return=!1,e.stop()}class dd extends cd{_childCommandsDefinitions=[];refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){C(this._childCommandsDefinitions,{command:e,priority:t.priority||"normal"}),e.on("change:isEnabled",(()=>this._checkEnabled())),this._checkEnabled()}_checkEnabled(){this.isEnabled=!!this._getFirstEnabledCommand()}_getFirstEnabledCommand(){const e=this._childCommandsDefinitions.find((({command:e})=>e.isEnabled));return e&&e.command}}class hd{_commands;constructor(){this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){const i=this.get(e);if(!i)throw new x("commandcollection-command-not-found",this,{commandName:e});return i.execute(...t)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const e of this.commands())e.destroy()}}class md extends(R()){_context;_plugins=new Map;_availablePlugins;_contextPlugins;constructor(e,t=[],i=[]){super(),this._context=e,this._availablePlugins=new Map;for(const e of t)e.pluginName&&this._availablePlugins.set(e.pluginName,e);this._contextPlugins=new Map;for(const[e,t]of i)this._contextPlugins.set(e,t),this._contextPlugins.set(t,e),e.pluginName&&this._availablePlugins.set(e.pluginName,e)}*[Symbol.iterator](){for(const e of this._plugins)"function"==typeof e[0]&&(yield e)}get(e){const t=this._plugins.get(e);if(!t){let t=e;throw"function"==typeof e&&(t=e.pluginName||e.name),new x("plugincollection-plugin-not-loaded",this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}async init(e,t=[],i=[]){const n=this,o=this._context;!function e(t,i=new Set){t.forEach((t=>{a(t)&&(i.has(t)||(i.add(t),t.pluginName&&!n._availablePlugins.has(t.pluginName)&&n._availablePlugins.set(t.pluginName,t),t.requires&&e(t.requires,i)))}))}(e),d(e);const s=[...function e(t,i=new Set){return t.map((e=>a(e)?e:n._availablePlugins.get(e))).reduce(((t,n)=>i.has(n)?t:(i.add(n),n.requires&&(d(n.requires,n),e(n.requires,i).forEach((e=>t.add(e)))),t.add(n))),new Set)}(e.filter((e=>!c(e,t))))];!function(e,t){for(const i of t){if("function"!=typeof i)throw new x("plugincollection-replace-plugin-invalid-type",null,{pluginItem:i});const t=i.pluginName;if(!t)throw new x("plugincollection-replace-plugin-missing-name",null,{pluginItem:i});if(i.requires&&i.requires.length)throw new x("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const o=n._availablePlugins.get(t);if(!o)throw new x("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:t});const s=e.indexOf(o);if(-1===s){if(n._contextPlugins.has(o))return;throw new x("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:t})}if(o.requires&&o.requires.length)throw new x("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:t});e.splice(s,1,i),n._availablePlugins.set(t,i)}}(s,i);const r=function(e){return e.map((e=>{let t=n._contextPlugins.get(e);return t=t||new e(o),n._add(e,t),t}))}(s);return await h(r,"init"),await h(r,"afterInit"),r;function a(e){return"function"==typeof e}function l(e){return a(e)&&!!e.isContextPlugin}function c(e,t){return t.some((t=>t===e||u(e)===t||u(t)===e))}function u(e){return a(e)?e.pluginName||e.name:e}function d(e,i=null){e.map((e=>a(e)?e:n._availablePlugins.get(e)||e)).forEach((e=>{!function(e){if("function"==typeof e&&e._throwErrorWhenUsedAsAPlugin)throw new x("plugincollection-plugin-invalid-constructor",o,{name:e.name})}(e),function(e,t){if(!a(e)){if(t)throw new x("plugincollection-soft-required",o,{missingPlugin:e,requiredBy:u(t)});throw new x("plugincollection-plugin-not-found",o,{plugin:e})}}(e,i),function(e,t){if(l(t)&&!l(e))throw new x("plugincollection-context-required",o,{plugin:u(e),requiredBy:u(t)})}(e,i),function(e,i){if(i&&c(e,t))throw new x("plugincollection-required",o,{plugin:u(e),requiredBy:u(i)})}(e,i)}))}function h(e,t){return e.reduce(((e,i)=>i[t]?n._contextPlugins.has(i)?e:e.then(i[t].bind(i)):e),Promise.resolve())}}destroy(){const e=[];for(const[,t]of this)"function"!=typeof t.destroy||this._contextPlugins.has(t)||e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);const i=e.pluginName;if(i){if(this._plugins.has(i))throw new x("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}}class gd{config;plugins;locale;t;editors;static defaultConfig;static builtinPlugins;_contextOwner=null;constructor(e){const{translations:t,...i}=e||{};this.config=new Ne(i,this.constructor.defaultConfig);const n=this.constructor.builtinPlugins;this.config.define("plugins",n),this.plugins=new md(this,n);const o=this.config.get("language")||{};this.locale=new Qt({uiLanguage:"string"==typeof o?o:o.ui,contentLanguage:this.config.get("language.content"),translations:t}),this.t=this.locale.t,this.editors=new Xt}initPlugins(){const e=this.config.get("plugins")||[],t=this.config.get("substitutePlugins")||[];for(const i of e.concat(t)){if("function"!=typeof i)throw new x("context-initplugins-constructor-only",null,{Plugin:i});if(!0!==i.isContextPlugin)throw new x("context-initplugins-invalid-plugin",null,{Plugin:i})}return this.plugins.init(e,[],t)}destroy(){return Promise.all(Array.from(this.editors,(e=>e.destroy()))).then((()=>this.plugins.destroy()))}_addEditor(e,t){if(this._contextOwner)throw new x("context-addeditor-private-context");this.editors.add(e),t&&(this._contextOwner=e)}_removeEditor(e){return this.editors.has(e)&&this.editors.remove(e),this._contextOwner===e?this.destroy():Promise.resolve()}_getEditorConfig(){const e={};for(const t of this.config.names())["plugins","removePlugins","extraPlugins"].includes(t)||(e[t]=this.config.get(t));return e}static create(e){return new Promise((t=>{const i=new this(e);t(i.initPlugins().then((()=>i)))}))}static get _throwErrorWhenUsedAsAPlugin(){return!0}}class fd extends(G()){context;constructor(e){super(),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}static get isOfficialPlugin(){return!1}static get isPremiumPlugin(){return!1}}class pd extends oi{editor;constructor(e){super(),this.editor=e}set(e,t,i={}){if("string"==typeof t){const e=t;t=(t,i)=>{this.editor.execute(e),i()}}super.set(e,t,i)}}class bd{crashes=[];state="initializing";_crashNumberLimit;_now=Date.now;_minimumNonErrorTimePeriod;_boundErrorHandler;_listeners;constructor(e){if(this.crashes=[],this._crashNumberLimit="number"==typeof e.crashNumberLimit?e.crashNumberLimit:3,this._minimumNonErrorTimePeriod="number"==typeof e.minimumNonErrorTimePeriod?e.minimumNonErrorTimePeriod:5e3,this._boundErrorHandler=e=>{const t="error"in e?e.error:e.reason;t instanceof Error&&this._handleError(t,e)},this._listeners={},!this._restart)throw new Error("The Watchdog class was split into the abstract `Watchdog` class and the `EditorWatchdog` class. Please, use `EditorWatchdog` if you have used the `Watchdog` class previously.")}destroy(){this._stopErrorHandling(),this._listeners={}}on(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}off(e,t){this._listeners[e]=this._listeners[e].filter((e=>e!==t))}_fire(e,...t){const i=this._listeners[e]||[];for(const e of i)e.apply(this,[null,...t])}_startErrorHandling(){window.addEventListener("error",this._boundErrorHandler),window.addEventListener("unhandledrejection",this._boundErrorHandler)}_stopErrorHandling(){window.removeEventListener("error",this._boundErrorHandler),window.removeEventListener("unhandledrejection",this._boundErrorHandler)}_handleError(e,t){if(this._shouldReactToError(e)){this.crashes.push({message:e.message,stack:e.stack,filename:t instanceof ErrorEvent?t.filename:void 0,lineno:t instanceof ErrorEvent?t.lineno:void 0,colno:t instanceof ErrorEvent?t.colno:void 0,date:this._now()});const i=this._shouldRestart();this.state="crashed",this._fire("stateChange"),this._fire("error",{error:e,causesRestart:i}),i?this._restart():(this.state="crashedPermanently",this._fire("stateChange"))}}_shouldReactToError(e){return e.is&&e.is("CKEditorError")&&void 0!==e.context&&null!==e.context&&"ready"===this.state&&this._isErrorComingFromThisItem(e)}_shouldRestart(){return this.crashes.length<=this._crashNumberLimit||(this.crashes[this.crashes.length-1].date-this.crashes[this.crashes.length-1-this._crashNumberLimit].date)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}}function wd(e,t=new Set){const i=[e],n=new Set;let o=0;for(;i.length>o;){const e=i[o++];if(!n.has(e)&&vd(e)&&!t.has(e))if(n.add(e),Symbol.iterator in e)try{for(const t of e)i.push(t)}catch{}else for(const t in e)"defaultValue"!==t&&i.push(e[t])}return n}function vd(e){const t=Object.prototype.toString.call(e),i=typeof e;return!("number"===i||"boolean"===i||"string"===i||"symbol"===i||"function"===i||"[object Date]"===t||"[object RegExp]"===t||"[object Module]"===t||null==e||e._watchdogExcluded||e instanceof EventTarget||e instanceof Event)}function yd(e,t,i=new Set){if(e===t&&"object"==typeof(n=e)&&null!==n)return!0;var n;const o=wd(e,i),s=wd(t,i);for(const e of o)if(s.has(e))return!0;return!1}class _d extends bd{_editor=null;_lifecyclePromise=null;_throttledSave;_data;_lastDocumentVersion;_elementOrData;_initUsingData=!0;_editables={};_config;_excludedProps;constructor(e,t={}){super(t),this._throttledSave=Qi(this._save.bind(this),"number"==typeof t.saveInterval?t.saveInterval:5e3),e&&(this._creator=(t,i)=>e.create(t,i)),this._destructor=e=>e.destroy()}get editor(){return this._editor}get _item(){return this._editor}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}_restart(){return Promise.resolve().then((()=>(this.state="initializing",this._fire("stateChange"),this._destroy()))).catch((e=>{console.error("An error happened during the editor destroying.",e)})).then((()=>{const e={},t=[],i=this._config.rootsAttributes||{},n={};for(const[o,s]of Object.entries(this._data.roots))s.isLoaded?(e[o]="",n[o]=i[o]||{}):t.push(o);const o={...this._config,extraPlugins:this._config.extraPlugins||[],lazyRoots:t,rootsAttributes:n,_watchdogInitialData:this._data};return delete o.initialData,o.extraPlugins.push(kd),this._initUsingData?this.create(e,o,o.context):Me(this._elementOrData)?this.create(this._elementOrData,o,o.context):this.create(this._editables,o,o.context)})).then((()=>{this._fire("restart")}))}create(e=this._elementOrData,t=this._config,i){return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then((()=>(super._startErrorHandling(),this._elementOrData=e,this._initUsingData="string"==typeof e||Object.keys(e).length>0&&"string"==typeof Object.values(e)[0],this._config=this._cloneEditorConfiguration(t)||{},this._config.context=i,this._creator(e,this._config)))).then((e=>{this._editor=e,e.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=e.model.document.version,this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this.state="ready",this._fire("stateChange")})).finally((()=>{this._lifecyclePromise=null})),this._lifecyclePromise}destroy(){return this._lifecyclePromise=Promise.resolve(this._lifecyclePromise).then((()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy()))).finally((()=>{this._lifecyclePromise=null})),this._lifecyclePromise}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling(),this._throttledSave.cancel();const e=this._editor;return this._editor=null,e.model.document.off("change:data",this._throttledSave),this._destructor(e)}))}_save(){const e=this._editor.model.document.version;try{this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this._lastDocumentVersion=e}catch(e){console.error(e,"An error happened during restoring editor data. Editor will be restored from the previously saved data.")}}_setExcludedProperties(e){this._excludedProps=e}_getData(){const e=this._editor,t=e.model.document.roots.filter((e=>e.isAttached()&&"$graveyard"!=e.rootName)),{plugins:i}=e,n=i.has("CommentsRepository")&&i.get("CommentsRepository"),o=i.has("TrackChanges")&&i.get("TrackChanges"),s={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};t.forEach((e=>{s.roots[e.rootName]={content:JSON.stringify(Array.from(e.getChildren())),attributes:JSON.stringify(Array.from(e.getAttributes())),isLoaded:e._isLoaded}}));for(const t of e.model.markers)t._affectsData&&(s.markers[t.name]={rangeJSON:t.getRange().toJSON(),usingOperation:t._managedUsingOperations,affectsData:t._affectsData});return n&&(s.commentThreads=JSON.stringify(n.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),o&&(s.suggestions=JSON.stringify(o.getSuggestions({toJSON:!0,skipNotAttached:!0}))),s}_getEditables(){const e={};for(const t of this.editor.model.document.getRootNames()){const i=this.editor.ui.getEditableElement(t);i&&(e[t]=i)}return e}_isErrorComingFromThisItem(e){return yd(this._editor,e.context,this._excludedProps)}_cloneEditorConfiguration(e){return Le(e,((e,t)=>Me(e)||"context"===t?e:void 0))}}class kd{editor;_data;constructor(e){this.editor=e,this._data=e.config.get("_watchdogInitialData")}init(){this.editor.data.on("init",(e=>{e.stop(),this.editor.model.enqueueChange({isUndoable:!1},(e=>{this._restoreCollaborationData(),this._restoreEditorData(e)})),this.editor.data.fire("ready")}),{priority:999})}_createNode(e,t){if("name"in t){const i=e.createElement(t.name,t.attributes);if(t.children)for(const n of t.children)i._appendChild(this._createNode(e,n));return i}return e.createText(t.data,t.attributes)}_restoreEditorData(e){const t=this.editor;Object.entries(this._data.roots).forEach((([i,{content:n,attributes:o}])=>{const s=JSON.parse(n),r=JSON.parse(o),a=t.model.document.getRoot(i);for(const[t,i]of r)e.setAttribute(t,i,a);for(const t of s){const i=this._createNode(e,t);e.insert(i,a,"end")}})),Object.entries(this._data.markers).forEach((([i,n])=>{const{document:o}=t.model,{rangeJSON:{start:s,end:r},...a}=n,l=o.getRoot(s.root),c=e.createPositionFromPath(l,s.path,s.stickiness),u=e.createPositionFromPath(l,r.path,r.stickiness),d=e.createRange(c,u);e.addMarker(i,{range:d,...a})}))}_restoreCollaborationData(){const e=JSON.parse(this._data.commentThreads),t=JSON.parse(this._data.suggestions);if(this.editor.plugins.has("CommentsRepository")){const t=this.editor.plugins.get("CommentsRepository");for(const e of t.getCommentThreads())t._removeCommentThread({threadId:e.id});e.forEach((e=>{const t=this.editor.config.get("collaboration.channelId");this.editor.plugins.get("CommentsRepository").addCommentThread({channelId:t,...e})}))}if(this.editor.plugins.has("TrackChangesEditing")){const e=this.editor.plugins.get("TrackChangesEditing");for(const t of e.getSuggestions())e._removeSuggestion(t);t.forEach((t=>{e.addSuggestionData(t)}))}}}const Cd=Symbol("MainQueueId");class xd extends bd{_watchdogs=new Map;_watchdogConfig;_context=null;_contextProps=new Set;_actionQueues=new Ad;_contextConfig;_item;constructor(e,t={}){super(t),this._watchdogConfig=t,this._creator=t=>e.create(t),this._destructor=e=>e.destroy(),this._actionQueues.onEmpty((()=>{"initializing"===this.state&&(this.state="ready",this._fire("stateChange"))}))}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}get context(){return this._context}create(e={}){return this._actionQueues.enqueue(Cd,(()=>(this._contextConfig=e,this._create())))}getItem(e){return this._getWatchdog(e)._item}getItemState(e){return this._getWatchdog(e).state}add(e){const t=Td(e);return Promise.all(t.map((e=>this._actionQueues.enqueue(e.id,(()=>{if("destroyed"===this.state)throw new Error("Cannot add items to destroyed watchdog.");if(!this._context)throw new Error("Context was not created yet. You should call the `ContextWatchdog#create()` method first.");let t;if(this._watchdogs.has(e.id))throw new Error(`Item with the given id is already added: '${e.id}'.`);if("editor"===e.type)return t=new _d(null,this._watchdogConfig),t.setCreator(e.creator),t._setExcludedProperties(this._contextProps),e.destructor&&t.setDestructor(e.destructor),this._watchdogs.set(e.id,t),t.on("error",((i,{error:n,causesRestart:o})=>{this._fire("itemError",{itemId:e.id,error:n}),o&&this._actionQueues.enqueue(e.id,(()=>new Promise((i=>{const n=()=>{t.off("restart",n),this._fire("itemRestart",{itemId:e.id}),i()};t.on("restart",n)}))))})),t.create(e.sourceElementOrData,e.config,this._context);throw new Error(`Not supported item type: '${e.type}'.`)})))))}remove(e){const t=Td(e);return Promise.all(t.map((e=>this._actionQueues.enqueue(e,(()=>{const t=this._getWatchdog(e);return this._watchdogs.delete(e),t.destroy()})))))}destroy(){return this._actionQueues.enqueue(Cd,(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_restart(){return this._actionQueues.enqueue(Cd,(()=>(this.state="initializing",this._fire("stateChange"),this._destroy().catch((e=>{console.error("An error happened during destroying the context or items.",e)})).then((()=>this._create())).then((()=>this._fire("restart"))))))}_create(){return Promise.resolve().then((()=>(this._startErrorHandling(),this._creator(this._contextConfig)))).then((e=>(this._context=e,this._contextProps=wd(this._context),Promise.all(Array.from(this._watchdogs.values()).map((e=>(e._setExcludedProperties(this._contextProps),e.create(void 0,void 0,this._context))))))))}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling();const e=this._context;return this._context=null,this._contextProps=new Set,Promise.all(Array.from(this._watchdogs.values()).map((e=>e.destroy()))).then((()=>this._destructor(e)))}))}_getWatchdog(e){const t=this._watchdogs.get(e);if(!t)throw new Error(`Item with the given id was not registered: ${e}.`);return t}_isErrorComingFromThisItem(e){for(const t of this._watchdogs.values())if(t._isErrorComingFromThisItem(e))return!1;return yd(this._context,e.context)}}class Ad{_onEmptyCallbacks=[];_queues=new Map;_activeActions=0;onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){const i=e===Cd;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());const n=(i?Promise.all(this._queues.values()):Promise.all([this._queues.get(Cd),this._queues.get(e)])).then(t),o=n.catch((()=>{}));return this._queues.set(e,o),n.finally((()=>{this._activeActions--,this._queues.get(e)===o&&0===this._activeActions&&this._onEmptyCallbacks.forEach((e=>e()))}))}}function Td(e){return Array.isArray(e)?e:[e]}const Ed="contentEditing",Sd="common";class Pd{keystrokeInfos=new Map;_editor;constructor(e){this._editor=e;const t=e.config.get("menuBar.isVisible"),i=e.locale.t;this.addKeystrokeInfoCategory({id:Ed,label:i("Content editing keystrokes"),description:i("These keyboard shortcuts allow for quick access to content editing features.")});const n=[{label:i("Close contextual balloons, dropdowns, and dialogs"),keystroke:"Esc"},{label:i("Open the accessibility help dialog"),keystroke:"Alt+0"},{label:i("Move focus between form fields (inputs, buttons, etc.)"),keystroke:[["Tab"],["Shift+Tab"]]},{label:i("Move focus to the toolbar, navigate between toolbars"),keystroke:"Alt+F10",mayRequireFn:!0},{label:i("Navigate through the toolbar or menu bar"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]},{label:i("Execute the currently focused button. Executing buttons that interact with the editor content moves the focus back to the content."),keystroke:[["Enter"],["Space"]]}];t&&n.push({label:i("Move focus to the menu bar, navigate between menu bars"),keystroke:"Alt+F9",mayRequireFn:!0}),this.addKeystrokeInfoCategory({id:"navigation",label:i("User interface and content navigation keystrokes"),description:i("Use the following keystrokes for more efficient navigation in the CKEditor 5 user interface."),groups:[{id:"common",keystrokes:n}]})}addKeystrokeInfoCategory({id:e,label:t,description:i,groups:n}){this.keystrokeInfos.set(e,{id:e,label:t,description:i,groups:new Map}),this.addKeystrokeInfoGroup({categoryId:e,id:Sd}),n&&n.forEach((t=>{this.addKeystrokeInfoGroup({categoryId:e,...t})}))}addKeystrokeInfoGroup({categoryId:e=Ed,id:t,label:i,keystrokes:n}){const o=this.keystrokeInfos.get(e);if(!o)throw new x("accessibility-unknown-keystroke-info-category",this._editor,{groupId:t,categoryId:e});o.groups.set(t,{id:t,label:i,keystrokes:n||[]})}addKeystrokeInfos({categoryId:e=Ed,groupId:t=Sd,keystrokes:i}){if(!this.keystrokeInfos.has(e))throw new x("accessibility-unknown-keystroke-info-category",this._editor,{categoryId:e,keystrokes:i});const n=this.keystrokeInfos.get(e);if(!n.groups.has(t))throw new x("accessibility-unknown-keystroke-info-group",this._editor,{groupId:t,categoryId:e,keystrokes:i});n.groups.get(t).keystrokes.push(...i)}}function Id(e){return Object.getPrototypeOf(e).constructor.editorName}function Vd(e){if(!e)return;const t=Array.isArray(e)?{items:e}:e,i=function e(t){return t.flatMap((t=>"string"==typeof t?[t]:e(t.items)))}(t.items||[]);return{isMultiline:i.includes("-"),shouldNotGroupWhenFull:!!t.shouldNotGroupWhenFull,items:(n=i,n.filter((e=>"|"!==e&&"-"!==e)))};var n}function Od(){let e="unknown",t="unknown";return r.isMac?e="mac":r.isWindows?e="windows":r.isiOS?e="ios":r.isAndroid&&(e="android"),r.isGecko?t="gecko":r.isBlink?t="blink":r.isSafari&&(t="safari"),{os:e,browser:t}}class Rd extends(G()){static get editorName(){return"Editor"}accessibility;commands;config;conversion;data;editing;locale;model;plugins;keystrokes;t;static defaultConfig;static builtinPlugins;_context;_readOnlyLocks;static get _throwErrorWhenUsedAsAPlugin(){return!0}constructor(e={}){if(super(),"object"!=typeof e||Array.isArray(e))throw new x("editor-config-invalid-type");if("sanitizeHtml"in e)throw new x("editor-config-sanitizehtml-not-supported");const t=this.constructor,{translations:i,...n}=t.defaultConfig||{},{translations:o=i,...s}=e,r=e.language||n.language;this._context=e.context||new gd({language:r,translations:o}),this._context._addEditor(this,!e.context);const a=Array.from(t.builtinPlugins||[]);this.config=new Ne(s,n),this.config.define("plugins",a),this.config.define(this._context._getEditorConfig()),function(e){let t=e.get("licenseKey");if(!t&&window.CKEDITOR_GLOBAL_LICENSE_KEY&&(t=window.CKEDITOR_GLOBAL_LICENSE_KEY,e.set("licenseKey",t)),!t)throw new x("license-key-missing")}(this.config),this.plugins=new md(this,a,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new hd,this.set("state","initializing"),this.once("ready",(()=>this.state="ready"),{priority:"high"}),this.once("destroy",(()=>this.state="destroyed"),{priority:"high"}),this.model=new fc(this.config),this.on("change:isReadOnly",(()=>{this.model.document.isReadOnly=this.isReadOnly}));const l=new To;this.data=new Wa(this.model,l),this.editing=new Ea(this.model,l),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new Ga([this.editing.downcastDispatcher,this.data.downcastDispatcher],this.data.upcastDispatcher),this.conversion.addAlias("dataDowncast",this.data.downcastDispatcher),this.conversion.addAlias("editingDowncast",this.editing.downcastDispatcher),this.keystrokes=new pd(this),this.keystrokes.listenTo(this.editing.view.document),this.accessibility=new Pd(this),function(e){const t=e.config.get("licenseKey"),i=window[Symbol.for("cke distribution")]||"sh";function n(t,i){e.enableReadOnlyMode(Symbol("invalidLicense")),e._showLicenseError(t,i)}if("GPL"==t)return void("cloud"==i&&n("distributionChannel"));const o=fi(t);if(!o)return void n("invalid");if(!function(e){return["exp","jti","vc"].every((t=>t in e))}(o))return void n("invalid");if(o.distributionChannel&&!zt(o.distributionChannel).includes(i))return void n("distributionChannel");if(function(e){const t=Array.isArray(e)?e:[e],i=function(){const e=[];for(let t=0;t<256;t++){let i=t;for(let e=0;e<8;e++)1&i?i=3988292384^i>>>1:i>>>=1;e[t]=i}return e}();let n=-1;const o=t.map((e=>Array.isArray(e)?e.join(""):String(e))).join("");for(let e=0;e>>8^i[255&(n^o.charCodeAt(e))];return n=~n>>>0,n.toString(16).padStart(8,"0")}(function(e){const t=Object.getOwnPropertyNames(e).sort().filter((t=>"vc"!=t&&null!=e[t])).map((t=>e[t]));return t}(o))!=o.vc.toLowerCase())return void n("invalid");if(new Date(1e3*o.exp)0&&!function(e){const{hostname:t}=new URL(window.location.href);if(e.includes(t))return!0;const i=t.split(".");return e.filter((e=>e.includes("*"))).map((e=>e.split("."))).filter((e=>e.length<=i.length)).map((e=>Array(i.length-e.length).fill("*"===e[0]?"*":"").concat(e))).some((e=>i.every(((t,i)=>e[i]===t||"*"===e[i]))))}(s))n("domainLimit");else if(["evaluation","trial"].includes(o.licenseType)&&1e3*o.exp{n(`${t}Limit`)}),6e5);e.on("destroy",(()=>{clearTimeout(i)}))}o.usageEndpoint&&e.once("ready",(()=>{const i={requestId:_(),requestTime:Math.round(Date.now()/1e3),license:t,editor:Ld(e)};e._sendUsageRequest(o.usageEndpoint,i).then((e=>{const{status:t,message:i}=e;i&&console.warn(i),"ok"!=t&&n("usageLimit")}),(()=>{var e;e={url:o.usageEndpoint},console.error(...E("license-key-validation-endpoint-not-reachable",e))}))}),{priority:"high"})}}(this)}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new x("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new x("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)||(this._readOnlyLocks.add(e),1===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!0,!1))}disableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new x("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),0===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!1,!0))}setData(e){this.data.set(e)}getData(e){return this.data.get(e)}initPlugins(){const e=this.config,t=e.get("plugins"),i=e.get("removePlugins")||[],n=e.get("extraPlugins")||[],o=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(n),i,o).then((e=>(function(e){const t=e.config.get("licenseKey");if("GPL"===t)return;const i=fi(t);if(!i)return;const n=[...e.plugins].map((([e])=>e)).find((e=>{return!!e.pluginName&&!!e.licenseFeatureCode&&(t=i,n=e.licenseFeatureCode,(t.removeFeatures||[]).includes(n));var t,n}));n&&(e.enableReadOnlyMode(Symbol("invalidLicense")),e._showLicenseError("pluginNotAllowed",n.pluginName))}(this),e)))}destroy(){let e=Promise.resolve();return"initializing"==this.state&&(e=new Promise((e=>this.once("ready",e)))),e.then((()=>{this.fire("destroy"),this.stopListening(),this.commands.destroy()})).then((()=>this.plugins.destroy())).then((()=>{this.model.destroy(),this.data.destroy(),this.editing.destroy(),this.keystrokes.destroy()})).then((()=>this._context._removeEditor(this)))}execute(e,...t){try{return this.commands.execute(e,...t)}catch(e){x.rethrowUnexpectedError(e,this)}}focus(){this.editing.view.focus()}static create(...e){throw new Error("This is an abstract method.")}static Context=gd;static EditorWatchdog=_d;static ContextWatchdog=xd;_showLicenseError(e,t){setTimeout((()=>{if("invalid"==e)throw new x("invalid-license-key");if("expired"==e)throw new x("license-key-expired");if("domainLimit"==e)throw new x("license-key-domain-limit");if("pluginNotAllowed"==e){const e=t.replace(/(Editing|UI)$/,""),i=this.plugins.has(e);throw new x("license-key-plugin-not-allowed",null,{pluginName:i?e:t})}if("featureNotAllowed"==e)throw new x("license-key-feature-not-allowed",null,{featureName:t});if("evaluationLimit"==e)throw new x("license-key-evaluation-limit");if("trialLimit"==e)throw new x("license-key-trial-limit");if("developmentLimit"==e)throw new x("license-key-development-limit");if("usageLimit"==e)throw new x("license-key-usage-limit");if("distributionChannel"==e)throw new x("license-key-invalid-distribution-channel")}),0),this._showLicenseError=()=>{}}async _sendUsageRequest(e,t){const i=new Headers({"Content-Type":"application/json"}),n=await fetch(new URL(e),{method:"POST",headers:i,body:JSON.stringify(t)});if(!n.ok)throw new Error(`HTTP Response: ${n.status}`);return n.json()}}function Ld(e){const t=function(e){return{sessionId:(localStorage.getItem("__ckeditor-session-id")||localStorage.setItem("__ckeditor-session-id",_()),localStorage.getItem("__ckeditor-session-id")),pageSessionId:(n.window.CKEDITOR_PAGE_SESSION_ID=n.window.CKEDITOR_PAGE_SESSION_ID||_(),n.window.CKEDITOR_PAGE_SESSION_ID),hostname:window.location.hostname,version:globalThis.CKEDITOR_VERSION,type:Id(e),plugins:(t=e.plugins,Array.from(t).filter((([e])=>!!e.pluginName)).map((([e])=>{const{pluginName:t,isContextPlugin:i,isOfficialPlugin:n,isPremiumPlugin:o}=e;return{isContext:!!i,isOfficial:!!n,isPremium:!!o,name:t}}))),distribution:{channel:window[Symbol.for("cke distribution")]||"sh"},env:Od(),integration:Object.create(null),menuBar:{isVisible:!!e.config.get("menuBar.isVisible")},language:{ui:e.locale.uiLanguage,content:e.locale.contentLanguage},toolbar:{main:Vd(e.config.get("toolbar")),block:Vd(e.config.get("blockToolbar")),balloon:Vd(e.config.get("balloonToolbar"))}};var t}(e);return e.fire("collectUsageData",{setUsageData:function(e,i){if(void 0!==po(t,e))throw new x("editor-usage-data-path-already-set",{path:e});xo(t,e,i)}}),t}function Bd(e){return class extends e{sourceElement;updateSourceElement(e){if(!this.sourceElement)throw new x("editor-missing-sourceelement",this);const t=this.config.get("updateSourceElementOnDestroy"),i=this.sourceElement instanceof HTMLTextAreaElement;if(!t&&!i)return void rt(this.sourceElement,"");const n="string"==typeof e?e:this.data.get();rt(this.sourceElement,n)}}}class Md extends fd{_actions;static get pluginName(){return"PendingActions"}static get isOfficialPlugin(){return!0}init(){this.set("hasAny",!1),this._actions=new Xt({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new x("pendingactions-add-invalid-message",this);const t=new(G());return t.set("message",e),this._actions.add(t),this.hasAny=!0,t}remove(e){this._actions.remove(e),this.hasAny=!!this._actions.length}get first(){return this._actions.get(0)}[Symbol.iterator](){return this._actions[Symbol.iterator]()}}class Nd extends(Bd(Rd)){static get editorName(){return"ClassicEditor"}ui;constructor(e,t={}){if(!Fd(e)&&void 0!==t.initialData)throw new x("editor-create-initial-data",null);super(t),this.config.define("menuBar.isVisible",!1),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return Fd(e)?(t=e)instanceof HTMLTextAreaElement?t.value:t.innerHTML:e;var t}(e)),Fd(e)&&(this.sourceElement=e),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=this.config.get("menuBar"),o=new rd(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:i,useMenuBar:n.isVisible,label:this.config.get("label")});this.ui=new lu(this,o),function(e){if(!mt(e.updateSourceElement))throw new x("attachtoform-missing-elementapi-interface",e);const t=e.sourceElement;if(function(e){return!!e&&"textarea"===e.tagName.toLowerCase()}(t)&&t.form){let i;const n=t.form,o=()=>e.updateSourceElement();mt(n.submit)&&(i=n.submit,n.submit=()=>{o(),i.apply(n)}),n.addEventListener("submit",o),e.on("destroy",(()=>{n.removeEventListener("submit",o),i&&(n.submit=i)}))}}(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise((i=>{const n=new this(e,t);i(n.initPlugins().then((()=>n.ui.init(Fd(e)?e:null))).then((()=>n.data.init(n.config.get("initialData")))).then((()=>n.fire("ready"))).then((()=>n)))}))}}function Fd(e){return Me(e)}class Dd extends er{domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"];constructor(e){super(e);const t=this.document;function i(e){return(i,n)=>{n.preventDefault();const o=n.dropRange?[n.dropRange]:null,s=new v(t,e);t.fire(s,{dataTransfer:n.dataTransfer,method:i.name,targetRanges:o,target:n.target,domEvent:n.domEvent}),s.stop.called&&n.stopPropagation()}}this.listenTo(t,"paste",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"drop",i("clipboardInput"),{priority:"low"}),this.listenTo(t,"dragover",i("dragging"),{priority:"low"})}onDomEvent(e){const t="clipboardData"in e?e.clipboardData:e.dataTransfer,i="drop"==e.type||"paste"==e.type,n={dataTransfer:new mr(t,{cacheFiles:i})};if("drop"==e.type||"dragover"==e.type){const t=We(e);n.dropRange=t&&this.view.domConverter.domRangeToView(t)}this.fire(e.type,e,n)}}const zd=["figcaption","li"],Hd=["ol","ul"];function Ud(e,t){if(t.is("$text")||t.is("$textProxy"))return t.data;if(t.is("element","img")&&t.hasAttribute("alt"))return t.getAttribute("alt");if(t.is("element","br"))return"\n";let i="",n=null;for(const o of t.getChildren())i+=qd(o,n)+Ud(e,o),n=o;if(t.is("rawElement")){const n=document.implementation.createHTMLDocument("").createElement("div");t.render(n,e),i+=$d(n)}return i}function $d(e){let t="";if(e.nodeType===Node.TEXT_NODE)return e.textContent;if("BR"===e.tagName)return"\n";for(const i of e.childNodes)t+=$d(i);return t}function qd(e,t){return t?e.is("element","li")&&!e.isEmpty&&e.getChild(0).is("containerElement")||Hd.includes(e.name)&&Hd.includes(t.name)?"\n\n":e.is("containerElement")||t.is("containerElement")?zd.includes(e.name)||zd.includes(t.name)?"\n":e.is("element")&&e.getCustomProperty("dataPipeline:transparentRendering")||t.is("element")&&t.getCustomProperty("dataPipeline:transparentRendering")?"":"\n\n":"":""}function jd(e){return e}function Wd(e,t,i,n){if(t===e)return!0;switch(typeof t){case"object":return function(e,t,i,n){if(null==t)return!0;if(Array.isArray(t))return Gd(e,t,i,n);if(t instanceof Map)return function(e,t,i,n){if(0===t.size)return!0;if(!(e instanceof Map))return!1;for(const[o,s]of t.entries())if(!1===i(e.get(o),s,o,e,t,n))return!1;return!0}(e,t,i,n);if(t instanceof Set)return function(e,t,i,n){return 0===t.size||e instanceof Set&&Gd([...e],[...t],i,n)}(e,t,i,n);const o=Object.keys(t);if(null==e)return 0===o.length;if(0===o.length)return!0;if(n&&n.has(t))return n.get(t)===e;n&&n.set(t,e);try{for(let s=0;s0?Wd(e,{...t},i,n):bo(e,t);default:return z(e)?"string"!=typeof t||""===t:bo(e,t)}}function Gd(e,t,i,n){if(0===t.length)return!0;if(!Array.isArray(e))return!1;const o=new Set;for(let s=0;sKd(e,t));case"string":case"symbol":case"number":return function(e){return function(t){return po(t,e)}}(e)}var t,i}class Yd extends ad{_markersToCopy=new Map;static get pluginName(){return"ClipboardMarkersUtils"}static get isOfficialPlugin(){return!0}_registerMarkerToCopy(e,t){this._markersToCopy.set(e,t)}_copySelectedFragmentWithMarkers(e,t,i=e=>e.model.getSelectedContent(e.model.document.selection)){return this.editor.model.change((n=>{const o=n.model.document.selection;n.setSelection(t);const s=this._insertFakeMarkersIntoSelection(n,n.model.document.selection,e),r=i(n),a=this._removeFakeMarkersInsideElement(n,r);for(const[e,t]of Object.entries(s)){a[e]||=n.createRangeIn(r);for(const e of t)n.remove(e)}r.markers.clear();for(const[e,t]of Object.entries(a))r.markers.set(e,t);return n.setSelection(o),r}))}_pasteMarkersIntoTransformedElement(e,t){const i=this._getPasteMarkersFromRangeMap(e);return this.editor.model.change((e=>{const n=this._insertFakeMarkersElements(e,i),o=t(e),s=this._removeFakeMarkersInsideElement(e,o);for(const t of Object.values(n).flat())e.remove(t);for(const[t,i]of Object.entries(s))e.model.markers.has(t)||e.addMarker(t,{usingOperation:!0,affectsData:!0,range:i});return o}))}_pasteFragmentWithMarkers(e){const t=this._getPasteMarkersFromRangeMap(e.markers);e.markers.clear();for(const i of t)e.markers.set(i.name,i.range);return this.editor.model.insertContent(e)}_forceMarkersCopy(e,t,i={allowedActions:"all",copyPartiallySelected:!0,duplicateOnPaste:!0}){const n=this._markersToCopy.get(e);this._markersToCopy.set(e,i),t(),n?this._markersToCopy.set(e,n):this._markersToCopy.delete(e)}_isMarkerCopyable(e,t){const i=this._getMarkerClipboardConfig(e);if(!i)return!1;if(!t)return!0;const{allowedActions:n}=i;return"all"===n||n.includes(t)}_hasMarkerConfiguration(e){return!!this._getMarkerClipboardConfig(e)}_getMarkerClipboardConfig(e){const[t]=e.split(":");return this._markersToCopy.get(t)||null}_insertFakeMarkersIntoSelection(e,t,i){const n=this._getCopyableMarkersFromSelection(e,t,i);return this._insertFakeMarkersElements(e,n)}_getCopyableMarkersFromSelection(e,t,i){const n=Array.from(t.getRanges()),o=new Set(n.flatMap((t=>Array.from(e.model.markers.getMarkersIntersectingRange(t)))));return Array.from(o).filter((e=>{if(!this._isMarkerCopyable(e.name,i))return!1;const{copyPartiallySelected:t}=this._getMarkerClipboardConfig(e.name);if(!t){const t=e.getRange();return n.some((e=>e.containsRange(t,!0)))}return!0})).map((e=>({name:"dragstart"===i?this._getUniqueMarkerName(e.name):e.name,range:e.getRange()})))}_getPasteMarkersFromRangeMap(e,t=null){const{model:i}=this.editor;return(e instanceof Map?Array.from(e.entries()):Object.entries(e)).flatMap((([e,n])=>{if(!this._hasMarkerConfiguration(e))return[{name:e,range:n}];if(this._isMarkerCopyable(e,t)){const t=this._getMarkerClipboardConfig(e),o=i.markers.has(e)&&"$graveyard"===i.markers.get(e).getRange().root.rootName;return(t.duplicateOnPaste||o)&&(e=this._getUniqueMarkerName(e)),[{name:e,range:n}]}return[]}))}_insertFakeMarkersElements(e,t){const i={},n=t.flatMap((e=>{const{start:t,end:i}=e.range;return[{position:t,marker:e,type:"start"},{position:i,marker:e,type:"end"}]})).sort((({position:e},{position:t})=>e.isBefore(t)?1:-1));for(const{position:t,marker:o,type:s}of n){const n=e.createElement("$marker",{"data-name":o.name,"data-type":s});i[o.name]||(i[o.name]=[]),i[o.name].push(n),e.insert(n,t)}return i}_removeFakeMarkersInsideElement(e,t){const i=this._getAllFakeMarkersFromElement(e,t).reduce(((t,i)=>{const n=i.markerElement&&e.createPositionBefore(i.markerElement);let o=t[i.name],s=!1;return o?.start&&o?.end&&(this._getMarkerClipboardConfig(i.name).duplicateOnPaste?t[this._getUniqueMarkerName(i.name)]=t[i.name]:s=!0,o=null),s||(t[i.name]={...o,[i.type]:n}),i.markerElement&&e.remove(i.markerElement),t}),{});return function(e,t=jd){return null==e?{}:function(e,t){const i={},n=Object.keys(e);for(let o=0;onew Pr(i.start||e.createPositionFromPath(t,[0]),i.end||e.createPositionAt(t,"end"))))}_getAllFakeMarkersFromElement(e,t){const i=Array.from(e.createRangeIn(t)).flatMap((({item:e})=>{if(!e.is("element","$marker"))return[];const t=e.getAttribute("data-name"),i=e.getAttribute("data-type");return[{markerElement:e,name:t,type:i}]})),n=[],o=[];for(const e of i)"end"===e.type&&(i.some((t=>t.name===e.name&&"start"===t.type))||n.push({markerElement:null,name:e.name,type:"start"})),"start"===e.type&&(i.some((t=>t.name===e.name&&"end"===t.type))||o.unshift({markerElement:null,name:e.name,type:"end"}));return[...n,...i,...o]}_getUniqueMarkerName(e){const t=e.split(":"),i=_().substring(1,6);return 3===t.length?`${t.slice(0,2).join(":")}:${i}`:`${t.join(":")}:${i}`}}class Qd extends ad{static get pluginName(){return"ClipboardPipeline"}static get isOfficialPlugin(){return!0}static get requires(){return[Yd]}init(){this.editor.editing.view.addObserver(Dd),this._setupPasteDrop(),this._setupCopyCut()}_fireOutputTransformationEvent(e,t,i){const n=this.editor.plugins.get("ClipboardMarkersUtils");this.editor.model.enqueueChange({isUndoable:"cut"===i},(()=>{const o=n._copySelectedFragmentWithMarkers(i,t);this.fire("outputTransformation",{dataTransfer:e,content:o,method:i})}))}_setupPasteDrop(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,o=this.editor.plugins.get("ClipboardMarkersUtils");this.listenTo(n,"clipboardInput",((t,i)=>{"paste"!=i.method||e.model.canEditAt(e.model.document.selection)||t.stop()}),{priority:"highest"}),this.listenTo(n,"clipboardInput",((e,t)=>{const n=t.dataTransfer;let o;if(t.content)o=t.content;else{let e="";n.getData("text/html")?e=function(e){return e.replace(/(\s+)<\/span>/g,((e,t)=>1==t.length?" ":t)).replace(//g,"")}(n.getData("text/html")):n.getData("text/plain")&&(((s=(s=n.getData("text/plain")).replace(/&/g,"&").replace(//g,">").replace(/\r?\n\r?\n/g,"

").replace(/\r?\n/g,"
").replace(/\t/g,"    ").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g,"  ")).includes("

")||s.includes("
"))&&(s=`

${s}

`),e=s),o=this.editor.data.htmlProcessor.toView(e)}var s;const r=new v(this,"inputTransformation"),a=n.getData("application/ckeditor5-editor-id")||null;this.fire(r,{content:o,dataTransfer:n,sourceEditorId:a,targetRanges:t.targetRanges,method:t.method}),r.stop.called&&e.stop(),i.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,i)=>{if(i.content.isEmpty)return;const n=this.editor.data.toModel(i.content,"$clipboardHolder");0!=n.childCount&&(e.stop(),t.change((()=>{this.fire("contentInsertion",{content:n,method:i.method,sourceEditorId:i.sourceEditorId,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,t)=>{t.resultRange=o._pasteFragmentWithMarkers(t.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,n=(e,i)=>{const n=i.dataTransfer;i.preventDefault(),this._fireOutputTransformationEvent(n,t.selection,e.name)};this.listenTo(i,"copy",n,{priority:"low"}),this.listenTo(i,"cut",((t,i)=>{e.model.canEditAt(e.model.document.selection)?n(t,i):i.preventDefault()}),{priority:"low"}),this.listenTo(this,"outputTransformation",((t,n)=>{const o=e.data.toView(n.content,{isClipboardPipeline:!0});i.fire("clipboardOutput",{dataTransfer:n.dataTransfer,content:o,method:n.method})}),{priority:"low"}),this.listenTo(i,"clipboardOutput",((i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",Ud(e.data.htmlProcessor.domConverter,n.content)),n.dataTransfer.setData("application/ckeditor5-editor-id",this.editor.id)),"cut"==n.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}class Xd{model;limit;_isLocked;_size;_batch=null;_changeCallback;_selectionChangeCallback;constructor(e,t=20){this.model=e,this._size=0,this.limit=t,this._isLocked=!1,this._changeCallback=(e,t)=>{t.isLocal&&t.isUndoable&&t!==this._batch&&this._reset(!0)},this._selectionChangeCallback=()=>{this._reset()},this.model.document.on("change",this._changeCallback),this.model.document.selection.on("change:range",this._selectionChangeCallback),this.model.document.selection.on("change:attribute",this._selectionChangeCallback)}get batch(){return this._batch||(this._batch=this.model.createBatch({isTyping:!0})),this._batch}get size(){return this._size}input(e){this._size+=e,this._size>=this.limit&&this._reset(!0)}get isLocked(){return this._isLocked}lock(){this._isLocked=!0}unlock(){this._isLocked=!1}destroy(){this.model.document.off("change",this._changeCallback),this.model.document.selection.off("change:range",this._selectionChangeCallback),this.model.document.selection.off("change:attribute",this._selectionChangeCallback)}_reset(e=!1){this.isLocked&&!e||(this._batch=null,this._size=0)}}class Zd extends cd{_buffer;constructor(e,t){super(e),this._buffer=new Xd(e.model,t),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,i=t.document,n=e.text||"",o=n.length;let s=i.selection;if(e.selection?s=e.selection:e.range&&(s=t.createSelection(e.range)),!t.canEditAt(s))return;const r=e.resultRange;t.enqueueChange(this._buffer.batch,(e=>{this._buffer.lock();const a=Array.from(i.selection.getAttributes());t.deleteContent(s),n&&t.insertContent(e.createText(n,a),s),r?e.setSelection(r):s.is("documentSelection")||e.setSelection(s),this._buffer.unlock(),this._buffer.input(o)}))}}const eh=["insertText","insertReplacementText"],th=[...eh,"insertCompositionText"];class ih extends Gs{focusObserver;constructor(e){super(e),this.focusObserver=e.getObserver(ur);const t=r.isAndroid?th:eh,i=e.document;i.on("beforeinput",((n,o)=>{if(!this.isEnabled)return;const{data:s,targetRanges:r,inputType:a,domEvent:l,isComposing:c}=o;if(!t.includes(a))return;this.focusObserver.flush();const u=new v(i,"insertText");i.fire(u,new Zs(e,l,{text:s,selection:e.createSelection(r),isComposing:c})),u.stop.called&&n.stop()})),r.isAndroid||i.on("compositionend",((t,{data:n,domEvent:o})=>{this.isEnabled&&n&&i.fire("insertText",new Zs(e,o,{text:n,isComposing:!0}))}),{priority:"low"})}observe(){}stopObserving(){}}class nh extends ad{_typingQueue;static get pluginName(){return"Input"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model,i=e.editing.view,n=e.editing.mapper,o=t.document.selection;this._typingQueue=new oh(e),i.addObserver(ih);const s=new Zd(e,e.config.get("typing.undoStep")||20);e.commands.add("insertText",s),e.commands.add("input",s),this.listenTo(i.document,"beforeinput",(()=>{this._typingQueue.flush("next beforeinput")}),{priority:"high"}),this.listenTo(i.document,"insertText",((e,a)=>{const{text:l,selection:c}=a;if(i.document.selection.isFake&&c&&i.document.selection.isSimilar(c)&&a.preventDefault(),c&&Array.from(c.getRanges()).some((e=>!e.isCollapsed))&&a.preventDefault(),!s.isEnabled)return void a.preventDefault();let u;c&&(u=Array.from(c.getRanges()).filter((e=>e.root.is("rootElement"))).map((e=>n.toModelRange(e))).map((e=>ec(e,t.schema)||e))),u&&u.length||(u=Array.from(o.getRanges()));let d=l;if(r.isAndroid){const e=Array.from(u[0].getItems()).reduce(((e,t)=>e+(t.is("$textProxy")?t.data:"")),"");if(e&&(e.length<=d.length?d.startsWith(e)&&(d=d.substring(e.length),u[0].start=u[0].start.getShiftedBy(e.length)):e.startsWith(d)&&(u[0].start=u[0].start.getShiftedBy(d.length),d="")),0==d.length&&u[0].isCollapsed)return}const h={text:d,selection:t.createSelection(u)};this._typingQueue.push(h,Boolean(a.isComposing)),a.domEvent.defaultPrevented&&this._typingQueue.flush("beforeinput default prevented")})),r.isAndroid?this.listenTo(i.document,"keydown",((e,n)=>{!o.isCollapsed&&229==n.keyCode&&i.document.isComposing&&sh(t,s)})):this.listenTo(i.document,"compositionstart",(()=>{o.isCollapsed||sh(t,s)}),{priority:"high"}),this.listenTo(i.document,"mutations",((e,{mutations:t})=>{if(this._typingQueue.hasAffectedElements())for(const{node:e}of t){const t=rh(e,n),i=n.toModelElement(t);if(this._typingQueue.isElementAffected(i))return void this._typingQueue.flush("mutations")}})),this.listenTo(i.document,"compositionend",(()=>{this._typingQueue.flush("before composition end")}),{priority:"high"}),this.listenTo(i.document,"compositionend",(()=>{this._typingQueue.flush("after composition end");const e=[];if(this._typingQueue.hasAffectedElements())for(const t of this._typingQueue.flushAffectedElements()){const i=n.toViewElement(t);i&&e.push({type:"children",node:i})}!e.length&&r.isAndroid||i.document.fire("mutations",{mutations:e})}),{priority:"lowest"})}destroy(){super.destroy(),this._typingQueue.destroy()}}class oh{editor;flushDebounced=Wi((()=>this.flush("timeout")),50);_queue=[];_isComposing=!1;_affectedElements=new Set;constructor(e){this.editor=e}destroy(){for(this.flushDebounced.cancel(),this._affectedElements.clear();this._queue.length;)this.shift()}get length(){return this._queue.length}push(e,t){const i={text:e.text};if(e.selection){i.selectionRanges=[];for(const t of e.selection.getRanges())i.selectionRanges.push(jr.fromRange(t)),this._affectedElements.add(t.start.parent)}this._queue.push(i),this._isComposing||=t,this.flushDebounced()}shift(){const e=this._queue.shift(),t={text:e.text};if(e.selectionRanges){const i=e.selectionRanges.map((e=>function(e){const t=e.toRange();return e.detach(),"$graveyard"==t.root.rootName?null:t}(e))).filter((e=>!!e));i.length&&(t.selection=this.editor.model.createSelection(i))}return t}flush(e){const t=this.editor,i=t.model,n=t.editing.view;if(this.flushDebounced.cancel(),!this._queue.length)return;const o=t.commands.get("insertText").buffer;i.enqueueChange(o.batch,(()=>{for(o.lock();this._queue.length;){const e=this.shift();t.execute("insertText",e)}o.unlock(),this._isComposing||this._affectedElements.clear(),this._isComposing=!1})),n.scrollToTheSelection()}isElementAffected(e){return this._affectedElements.has(e)}hasAffectedElements(){return this._affectedElements.size>0}flushAffectedElements(){const e=Array.from(this._affectedElements);return this._affectedElements.clear(),e}}function sh(e,t){if(!t.isEnabled)return;const i=t.buffer;i.lock(),e.enqueueChange(i.batch,(()=>{e.deleteContent(e.document.selection)})),i.unlock()}function rh(e,t){let i=e.is("$text")?e.parent:e;for(;!t.toModelElement(i);)i=i.parent;return i}class ah extends cd{direction;_buffer;constructor(e,t){super(e),this.direction=t,this._buffer=new Xd(e.model,e.config.get("typing.undoStep")),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}execute(e={}){const t=this.editor.model,i=t.document;t.enqueueChange(this._buffer.batch,(n=>{this._buffer.lock();const o=n.createSelection(e.selection||i.selection);if(!t.canEditAt(o))return;const s=e.sequence||1,r=o.isCollapsed;if(o.isCollapsed&&t.modifySelection(o,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(s))return void this._replaceEntireContentWithParagraph(n);if(this._shouldReplaceFirstBlockWithParagraph(o,s))return void this.editor.execute("paragraph",{selection:o});if(o.isCollapsed)return;let a=0;o.getFirstRange().getMinimalFlatRanges().forEach((e=>{a+=ee(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),t.deleteContent(o,{doNotResetEntireContent:r,direction:this.direction}),this._buffer.input(a),n.setSelection(o),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,i=t.document.selection,n=t.schema.getLimitElement(i);if(!i.isCollapsed||!i.containsEntireContent(n))return!1;if(!t.schema.checkChild(n,"paragraph"))return!1;const o=n.getChild(0);return!o||!o.is("element","paragraph")}_replaceEntireContentWithParagraph(e){const t=this.editor.model,i=t.document.selection,n=t.schema.getLimitElement(i),o=e.createElement("paragraph");e.remove(e.createRangeIn(n)),e.insert(o,n),e.setSelection(o,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const i=this.editor.model;if(t>1||"backward"!=this.direction)return!1;if(!e.isCollapsed)return!1;const n=e.getFirstPosition(),o=i.schema.getLimitElement(n),s=o.getChild(0);return n.parent==s&&!!e.containsEntireContent(s)&&!!i.schema.checkChild(o,"paragraph")&&"paragraph"!=s.name}}const lh="word",ch="selection",uh="backward",dh="forward",hh={deleteContent:{unit:ch,direction:uh},deleteContentBackward:{unit:"codePoint",direction:uh},deleteWordBackward:{unit:lh,direction:uh},deleteHardLineBackward:{unit:ch,direction:uh},deleteSoftLineBackward:{unit:ch,direction:uh},deleteContentForward:{unit:"character",direction:dh},deleteWordForward:{unit:lh,direction:dh},deleteHardLineForward:{unit:ch,direction:dh},deleteSoftLineForward:{unit:ch,direction:dh}};class mh extends Gs{constructor(e){super(e);const t=e.document;let i=0;t.on("keydown",(()=>{i++})),t.on("keyup",(()=>{i=0})),t.on("beforeinput",((n,o)=>{if(!this.isEnabled)return;const{targetRanges:s,domEvent:a,inputType:l}=o,c=hh[l];if(!c)return;const u={direction:c.direction,unit:c.unit,sequence:i};u.unit==ch&&(u.selectionToRemove=e.createSelection(s[0])),"deleteContentBackward"===l&&(r.isAndroid&&(u.sequence=1),function(e){if(1!=e.length||e[0].isCollapsed)return!1;const t=e[0].getWalker({direction:"backward",singleCharacters:!0,ignoreElementEnd:!0});let i=0;for(const{nextPosition:e,item:n}of t){if(e.parent.is("$text")){const t=e.parent.data,n=e.offset;if(ui(t,n)||di(t,n)||mi(t,n))continue;i++}else(n.is("containerElement")||n.is("emptyElement"))&&i++;if(i>1)return!0}return!1}(s)&&(u.unit=ch,u.selectionToRemove=e.createSelection(s)));const d=new jo(t,"delete",s[0]);t.fire(d,new Zs(e,a,u)),d.stop.called&&n.stop()})),r.isBlink&&function(e){const t=e.view,i=t.document;let n=null,o=!1;function s(e){return e==Rt.backspace||e==Rt.delete}function r(e){return e==Rt.backspace?uh:dh}i.on("keydown",((e,{keyCode:t})=>{n=t,o=!1})),i.on("keyup",((a,{keyCode:l,domEvent:c})=>{const u=i.selection,d=e.isEnabled&&l==n&&s(l)&&!u.isCollapsed&&!o;if(n=null,d){const e=u.getFirstRange(),n=new jo(i,"delete",e),o={unit:ch,direction:r(l),selectionToRemove:u};i.fire(n,new Zs(t,c,o))}})),i.on("beforeinput",((e,{inputType:t})=>{const i=hh[t];s(n)&&i&&i.direction==r(n)&&(o=!0)}),{priority:"high"}),i.on("beforeinput",((e,{inputType:t,data:i})=>{n==Rt.delete&&"insertText"==t&&""==i&&e.stop()}),{priority:"high"})}(this)}observe(){}stopObserving(){}}class gh extends ad{_undoOnBackspace;static get pluginName(){return"Delete"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=t.document,n=e.model.document;t.addObserver(mh),this._undoOnBackspace=!1;const o=new ah(e,"forward");e.commands.add("deleteForward",o),e.commands.add("forwardDelete",o),e.commands.add("delete",new ah(e,"backward")),this.listenTo(i,"delete",((n,o)=>{i.isComposing||o.preventDefault();const{direction:s,sequence:r,selectionToRemove:a,unit:l}=o,c="forward"===s?"deleteForward":"delete",u={sequence:r};if("selection"==l){const t=Array.from(a.getRanges()).map((t=>e.editing.mapper.toModelRange(t))).map((t=>ec(t,e.model.schema)||t));u.selection=e.model.createSelection(t)}else u.unit=l;e.execute(c,u),t.scrollToTheSelection()}),{priority:"low"}),this.listenTo(i,"keydown",((o,s)=>{if(i.isComposing||s.keyCode!=Rt.backspace||!n.selection.isCollapsed)return;const r=e.model.schema.getLimitElement(n.selection),a=e.model.createPositionAt(r,0);if(a.isTouching(n.selection.getFirstPosition())){s.preventDefault();const n=e.model.schema.getNearestSelectionRange(a,"forward");if(!n)return;const o=t.createSelection(e.editing.mapper.toViewRange(n)),r=o.getFirstRange(),l=new jo(document,"delete",r),c={unit:"selection",direction:"backward",selectionToRemove:o};i.fire(l,new Zs(t,s.domEvent,c))}})),this.editor.plugins.has("UndoEditing")&&(this.listenTo(i,"delete",((t,i)=>{this._undoOnBackspace&&"backward"==i.direction&&1==i.sequence&&"codePoint"==i.unit&&(this._undoOnBackspace=!1,e.execute("undo"),i.preventDefault(),t.stop())}),{context:"$capture"}),this.listenTo(n,"change",(()=>{this._undoOnBackspace=!1})))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class fh extends ad{static get requires(){return[nh,gh]}static get pluginName(){return"Typing"}static get isOfficialPlugin(){return!0}}function ph(e,t){let i=e.start;return{text:Array.from(e.getWalker({ignoreElementEnd:!1})).reduce(((e,{item:n})=>n.is("$text")||n.is("$textProxy")?e+n.data:(i=t.createPositionAfter(n),"")),""),range:t.createRange(i,e.end)}}class bh extends(G()){model;testCallback;_hasMatch;constructor(e,t){super(),this.model=e,this.testCallback=t,this._hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",(()=>{this.isEnabled?this._startListening():(this.stopListening(e.document.selection),this.stopListening(e.document))})),this._startListening()}get hasMatch(){return this._hasMatch}_startListening(){const e=this.model.document;this.listenTo(e.selection,"change:range",((t,{directChange:i})=>{i&&(e.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this._hasMatch=!1))})),this.listenTo(e,"change:data",((e,t)=>{!t.isUndo&&t.isLocal&&this._evaluateTextBeforeSelection("data",{batch:t})}))}_evaluateTextBeforeSelection(e,t={}){const i=this.model,n=i.document.selection,o=i.createRange(i.createPositionAt(n.focus.parent,0),n.focus),{text:s,range:r}=ph(o,i),a=this.testCallback(s);if(!a&&this.hasMatch&&this.fire("unmatched"),this._hasMatch=!!a,a){const i=Object.assign(t,{text:s,range:r});"object"==typeof a&&Object.assign(i,a),this.fire(`matched:${e}`,i)}}}class wh extends ad{attributes;_overrideUid;_isNextGravityRestorationSkipped=!1;static get pluginName(){return"TwoStepCaretMovement"}static get isOfficialPlugin(){return!0}constructor(e){super(e),this.attributes=new Set,this._overrideUid=null}init(){const e=this.editor,t=e.model,i=e.editing.view,n=e.locale,o=t.document.selection;this.listenTo(i.document,"arrowKey",((e,t)=>{if(!o.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const i=t.keyCode==Rt.arrowright,s=t.keyCode==Rt.arrowleft;if(!i&&!s)return;const r=n.contentLanguageDirection;let a=!1;a="ltr"===r&&i||"rtl"===r&&s?this._handleForwardMovement(t):this._handleBackwardMovement(t),!0===a&&e.stop()}),{context:"$text",priority:"highest"}),this.listenTo(o,"change:range",((e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&xh(o.getFirstPosition(),this.attributes)||this._restoreGravity())})),this._enableClickingAfterNode(),this._enableInsertContentSelectionAttributesFixer(),this._handleDeleteContentAfterNode()}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,i=this.editor.model,n=i.document.selection,o=n.getFirstPosition();return!(this._isGravityOverridden||o.isAtStart&&vh(n,t)||!xh(o,t)||(e&&kh(e),vh(n,t)&&xh(o,t,!0)?_h(i,t):this._overrideGravity(),0))}_handleBackwardMovement(e){const t=this.attributes,i=this.editor.model,n=i.document.selection,o=n.getFirstPosition();return this._isGravityOverridden?(e&&kh(e),this._restoreGravity(),xh(o,t,!0)?_h(i,t):yh(i,t,o),!0):o.isAtStart?!!vh(n,t)&&(e&&kh(e),yh(i,t,o),!0):!vh(n,t)&&xh(o,t,!0)?(e&&kh(e),yh(i,t,o),!0):!!Ch(o,t)&&(o.isAtEnd&&!vh(n,t)&&xh(o,t)?(e&&kh(e),yh(i,t,o),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1))}_enableClickingAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view.document;e.editing.view.addObserver(wc),e.editing.view.addObserver(vc);let o=!1,s=!1;this.listenTo(n,"touchstart",(()=>{s=!1,o=!0})),this.listenTo(n,"mousedown",(()=>{s=!0})),this.listenTo(n,"selectionChange",(()=>{const e=this.attributes;if(!s&&!o)return;if(s=!1,o=!1,!i.isCollapsed)return;if(!vh(i,e))return;const n=i.getFirstPosition();xh(n,e)&&(n.isAtStart||xh(n,e,!0)?_h(t,e):this._isGravityOverridden||this._overrideGravity())}))}_enableInsertContentSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection,i=this.attributes;this.listenTo(e,"insertContent",(()=>{const n=t.getFirstPosition();vh(t,i)&&xh(n,i)&&_h(e,i)}),{priority:"low"})}_handleDeleteContentAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view;let o=!1,s=!1;this.listenTo(n.document,"delete",((e,t)=>{o="backward"===t.direction}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{if(!o)return;const e=i.getFirstPosition();s=vh(i,this.attributes)&&!Ch(e,this.attributes)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{o&&(o=!1,s||e.model.enqueueChange((()=>{const e=i.getFirstPosition();vh(i,this.attributes)&&xh(e,this.attributes)&&(e.isAtStart||xh(e,this.attributes,!0)?_h(t,this.attributes):this._isGravityOverridden||this._overrideGravity())})))}),{priority:"low"})}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change((e=>e.overrideSelectionGravity()))}_restoreGravity(){this.editor.model.change((e=>{e.restoreSelectionGravity(this._overrideUid),this._overrideUid=null}))}}function vh(e,t){for(const i of t)if(e.hasAttribute(i))return!0;return!1}function yh(e,t,i){const n=i.nodeBefore;e.change((i=>{if(n){const t=[],o=e.schema.isObject(n)&&e.schema.isInline(n);for(const[i,s]of n.getAttributes())!e.schema.checkAttribute("$text",i)||o&&!1===e.schema.getAttributeProperties(i).copyFromObject||t.push([i,s]);i.setSelectionAttribute(t)}else i.removeSelectionAttribute(t)}))}function _h(e,t){e.change((e=>{e.removeSelectionAttribute(t)}))}function kh(e){e.preventDefault()}function Ch(e,t){return xh(e.getShiftedBy(-1),t)}function xh(e,t,i=!1){const{nodeBefore:n,nodeAfter:o}=e;for(const e of t){const t=n?n.getAttribute(e):void 0,s=o?o.getAttribute(e):void 0;if((!i||void 0!==t&&void 0!==s)&&s!==t)return!0}return!1}function Ah(e){if(null==e)return"";if("string"==typeof e)return e;if(Array.isArray(e))return e.map(Ah).join(",");const t=String(e);return"0"===t&&Object.is(Number(e),-0)?"-0":t}function Th(e){return new RegExp(`(^|\\s)(${e})([^${e}]*)(${e})$`)}function Eh(e,t,i,n){return n.createRange(Sh(e,t,i,!0,n),Sh(e,t,i,!1,n))}function Sh(e,t,i,n,o){let s=e.textNode||(n?e.nodeBefore:e.nodeAfter),r=null;for(;s&&s.getAttribute(t)==i;)r=s,s=n?s.previousSibling:s.nextSibling;return r?o.createPositionAt(r,n?"before":"after"):e}function Ph(e,t,i,n){const o=e.editing.view,s=new Set;o.document.registerPostFixer((o=>{const r=e.model.document.selection;let a=!1;if(r.hasAttribute(t)){const l=Eh(r.getFirstPosition(),t,r.getAttribute(t),e.model),c=e.editing.mapper.toViewRange(l);for(const e of c.getItems())e.is("element",i)&&!e.hasClass(n)&&(o.addClass(n,e),s.add(e),a=!0)}return a})),e.conversion.for("editingDowncast").add((e=>{function t(){o.change((e=>{for(const t of s.values())e.removeClass(n,t),s.delete(t)}))}e.on("insert",t,{priority:"highest"}),e.on("remove",t,{priority:"highest"}),e.on("attribute",t,{priority:"highest"}),e.on("selection",t,{priority:"highest"})}))}function*Ih(e,t){for(const i of t)i&&e.getAttributeProperties(i[0]).copyOnEnter&&(yield i)}Th('"'),Th("'"),Th("'"),Th('"'),Th('"'),Th("'");class Vh extends cd{execute(){this.editor.model.change((e=>{this.enterBlock(e),this.fire("afterExecute",{writer:e})}))}enterBlock(e){const t=this.editor.model,i=t.document.selection,n=t.schema,o=i.isCollapsed,s=i.getFirstRange(),r=s.start.parent,a=s.end.parent;if(n.isLimit(r)||n.isLimit(a))return o||r!=a||t.deleteContent(i),!1;if(o){const t=Ih(e.model.schema,i.getAttributes());return Oh(e,s.start),e.setSelectionAttribute(t),!0}{const n=!(s.start.isAtStart&&s.end.isAtEnd),o=r==a;if(t.deleteContent(i,{leaveUnmerged:n}),n){if(o)return Oh(e,i.focus),!0;e.setSelection(a,0)}}return!1}}function Oh(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}const Rh={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class Lh extends Gs{constructor(e){super(e);const t=this.document;let i=!1;t.on("keydown",((e,t)=>{i=t.shiftKey})),t.on("beforeinput",((n,o)=>{if(!this.isEnabled)return;let s=o.inputType;r.isSafari&&i&&"insertParagraph"==s&&(s="insertLineBreak");const a=o.domEvent,l=Rh[s];if(!l)return;const c=new jo(t,"enter",o.targetRanges[0]);t.fire(c,new Zs(e,a,{isSoft:l.isSoft})),c.stop.called&&n.stop()}))}observe(){}stopObserving(){}}class Bh extends ad{static get pluginName(){return"Enter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=t.document,n=this.editor.t;t.addObserver(Lh),e.commands.add("enter",new Vh(e)),this.listenTo(i,"enter",((n,o)=>{i.isComposing||o.preventDefault(),o.isSoft||(e.execute("enter"),t.scrollToTheSelection())}),{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:n("Insert a hard break (a new paragraph)"),keystroke:"Enter"}]})}}class Mh extends cd{execute(){const e=this.editor.model,t=e.document;e.change((i=>{!function(e,t,i){const n=i.isCollapsed,o=i.getFirstRange(),s=o.start.parent,r=o.end.parent,a=s==r;if(n){const n=Ih(e.schema,i.getAttributes());Nh(e,t,o.end),t.removeSelectionAttribute(i.getAttributeKeys()),t.setSelectionAttribute(n)}else{const n=!(o.start.isAtStart&&o.end.isAtEnd);e.deleteContent(i,{leaveUnmerged:n}),a?Nh(e,t,i.focus):n&&t.setSelection(r,0)}}(e,i,t.selection),this.fire("afterExecute",{writer:i})}))}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=function(e,t){if(t.rangeCount>1)return!1;const i=t.anchor;if(!i||!e.checkChild(i,"softBreak"))return!1;const n=t.getFirstRange(),o=n.start.parent,s=n.end.parent;return!Fh(o,e)&&!Fh(s,e)||o===s}(e.schema,t.selection)}}function Nh(e,t,i){const n=t.createElement("softBreak");e.insertContent(n,i),t.setSelection(n,"after")}function Fh(e,t){return!e.is("rootElement")&&(t.isLimit(e)||Fh(e.parent,t))}class Dh extends ad{static get pluginName(){return"ShiftEnter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.conversion,n=e.editing.view,o=n.document,s=this.editor.t;t.register("softBreak",{allowWhere:"$text",isInline:!0}),i.for("upcast").elementToElement({model:"softBreak",view:"br"}),i.for("downcast").elementToElement({model:"softBreak",view:(e,{writer:t})=>t.createEmptyElement("br")}),n.addObserver(Lh),e.commands.add("shiftEnter",new Mh(e)),this.listenTo(o,"enter",((t,i)=>{o.isComposing||i.preventDefault(),i.isSoft&&(e.execute("shiftEnter"),n.scrollToTheSelection())}),{priority:"low"}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:s("Insert a soft break (a <br> element)"),keystroke:"Shift+Enter"}]})}}class zh extends(R()){_stack=[];add(e,t){const i=this._stack,n=i[0];this._insertDescriptor(e);const o=i[0];n===o||Hh(n,o)||this.fire("change:top",{oldDescriptor:n,newDescriptor:o,writer:t})}remove(e,t){const i=this._stack,n=i[0];this._removeDescriptor(e);const o=i[0];n===o||Hh(n,o)||this.fire("change:top",{oldDescriptor:n,newDescriptor:o,writer:t})}_insertDescriptor(e){const t=this._stack,i=t.findIndex((t=>t.id===e.id));if(Hh(e,t[i]))return;i>-1&&t.splice(i,1);let n=0;for(;t[n]&&(o=t[n],s=e,o.priority>s.priority||!(o.priorityUh(s.classes));)n++;var o,s;t.splice(n,0,e)}_removeDescriptor(e){const t=this._stack,i=t.findIndex((t=>t.id===e));i>-1&&t.splice(i,1)}}function Hh(e,t){return e&&t&&e.priority==t.priority&&Uh(e.classes)==Uh(t.classes)}function Uh(e){return Array.isArray(e)?e.sort().join(","):e}const $h="ck-widget_selected";function qh(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function jh(e,t,i={}){if(!e.is("containerElement"))throw new x("widget-to-widget-wrong-element-type",null,{element:e});return t.setAttribute("contenteditable","false",e),t.addClass("ck-widget",e),t.setCustomProperty("widget",!0,e),e.getFillerOffset=Qh,t.setCustomProperty("widgetLabel",[],e),i.label&&function(e,t){e.getCustomProperty("widgetLabel").push(t)}(e,i.label),i.hasSelectionHandle&&function(e,t){const i=t.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(e){const t=this.toDomElement(e),i=new en;return i.set("content",''),i.render(),t.appendChild(i.element),t}));t.insert(t.createPositionAt(e,0),i),t.addClass(["ck-widget_with-selection-handle"],e)}(e,t),Kh(e,t),e}function Wh(e,t,i){if(t.classes&&i.addClass(zt(t.classes),e),t.attributes)for(const n in t.attributes)i.setAttribute(n,t.attributes[n],e)}function Gh(e,t,i){if(t.classes&&i.removeClass(zt(t.classes),e),t.attributes)for(const n in t.attributes)i.removeAttribute(n,e)}function Kh(e,t,i=Wh,n=Gh){const o=new zh;o.on("change:top",((t,o)=>{o.oldDescriptor&&n(e,o.oldDescriptor,o.writer),o.newDescriptor&&i(e,o.newDescriptor,o.writer)})),t.setCustomProperty("addHighlight",((e,t,i)=>o.add(t,i)),e),t.setCustomProperty("removeHighlight",((e,t,i)=>o.remove(t,i)),e)}function Jh(e,t,i={}){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),!1!==i.withAriaRole&&t.setAttribute("role","textbox",e),e.isReadOnly||t.setAttribute("tabindex","-1",e),i.label&&t.setAttribute("aria-label",i.label,e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",((i,n,o)=>{t.setAttribute("contenteditable",o?"false":"true",e),o?t.removeAttribute("tabindex",e):t.setAttribute("tabindex","-1",e)})),e.on("change:isFocused",((i,n,o)=>{o?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)})),Kh(e,t),e}function Yh(e,t){const i=e.getSelectedElement();if(i){const n=tm(e);if(n)return t.createRange(t.createPositionAt(i,n))}return t.schema.findOptimalInsertionRange(e)}function Qh(){return null}function Xh(e){const t=e=>{const{width:t,paddingLeft:i,paddingRight:n}=e.ownerDocument.defaultView.getComputedStyle(e);return parseFloat(t)-(parseFloat(i)||0)-(parseFloat(n)||0)},i=e.parentElement;if(!i)return 0;let n=t(i),o=0,s=i;for(;isNaN(n);){if(s=s.parentElement,++o>5)return 0;n=t(s)}return n}const Zh="widget-type-around";function em(e,t,i){return!!e&&qh(e)&&!i.isInline(t)}function tm(e){return e.getAttribute(Zh)}const im=["before","after"],nm=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,om="ck-widget__type-around_disabled";class sm extends ad{_currentFakeCaretModelElement=null;static get pluginName(){return"WidgetTypeAround"}static get isOfficialPlugin(){return!0}static get requires(){return[Bh,gh]}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",((i,n,o)=>{t.change((e=>{for(const i of t.document.roots)o?e.removeClass(om,i):e.addClass(om,i)})),o||e.model.change((e=>{e.removeSelectionAttribute(Zh)}))})),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableInsertObjectIntegration(),this._enableDeleteContentIntegration()}destroy(){super.destroy(),this._currentFakeCaretModelElement=null}_insertParagraph(e,t){const i=this.editor,n=i.editing.view,o=i.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);i.execute("insertParagraph",{position:i.model.createPositionAt(e,t),attributes:o}),n.focus(),n.scrollToTheSelection()}_listenToIfEnabled(e,t,i,n){this.listenTo(e,t,((...e)=>{this.isEnabled&&i(...e)}),n)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=tm(e);if(!t)return!1;const i=e.getSelectedElement();return this._insertParagraph(i,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,i=e.locale.t,n={before:i("Insert paragraph before block"),after:i("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",((e,o,s)=>{const r=s.mapper.toViewElement(o.item);r&&em(r,o.item,t)&&(!function(e,t,i){const n=e.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(e){const i=this.toDomElement(e);return function(e,t){for(const i of im){const n=new vi({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${i}`],title:t[i],"aria-hidden":"true"},children:[e.ownerDocument.importNode(nm,!0)]});e.appendChild(n.render())}}(i,t),function(e){const t=new vi({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(i),i}));e.insert(e.createPositionAt(i,"end"),n)}(s.writer,n,r),r.getCustomProperty("widgetLabel").push((()=>this.isEnabled?i("Press Enter to type after or press Shift + Enter to type before the widget"):"")))}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,i=t.document.selection,n=t.schema,o=e.editing.view;function s(e){return`ck-widget_type-around_show-fake-caret_${e}`}this._listenToIfEnabled(o.document,"arrowKey",((e,t)=>{this._handleArrowKeyPress(e,t)}),{context:[qh,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",((t,i)=>{i.directChange&&e.model.change((e=>{e.removeSelectionAttribute(Zh)}))})),this._listenToIfEnabled(t.document,"change:data",(()=>{const t=i.getSelectedElement();t&&em(e.editing.mapper.toViewElement(t),t,n)||e.model.change((e=>{e.removeSelectionAttribute(Zh)}))})),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",((e,t,i)=>{const o=i.writer;if(this._currentFakeCaretModelElement){const e=i.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(o.removeClass(im.map(s),e),this._currentFakeCaretModelElement=null)}const r=t.selection.getSelectedElement();if(!r)return;const a=i.mapper.toViewElement(r);if(!em(a,r,n))return;const l=tm(t.selection);l&&(o.addClass(s(l),a),this._currentFakeCaretModelElement=r)})),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",((t,i,n)=>{n||e.model.change((e=>{e.removeSelectionAttribute(Zh)}))}))}_handleArrowKeyPress(e,t){const i=this.editor,n=i.model,o=n.document.selection,s=n.schema,r=i.editing.view;if(t.shiftKey)return;const a=function(e,t){const i=Ft(e,t);return"down"===i||"right"===i}(t.keyCode,i.locale.contentLanguageDirection),l=r.document.selection.getSelectedElement();let c;em(l,i.editing.mapper.toModelElement(l),s)?c=this._handleArrowKeyPressOnSelectedWidget(a):o.isCollapsed?c=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):t.shiftKey||(c=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),c&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,i=tm(t.document.selection);return t.change((t=>i?i!==(e?"after":"before")&&(t.removeSelectionAttribute(Zh),!0):(t.setSelectionAttribute(Zh,e?"after":"before"),!0)))}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,i=t.model,n=i.schema,o=t.plugins.get("Widget"),s=o._getObjectElementNextToSelection(e);return!!em(t.editing.mapper.toViewElement(s),s,n)&&(i.change((t=>{o._setSelectionOverElement(s),t.setSelectionAttribute(Zh,e?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,i=t.model,n=i.schema,o=t.editing.mapper,s=i.document.selection,r=e?s.getLastPosition().nodeBefore:s.getFirstPosition().nodeAfter;return!!em(o.toViewElement(r),r,n)&&(i.change((t=>{t.setSelection(r,"on"),t.setSelectionAttribute(Zh,e?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",((i,n)=>{const o=n.domTarget.closest(".ck-widget__type-around__button");if(!o)return;const s=o.classList.contains("ck-widget__type-around__button_before")?"before":"after",r=function(e,t){const i=e.closest(".ck-widget");return t.mapDomToView(i)}(o,t.domConverter),a=e.editing.mapper.toModelElement(r);this._insertParagraph(a,s),n.preventDefault(),i.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,i=e.editing.view;this._listenToIfEnabled(i.document,"enter",((i,n)=>{if("atTarget"!=i.eventPhase)return;const o=t.getSelectedElement(),s=e.editing.mapper.toViewElement(o),r=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:em(s,o,r)&&(this._insertParagraph(o,n.isSoft?"before":"after"),a=!0),a&&(n.preventDefault(),i.stop())}),{context:qh})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view.document;this._listenToIfEnabled(e,"insertText",((t,i)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(i.selection=e.selection)}),{priority:"high"}),r.isAndroid?this._listenToIfEnabled(e,"keydown",((e,t)=>{229==t.keyCode&&this._insertParagraphAccordingToFakeCaretPosition()})):this._listenToIfEnabled(e,"compositionstart",(()=>{this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"highest"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,i=e.model,n=i.schema;this._listenToIfEnabled(t.document,"delete",((t,o)=>{if("atTarget"!=t.eventPhase)return;const s=tm(i.document.selection);if(!s)return;const r=o.direction,a=i.document.selection.getSelectedElement(),l="forward"==r;if("before"===s===l)e.execute("delete",{selection:i.createSelection(a,"on")});else{const t=n.getNearestSelectionRange(i.createPositionAt(a,s),r);if(t)if(t.isCollapsed){const o=i.createSelection(t.start);if(i.modifySelection(o,{direction:r}),o.focus.isEqual(t.start)){const e=function(e,t){let i=t;for(const n of t.getAncestors({parentFirst:!0})){if(n.childCount>1||e.isLimit(n))break;i=n}return i}(n,t.start.parent);i.deleteContent(i.createSelection(e,"on"),{doNotAutoparagraph:!0})}else i.change((i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")}))}else i.change((i=>{i.setSelection(t),e.execute(l?"deleteForward":"delete")}))}o.preventDefault(),t.stop()}),{context:qh})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",((e,[n,o])=>{if(o&&!o.is("documentSelection"))return;const s=tm(i);return s?(e.stop(),t.change((e=>{const o=i.getSelectedElement(),r=t.createPositionAt(o,s),a=e.createSelection(r),l=t.insertContent(n,a);return e.setSelection(a),l}))):void 0}),{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",((e,i)=>{const[,n,o={}]=i;if(n&&!n.is("documentSelection"))return;const s=tm(t);s&&(o.findOptimalPosition=s,i[3]=o)}),{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",((e,[i])=>{i&&!i.is("documentSelection")||tm(t)&&e.stop()}),{priority:"high"})}}function rm(e,t,i){const n=e.schema,o=e.createRangeIn(t.root),s="forward"==i?"elementStart":"elementEnd";for(const{previousPosition:e,item:r,type:a}of o.getWalker({startPosition:t,direction:i})){if(n.isLimit(r)&&!n.isInline(r))return e;if(a==s&&n.isBlock(r))return null}return null}function am(e,t,i){const n="backward"==i?t.end:t.start;if(e.checkChild(n,"$text"))return n;for(const{nextPosition:n}of t.getWalker({direction:i}))if(e.checkChild(n,"$text"))return n}class lm extends ad{_previouslySelected=new Set;static get pluginName(){return"Widget"}static get isOfficialPlugin(){return!0}static get requires(){return[sm,gh]}init(){const e=this.editor,t=e.editing.view,i=t.document,n=e.t;this.editor.editing.downcastDispatcher.on("selection",((t,i,n)=>{const o=n.writer,s=i.selection;if(s.isCollapsed)return;const r=s.getSelectedElement();if(!r)return;const a=e.editing.mapper.toViewElement(r);var l;qh(a)&&n.consumable.consume(s,"selection")&&o.setSelection(o.createRangeOn(a),{fake:!0,label:(l=a,l.getCustomProperty("widgetLabel").reduce(((e,t)=>"function"==typeof t?e?e+". "+t():t():e?e+". "+t:t),""))})})),this.editor.editing.downcastDispatcher.on("selection",((e,t,i)=>{this._clearPreviouslySelectedWidgets(i.writer);const n=i.writer,o=n.document.selection;let s=null;for(const e of o.getRanges())for(const t of e){const e=t.item;qh(e)&&(r=e,!(a=s)||!Array.from(r.getAncestors()).includes(a))&&(n.addClass($h,e),this._previouslySelected.add(e),s=e)}var r,a}),{priority:"low"}),t.addObserver(wc),t.addObserver(yc),this.listenTo(i,"mousedown",((...e)=>this._onMousedown(...e))),this.listenTo(i,"pointerdown",((...e)=>this._onPointerdown(...e))),this.listenTo(i,"arrowKey",((...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)}),{context:[qh,"$text"]}),this.listenTo(i,"arrowKey",((...e)=>{this._preventDefaultOnArrowKeyPress(...e)}),{context:"$root"}),this.listenTo(i,"arrowKey",function(e){const t=e.model;return(i,n)=>{const o=n.keyCode==Rt.arrowup,s=n.keyCode==Rt.arrowdown,r=n.shiftKey,a=t.document.selection;if(!o&&!s)return;const l=s,c=function(e,t,i){const n=e.model;if(i){const e=t.focus,i=rm(n,e,"forward");if(!i)return;const o=n.createRange(e,i),s=am(n.schema,o,"backward");if(s)return n.createRange(e,s)}else{const e=t.focus,i=rm(n,e,"backward");if(!i)return;const o=n.createRange(i,e),s=am(n.schema,o,"forward");if(s)return n.createRange(s,e)}}(e,a,l);if(c){if(c.isCollapsed){if(a.isCollapsed)return;if(r)return}(c.isCollapsed||function(e,t,i){const n=e.model,o=e.view.domConverter;if(i){const e=n.createSelection(t.start);n.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=n.createRange(e.focus,t.end))}const s=e.mapper.toViewRange(t),r=o.viewRangeToDom(s),a=Ze.getDomRangeRects(r);let l;for(const e of a)if(void 0!==l){if(Math.round(e.top)>=l)return!1;l=Math.max(l,Math.round(e.bottom))}else l=Math.round(e.bottom);return!0}(e,c,l))&&(t.change((e=>{const i=l?c.end:c.start;if(r){const n=t.createSelection(a.anchor);n.setFocus(i),e.setSelection(n)}else e.setSelection(i)})),i.stop(),n.preventDefault(),n.stopPropagation())}}}(this.editor.editing),{context:"$text"}),this.listenTo(i,"delete",((e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())}),{context:"$root"}),this.listenTo(i,"tab",((e,i)=>{this._selectNextEditable(i.shiftKey?"backward":"forward")&&(t.scrollToTheSelection(),i.preventDefault(),e.stop())}),{context:e=>qh(e)||e.is("editableElement"),priority:"low"}),this.listenTo(i,"keydown",((e,t)=>{t.keystroke==Rt.esc&&this._selectAncestorWidget()&&(t.preventDefault(),e.stop())}),{context:e=>e.is("editableElement"),priority:"low"}),e.accessibility.addKeystrokeInfoGroup({id:"widget",label:n("Keystrokes that can be used when a widget is selected (for example: image, table, etc.)"),keystrokes:[{label:n("Move focus from an editable area back to the parent widget"),keystroke:"Esc"},{label:n("Insert a new paragraph directly after a widget"),keystroke:"Enter"},{label:n("Insert a new paragraph directly before a widget"),keystroke:"Shift+Enter"},{label:n("Move the caret to allow typing directly before a widget"),keystroke:[["arrowup"],["arrowleft"]]},{label:n("Move the caret to allow typing directly after a widget"),keystroke:[["arrowdown"],["arrowright"]]}]})}_onMousedown(e,t){const i=t.target;i&&t.domEvent.detail>=3&&this._selectBlockContent(i)&&t.preventDefault()}_onPointerdown(e,t){if(!t.domEvent.isPrimary)return;const i=this.editor,n=i.editing.view,o=n.document;let s=t.target;if(!s)return;if(!qh(s)){const e=function(e){let t=e;for(;t;){if(t.is("editableElement")||qh(t))return t;t=t.parent}return null}(s);if(!e)return;if(qh(e))s=e;else{const e=function(e,t){const i=We(t.domEvent);let n=null;if(n=i?e.domConverter.domRangeToView(i):e.createRange(e.createPositionAt(t.target,0)),!n)return null;const o=n.start;if(!o.parent)return null;let s=o.parent;return o.parent.is("editableElement")&&(o.isAtEnd&&o.nodeBefore?s=o.nodeBefore:o.isAtStart&&o.nodeAfter&&(s=o.nodeAfter)),s.is("$text")?s.parent:s}(n,t);if(!e||!qh(e))return;s=e}}(r.isAndroid||r.isiOS)&&t.preventDefault(),o.isFocused||n.focus();const a=i.editing.mapper.toModelElement(s);this._setSelectionOverElement(a)}_selectBlockContent(e){const t=this.editor,i=t.model,n=t.editing.mapper,o=i.schema,s=n.findMappedViewAncestor(this.editor.editing.view.createPositionAt(e,0)),r=function(e,t){for(const i of e.getAncestors({includeSelf:!0,parentFirst:!0})){if(t.checkChild(i,"$text"))return i;if(t.isLimit(i)&&!t.isObject(i))break}return null}(n.toModelElement(s),i.schema);return!!r&&(i.change((e=>{const t=o.isLimit(r)?null:function(e,t){const i=new _r({startPosition:e});for(const{item:e}of i){if(t.isLimit(e)||!e.is("element"))return null;if(t.checkChild(e,"$text"))return e}return null}(e.createPositionAfter(r),o),i=e.createPositionAt(r,0),n=t?e.createPositionAt(t,0):e.createPositionAt(r,"end");e.setSelection(e.createRange(i,n))})),!0)}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,n=this.editor.model,o=n.schema,s=n.document.selection,r=s.getSelectedElement(),a=Ft(i,this.editor.locale.contentLanguageDirection),l="down"==a||"right"==a,c="up"==a||"down"==a;if(!t.shiftKey&&!s.isCollapsed){if(function(e,t){const i=e.getFirstPosition(),n=e.getLastPosition(),o=i.nodeAfter,s=n.nodeBefore;return!!o&&t.isObject(o)||!!s&&t.isObject(s)}(s,o)){const i=l?s.getLastPosition():s.getFirstPosition(),r=o.getNearestSelectionRange(i,l?"forward":"backward");r&&(n.change((e=>{e.setSelection(r)})),t.preventDefault(),e.stop())}return}const u=function(e,t){const i=e.document.selection,n=i.getSelectedElement(),o=tm(i);return n&&"before"==o?e.createSelection(n,"before"):n&&"after"==o?e.createSelection(n,"after"):e.createSelection(i.getRanges(),{backward:n&&e.schema.isObject(n)?!t:i.isBackward})}(n,l),d=n.createSelection(u);if(n.modifySelection(d,{direction:l?"forward":"backward"}),d.isEqual(u))return;d.focus.isTouching(u.focus)&&n.modifySelection(d,{direction:l?"forward":"backward"});const h=l?u.focus.nodeBefore:u.focus.nodeAfter,m=d.focus.nodeBefore,g=d.focus.nodeAfter,f=l?m:g;if(t.shiftKey)(r&&o.isObject(r)||f&&o.isObject(f)||h&&o.isObject(h))&&(n.change((e=>{e.setSelection(d)})),t.preventDefault(),e.stop());else if(f&&o.isObject(f)){if(o.isInline(f)&&c)return;n.change((e=>{e.setSelection(f,"on")})),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const i=this.editor.model,n=i.schema,o=i.document.selection.getSelectedElement();o&&n.isObject(o)&&(t.preventDefault(),e.stop())}_handleDelete(e){const t=this.editor.model.document.selection;if(!this.editor.model.canEditAt(t))return;if(!t.isCollapsed)return;const i=this._getObjectElementNextToSelection(e);return i?(this.editor.model.change((e=>{let n=t.anchor.parent;for(;n.isEmpty;){const t=n;n=t.parent,e.remove(t)}this._setSelectionOverElement(i)})),!0):void 0}_setSelectionOverElement(e){this.editor.model.change((t=>{t.setSelection(t.createRangeOn(e))}))}_getObjectElementNextToSelection(e){const t=this.editor.model,i=t.schema,n=t.document.selection,o=t.createSelection(n);if(t.modifySelection(o,{direction:e?"forward":"backward"}),o.isEqual(n))return null;const s=e?o.focus.nodeBefore:o.focus.nodeAfter;return s&&i.isObject(s)?s:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass($h,t);this._previouslySelected.clear()}_selectNextEditable(e){const t=this.editor.editing,i=t.view,n=this.editor.model,o=i.document.selection,s=n.document.selection;let r;if(s.rangeCount>1){const i=s.isBackward?s.getFirstRange():s.getLastRange();r=t.mapper.toViewPosition("forward"==e?i.end:i.start)}else r="forward"==e?o.getFirstPosition():o.getLastPosition();const a=this._findNextFocusRange(r,e);return!!a&&(n.change((e=>{e.setSelection(a)})),!0)}_findNextFocusRange(e,t){const i=this.editor.editing,n=i.view,o=this.editor.model,s=n.document.selection,r=s.editableElement,a=r.getPath();let l=s.getSelectedElement();l&&!qh(l)&&(l=null);const c="forward"==t?n.createRange(e,n.createPositionAt(e.root,"end")):n.createRange(n.createPositionAt(e.root,0),e);for(const{nextPosition:e}of c.getWalker({direction:t})){const n=e.parent;if(qh(n)&&n!=l){const e=i.mapper.toModelElement(n);if(!o.schema.isBlock(e))continue;if("extension"!=te(a,n.getPath()))return o.createRangeOn(e)}else if(n.is("editableElement")){if(n==r&&!l)continue;const s=i.mapper.toModelPosition(e),c=o.schema.getNearestSelectionRange(s,t);if(!c)continue;return n==r&&l?c:"extension"!=te(a,n.getPath())?o.createRangeIn(o.schema.getLimitElement(c)):c}}return null}_selectAncestorWidget(){const e=this.editor,t=e.editing.mapper,i=e.editing.view.document.selection.getFirstPosition().parent,n=(i.is("$text")?i.parent:i).findAncestor(qh);if(!n)return!1;const o=t.toModelElement(n);return!!o&&(e.model.change((e=>{e.setSelection(o,"on")})),!0)}}const cm='',um='',dm=at("px");class hm extends ad{positionLimiter;visibleStack;_viewToStack=new Map;_idToStack=new Map;_view=null;_rotatorView=null;_fakePanelsView=null;static get pluginName(){return"ContextualBalloon"}static get isOfficialPlugin(){return!0}constructor(e){super(e),this.positionLimiter=()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},this.decorate("getPositionOptions"),this.set("visibleView",null),this.set("_numberOfStacks",0),this.set("_singleViewMode",!1)}destroy(){super.destroy(),this._view&&this._view.destroy(),this._rotatorView&&this._rotatorView.destroy(),this._fakePanelsView&&this._fakePanelsView.destroy()}get view(){return this._view||this._createPanelView(),this._view}hasView(e){return Array.from(this._viewToStack.keys()).includes(e)}add(e){if(this._view||this._createPanelView(),this.hasView(e.view))throw new x("contextualballoon-add-view-exist",[this,e]);const t=e.stackId||"main";if(!this._idToStack.has(t))return this._idToStack.set(t,new Map([[e.view,e]])),this._viewToStack.set(e.view,this._idToStack.get(t)),this._numberOfStacks=this._idToStack.size,void(this._visibleStack&&!e.singleViewMode||this.showStack(t));const i=this._idToStack.get(t);e.singleViewMode&&this.showStack(t),i.set(e.view,e),this._viewToStack.set(e.view,i),i===this._visibleStack&&this._showView(e)}remove(e){if(!this.hasView(e))throw new x("contextualballoon-remove-view-not-exist",[this,e]);const t=this._viewToStack.get(e);this._singleViewMode&&this.visibleView===e&&(this._singleViewMode=!1),this.visibleView===e&&(1===t.size?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(t.values())[t.size-2])),1===t.size?(this._idToStack.delete(this._getStackId(t)),this._numberOfStacks=this._idToStack.size):t.delete(e),this._viewToStack.delete(e)}updatePosition(e){e&&(this._visibleStack.get(this.visibleView).position=e),this.view.pin(this.getPositionOptions()),this._fakePanelsView.updatePosition()}getPositionOptions(){let e=Array.from(this._visibleStack.values()).pop().position;return e&&(e.limiter||(e=Object.assign({},e,{limiter:this.positionLimiter})),e=Object.assign({},e,{viewportOffsetConfig:{...this.editor.ui.viewportOffset,top:this.editor.ui.viewportOffset.visualTop}})),e}showStack(e){this.visibleStack=e;const t=this._idToStack.get(e);if(!t)throw new x("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}_createPanelView(){this._view=new qi(this.editor.locale),this.editor.ui.view.body.add(this._view),this._rotatorView=this._createRotatorView(),this._fakePanelsView=this._createFakePanelsView()}get _visibleStack(){return this._viewToStack.get(this.visibleView)}_getStackId(e){return Array.from(this._idToStack.entries()).find((t=>t[1]===e))[0]}_showNextStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)+1;e[t]||(t=0),this.showStack(this._getStackId(e[t]))}_showPrevStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)-1;e[t]||(t=e.length-1),this.showStack(this._getStackId(e[t]))}_createRotatorView(){const e=new mm(this.editor.locale),t=this.editor.locale.t;return this.view.content.add(e),e.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",((e,t)=>!t&&e>1)),e.on("change:isNavigationVisible",(()=>this.updatePosition()),{priority:"low"}),e.bind("counter").to(this,"visibleView",this,"_numberOfStacks",((e,i)=>{if(i<2)return"";const n=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[n,i])})),e.buttonNextView.on("execute",(()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()})),e.buttonPrevView.on("execute",(()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()})),e}_createFakePanelsView(){const e=new gm(this.editor.locale,this.view);return e.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",((e,t)=>!t&&e>=2?Math.min(e-1,2):0)),e.listenTo(this.view,"change:top",(()=>e.updatePosition())),e.listenTo(this.view,"change:left",(()=>e.updatePosition())),this.editor.ui.view.body.add(e),e}_showView({view:e,balloonClassName:t="",withArrow:i=!0,singleViewMode:n=!1}){this.view.class=t,this.view.withArrow=i,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this.getPositionOptions()),this._fakePanelsView.updatePosition(),n&&(this._singleViewMode=!0)}}class mm extends Hi{focusTracker;buttonPrevView;buttonNextView;content;constructor(e){super(e);const t=e.t,i=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new ei,this.buttonPrevView=this._createButtonView(t("Previous"),cm),this.buttonNextView=this._createButtonView(t("Next"),um),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-rotator"],"z-index":"-1"},children:[{tag:"div",attributes:{class:["ck-balloon-rotator__navigation",i.to("isNavigationVisible",(e=>e?"":"ck-hidden"))]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:i.to("counter")}]},this.buttonNextView]},{tag:"div",attributes:{class:"ck-balloon-rotator__content"},children:this.content}]})}render(){super.render(),this.focusTracker.add(this.element)}destroy(){super.destroy(),this.focusTracker.destroy()}showView(e){this.hideView(),this.content.add(e)}hideView(){this.content.clear()}_createButtonView(e,t){const i=new Bn(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i}}class gm extends Hi{content;_balloonPanelView;constructor(e,t){super(e);const i=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("height",0),this.set("width",0),this.set("numberOfPanels",0),this.content=this.createCollection(),this._balloonPanelView=t,this.setTemplate({tag:"div",attributes:{class:["ck-fake-panel",i.to("numberOfPanels",(e=>e?"":"ck-hidden"))],style:{top:i.to("top",dm),left:i.to("left",dm),width:i.to("width",dm),height:i.to("height",dm)}},children:this.content}),this.on("change:numberOfPanels",((e,t,i,n)=>{i>n?this._addPanels(i-n):this._removePanels(n-i),this.updatePosition()}))}_addPanels(e){for(;e--;){const e=new Hi;e.setTemplate({tag:"div"}),this.content.add(e),this.registerChild(e)}}_removePanels(e){for(;e--;){const e=this.content.last;this.content.remove(e),this.deregisterChild(e),e.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:e,left:t}=this._balloonPanelView,{width:i,height:n}=new Ze(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:i,height:n})}}}class fm extends ad{_toolbarDefinitions=new Map;_balloon;static get requires(){return[hm]}static get pluginName(){return"WidgetToolbarRepository"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",(t=>{(function(e){const t=e.getSelectedElement();return!(!t||!qh(t))})(e.editing.view.document.selection)&&t.stop()}),{priority:"high"})}this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui,"update",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const e of this._toolbarDefinitions.values())e.view.destroy()}register(e,{ariaLabel:t,items:i,getRelatedElement:n,balloonClassName:o="ck-toolbar-container",positions:s}){if(!i.length)return void A("widget-toolbar-no-items",{toolbarId:e});const r=this.editor,a=r.t,l=new Hu(r.locale);if(l.ariaLabel=t||a("Widget toolbar"),this._toolbarDefinitions.has(e))throw new x("widget-toolbar-duplicated",this,{toolbarId:e});const c={view:l,getRelatedElement:n,balloonClassName:o,itemsConfig:i,positions:s,initialized:!1};r.ui.addToolbar(l,{isContextual:!0,beforeFocus:()=>{const e=n(r.editing.view.document.selection);e&&this._showToolbar(c,e)},afterBlur:()=>{this._hideToolbar(c)}}),this._toolbarDefinitions.set(e,c)}_updateToolbarsVisibility(){let e=0,t=null,i=null;for(const n of this._toolbarDefinitions.values()){const o=n.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&o)if(this.editor.ui.focusTracker.isFocused){const s=o.getAncestors().length;s>e&&(e=s,t=o,i=n)}else this._isToolbarVisible(n)&&this._hideToolbar(n);else this._isToolbarInBalloon(n)&&this._hideToolbar(n)}i&&this._showToolbar(i,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?pm(this.editor,t,e.positions):this._isToolbarInBalloon(e)||(e.initialized||(e.initialized=!0,e.view.fillFromConfig(e.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:e.view,position:bm(this.editor,t,e.positions),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",(()=>{for(const t of this._toolbarDefinitions.values())if(this._isToolbarVisible(t)){const i=t.getRelatedElement(this.editor.editing.view.document.selection);pm(this.editor,i,e.positions)}})))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function pm(e,t,i){const n=e.plugins.get("ContextualBalloon"),o=bm(e,t,i);n.updatePosition(o)}function bm(e,t,i){const n=e.editing.view,o=qi.defaultPositions;return{target:n.domConverter.mapViewToDom(t),positions:i||[o.northArrowSouth,o.northArrowSouthWest,o.northArrowSouthEast,o.southArrowNorth,o.southArrowNorthWest,o.southArrowNorthEast,o.viewportStickyNorth]}}class wm extends(G()){_referenceCoordinates;_options;_originalWidth;_originalHeight;_originalWidthPercents;_aspectRatio;constructor(e){super(),this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=e,this._referenceCoordinates=null}get originalWidth(){return this._originalWidth}get originalHeight(){return this._originalHeight}get originalWidthPercents(){return this._originalWidthPercents}get aspectRatio(){return this._aspectRatio}begin(e,t,i){const n=new Ze(t);this.activeHandlePosition=function(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const i of t)if(e.classList.contains(`ck-widget__resizer__handle-${i}`))return i}(e),this._referenceCoordinates=function(e,t){const i=new Ze(e),n=t.split("-"),o={x:"right"==n[1]?i.right:i.left,y:"bottom"==n[0]?i.bottom:i.top};return o.x+=e.ownerDocument.defaultView.scrollX,o.y+=e.ownerDocument.defaultView.scrollY,o}(t,function(e){const t=e.split("-"),i={top:"bottom",bottom:"top",left:"right",right:"left"};return`${i[t[0]]}-${i[t[1]]}`}(this.activeHandlePosition)),this._originalWidth=n.width,this._originalHeight=n.height,this._aspectRatio=n.width/n.height;const o=i.style.width;o&&o.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(o):this._originalWidthPercents=function(e,t=new Ze(e)){const i=Xh(e);return i?t.width/i*100:0}(i,n)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}class vm extends Hi{constructor(){super();const e=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",e.to("_viewPosition",(e=>e?`ck-orientation-${e}`:""))],style:{display:e.if("_isVisible","none",(e=>!e))}},children:[{text:e.to("_label")}]})}_bindToState(e,t){this.bind("_isVisible").to(t,"proposedWidth",t,"proposedHeight",((e,t)=>null!==e&&null!==t)),this.bind("_label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",((t,i,n)=>"px"===e.unit?`${t}×${i}`:`${n}%`)),this.bind("_viewPosition").to(t,"activeHandlePosition",t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",((e,t,i)=>t<50||i<50?"above-center":e))}_dismiss(){this.unbind(),this._isVisible=!1}}class ym extends(G()){_state;_sizeView;_options;_viewResizerWrapper=null;_initialViewWidth;constructor(e){super(),this._options=e,this.set("isEnabled",!0),this.set("isSelected",!1),this.bind("isVisible").to(this,"isEnabled",this,"isSelected",((e,t)=>e&&t)),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",(e=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),e.stop())}),{priority:"high"})}get state(){return this._state}show(){this._options.editor.editing.view.change((e=>{e.removeClass("ck-hidden",this._viewResizerWrapper)}))}hide(){this._options.editor.editing.view.change((e=>{e.addClass("ck-hidden",this._viewResizerWrapper)}))}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change((i=>{const n=i.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(t){const i=this.toDomElement(t);return e._appendHandles(i),e._appendSizeUI(i),i}));i.insert(i.createPositionAt(t,"end"),n),i.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=n,this.isVisible||this.hide()})),this.on("change:isVisible",(()=>{this.isVisible?(this.show(),this.redraw()):this.hide()}))}begin(e){this._state=new wm(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(e,this._getHandleHost(),this._getResizeHost())}updateSize(e){const t=this._proposeNewSize(e);this._options.editor.editing.view.change((e=>{const i=this._options.unit||"%",n=("%"===i?t.widthPercents:t.width)+i;e.setStyle("width",n,this._options.viewElement)}));const i=this._getHandleHost(),n=new Ze(i),o=Math.round(n.width),s=Math.round(n.height),r=new Ze(i);t.width=Math.round(r.width),t.height=Math.round(r.height),this.redraw(n),this.state.update({...t,handleHostWidth:o,handleHostHeight:s})}commit(){const e=this._options.unit||"%",t=("%"===e?this.state.proposedWidthPercents:this.state.proposedWidth)+e;this._options.editor.editing.view.change((()=>{this._cleanup(),this._options.onCommit(t)}))}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(e){const t=this._domResizerWrapper;if(!((i=t)&&i.ownerDocument&&i.ownerDocument.contains(i)))return;var i;const n=t.parentElement,o=this._getHandleHost(),s=this._viewResizerWrapper,r=[s.getStyle("width"),s.getStyle("height"),s.getStyle("left"),s.getStyle("top")];let a;if(n.isSameNode(o)){const t=e||new Ze(o);a=[t.width+"px",t.height+"px",void 0,void 0]}else a=[o.offsetWidth+"px",o.offsetHeight+"px",o.offsetLeft+"px",o.offsetTop+"px"];"same"!==te(r,a)&&this._options.editor.editing.view.change((e=>{e.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},s)}))}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss(),this._options.editor.editing.view.change((e=>{e.setStyle("width",this._initialViewWidth,this._options.viewElement)}))}_proposeNewSize(e){const t=this.state,i=(o=e).pageX,n=o.pageY;var o;const s=!this._options.isCentered||this._options.isCentered(this),r={x:t._referenceCoordinates.x-(i+t.originalWidth),y:n-t.originalHeight-t._referenceCoordinates.y};s&&t.activeHandlePosition.endsWith("-right")&&(r.x=i-(t._referenceCoordinates.x+t.originalWidth)),s&&(r.x*=2);let a=Math.abs(t.originalWidth+r.x),l=Math.abs(t.originalHeight+r.y);return"width"==(a/t.aspectRatio>l?"width":"height")?l=a/t.aspectRatio:a=l*t.aspectRatio,{width:Math.round(a),height:Math.round(l),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*a*100)/100,100)}}_getResizeHost(){const e=this._domResizerWrapper.parentElement;return this._options.getResizeHost(e)}_getHandleHost(){const e=this._domResizerWrapper.parentElement;return this._options.getHandleHost(e)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const n of t)e.appendChild(new vi({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(i=n,`ck-widget__resizer__handle-${i}`)}}).render());var i}_appendSizeUI(e){this._sizeView=new vm,this._sizeView.render(),e.appendChild(this._sizeView.element)}}class _m extends ad{_resizers=new Map;_observer;_redrawSelectedResizerThrottled;static get pluginName(){return"WidgetResize"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.editing,t=n.window.document;this.set("selectedResizer",null),this.set("_activeResizer",null),e.view.addObserver(wc),this._observer=new($e()),this.listenTo(e.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(t,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(t,"mouseup",this._mouseUpListener.bind(this)),this._redrawSelectedResizerThrottled=Qi((()=>this.redrawSelectedResizer()),200),this.editor.ui.on("update",this._redrawSelectedResizerThrottled),this.editor.model.document.on("change",(()=>{for(const[e,t]of this._resizers)e.isAttached()||(this._resizers.delete(e),t.destroy())}),{priority:"lowest"}),this._observer.listenTo(n.window,"resize",this._redrawSelectedResizerThrottled);const i=this.editor.editing.view.document.selection;i.on("change",(()=>{const e=i.getSelectedElement(),t=this.getResizerByViewElement(e)||null;t?this.select(t):this.deselect()}))}redrawSelectedResizer(){this.selectedResizer&&this.selectedResizer.isVisible&&this.selectedResizer.redraw()}destroy(){super.destroy(),this._observer.stopListening();for(const e of this._resizers.values())e.destroy();this._redrawSelectedResizerThrottled.cancel()}select(e){this.deselect(),this.selectedResizer=e,this.selectedResizer.isSelected=!0}deselect(){this.selectedResizer&&(this.selectedResizer.isSelected=!1),this.selectedResizer=null}attachTo(e){const t=new ym(e),i=this.editor.plugins;if(t.attach(),i.has("WidgetToolbarRepository")){const e=i.get("WidgetToolbarRepository");t.on("begin",(()=>{e.forceDisabled("resize")}),{priority:"lowest"}),t.on("cancel",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"}),t.on("commit",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"})}this._resizers.set(e.viewElement,t);const n=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(n)==t&&this.select(t),t}getResizerByViewElement(e){return this._resizers.get(e)}_getResizerByHandle(e){for(const t of this._resizers.values())if(t.containsHandle(e))return t}_mouseDownListener(e,t){const i=t.domTarget;ym.isResizeHandle(i)&&(this._activeResizer=this._getResizerByHandle(i)||null,this._activeResizer&&(this._activeResizer.begin(i),e.stop(),t.preventDefault()))}_mouseMoveListener(e,t){this._activeResizer&&this._activeResizer.updateSize(t)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}const km=at("px");class Cm extends Hi{constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,left:null,top:null,width:null}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-clipboard-drop-target-line",e.if("isVisible","ck-hidden",(e=>!e))],style:{left:e.to("left",(e=>km(e))),top:e.to("top",(e=>km(e))),width:e.to("width",(e=>km(e)))}}})}}class xm extends ad{removeDropMarkerDelayed=ai((()=>this.removeDropMarker()),40);_updateDropMarkerThrottled=Qi((e=>this._updateDropMarker(e)),40);_reconvertMarkerThrottled=Qi((()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")}),0);_dropTargetLineView=new Cm;_domEmitter=new($e());_scrollables=new Map;static get pluginName(){return"DragDropTarget"}static get isOfficialPlugin(){return!0}init(){this._setupDropMarker()}destroy(){this._domEmitter.stopListening();for(const{resizeObserver:e}of this._scrollables.values())e.destroy();return this._updateDropMarkerThrottled.cancel(),this.removeDropMarkerDelayed.cancel(),this._reconvertMarkerThrottled.cancel(),super.destroy()}updateDropMarker(e,t,i,n,o,s){this.removeDropMarkerDelayed.cancel();const r=Am(this.editor,e,t,i,n,o,s);return r?s&&s.containsRange(r)||r&&!this.editor.model.canEditAt(r)?(this.removeDropMarker(),null):(this._updateDropMarkerThrottled(r),r):null}getFinalDropRange(e,t,i,n,o,s){const r=Am(this.editor,e,t,i,n,o,s);return this.removeDropMarker(),r}removeDropMarker(){const e=this.editor.model;this.removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),this._dropTargetLineView.isVisible=!1,e.markers.has("drop-target")&&e.change((e=>{e.removeMarker("drop-target")}))}_setupDropMarker(){const e=this.editor;e.ui.view.body.add(this._dropTargetLineView),e.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),e.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(t,{writer:i})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return this._dropTargetLineView.isVisible=!1,this._createDropTargetPosition(i);t.markerRange.isCollapsed?this._updateDropTargetLine(t.markerRange):this._dropTargetLineView.isVisible=!1}})}_updateDropMarker(e){const t=this.editor,i=t.model.markers;t.model.change((t=>{i.has("drop-target")?i.get("drop-target").getRange().isEqual(e)||t.updateMarker("drop-target",{range:e}):t.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})}))}_createDropTargetPosition(e){return e.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(e){const t=this.toDomElement(e);return t.append("⁠",e.createElement("span"),"⁠"),t}))}_updateDropTargetLine(e){const t=this.editor.editing,i=e.start.nodeBefore,o=e.start.nodeAfter,s=e.start.parent,r=i?t.mapper.toViewElement(i):null,a=r?t.view.domConverter.mapViewToDom(r):null,l=o?t.mapper.toViewElement(o):null,c=l?t.view.domConverter.mapViewToDom(l):null,u=t.mapper.toViewElement(s);if(!u)return;const d=t.view.domConverter.mapViewToDom(u),h=this._getScrollableRect(u),{scrollX:m,scrollY:g}=n.window,f=a?new Ze(a):null,p=c?new Ze(c):null,b=new Ze(d).excludeScrollbarsAndBorders(),w=f?f.bottom:b.top,v=p?p.top:b.bottom,y=n.window.getComputedStyle(d),_=w<=v?(w+v)/2:v;if(h.top<_&&_a.schema.checkChild(s,e)))){if(a.schema.checkChild(s,"$text"))return a.createRange(s);if(t)return Em(e,Pm(e,t.parent),n,o)}}}else if(a.schema.isInline(c))return Em(e,c,n,o);if(a.schema.isBlock(c))return Em(e,c,n,o);if(a.schema.checkChild(c,"$block")){const t=Array.from(c.getChildren()).filter((t=>t.is("element")&&!Tm(e,t)));let i=0,s=t.length;if(0==s)return a.createRange(a.createPositionAt(c,"end"));for(;i{i?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")})),r.isAndroid&&this.forceDisabled("noAndroidSupport"),e.plugins.has("BlockToolbar")){const t=e.plugins.get("BlockToolbar").buttonView.element;this._domEmitter.listenTo(t,"dragstart",((e,t)=>this._handleBlockDragStart(t))),this._domEmitter.listenTo(n.document,"dragover",((e,t)=>this._handleBlockDragging(t))),this._domEmitter.listenTo(n.document,"drop",((e,t)=>this._handleBlockDragging(t))),this._domEmitter.listenTo(n.document,"dragend",(()=>this._handleBlockDragEnd()),{useCapture:!0}),this.isEnabled&&t.setAttribute("draggable","true"),this.on("change:isEnabled",((e,i,n)=>{t.setAttribute("draggable",n?"true":"false")}))}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(e){if(!this.isEnabled)return;const t=this.editor.model,i=t.document.selection,n=this.editor.editing.view,o=Array.from(i.getSelectedBlocks()),s=t.createRange(t.createPositionBefore(o[0]),t.createPositionAfter(o[o.length-1]));t.change((e=>e.setSelection(s))),this._isBlockDragging=!0,n.focus(),n.getObserver(Dd).onDomEvent(e)}_handleBlockDragging(e){if(!this.isEnabled||!this._isBlockDragging)return;const t=e.clientX+("ltr"==this.editor.locale.contentLanguageDirection?100:-100),i=e.clientY,n=document.elementFromPoint(t,i),o=this.editor.editing.view;n&&n.closest(".ck-editor__editable")&&o.getObserver(Dd).onDomEvent({...e,type:e.type,dataTransfer:e.dataTransfer,target:n,clientX:t,clientY:i,preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}}class Vm extends ad{_draggedRange;_draggingUid;_draggableElement;_clearDraggableAttributesDelayed=ai((()=>this._clearDraggableAttributes()),40);_blockMode=!1;_domEmitter=new($e());_previewContainer;static get pluginName(){return"DragDrop"}static get isOfficialPlugin(){return!0}static get requires(){return[Qd,lm,xm,Im]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,t.addObserver(Dd),t.addObserver(yc),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",((e,t,i)=>{i?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((e,t,i)=>{i||this._finalizeDragging(!1)})),r.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._previewContainer&&this._previewContainer.remove(),this._domEmitter.stopListening(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,i=e.editing.view,o=i.document,s=e.plugins.get(xm);this.listenTo(o,"dragstart",((i,n)=>{if(n.target?.is("editableElement"))return void n.preventDefault();if(this._prepareDraggedRange(n.target),!this._draggedRange)return void n.preventDefault();this._draggingUid=_();const o=this.isEnabled&&e.model.canEditAt(this._draggedRange);n.dataTransfer.effectAllowed=o?"copyMove":"copy",n.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const s=t.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(n.dataTransfer,s,"dragstart");const{dataTransfer:r,domTarget:a,domEvent:l}=n,{clientX:c}=l;this._updatePreview({dataTransfer:r,domTarget:a,clientX:c}),n.stopPropagation(),o||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(o,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this._domEmitter.listenTo(n.document,"dragend",(()=>{this._blockMode=!1}),{useCapture:!0}),this.listenTo(o,"dragenter",(()=>{this.isEnabled&&i.focus()})),this.listenTo(o,"dragleave",(()=>{s.removeDropMarkerDelayed()})),this.listenTo(o,"dragging",((e,t)=>{if(!this.isEnabled)return void(t.dataTransfer.dropEffect="none");const{clientX:i,clientY:n}=t.domEvent;s.updateDropMarker(t.target,t.targetRanges,i,n,this._blockMode,this._draggedRange)?(this._draggedRange||(t.dataTransfer.dropEffect="copy"),r.isGecko||("copy"==t.dataTransfer.effectAllowed?t.dataTransfer.dropEffect="copy":["all","copyMove"].includes(t.dataTransfer.effectAllowed)&&(t.dataTransfer.dropEffect="move")),e.stop()):t.dataTransfer.dropEffect="none"}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get(xm);this.listenTo(t,"clipboardInput",((t,n)=>{if("drop"!=n.method)return;const{clientX:o,clientY:s}=n.domEvent,r=i.getFinalDropRange(n.target,n.targetRanges,o,s,this._blockMode,this._draggedRange);return r?(this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid=""),"move"==Om(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(r,!0)?(this._finalizeDragging(!1),void t.stop()):void(n.targetRanges=[e.editing.mapper.toViewRange(r)])):(this._finalizeDragging(!1),void t.stop())}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(Qd);e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i=t.targetRanges.map((e=>this.editor.editing.mapper.toModelRange(e)));this.editor.model.change((e=>e.setSelection(i)))}),{priority:"high"}),e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i="move"==Om(t.dataTransfer),n=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(n&&i)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"pointerdown",((n,o)=>{if(r.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let s=Rm(o.target);if(r.isBlink&&!e.isReadOnly&&!s&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();e&&qh(e)||(s=i.selection.editableElement)}s&&(t.change((e=>{e.setAttribute("draggable","true",s)})),this._draggableElement=e.editing.mapper.toModelElement(s))})),this.listenTo(i,"pointerup",(()=>{r.isAndroid||this._clearDraggableAttributesDelayed()}))}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change((t=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null}))}_finalizeDragging(e){const t=this.editor,i=t.model;t.plugins.get(xm).removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._previewContainer&&(this._previewContainer.remove(),this._previewContainer=void 0),this._draggedRange&&(e&&this.isEnabled&&i.change((e=>{const t=i.createSelection(this._draggedRange);i.deleteContent(t,{doNotAutoparagraph:!0});const n=t.getFirstPosition().parent;n.isEmpty&&!i.schema.checkChild(n,"$text")&&i.schema.checkChild(n,"paragraph")&&e.insertElement("paragraph",n,0)})),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(e){const t=this.editor,i=t.model,n=i.document.selection,o=e?Rm(e):null;if(o){const e=t.editing.mapper.toModelElement(o);return this._draggedRange=jr.fromRange(i.createRangeOn(e)),this._blockMode=i.schema.isBlock(e),void(t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop"))}if(n.isCollapsed&&!n.getFirstPosition().parent.isEmpty)return;const s=Array.from(n.getSelectedBlocks()),r=n.getFirstRange();if(0==s.length)return void(this._draggedRange=jr.fromRange(r));const a=Lm(i,s);if(s.length>1)this._draggedRange=jr.fromRange(a),this._blockMode=!0;else if(1==s.length){const e=r.start.isTouching(a.start)&&r.end.isTouching(a.end);this._draggedRange=jr.fromRange(e?a:r),this._blockMode=e}i.change((e=>e.setSelection(this._draggedRange.toRange())))}_updatePreview({dataTransfer:e,domTarget:t,clientX:i}){const o=this.editor.editing.view,s=o.document.selection.editableElement,a=o.domConverter.mapViewToDom(s),l=n.window.getComputedStyle(a);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=oe(n.document,"div",{style:"position: fixed; left: -999999px;"}),n.document.body.appendChild(this._previewContainer));const c=oe(n.document,"div");c.className="ck ck-content ck-clipboard-preview";const u=new Ze(a),d=parseFloat(l.paddingLeft),h=parseFloat(l.paddingRight),m=parseFloat(l.width)-d-h;if(a.contains(t)){if(!r.isiOS)return;c.style.maxWidth=`${m}px`,c.style.padding="10px",c.style.minWidth="200px",c.style.minHeight="20px",c.style.boxSizing="border-box",c.style.backgroundColor="var(--ck-color-base-background)"}else if(r.isiOS)c.style.width=`${m}px`,c.style.backgroundColor="var(--ck-color-base-background)";else{const e=u.left-i+d;c.style.width=`${m+e}px`,c.style.paddingLeft=`${e}px`}o.domConverter.setContentOf(c,e.getData("text/html")),e.setDragImage(c,0,0),this._previewContainer.appendChild(c)}}function Om(e){return r.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function Rm(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(qh);if(qh(e))return e;const t=e.findAncestor((e=>qh(e)||e.is("editableElement")));return qh(t)?t:null}function Lm(e,t){const i=t[0],n=t[t.length-1],o=i.getCommonAncestor(n),s=e.createPositionBefore(i),r=e.createPositionAfter(n);if(o&&o.is("element")&&!e.schema.isLimit(o)){const t=e.createRangeOn(o),i=s.isTouching(t.start),n=r.isTouching(t.end);if(i&&n)return Lm(e,[o])}return e.createRange(s,r)}class Bm extends ad{static get pluginName(){return"PastePlainText"}static get isOfficialPlugin(){return!0}static get requires(){return[Qd]}init(){const e=this.editor,t=e.model,i=e.editing.view,n=t.document.selection;i.addObserver(Dd),e.plugins.get(Qd).on("contentInsertion",((e,i)=>{(function(e,t){let i=t.createRangeIn(e);if(1==e.childCount){const n=e.getChild(0);n.is("element")&&t.schema.isBlock(n)&&!t.schema.isObject(n)&&!t.schema.isLimit(n)&&(i=t.createRangeIn(n))}for(const e of i.getItems()){if(!t.schema.isInline(e))return!1;if(Array.from(e.getAttributeKeys()).find((e=>t.schema.getAttributeProperties(e).isFormatting)))return!1}return!0})(i.content,t)&&t.change((e=>{const o=Array.from(n.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));n.isCollapsed||t.deleteContent(n,{doNotAutoparagraph:!0}),o.push(...n.getAttributes());const s=e.createRangeIn(i.content);for(const i of s.getItems())for(const n of o)t.schema.checkAttribute(i,n[0])&&e.setAttribute(n[0],n[1],i)}))}))}}class Mm extends ad{static get pluginName(){return"Clipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[Yd,Qd,Vm,Bm]}init(){const e=this.editor,t=this.editor.t;e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Copy selected content"),keystroke:"CTRL+C"},{label:t("Paste content"),keystroke:"CTRL+V"},{label:t("Paste content as plain text"),keystroke:"CTRL+SHIFT+V"}]})}}class Nm extends cd{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let i=e.schema.getLimitElement(t);if(t.containsEntireContent(i)||!Fm(e.schema,i))do{if(i=i.parent,!i)return}while(!Fm(e.schema,i));e.change((e=>{e.setSelection(i,"in")}))}}function Fm(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const Dm=Mt("Ctrl+A");class zm extends ad{static get pluginName(){return"SelectAllEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=e.editing.view.document;e.commands.add("selectAll",new Nm(e)),this.listenTo(i,"keydown",((t,i)=>{Bt(i)===Dm&&(e.execute("selectAll"),i.preventDefault())})),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Select all"),keystroke:"CTRL+A"}]})}}class Hm extends ad{static get pluginName(){return"SelectAllUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(()=>{const e=this._createButton(Bn);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add("menuBar:selectAll",(()=>this._createButton(Yu)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("selectAll"),o=new e(t.locale),s=i.t;return o.set({label:s("Select all"),icon:'',keystroke:"Ctrl+A"}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{t.execute("selectAll"),t.editing.view.focus()})),o}}class Um extends ad{static get requires(){return[zm,Hm]}static get pluginName(){return"SelectAll"}static get isOfficialPlugin(){return!0}}class $m extends cd{_stack=[];_createdBatches=new WeakSet;constructor(e){super(e),this.refresh(),this._isEnabledBasedOnSelection=!1,this.listenTo(e.data,"set",((e,t)=>{t[1]={...t[1]};const i=t[1];i.batchType||(i.batchType={isUndoable:!1})}),{priority:"high"}),this.listenTo(e.data,"set",((e,t)=>{t[1].batchType.isUndoable||this.clearStack()}))}refresh(){this.isEnabled=this._stack.length>0}get createdBatches(){return this._createdBatches}addBatch(e){const t=this.editor.model.document.selection,i={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:i}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,i){const n=this.editor.model,o=n.document,s=[],r=e.map((e=>e.getTransformedByOperations(i))),a=r.flat();for(const e of r){const t=e.filter((e=>e.root!=o.graveyard)).filter((e=>!jm(e,a)));t.length&&(qm(t),s.push(t[0]))}s.length&&n.change((e=>{e.setSelection(s,{backward:t})}))}_undo(e,t){const i=this.editor.model,n=i.document;this._createdBatches.add(t);const o=e.operations.slice().filter((e=>e.isDocumentOperation));o.reverse();for(const e of o){const o=e.baseVersion+1,s=Array.from(n.history.getOperations(o)),r=_l([e.getReversed()],s,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let o of r){const s=o.affectedSelectable;s&&!i.canEditAt(s)&&(o=new dl(o.baseVersion)),t.addOperation(o),i.applyOperation(o),n.history.setOperationAsUndone(e,o)}}}}function qm(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}class Wm extends $m{execute(e=null){const t=e?this._stack.findIndex((t=>t.batch==e)):this._stack.length-1,i=this._stack.splice(t,1)[0],n=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(n,(()=>{this._undo(i.batch,n);const e=this.editor.model.document.history.getOperations(i.batch.baseVersion);this._restoreSelection(i.selection.ranges,i.selection.isBackward,e)})),this.fire("revert",i.batch,n),this.refresh()}}class Gm extends $m{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(t,(()=>{const i=e.batch.operations[e.batch.operations.length-1].baseVersion+1,n=this.editor.model.document.history.getOperations(i);this._restoreSelection(e.selection.ranges,e.selection.isBackward,n),this._undo(e.batch,t)})),this.fire("revert",e.batch,t),this.refresh()}}class Km extends ad{_undoCommand;_redoCommand;_batchRegistry=new WeakSet;static get pluginName(){return"UndoEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;this._undoCommand=new Wm(e),this._redoCommand=new Gm(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",((e,t)=>{const i=t[0];if(!i.isDocumentOperation)return;const n=i.batch,o=this._redoCommand.createdBatches.has(n),s=this._undoCommand.createdBatches.has(n);this._batchRegistry.has(n)||(this._batchRegistry.add(n),n.isUndoable&&(o?this._undoCommand.addBatch(n):s||(this._undoCommand.addBatch(n),this._redoCommand.clearStack())))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((e,t,i)=>{this._redoCommand.addBatch(i)})),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Undo"),keystroke:"CTRL+Z"},{label:t("Redo"),keystroke:[["CTRL+Y"],["CTRL+SHIFT+Z"]]}]})}}const Jm='',Ym='';class Qm extends ad{static get pluginName(){return"UndoUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?Jm:Ym,o="ltr"==t.uiLanguageDirection?Ym:Jm;this._addButtonsToFactory("undo",i("Undo"),"CTRL+Z",n),this._addButtonsToFactory("redo",i("Redo"),"CTRL+Y",o)}_addButtonsToFactory(e,t,i,n){const o=this.editor;o.ui.componentFactory.add(e,(()=>{const o=this._createButton(Bn,e,t,i,n);return o.set({tooltip:!0}),o})),o.ui.componentFactory.add("menuBar:"+e,(()=>this._createButton(Yu,e,t,i,n)))}_createButton(e,t,i,n,o){const s=this.editor,r=s.locale,a=s.commands.get(t),l=new e(r);return l.set({label:i,icon:o,keystroke:n}),l.bind("isEnabled").to(a,"isEnabled"),this.listenTo(l,"execute",(()=>{s.execute(t),s.editing.view.focus()})),l}}class Xm extends ad{static get requires(){return[Km,Qm]}static get pluginName(){return"Undo"}static get isOfficialPlugin(){return!0}}const Zm='';class eg extends ad{view;static _visibleDialogPlugin;_onHide;static get pluginName(){return"Dialog"}static get isOfficialPlugin(){return!0}constructor(e){super(e);const t=e.t;this._initShowHideListeners(),this._initFocusToggler(),this._initMultiRootIntegration(),this.set({id:null,isOpen:!1}),e.accessibility.addKeystrokeInfos({categoryId:"navigation",keystrokes:[{label:t("Move focus in and out of an active dialog window"),keystroke:"Ctrl+F6",mayRequireFn:!0}]})}destroy(){super.destroy(),eg._visibleDialogPlugin===this&&this._unlockBodyScroll()}_initShowHideListeners(){this.on("show",((e,t)=>{this._show(t)})),this.on("show",((e,t)=>{t.onShow&&t.onShow(this)}),{priority:"low"}),this.on("hide",(()=>{eg._visibleDialogPlugin&&eg._visibleDialogPlugin._hide()})),this.on("hide",(()=>{this._onHide&&(this._onHide(this),this._onHide=void 0)}),{priority:"low"})}_initFocusToggler(){const e=this.editor;e.keystrokes.set("Ctrl+F6",((t,i)=>{this.isOpen&&!this.view.isModal&&(this.view.focusTracker.isFocused?e.editing.view.focus():this.view.focus(),i())}))}_initMultiRootIntegration(){const e=this.editor.model;e.document.on("change:data",(()=>{if(!this.view)return;const t=e.document.differ.getChangedRoots();for(const e of t)e.state&&this.view.updatePosition()}))}show(e){this.hide(),this.fire(`show:${e.id}`,e)}_show({id:e,icon:t,title:i,hasCloseButton:n=!0,content:o,actionButtons:s,className:r,isModal:a,position:l,onHide:c,keystrokeHandlerOptions:u}){const d=this.editor;this.view=new Gn(d.locale,{getCurrentDomRoot:()=>d.editing.view.getDomRoot(d.model.document.selection.anchor.root.rootName),getViewportOffset:()=>d.ui.viewportOffset,keystrokeHandlerOptions:u});const h=this.view;h.on("close",(()=>{this.hide()})),d.ui.view.body.add(h),d.keystrokes.listenTo(h.element),l||(l=a?$n:qn),a&&this._lockBodyScroll(),h.set({position:l,_isVisible:!0,className:r,isModal:a}),h.setupParts({icon:t,title:i,hasCloseButton:n,content:o,actionButtons:s}),this.id=e,c&&(this._onHide=c),this.isOpen=!0,eg._visibleDialogPlugin=this}hide(){eg._visibleDialogPlugin&&eg._visibleDialogPlugin.fire(`hide:${eg._visibleDialogPlugin.id}`)}_hide(){if(!this.view)return;const e=this.editor,t=this.view;t.isModal&&this._unlockBodyScroll(),t.contentView&&t.contentView.reset(),e.ui.view.body.remove(t),e.ui.focusTracker.remove(t.element),e.keystrokes.stopListening(t.element),t.destroy(),e.editing.view.focus(),this.id=null,this.isOpen=!1,eg._visibleDialogPlugin=null}_lockBodyScroll(){document.documentElement.classList.add("ck-dialog-scroll-locked")}_unlockBodyScroll(){document.documentElement.classList.remove("ck-dialog-scroll-locked")}}class tg extends Hi{constructor(e,t){super(e);const i=e.t,n=new du;n.text=i("Help Contents. To close this dialog press ESC."),this.setTemplate({tag:"div",attributes:{class:["ck","ck-accessibility-help-dialog__content"],"aria-labelledby":n.id,role:"document",tabindex:-1},children:[oe(document,"p",{},i("Below, you can find a list of keyboard shortcuts that can be used in the editor.")),...this._createCategories(Array.from(t.values())),n]})}focus(){this.element.focus()}_createCategories(e){return e.map((e=>{const t=[oe(document,"h3",{},e.label),...Array.from(e.groups.values()).map((e=>this._createGroup(e))).flat()];return e.description&&t.splice(1,0,oe(document,"p",{},e.description)),oe(document,"section",{},t)}))}_createGroup(e){const t=e.keystrokes.sort(((e,t)=>e.label.localeCompare(t.label))).map((e=>this._createGroupRow(e))).flat(),i=[oe(document,"dl",{},t)];return e.label&&i.unshift(oe(document,"h4",{},e.label)),i}_createGroupRow(e){const t=this.locale.t,i=oe(document,"dt"),n=oe(document,"dd"),o="string"==typeof(a=e.keystroke)?[[a]]:"string"==typeof a[0]?[a]:a,s=[];var a;for(const e of o)s.push(e.map(ig).join(""));return i.innerHTML=e.label,n.innerHTML=s.join(", ")+(e.mayRequireFn&&r.isMac?` ${t("(may require Fn)")}`:""),[i,n]}}function ig(e){return Nt(e).split("+").map((e=>`${e}`)).join("+")}class ng extends ad{contentView=null;static get requires(){return[eg]}static get pluginName(){return"AccessibilityHelp"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t;e.ui.componentFactory.add("accessibilityHelp",(()=>{const e=this._createButton(Bn);return e.set({tooltip:!0,withText:!1,label:t("Accessibility help")}),e})),e.ui.componentFactory.add("menuBar:accessibilityHelp",(()=>{const e=this._createButton(Yu);return e.label=t("Accessibility"),e})),e.keystrokes.set("Alt+0",((e,t)=>{this._toggleDialog(),t()})),this._setupRootLabels()}_createButton(e){const t=this.editor,i=t.plugins.get("Dialog"),n=new e(t.locale);return n.set({keystroke:"Alt+0",icon:Zm,isToggleable:!0}),n.on("execute",(()=>this._toggleDialog())),n.bind("isOn").to(i,"id",(e=>"accessibilityHelp"===e)),n}_setupRootLabels(){const e=this.editor,t=e.editing.view,i=e.t;function n(e,t){const n=[t.getAttribute("aria-label"),i("Press %0 for help.",[Nt("Alt+0")])].filter((e=>e)).join(". ");e.setAttribute("aria-label",n,t)}e.ui.on("ready",(()=>{t.change((e=>{for(const i of t.document.roots)n(e,i)})),e.on("addRoot",((i,o)=>{const s=e.editing.view.document.getRoot(o.rootName);t.change((e=>n(e,s)))}),{priority:"low"})}))}_toggleDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.locale.t;this.contentView||(this.contentView=new tg(e.locale,e.accessibility.keystrokeInfos)),"accessibilityHelp"===t.id?t.hide():t.show({id:"accessibilityHelp",className:"ck-accessibility-help-dialog",title:i("Accessibility help"),icon:Zm,hasCloseButton:!0,content:this.contentView})}}class og extends(G()){total;_reader;_data;constructor(){super();const e=new window.FileReader;this._reader=e,this._data=void 0,this.set("loaded",0),e.onprogress=e=>{this.loaded=e.loaded}}get error(){return this._reader.error}get data(){return this._data}read(e){const t=this._reader;return this.total=e.size,new Promise(((i,n)=>{t.onload=()=>{const e=t.result;this._data=e,i(e)},t.onerror=()=>{n("error")},t.onabort=()=>{n("aborted")},this._reader.readAsDataURL(e)}))}abort(){this._reader.abort()}}class sg extends ad{loaders=new Xt;_loadersMap=new Map;_pendingAction=null;static get pluginName(){return"FileRepository"}static get isOfficialPlugin(){return!0}static get requires(){return[Md]}init(){this.loaders.on("change",(()=>this._updatePendingAction())),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0))}getLoader(e){return this._loadersMap.get(e)||null}createLoader(e){if(!this.createUploadAdapter)return A("filerepository-no-upload-adapter"),null;const t=new rg(Promise.resolve(e),this.createUploadAdapter);return this.loaders.add(t),this._loadersMap.set(e,t),e instanceof Promise&&t.file.then((e=>{this._loadersMap.set(e,t)})).catch((()=>{})),t.on("change:uploaded",(()=>{let e=0;for(const t of this.loaders)e+=t.uploaded;this.uploaded=e})),t.on("change:uploadTotal",(()=>{let e=0;for(const t of this.loaders)t.uploadTotal&&(e+=t.uploadTotal);this.uploadTotal=e})),t}destroyLoader(e){const t=e instanceof rg?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach(((e,i)=>{e===t&&this._loadersMap.delete(i)}))}_updatePendingAction(){const e=this.editor.plugins.get(Md);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,i=e=>`${t("Upload in progress")} ${parseInt(e)}%.`;this._pendingAction=e.add(i(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",i)}}else e.remove(this._pendingAction),this._pendingAction=null}}class rg extends(G()){id;_filePromiseWrapper;_adapter;_reader;constructor(e,t){super(),this.id=_(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new og,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0)),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then((e=>this._filePromiseWrapper?e:null)):Promise.resolve(null)}get data(){return this._reader.data}read(){if("idle"!=this.status)throw new x("filerepository-read-wrong-status",this);return this.status="reading",this.file.then((e=>this._reader.read(e))).then((e=>{if("reading"!==this.status)throw this.status;return this.status="idle",e})).catch((e=>{if("aborted"===e)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:e}))}upload(){if("idle"!=this.status)throw new x("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then((()=>this._adapter.upload())).then((e=>(this.uploadResponse=e,this.status="idle",e))).catch((e=>{if("aborted"===this.status)throw"aborted";throw this.status="error",e}))}abort(){const e=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==e?this._reader.abort():"uploading"==e&&this._adapter.abort&&this._adapter.abort():(this._filePromiseWrapper.promise.catch((()=>{})),this._filePromiseWrapper.rejecter("aborted")),this._destroy()}_destroy(){this._filePromiseWrapper=void 0,this._reader=void 0,this._adapter=void 0,this.uploadResponse=void 0}_createFilePromiseWrapper(e){const t={};return t.promise=new Promise(((i,n)=>{t.rejecter=n,t.isFulfilled=!1,e.then((e=>{t.isFulfilled=!0,i(e)})).catch((e=>{t.isFulfilled=!0,n(e)}))})),t}}class ag{loader;options;xhr;constructor(e,t){this.loader=e,this.options=t}upload(){return this.loader.file.then((e=>new Promise(((t,i)=>{this._initRequest(),this._initListeners(t,i,e),this._sendRequest(e)}))))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.options.uploadUrl,!0),e.responseType="json"}_initListeners(e,t,i){const n=this.xhr,o=this.loader,s=`Couldn't upload file: ${i.name}.`;n.addEventListener("error",(()=>t(s))),n.addEventListener("abort",(()=>t())),n.addEventListener("load",(()=>{const i=n.response;if(!i||i.error)return t(i&&i.error&&i.error.message?i.error.message:s);const o=i.url?{default:i.url}:i.urls;e({...i,urls:o})})),n.upload&&n.upload.addEventListener("progress",(e=>{e.lengthComputable&&(o.uploadTotal=e.total,o.uploaded=e.loaded)}))}_sendRequest(e){let t=this.options.headers||{};"function"==typeof t&&(t=t(e));const i=this.options.withCredentials||!1;for(const e of Object.keys(t))this.xhr.setRequestHeader(e,t[e]);this.xhr.withCredentials=i;const n=new FormData;n.append("upload",e),this.xhr.send(n)}}const lg="ckCsrfToken";class cg{loader;url;t;xhr;constructor(e,t,i){this.loader=e,this.url=t,this.t=i}upload(){return this.loader.file.then((e=>new Promise(((t,i)=>{this._initRequest(),this._initListeners(t,i,e),this._sendRequest(e)}))))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.url,!0),e.responseType="json"}_initListeners(e,t,i){const n=this.xhr,o=this.loader,s=(0,this.t)("Cannot upload file:")+` ${i.name}.`;n.addEventListener("error",(()=>t(s))),n.addEventListener("abort",(()=>t())),n.addEventListener("load",(()=>{const i=n.response;if(!i||!i.uploaded)return t(i&&i.error&&i.error.message?i.error.message:s);e({default:i.url})})),n.upload&&n.upload.addEventListener("progress",(e=>{e.lengthComputable&&(o.uploadTotal=e.total,o.uploaded=e.loaded)}))}_sendRequest(e){const t=new FormData;t.append("upload",e),t.append("ckCsrfToken",function(){let e=function(e){e=e.toLowerCase();const t=document.cookie.split(";");for(const i of t){const t=i.split("=");if(decodeURIComponent(t[0].trim().toLowerCase())===e)return decodeURIComponent(t[1])}return null}(lg);var t,i;return e&&40==e.length||(e=function(){let e="";const t=new Uint8Array(40);window.crypto.getRandomValues(t);for(let i=0;i.5?n.toUpperCase():n}return e}(),t=lg,i=e,document.cookie=encodeURIComponent(t)+"="+encodeURIComponent(i)+";path=/"),e}()),this.xhr.send(t)}}function ug(e,t,i,n){let o,s=null;"function"==typeof n?o=n:(s=e.commands.get(n),o=()=>{e.execute(n)}),e.model.document.on("change:data",((r,a)=>{if(s&&!s.isEnabled||!t.isEnabled)return;const l=Zt(e.model.document.selection.getRanges());if(!l.isCollapsed)return;if(a.isUndo||!a.isLocal)return;const c=Array.from(e.model.document.differ.getChanges()),u=c[0];if(1!=c.length||"insert"!==u.type||"$text"!=u.name||1!=u.length)return;const d=u.position.parent;if(d.is("element","codeBlock"))return;if(d.is("element","listItem")&&"function"!=typeof n&&!["numberedList","bulletedList","todoList"].includes(n))return;if(s&&!0===s.value)return;const h=d.getChild(0),m=e.model.createRangeOn(h);if(!m.containsRange(l)&&!l.end.isEqual(m.end))return;const g=i.exec(h.data.substr(0,l.end.offset));g&&e.model.enqueueChange((t=>{const i=e.model.document.selection,n=t.createPositionAt(d,0),s=t.createPositionAt(d,g[0].length),r=new jr(n,s);if(!1!==o({match:g})){const e=Array.from(i.getAttributes());t.remove(r);const n=i.getFirstRange(),o=t.createRangeIn(d);!d.isEmpty||o.isEqual(n)||o.containsRange(n,!0)||t.remove(d),function(e,t,i){const n=e.model.schema,o=t.getFirstPosition();let s=new Pa(o);n.checkChild(s,"$text")&&(s=s.push("$text"));for(const[t,o]of i)n.checkAttribute(s,t)&&e.setSelectionAttribute(t,o)}(t,i,e)}r.detach(),e.model.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}))}))}function dg(e,t,i,n){let o,s;i instanceof RegExp?o=i:s=i,s=s||(e=>{let t;const i=[],n=[];for(;null!==(t=o.exec(e))&&!(t&&t.length<4);){let{index:e,1:o,2:s,3:r}=t;const a=o+s+r;e+=t[0].length-a.length;const l=[e,e+o.length],c=[e+o.length+s.length,e+o.length+s.length+r.length];i.push(l),i.push(c),n.push([e+o.length,e+o.length+s.length])}return{remove:i,format:n}}),e.model.document.on("change:data",((i,o)=>{if(o.isUndo||!o.isLocal||!t.isEnabled)return;const r=e.model,a=r.document.selection;if(!a.isCollapsed)return;const l=Array.from(r.document.differ.getChanges()),c=l[0];if(1!=l.length||"insert"!==c.type||"$text"!=c.name||1!=c.length)return;const u=a.focus,d=u.parent,{text:h,range:m}=function(e,t){let i=e.start;return{text:Array.from(e.getItems()).reduce(((e,n)=>!n.is("$text")&&!n.is("$textProxy")||n.getAttribute("code")?(i=t.createPositionAfter(n),""):e+n.data),""),range:t.createRange(i,e.end)}}(r.createRange(r.createPositionAt(d,0),u),r),g=s(h),f=hg(m.start,g.format,r),p=hg(m.start,g.remove,r);f.length&&p.length&&r.enqueueChange((t=>{if(!1!==n(t,f)){for(const e of p.reverse())t.remove(e);r.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}}))}))}function hg(e,t,i){return t.filter((e=>void 0!==e[0]&&void 0!==e[1])).map((t=>i.createRange(e.getShiftedBy(t[0]),e.getShiftedBy(t[1]))))}function mg(e,t){return(i,n)=>{if(!e.commands.get(t).isEnabled)return!1;const o=e.model.schema.getValidRanges(n,t);for(const e of o)i.setAttribute(t,!0,e);i.removeSelectionAttribute(t)}}class gg extends cd{attributeKey;constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,!0):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(i.getRanges(),this.attributeKey,{includeEmptyRanges:!0});for(const t of o){let i=t,o=this.attributeKey;t.isCollapsed&&(i=t.start.parent,o=Yr._getStoreAttributeKey(this.attributeKey)),n?e.setAttribute(o,n,i):e.removeAttribute(o,i)}}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.hasAttribute(this.attributeKey);for(const e of i.getRanges())for(const i of e.getItems())if(t.checkAttribute(i,this.attributeKey))return i.hasAttribute(this.attributeKey);return!1}}const fg="bold";class pg extends ad{static get pluginName(){return"BoldEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:fg}),e.model.schema.setAttributeProperties(fg,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:fg,view:"strong",upcastAlso:["b",e=>{const t=e.getStyle("font-weight");return t&&("bold"==t||Number(t)>=600)?{name:!0,styles:["font-weight"]}:null}]}),e.commands.add(fg,new gg(e,fg)),e.keystrokes.set("CTRL+B",fg),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Bold text"),keystroke:"CTRL+B"}]})}}function bg({editor:e,commandName:t,plugin:i,icon:n,label:o,keystroke:s}){return r=>{const a=e.commands.get(t),l=new r(e.locale);return l.set({label:o,icon:n,keystroke:s,isToggleable:!0}),l.bind("isEnabled").to(a,"isEnabled"),l.bind("isOn").to(a,"value"),l instanceof Yu?l.set({role:"menuitemcheckbox"}):l.set({tooltip:!0}),i.listenTo(l,"execute",(()=>{e.execute(t),e.editing.view.focus()})),l}}const wg="bold";class vg extends ad{static get pluginName(){return"BoldUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=bg({editor:e,commandName:wg,plugin:this,icon:Fu,label:t("Bold"),keystroke:"CTRL+B"});e.ui.componentFactory.add(wg,(()=>i(Bn))),e.ui.componentFactory.add("menuBar:"+wg,(()=>i(Yu)))}}const yg="italic";class _g extends ad{static get pluginName(){return"ItalicEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:yg}),e.model.schema.setAttributeProperties(yg,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:yg,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add(yg,new gg(e,yg)),e.keystrokes.set("CTRL+I",yg),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Italic text"),keystroke:"CTRL+I"}]})}}const kg="italic";class Cg extends ad{static get pluginName(){return"ItalicUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=bg({editor:e,commandName:kg,plugin:this,icon:'',keystroke:"CTRL+I",label:t("Italic")});e.ui.componentFactory.add(kg,(()=>i(Bn))),e.ui.componentFactory.add("menuBar:"+kg,(()=>i(Yu)))}}const xg="underline";class Ag extends ad{static get pluginName(){return"UnderlineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:xg}),e.model.schema.setAttributeProperties(xg,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:xg,view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),e.commands.add(xg,new gg(e,xg)),e.keystrokes.set("CTRL+U","underline"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Underline text"),keystroke:"CTRL+U"}]})}}const Tg="underline";class Eg extends ad{static get pluginName(){return"UnderlineUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=bg({editor:e,commandName:Tg,plugin:this,icon:'',label:t("Underline"),keystroke:"CTRL+U"});e.ui.componentFactory.add(Tg,(()=>i(Bn))),e.ui.componentFactory.add("menuBar:"+Tg,(()=>i(Yu)))}}const Sg="strikethrough";class Pg extends ad{static get pluginName(){return"StrikethroughEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:Sg}),e.model.schema.setAttributeProperties(Sg,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Sg,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),e.commands.add(Sg,new gg(e,Sg)),e.keystrokes.set("CTRL+SHIFT+X","strikethrough"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Strikethrough text"),keystroke:"CTRL+SHIFT+X"}]})}}const Ig="strikethrough";class Vg extends ad{static get pluginName(){return"StrikethroughUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=bg({editor:e,commandName:Ig,plugin:this,icon:'',keystroke:"CTRL+SHIFT+X",label:t("Strikethrough")});e.ui.componentFactory.add(Ig,(()=>i(Bn))),e.ui.componentFactory.add("menuBar:"+Ig,(()=>i(Yu)))}}const Og="code";class Rg extends ad{static get pluginName(){return"CodeEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[wh]}init(){const e=this.editor,t=this.editor.t;e.model.schema.extend("$text",{allowAttributes:Og}),e.model.schema.setAttributeProperties(Og,{isFormatting:!0,copyOnEnter:!1}),e.conversion.attributeToElement({model:Og,view:"code"}),e.commands.add(Og,new gg(e,Og)),e.plugins.get(wh).registerAttribute(Og),Ph(e,Og,"code","ck-code_selected"),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Move out of an inline code style"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}}const Lg="code";class Bg extends ad{static get pluginName(){return"CodeUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=bg({editor:e,commandName:Lg,plugin:this,icon:'',label:t("Code")});e.ui.componentFactory.add(Lg,(()=>i(Bn))),e.ui.componentFactory.add("menuBar:"+Lg,(()=>i(Yu)))}}const Mg="subscript";class Ng extends ad{static get pluginName(){return"SubscriptEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Mg}),e.model.schema.setAttributeProperties(Mg,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Mg,view:"sub",upcastAlso:[{styles:{"vertical-align":"sub"}}]}),e.commands.add(Mg,new gg(e,Mg))}}const Fg="subscript";class Dg extends ad{static get pluginName(){return"SubscriptUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=bg({editor:e,commandName:Fg,plugin:this,icon:'',label:t("Subscript")});e.ui.componentFactory.add(Fg,(()=>i(Bn))),e.ui.componentFactory.add("menuBar:"+Fg,(()=>i(Yu)))}}const zg="superscript";class Hg extends ad{static get pluginName(){return"SuperscriptEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:zg}),e.model.schema.setAttributeProperties(zg,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:zg,view:"sup",upcastAlso:[{styles:{"vertical-align":"super"}}]}),e.commands.add(zg,new gg(e,zg))}}const Ug="superscript";class $g extends ad{static get pluginName(){return"SuperscriptUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=bg({editor:e,commandName:Ug,plugin:this,icon:'',label:t("Superscript")});e.ui.componentFactory.add(Ug,(()=>i(Bn))),e.ui.componentFactory.add("menuBar:"+Ug,(()=>i(Yu)))}}class qg extends cd{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,n=t.document.selection,o=Array.from(n.getSelectedBlocks()),s=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(s){const t=o.filter((e=>jg(e)||Gg(i,e)));this._applyQuote(e,t)}else this._removeQuote(e,o.filter(jg))}))}_getValue(){const e=Zt(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!jg(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=Zt(e.getSelectedBlocks());return!!i&&Gg(t,i)}_removeQuote(e,t){Wg(e,t).reverse().forEach((t=>{if(t.start.isAtStart&&t.end.isAtEnd)return void e.unwrap(t.start.parent);if(t.start.isAtStart){const i=e.createPositionBefore(t.start.parent);return void e.move(t,i)}t.end.isAtEnd||e.split(t.end);const i=e.createPositionAfter(t.end.parent);e.move(t,i)}))}_applyQuote(e,t){const i=[];Wg(e,t).reverse().forEach((t=>{let n=jg(t.start);n||(n=e.createElement("blockQuote"),e.wrap(t,n)),i.push(n)})),i.reverse().reduce(((t,i)=>t.nextSibling==i?(e.merge(e.createPositionAfter(t)),t):i))}}function jg(e){return"blockQuote"==e.parent.name?e.parent:null}function Wg(e,t){let i,n=0;const o=[];for(;n{const n=e.model.document.differ.getChanges();for(const e of n)if("insert"==e.type){const n=e.position.nodeAfter;if(!n)continue;if(n.is("element","blockQuote")&&n.isEmpty)return i.remove(n),!0;if(n.is("element","blockQuote")&&!t.checkChild(e.position,n))return i.unwrap(n),!0;if(n.is("element")){const e=i.createRangeIn(n);for(const n of e.getItems())if(n.is("element","blockQuote")&&!t.checkChild(i.createPositionBefore(n),n))return i.unwrap(n),!0}}else if("remove"==e.type){const t=e.position.parent;if(t.is("element","blockQuote")&&t.isEmpty)return i.remove(t),!0}return!1}));const i=this.editor.editing.view.document,n=e.model.document.selection,o=e.commands.get("blockQuote");this.listenTo(i,"enter",((t,i)=>{n.isCollapsed&&o.value&&n.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"}),this.listenTo(i,"delete",((t,i)=>{if("backward"!=i.direction||!n.isCollapsed||!o.value)return;const s=n.getLastPosition().parent;s.isEmpty&&!s.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"})}}class Jg extends ad{static get pluginName(){return"BlockQuoteUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("blockQuote",(()=>{const e=this._createButton(Bn);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add("menuBar:blockQuote",(()=>{const e=this._createButton(Yu);return e.set({role:"menuitemcheckbox"}),e}))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("blockQuote"),o=new e(t.locale),s=i.t;return o.set({label:s("Block quote"),icon:'',isToggleable:!0}),o.bind("isEnabled").to(n,"isEnabled"),o.bind("isOn").to(n,"value"),this.listenTo(o,"execute",(()=>{t.execute("blockQuote"),t.editing.view.focus()})),o}}class Yg extends cd{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=Zt(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&Qg(t,e.schema)}execute(e={}){const t=this.editor.model,i=t.document,n=e.selection||i.selection;t.canEditAt(n)&&t.change((e=>{const i=n.getSelectedBlocks();for(const n of i)!n.is("element","paragraph")&&Qg(n,t.schema)&&e.rename(n,"paragraph")}))}}function Qg(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class Xg extends cd{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,i=e.attributes;let n=e.position;return t.canEditAt(n)?t.change((e=>{if(n=this._findPositionToInsertParagraph(n,e),!n)return null;const o=e.createElement("paragraph");return i&&t.schema.setAllowedAttributes(o,i,e),t.insertContent(o,n),e.setSelection(o,"in"),e.createPositionAt(o,0)})):null}_findPositionToInsertParagraph(e,t){const i=this.editor.model;if(i.schema.checkChild(e,"paragraph"))return e;const n=i.schema.findAllowedParent(e,"paragraph");if(!n)return null;const o=e.parent,s=i.schema.checkChild(o,"$text");return o.isEmpty||s&&e.isAtEnd?i.createPositionAfter(o):!o.isEmpty&&s&&e.isAtStart?i.createPositionBefore(o):t.split(e,n).position}}class Zg extends ad{static get pluginName(){return"Paragraph"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new Yg(e)),e.commands.add("insertParagraph",new Xg(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>Zg.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}static paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"])}class ef extends cd{modelElements;constructor(e,t){super(e),this.modelElements=t}refresh(){const e=Zt(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>tf(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,i=t.document,n=e.value;t.change((e=>{const o=Array.from(i.selection.getSelectedBlocks()).filter((e=>tf(e,n,t.schema)));for(const t of o)t.is("element",n)||e.rename(t,n)}))}}function tf(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const nf="paragraph";class of extends ad{static get pluginName(){return"HeadingEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[Zg]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const n of t)"paragraph"!==n.model&&(e.model.schema.register(n.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(n),i.push(n.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new ef(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,n)=>{const o=e.model.document.selection.getFirstPosition().parent;i.some((e=>o.is("element",e.model)))&&!o.is("element",nf)&&0===o.childCount&&n.writer.rename(o,nf)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:k.low+1})}}class sf extends(G()){constructor(e,t){super(),t&&Qs(this,t),e&&this.set(e)}}class rf extends ad{static get pluginName(){return"HeadingUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=function(e){const t=e.t,i={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map((e=>{const t=i[e.title];return t&&t!=e.title&&(e.title=t),e}))}(e),n=t("Choose heading"),o=t("Heading");e.ui.componentFactory.add("heading",(t=>{const s={},r=new Xt,a=e.commands.get("heading"),l=e.commands.get("paragraph"),c=[a];for(const e of i){const t={type:"button",model:new sf({label:e.title,class:e.class,role:"menuitemradio",withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(l,"value"),t.model.set("commandName","paragraph"),c.push(l)):(t.model.bind("isOn").to(a,"value",(t=>t===e.model)),t.model.set({commandName:"heading",commandValue:e.model})),r.add(t),s[e.model]=e.title}const u=Pu(t);return Ou(u,r,{ariaLabel:o,role:"menu"}),u.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),u.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),u.bind("isEnabled").toMany(c,"isEnabled",((...e)=>e.some((e=>e)))),u.buttonView.bind("label").to(a,"value",l,"value",((e,t)=>{const i=t?"paragraph":e;return"boolean"==typeof i?n:s[i]?s[i]:n})),u.buttonView.bind("ariaLabel").to(a,"value",l,"value",((e,t)=>{const i=t?"paragraph":e;return"boolean"==typeof i?o:s[i]?`${s[i]}, ${o}`:o})),this.listenTo(u,"execute",(t=>{const{commandName:i,commandValue:n}=t.source;e.execute(i,n?{value:n}:void 0),e.editing.view.focus()})),u})),e.ui.componentFactory.add("menuBar:heading",(n=>{const o=new Gu(n),s=e.commands.get("heading"),r=e.commands.get("paragraph"),a=[s],l=new Ku(n);o.set({class:"ck-heading-dropdown"}),l.set({ariaLabel:t("Heading"),role:"menu"}),o.buttonView.set({label:t("Heading")}),o.panelView.children.add(l);for(const t of i){const i=new hn(n,o),c=new Yu(n);i.children.add(c),l.items.add(i),c.set({isToggleable:!0,label:t.title,role:"menuitemradio",class:t.class}),c.delegate("execute").to(o),c.on("execute",(()=>{const i="paragraph"===t.model?"paragraph":"heading";e.execute(i,{value:t.model}),e.editing.view.focus()})),"paragraph"===t.model?(c.bind("isOn").to(r,"value"),a.push(r)):c.bind("isOn").to(s,"value",(e=>e===t.model))}return o.bind("isEnabled").toMany(a,"isEnabled",((...e)=>e.some((e=>e)))),o}))}}class af extends cd{refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n=t.model,o=i.getClosestSelectedImageElement(n.document.selection);n.change((t=>{t.setAttribute("alt",e.newValue,o)}))}}function lf(e){return e.createContainerElement("figure",{class:"image"},[e.createEmptyElement("img"),e.createSlot("children")])}function cf(e,t){const i=e.plugins.get("ImageUtils"),n=e.plugins.has("ImageInlineEditing")&&e.plugins.has("ImageBlockEditing");return e=>i.isInlineImageView(e)?n&&("block"==e.getStyle("display")||e.findAncestor(i.isBlockImageView)?"imageBlock":"imageInline")!==t?null:o(e):null;function o(e){const t={name:!0};return e.hasAttribute("src")&&(t.attributes=["src"]),t}}function uf(e,t){const i=Zt(t.getSelectedBlocks());return!i||e.isObject(i)||i.isEmpty&&"listItem"!=i.name?"imageBlock":"imageInline"}function df(e){return e&&e.endsWith("px")?parseInt(e):null}function hf(e){const t=df(e.getStyle("width")),i=df(e.getStyle("height"));return!(!t||!i)}const mf=/^(image|image-inline)$/;class gf extends ad{_domEmitter=new($e());static get pluginName(){return"ImageUtils"}static get isOfficialPlugin(){return!0}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(e={},t=null,i=null,n={}){const o=this.editor,s=o.model,r=s.document.selection,a=ff(o,t||r,i);e={...Object.fromEntries(r.getAttributes()),...e};for(const t in e)s.schema.checkAttribute(a,t)||delete e[t];return s.change((i=>{const{setImageSizes:o=!0}=n,r=i.createElement(a,e);return s.insertObject(r,t,null,{setSelection:"on",findOptimalPosition:t||"imageInline"==a?void 0:"auto"}),r.parent?(o&&this.setImageNaturalSizeAttributes(r),r):null}))}setImageNaturalSizeAttributes(e){const t=e.getAttribute("src");t&&(e.getAttribute("width")||e.getAttribute("height")||this.editor.model.change((i=>{const o=new n.window.Image;this._domEmitter.listenTo(o,"load",(()=>{e.getAttribute("width")||e.getAttribute("height")||this.editor.model.enqueueChange(i.batch,(t=>{t.setAttribute("width",o.naturalWidth,e),t.setAttribute("height",o.naturalHeight,e)})),this._domEmitter.stopListening(o,"load")})),o.src=t})))}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const i=e.getSelectedElement();if(i&&this.isImageWidget(i))return i;let n=t.parent;for(;n;){if(n.is("element")&&this.isImageWidget(n))return n;n=n.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}getImageWidgetFromImageView(e){return e.findAncestor({classes:mf})}isImageAllowed(){const e=this.editor.model.document.selection;return function(e,t){if("imageBlock"==ff(e,t,null)){const i=function(e,t){const i=Yh(e,t).start.parent;return i.isEmpty&&!i.is("element","$root")?i.parent:i}(t,e.model);if(e.model.schema.checkChild(i,"imageBlock"))return!0}else if(e.model.schema.checkChild(t.focus,"imageInline"))return!0;return!1}(this.editor,e)&&function(e){return[...e.focus.getAncestors()].every((e=>!e.is("element","imageBlock")))}(e)}toImageWidget(e,t,i){return t.setCustomProperty("image",!0,e),jh(e,t,{label:()=>{const t=this.findViewImgElement(e).getAttribute("alt");return t?`${t} ${i}`:i}})}isImageWidget(e){return!!e.getCustomProperty("image")&&qh(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:i}of t.createRangeIn(e))if(this.isInlineImageView(i))return i}destroy(){return this._domEmitter.stopListening(),super.destroy()}}function ff(e,t,i){const n=e.model.schema,o=e.config.get("image.insert.type");return e.plugins.has("ImageBlockEditing")?e.plugins.has("ImageInlineEditing")?i||("inline"===o?"imageInline":"auto"!==o?"imageBlock":t.is("selection")?uf(n,t):n.checkChild(t,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}class pf extends ad{static get requires(){return[gf]}static get pluginName(){return"ImageTextAlternativeEditing"}static get isOfficialPlugin(){return!0}init(){this.editor.commands.add("imageTextAlternative",new af(this.editor))}}function bf(e){return class extends e{disableCssTransitions(){this._isCssTransitionsDisabled=!0}enableCssTransitions(){this._isCssTransitionsDisabled=!1}constructor(...e){super(...e),this.set("_isCssTransitionsDisabled",!1),this.initializeCssTransitionDisablerMixin()}initializeCssTransitionDisablerMixin(){this.template&&this.extendTemplate({attributes:{class:[this.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}}}class wf extends Hi{children;constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("class",["ck","ck-form__row",...zt(t.class||[])]),this.children=this.createCollection(),t.children&&t.children.forEach((e=>this.children.add(e))),this.set("_role",null),this.set("_ariaLabelledBy",null),t.labelView&&this.set({_role:"group",_ariaLabelledBy:t.labelView.id}),this.setTemplate({tag:"div",attributes:{class:i.to("class",(e=>e.join(" "))),role:i.to("_role"),"aria-labelledby":i.to("_ariaLabelledBy")},children:this.children})}}function vf({view:e}){e.listenTo(e.element,"submit",((t,i)=>{i.preventDefault(),e.fire("submit")}),{useCapture:!0})}class yf extends Hi{fieldView;labelView;statusView;fieldWrapperChildren;constructor(e,t){super(e);const i=`ck-labeled-field-view-${_()}`,n=`ck-labeled-field-view-status-${_()}`;this.fieldView=t(this,i,n),this.set("label",void 0),this.set("isEnabled",!0),this.set("isEmpty",!0),this.set("isFocused",!1),this.set("errorText",null),this.set("infoText",null),this.set("class",void 0),this.set("placeholder",void 0),this.labelView=this._createLabelView(i),this.statusView=this._createStatusView(n),this.fieldWrapperChildren=this.createCollection([this.fieldView,this.labelView]),this.bind("_statusText").to(this,"errorText",this,"infoText",((e,t)=>e||t));const o=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",o.to("class"),o.if("isEnabled","ck-disabled",(e=>!e)),o.if("isEmpty","ck-labeled-field-view_empty"),o.if("isFocused","ck-labeled-field-view_focused"),o.if("placeholder","ck-labeled-field-view_placeholder"),o.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:this.fieldWrapperChildren},this.statusView]})}_createLabelView(e){const t=new du(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new Hi(this.locale),i=this.bindTemplate;return t.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",i.if("errorText","ck-labeled-field-view__status_error"),i.if("_statusText","ck-hidden",(e=>!e))],id:e,role:i.if("errorText","alert")},children:[{text:i.to("_statusText")}]}),t}focus(e){this.fieldView.focus(e)}}class _f extends Hi{focusTracker;constructor(e){super(e),this.set("value",void 0),this.set("id",void 0),this.set("placeholder",void 0),this.set("tabIndex",void 0),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById",void 0),this.set("ariaLabel",void 0),this.focusTracker=new ei,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck","ck-input",t.if("isFocused","ck-input_focused"),t.if("isEmpty","ck-input-text_empty"),t.if("hasError","ck-error")],id:t.to("id"),placeholder:t.to("placeholder"),tabindex:t.to("tabIndex"),readonly:t.to("isReadOnly"),"aria-invalid":t.if("hasError",!0),"aria-describedby":t.to("ariaDescribedById"),"aria-label":t.to("ariaLabel")},on:{input:t.to(((...e)=>{this.fire("input",...e),this._updateIsEmpty()})),change:t.to(this._updateIsEmpty.bind(this))}})}render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on("change:value",((e,t,i)=>{this._setDomElementValue(i),this._updateIsEmpty()}))}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}reset(){this.value=this.element.value="",this._updateIsEmpty()}_updateIsEmpty(){this.isEmpty=!this.element.value}_setDomElementValue(e){this.element.value=e||0===e?e:""}}class kf extends _f{constructor(e){super(e),this.set("inputMode","text");const t=this.bindTemplate;this.extendTemplate({attributes:{inputmode:t.to("inputMode")}})}}class Cf extends kf{constructor(e){super(e),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}class xf extends kf{constructor(e,{min:t,max:i,step:n}={}){super(e);const o=this.bindTemplate;this.set("min",t),this.set("max",i),this.set("step",n),this.extendTemplate({attributes:{type:"number",class:["ck-input-number"],min:o.to("min"),max:o.to("max"),step:o.to("step")}})}}const Af=(e,t,i)=>{const n=new Cf(e.locale);return n.set({id:t,ariaDescribedById:i}),n.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),n.bind("hasError").to(e,"errorText",(e=>!!e)),n.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(n),n},Tf=(e,t,i)=>{const n=new xf(e.locale);return n.set({id:t,ariaDescribedById:i,inputMode:"numeric"}),n.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),n.bind("hasError").to(e,"errorText",(e=>!!e)),n.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(n),n},Ef=(e,t,i)=>{const n=Pu(e.locale);return n.set({id:t,ariaDescribedById:i}),n.bind("isEnabled").to(e),n};class Sf extends Hi{focusTracker;keystrokes;labeledInput;backButtonView;saveButtonView;children;_focusables;_focusCycler;constructor(e){super(e),this.focusTracker=new ei,this.keystrokes=new oi,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.labeledInput=this._createLabeledInputView(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new wf(e,{children:[this.labeledInput,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this._focusables=new wi,this.keystrokes.set("Esc",((e,t)=>{this.fire("cancel"),t()})),this._focusCycler=new Nn({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),vf({view:this}),[this.backButtonView,this.labeledInput,this.saveButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createBackButton(){const e=this.locale.t,t=new Bn(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:cm,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new Bn(this.locale);return t.set({label:e("Save"),withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Rn(this.locale,{label:e("Text Alternative")});return t.children.add(this.backButtonView,0),t}_createLabeledInputView(){const e=this.locale.t,t=new yf(this.locale,Af);return t.label=e("Text alternative"),t.class="ck-labeled-field-view_full-width",t}}function Pf(e){const t=e.editing.view,i=qi.defaultPositions,n=e.plugins.get("ImageUtils");return{target:t.domConverter.mapViewToDom(n.getClosestSelectedImageWidget(t.document.selection)),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}class If extends ad{_balloon;_form;static get requires(){return[hm]}static get pluginName(){return"ImageTextAlternativeUI"}static get isOfficialPlugin(){return!0}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",(i=>{const n=e.commands.get("imageTextAlternative"),o=new Bn(i);return o.set({label:t("Change image text alternative"),icon:'',tooltip:!0}),o.bind("isEnabled").to(n,"isEnabled"),o.bind("isOn").to(n,"value",(e=>!!e)),this.listenTo(o,"execute",(()=>{this._showForm()})),o}))}_createForm(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(bf(Sf))(e.locale),this._form.render(),this.listenTo(this._form,"submit",(()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this.listenTo(e.ui,"update",(()=>{i.getClosestSelectedImageWidget(t.selection)?this._isVisible&&function(e){const t=e.plugins.get("ContextualBalloon");if(e.plugins.get("ImageUtils").getClosestSelectedImageWidget(e.editing.view.document.selection)){const i=Pf(e);t.updatePosition(i)}}(e):this._hideForm(!0)})),mn({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const e=this.editor,t=e.commands.get("imageTextAlternative"),i=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:Pf(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class Vf extends ad{static get requires(){return[pf,If]}static get pluginName(){return"ImageTextAlternative"}static get isOfficialPlugin(){return!0}}function Of(e,t){const i=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const o=n.writer,s=n.mapper.toViewElement(i.item),r=e.findViewImgElement(s);null===i.attributeNewValue?(o.removeAttribute("srcset",r),o.removeAttribute("sizes",r)):i.attributeNewValue&&(o.setAttribute("srcset",i.attributeNewValue,r),o.setAttribute("sizes","100vw",r))};return e=>{e.on(`attribute:srcset:${t}`,i)}}function Rf(e,t,i){const n=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const o=n.writer,s=n.mapper.toViewElement(i.item),r=e.findViewImgElement(s);o.setAttribute(i.attributeKey,i.attributeNewValue||"",r)};return e=>{e.on(`attribute:${i}:${t}`,n)}}class Lf extends Gs{observe(e){this.listenTo(e,"load",((e,t)=>{const i=t.target;this.checkShouldIgnoreEventFromTarget(i)||"IMG"==i.tagName&&this._fireEvents(t)}),{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}class Bf extends cd{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||"block"===t&&A("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||"inline"===t&&A("image-inline-plugin-required")}refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=zt(e.source),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(i.getAttributes());t.forEach(((t,s)=>{const r=i.getSelectedElement();if("string"==typeof t&&(t={src:t}),s&&r&&n.isImage(r)){const i=this.editor.model.createPositionAfter(r);n.insertImage({...t,...o},i,e.imageType)}else e.breakBlock?n.insertImage({...t,...o},i.getFirstPosition(),e.imageType):n.insertImage({...t,...o},null,e.imageType)}))}}class Mf extends cd{constructor(e){super(e),this.decorate("cleanupImage")}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=e.isImage(t),this.value=this.isEnabled?t.getAttribute("src"):null}execute(e){const t=this.editor.model.document.selection.getSelectedElement(),i=this.editor.plugins.get("ImageUtils");this.editor.model.change((n=>{n.setAttribute("src",e.source,t),this.cleanupImage(n,t),i.setImageNaturalSizeAttributes(t)}))}cleanupImage(e,t){e.removeAttribute("srcset",t),e.removeAttribute("sizes",t),e.removeAttribute("sources",t),e.removeAttribute("width",t),e.removeAttribute("height",t),e.removeAttribute("alt",t)}}class Nf extends ad{static get requires(){return[gf]}static get pluginName(){return"ImageEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(Lf),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:"srcset"});const i=new Bf(e),n=new Mf(e);e.commands.add("insertImage",i),e.commands.add("replaceImageSource",n),e.commands.add("imageInsert",i)}}class Ff extends ad{static get requires(){return[gf]}static get pluginName(){return"ImageSizeAttributes"}static get isOfficialPlugin(){return!0}afterInit(){this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline")}_registerSchema(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["width","height"]}),this.editor.plugins.has("ImageInlineEditing")&&e.extend("imageInline",{allowAttributes:["width","height"]})}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n="imageBlock"===e?"figure":"img";function o(t,n,o,s,r=!1){t.on(`attribute:${n}:${e}`,((t,n,a)=>{if(!a.consumable.consume(n.item,t.name))return;const l=a.writer,c=a.mapper.toViewElement(n.item),u=i.findViewImgElement(c);null!==n.attributeNewValue?l.setAttribute(o,n.attributeNewValue,u):l.removeAttribute(o,u);const d=n.item.getAttribute("width"),h=n.item.getAttribute("height"),m=d&&h;if(m&&r&&l.setAttribute("loading","lazy",u),n.item.hasAttribute("sources"))return;const g=n.item.hasAttribute("resizedWidth");("imageInline"!==e||g||s)&&m&&l.setStyle("aspect-ratio",`${d}/${h}`,u)}))}t.conversion.for("upcast").attributeToAttribute({view:{name:n,styles:{width:/.+/}},model:{key:"width",value:e=>hf(e)?df(e.getStyle("width")):null}}).attributeToAttribute({view:{name:n,key:"width"},model:"width"}).attributeToAttribute({view:{name:n,styles:{height:/.+/}},model:{key:"height",value:e=>hf(e)?df(e.getStyle("height")):null}}).attributeToAttribute({view:{name:n,key:"height"},model:"height"}),t.conversion.for("editingDowncast").add((e=>{o(e,"width","width",!0,!0),o(e,"height","height",!0,!0)})),t.conversion.for("dataDowncast").add((e=>{o(e,"width","width",!1),o(e,"height","height",!1)})),t.conversion.for("upcast").add((e=>{e.on("element:img",((e,t,i)=>{const n=t.viewItem.getAttribute("width"),o=t.viewItem.getAttribute("height");n&&o&&i.consumable.consume(t.viewItem,{styles:["aspect-ratio"]})}))}))}}class Df extends cd{_modelElementName;constructor(e,t){super(e),this._modelElementName=t}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=e.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=e.isInlineImage(t):this.isEnabled=e.isBlockImage(t)}execute(e={}){const t=this.editor,i=this.editor.model,n=t.plugins.get("ImageUtils"),o=n.getClosestSelectedImageElement(i.document.selection),s=Object.fromEntries(o.getAttributes());return s.src||s.uploadId?i.change((t=>{const{setImageSizes:r=!0}=e,a=Array.from(i.markers).filter((e=>e.getRange().containsItem(o))),l=n.insertImage(s,i.createSelection(o,"on"),this._modelElementName,{setImageSizes:r});if(!l)return null;const c=t.createRangeOn(l);for(const e of a){const i=e.getRange(),n="$graveyard"!=i.root.rootName?i.getJoined(c,!0):c;t.updateMarker(e,{range:n})}return{oldElement:o,newElement:l}})):null}}class zf extends ad{static get requires(){return[gf]}static get pluginName(){return"ImagePlaceholder"}static get isOfficialPlugin(){return!0}afterInit(){this._setupSchema(),this._setupConversion(),this._setupLoadListener()}_setupSchema(){const e=this.editor.model.schema;e.isRegistered("imageBlock")&&e.extend("imageBlock",{allowAttributes:["placeholder"]}),e.isRegistered("imageInline")&&e.extend("imageInline",{allowAttributes:["placeholder"]})}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("editingDowncast").add((e=>{e.on("attribute:placeholder",((e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;if(!t.item.is("element","imageBlock")&&!t.item.is("element","imageInline"))return;n.consumable.consume(t.item,e.name);const o=n.writer,s=n.mapper.toViewElement(t.item),r=i.findViewImgElement(s);t.attributeNewValue?(o.addClass("image_placeholder",r),o.setStyle("background-image",`url(${t.attributeNewValue})`,r),o.setCustomProperty("editingPipeline:doNotReuseOnce",!0,r)):(o.removeClass("image_placeholder",r),o.removeStyle("background-image",r))}))}))}_setupLoadListener(){const e=this.editor,t=e.model,i=e.editing,n=i.view,o=e.plugins.get("ImageUtils");n.addObserver(Lf),this.listenTo(n.document,"imageLoaded",((e,s)=>{const r=n.domConverter.mapDomToView(s.target);if(!r)return;const a=o.getImageWidgetFromImageView(r);if(!a)return;const l=i.mapper.toModelElement(a);l&&l.hasAttribute("placeholder")&&t.enqueueChange({isUndoable:!1},(e=>{e.removeAttribute("placeholder",l)}))}))}}class Hf extends ad{static get requires(){return[Nf,Ff,gf,zf,Qd]}static get pluginName(){return"ImageBlockEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),e.plugins.has("ImageInlineEditing")&&(e.commands.add("imageTypeBlock",new Df(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:t})=>lf(t)}),i.for("editingDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:i})=>n.toImageWidget(lf(i),i,t("image widget"))}),i.for("downcast").add(Rf(n,"imageBlock","src")).add(Rf(n,"imageBlock","alt")).add(Of(n,"imageBlock")),i.for("upcast").elementToElement({view:cf(e,"imageBlock"),model:(e,{writer:t})=>t.createElement("imageBlock",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)}).add(function(e){const t=(t,i,n)=>{if(!n.consumable.test(i.viewItem,{name:!0,classes:"image"}))return;const o=e.findViewImgElement(i.viewItem);if(!o||!n.consumable.test(o,{name:!0}))return;n.consumable.consume(i.viewItem,{name:!0,classes:"image"});const s=Zt(n.convertItem(o,i.modelCursor).modelRange.getItems());s?(n.convertChildren(i.viewItem,s),n.updateConversionResult(s,i)):n.consumable.revert(i.viewItem,{name:!0,classes:"image"})};return e=>{e.on("element:figure",t)}}(n))}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",((o,s)=>{const r=Array.from(s.content.getChildren());let a;if(!r.every(n.isInlineImageView))return;a=s.targetRanges?e.editing.mapper.toModelRange(s.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageBlock"===uf(t.schema,l)){const e=new _c(i.document),t=r.map((t=>e.createElement("figure",{class:"image"},t)));s.content=e.createDocumentFragment(t)}})),this.listenTo(o,"contentInsertion",((e,i)=>{"paste"===i.method&&t.change((e=>{const t=e.createRangeIn(i.content);for(const e of t.getItems())e.is("element","imageBlock")&&n.setImageNaturalSizeAttributes(e)}))}))}}class Uf extends Hi{buttonView;children;constructor(e,t){super(e);const i=this.bindTemplate;this.set("isCollapsed",!1),this.set("label",""),this.buttonView=this._createButtonView(),this.children=this.createCollection(),this.set("_collapsibleAriaLabelUid",void 0),t&&this.children.addMany(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-collapsible",i.if("isCollapsed","ck-collapsible_collapsed")]},children:[this.buttonView,{tag:"div",attributes:{class:["ck","ck-collapsible__children"],role:"region",hidden:i.if("isCollapsed","hidden"),"aria-labelledby":i.to("_collapsibleAriaLabelUid")},children:this.children}]})}render(){super.render(),this._collapsibleAriaLabelUid=this.buttonView.labelView.element.id}focus(){this.buttonView.focus()}_createButtonView(){const e=new Bn(this.locale),t=e.bindTemplate;return e.set({withText:!0,icon:vu}),e.extendTemplate({attributes:{"aria-expanded":t.to("isOn",(e=>String(e)))}}),e.bind("label").to(this),e.bind("isOn").to(this,"isCollapsed",(e=>!e)),e.on("execute",(()=>{this.isCollapsed=!this.isCollapsed})),e}}class $f extends Hi{focusTracker;keystrokes;_focusables;_focusCycler;children;constructor(e,t=[]){super(e),this.focusTracker=new ei,this.keystrokes=new oi,this._focusables=new wi,this.children=this.createCollection(),this._focusCycler=new Nn({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});for(const e of t)this.children.add(e),this._focusables.add(e),e instanceof Uf&&this._focusables.addMany(e.children);this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:-1},children:this.children})}render(){super.render(),vf({view:this});for(const e of this._focusables)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}}class qf extends ad{static get pluginName(){return"ImageInsertUI"}static get isOfficialPlugin(){return!0}static get requires(){return[gf]}dropdownView;_integrations=new Map;constructor(e){super(e),e.config.define("image.insert.integrations",["upload","assetManager","url"])}init(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("ImageUtils");this.set("isImageSelected",!1),this.listenTo(e.model.document,"change",(()=>{this.isImageSelected=i.isImage(t.getSelectedElement())}));const n=e=>this._createToolbarComponent(e);e.ui.componentFactory.add("insertImage",n),e.ui.componentFactory.add("imageInsert",n),e.ui.componentFactory.add("menuBar:insertImage",(e=>this._createMenuBarComponent(e)))}registerIntegration({name:e,observable:t,buttonViewCreator:i,formViewCreator:n,menuBarButtonViewCreator:o,requiresForm:s=!1,override:r=!1}){this._integrations.has(e)&&!r&&A("image-insert-integration-exists",{name:e}),this._integrations.set(e,{observable:t,buttonViewCreator:i,menuBarButtonViewCreator:o,formViewCreator:n,requiresForm:s})}_createToolbarComponent(e){const t=this.editor,i=e.t,n=this._prepareIntegrations();if(!n.length)return null;let o;const s=n[0];if(1==n.length){if(!s.requiresForm)return s.buttonViewCreator(!0);o=s.buttonViewCreator(!0)}else{const t=s.buttonViewCreator(!1);o=new xu(e,t),o.tooltip=!0,o.bind("label").to(this,"isImageSelected",(e=>i(e?"Replace image":"Insert image")))}const r=this.dropdownView=Pu(e,o),a=n.map((({observable:e})=>"function"==typeof e?e():e));return r.bind("isEnabled").toMany(a,"isEnabled",((...e)=>e.some((e=>e)))),r.once("change:isOpen",(()=>{const e=n.flatMap((({formViewCreator:e})=>e(1==n.length))),i=new $f(t.locale,e);r.panelView.children.add(i)})),r}_createMenuBarComponent(e){const t=e.t,i=this._prepareIntegrations();if(!i.length)return null;const n=i.flatMap((({menuBarButtonViewCreator:e})=>e(1==i.length))),o=new Gu(e),s=new Ku(e);o.panelView.children.add(s),o.buttonView.set({icon:'',label:t("Image")});for(const t of n){const i=new hn(e,o);i.children.add(t),s.items.add(i),t.delegate("execute").to(o)}return o}_prepareIntegrations(){const e=this.editor.config.get("image.insert.integrations"),t=[];if(!e.length)return A("image-insert-integrations-not-specified"),t;for(const i of e)this._integrations.has(i)?t.push(this._integrations.get(i)):["upload","assetManager","url"].includes(i)||A("image-insert-unknown-integration",{item:i});return t.length||A("image-insert-integrations-not-registered"),t}}class jf extends ad{static get requires(){return[Hf,lm,Vf,qf]}static get pluginName(){return"ImageBlock"}static get isOfficialPlugin(){return!0}}class Wf extends ad{static get requires(){return[Nf,Ff,gf,zf,Qd]}static get pluginName(){return"ImageInlineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.model.schema.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"],disallowIn:["caption"]}),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new Df(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToElement({model:"imageInline",view:(e,{writer:t})=>t.createEmptyElement("img")}),i.for("editingDowncast").elementToStructure({model:"imageInline",view:(e,{writer:i})=>n.toImageWidget(function(e){return e.createContainerElement("span",{class:"image-inline"},e.createEmptyElement("img"))}(i),i,t("image widget"))}),i.for("downcast").add(Rf(n,"imageInline","src")).add(Rf(n,"imageInline","alt")).add(Of(n,"imageInline")),i.for("upcast").elementToElement({view:cf(e,"imageInline"),model:(e,{writer:t})=>t.createElement("imageInline",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",((o,s)=>{const r=Array.from(s.content.getChildren());let a;if(!r.every(n.isBlockImageView))return;a=s.targetRanges?e.editing.mapper.toModelRange(s.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageInline"===uf(t.schema,l)){const e=new _c(i.document),t=r.map((t=>1===t.childCount?(Array.from(t.getAttributes()).forEach((i=>e.setAttribute(...i,n.findViewImgElement(t)))),t.getChild(0)):t));s.content=e.createDocumentFragment(t)}})),this.listenTo(o,"contentInsertion",((e,i)=>{"paste"===i.method&&t.change((e=>{const t=e.createRangeIn(i.content);for(const e of t.getItems())e.is("element","imageInline")&&n.setImageNaturalSizeAttributes(e)}))}))}}class Gf extends ad{static get requires(){return[Wf,lm,Vf,qf]}static get pluginName(){return"ImageInline"}static get isOfficialPlugin(){return!0}}class Kf extends cd{refresh(){const e=this.editor,t=e.plugins.get("ImageCaptionUtils"),i=e.plugins.get("ImageUtils");if(!e.plugins.has(Hf))return this.isEnabled=!1,void(this.value=!1);const n=e.model.document.selection,o=n.getSelectedElement();if(!o){const e=t.getCaptionFromModelSelection(n);return this.isEnabled=!!e,void(this.value=!!e)}this.isEnabled=i.isImage(o),this.isEnabled?this.value=!!t.getCaptionFromImageModelElement(o):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change((e=>{this.value?this._hideImageCaption(e):this._showImageCaption(e,t)}))}_showImageCaption(e,t){const i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageCaptionEditing"),o=this.editor.plugins.get("ImageUtils");let s=i.getSelectedElement();const r=n._getSavedCaption(s);o.isInlineImage(s)&&(this.editor.execute("imageTypeBlock"),s=i.getSelectedElement());const a=r||e.createElement("caption");e.append(a,s),t&&e.setSelection(a,"in")}_hideImageCaption(e){const t=this.editor,i=t.model.document.selection,n=t.plugins.get("ImageCaptionEditing"),o=t.plugins.get("ImageCaptionUtils");let s,r=i.getSelectedElement();r?s=o.getCaptionFromImageModelElement(r):(s=o.getCaptionFromModelSelection(i),r=s.parent),n._saveCaption(r,s),e.setSelection(r,"on"),e.remove(s)}}class Jf extends ad{static get pluginName(){return"ImageCaptionUtils"}static get isOfficialPlugin(){return!0}static get requires(){return[gf]}getCaptionFromImageModelElement(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}getCaptionFromModelSelection(e){const t=this.editor.plugins.get("ImageUtils"),i=e.getFirstPosition().findAncestor("caption");return i&&t.isBlockImage(i.parent)?i:null}matchImageCaptionViewElement(e){const t=this.editor.plugins.get("ImageUtils");return"figcaption"==e.name&&t.isBlockImageView(e.parent)?{name:!0}:null}}class Yf extends ad{static get requires(){return[gf,Jf]}static get pluginName(){return"ImageCaptionEditing"}static get isOfficialPlugin(){return!0}_savedCaptionsMap;constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema;t.isRegistered("caption")?t.extend("caption",{allowIn:"imageBlock"}):t.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleImageCaption",new Kf(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils"),o=e.t;e.conversion.for("upcast").elementToElement({view:e=>n.matchImageCaptionViewElement(e),model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>i.isBlockImage(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:n})=>{if(!i.isBlockImage(e.parent))return null;const s=n.createEditableElement("figcaption");n.setCustomProperty("imageCaption",!0,s),s.placeholder=o("Enter image caption"),Yn({view:t,element:s,keepOnFocus:!0});const r=e.parent.getAttribute("alt");return Jh(s,n,{label:r?o("Caption for image: %0",[r]):o("Caption for the image")})}})}_setupImageTypeCommandsIntegration(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.plugins.get("ImageCaptionUtils"),n=e.commands.get("imageTypeInline"),o=e.commands.get("imageTypeBlock"),s=e=>{if(!e.return)return;const{oldElement:n,newElement:o}=e.return;if(!n)return;if(t.isBlockImage(n)){const e=i.getCaptionFromImageModelElement(n);if(e)return void this._saveCaption(o,e)}const s=this._getSavedCaption(n);s&&this._saveCaption(o,s)};n&&this.listenTo(n,"execute",s,{priority:"low"}),o&&this.listenTo(o,"execute",s,{priority:"low"})}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?ea.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}_registerCaptionReconversion(){const e=this.editor,t=e.model,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils");t.document.on("change:data",(()=>{const o=t.document.differ.getChanges();for(const t of o){if("alt"!==t.attributeKey)continue;const o=t.range.start.nodeAfter;if(i.isBlockImage(o)){const t=n.getCaptionFromImageModelElement(o);if(!t)return;e.editing.reconvertItem(t)}}}))}}const Qf='';class Xf extends ad{static get requires(){return[Jf]}static get pluginName(){return"ImageCaptionUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageCaptionUtils"),n=e.t;e.ui.componentFactory.add("toggleImageCaption",(o=>{const s=e.commands.get("toggleImageCaption"),r=new Bn(o);return r.set({icon:Qf,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(s,"value","isEnabled"),r.bind("label").to(s,"value",(e=>n(e?"Toggle caption off":"Toggle caption on"))),this.listenTo(r,"execute",(()=>{e.execute("toggleImageCaption",{focusCaptionOnShow:!0});const n=i.getCaptionFromModelSelection(e.model.document.selection);if(n){const i=e.editing.mapper.toViewElement(n);t.scrollToTheSelection(),t.change((e=>{e.addClass("image__caption_highlighted",i)}))}e.editing.view.focus()})),r}))}}class Zf extends cd{_defaultStyles;_styles;constructor(e,t){super(e),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map((e=>{if(e.isDefault)for(const t of e.modelElements)this._defaultStyles[t]=e.name;return[e.name,e]})))}refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?e.hasAttribute("imageStyle")?this.value=e.getAttribute("imageStyle"):this.value=this._defaultStyles[e.name]:this.value=!1}execute(e={}){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils");i.change((t=>{const o=e.value,{setImageSizes:s=!0}=e;let r=n.getClosestSelectedImageElement(i.document.selection);o&&this.shouldConvertImageType(o,r)&&(this.editor.execute(n.isBlockImage(r)?"imageTypeInline":"imageTypeBlock",{setImageSizes:s}),r=n.getClosestSelectedImageElement(i.document.selection)),!o||this._styles.get(o).isDefault?t.removeAttribute("imageStyle",r):t.setAttribute("imageStyle",o,r),s&&n.setImageNaturalSizeAttributes(r)}))}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}}const ep='',tp='',ip='',np='',op='',sp='',rp={get inline(){return{name:"inline",title:"In line",icon:ep,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:tp,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:ip,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:np,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:op,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:sp,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:np,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:op,modelElements:["imageBlock"],className:"image-style-side"}}},ap=(()=>({full:'',left:ip,right:sp,center:np,inlineLeft:tp,inlineRight:op,inline:ep}))(),lp=[{name:"imageStyle:wrapText",title:"Wrap text",defaultItem:"imageStyle:alignLeft",items:["imageStyle:alignLeft","imageStyle:alignRight"]},{name:"imageStyle:breakText",title:"Break text",defaultItem:"imageStyle:block",items:["imageStyle:alignBlockLeft","imageStyle:block","imageStyle:alignBlockRight"]}];function cp(e){A("image-style-configuration-definition-invalid",e)}const up={normalizeStyles:function(e){return(e.configuredStyles.options||[]).map((e=>{return"string"==typeof(t="string"==typeof(t=e)?rp[t]?{...rp[t]}:{name:t}:function(e,t){const i={...t};for(const n in e)Object.prototype.hasOwnProperty.call(t,n)||(i[n]=e[n]);return i}(rp[t.name],t)).icon&&(t.icon=ap[t.icon]||t.icon),t;var t})).filter((t=>function(e,{isBlockPluginLoaded:t,isInlinePluginLoaded:i}){const{modelElements:n,name:o}=e;if(!(n&&n.length&&o))return cp({style:e}),!1;{const o=[t?"imageBlock":null,i?"imageInline":null];if(!n.some((e=>o.includes(e))))return A("image-style-missing-dependency",{style:e,missingPlugins:n.map((e=>"imageBlock"===e?"ImageBlockEditing":"ImageInlineEditing"))}),!1}return!0}(t,e)))},getDefaultStylesConfiguration:function(e,t){return e&&t?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:e?{options:["block","side"]}:t?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(e){return e.has("ImageBlockEditing")&&e.has("ImageInlineEditing")?[...lp]:[]},warnInvalidStyle:cp};var dp=i(541);function hp(e,t){for(const i of t)if(i.name===e)return i}class mp extends ad{static get pluginName(){return"ImageStyleEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[gf]}normalizedStyles;init(){const e=this.editor,t=e.plugins.has("ImageBlockEditing"),i=e.plugins.has("ImageInlineEditing");e.config.define("image.styles",up.getDefaultStylesConfiguration(t,i)),this.normalizedStyles=up.normalizeStyles({configuredStyles:e.config.get("image.styles"),isBlockPluginLoaded:t,isInlinePluginLoaded:i}),this._setupConversion(t,i),this._setupPostFixer(),e.commands.add("imageStyle",new Zf(e,this.normalizedStyles))}_setupConversion(e,t){const i=this.editor,n=i.model.schema,o=(s=this.normalizedStyles,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=hp(t.attributeNewValue,s),o=hp(t.attributeOldValue,s),r=i.mapper.toViewElement(t.item),a=i.writer;o&&a.removeClass(o.className,r),n&&a.addClass(n.className,r)});var s;const r=function(e){const t={imageInline:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageInline"))),imageBlock:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageBlock")))};return(i,n,o)=>{if(!n.modelRange)return;const s=n.viewItem,r=Zt(n.modelRange.getItems());if(r&&o.schema.checkAttribute(r,"imageStyle")){for(const e of t[r.name])o.consumable.consume(s,{classes:e.className})&&o.writer.setAttribute("imageStyle",e.name,r);!function(e,t,i,n){if(!e.consumable.test(t,{styles:["float"]}))return;let o=null;switch(t.getStyle("float")){case"left":o="alignLeft";break;case"right":o="alignRight"}if(!o)return;const s=hp(o,n);if(!s)return;const r=rp[s.name];dp(s,r)&&(e.writer.setAttribute("imageStyle",o,i),e.consumable.consume(t,{styles:["float"]}))}(o,s,r,e)}}}(this.normalizedStyles);i.editing.downcastDispatcher.on("attribute:imageStyle",o),i.data.downcastDispatcher.on("attribute:imageStyle",o),e&&(n.extend("imageBlock",{allowAttributes:"imageStyle"}),n.setAttributeProperties("imageStyle",{isFormatting:!0}),i.data.upcastDispatcher.on("element:figure",r,{priority:"low"})),t&&(n.extend("imageInline",{allowAttributes:"imageStyle"}),n.setAttributeProperties("imageStyle",{isFormatting:!0}),i.data.upcastDispatcher.on("element:img",r,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,i=e.plugins.get(gf),n=new Map(this.normalizedStyles.map((e=>[e.name,e])));t.registerPostFixer((e=>{let o=!1;for(const s of t.differ.getChanges())if("insert"==s.type||"attribute"==s.type&&"imageStyle"==s.attributeKey){let t="insert"==s.type?s.position.nodeAfter:s.range.start.nodeAfter;if(t&&t.is("element","paragraph")&&t.childCount>0&&(t=t.getChild(0)),!i.isImage(t))continue;const r=t.getAttribute("imageStyle");if(!r)continue;const a=n.get(r);a&&a.modelElements.includes(t.name)||(e.removeAttribute("imageStyle",t),o=!0)}return o}))}}function gp(e){return e}class fp extends ad{static get requires(){return[mp]}static get pluginName(){return"ImageStyleUI"}static get isOfficialPlugin(){return!0}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Wrap text":e("Wrap text"),"Break text":e("Break text"),"In line":e("In line"),"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=this.editor.plugins,t=this.editor.config.get("image.toolbar")||[],i=pp(e.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const e of i)this._createButton(e);const n=pp([...t.filter(z),...up.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const e of n)this._createDropdown(e,i)}_createDropdown(e,t){const i=this.editor.ui.componentFactory;i.add(e.name,(n=>{let o;const{defaultItem:s,items:r,title:a}=e,l=r.filter((e=>t.find((({name:t})=>bp(t)===e)))).map((e=>{const t=i.create(e);return e===s&&(o=t),t}));r.length!==l.length&&up.warnInvalidStyle({dropdown:e});const c=Pu(n,xu),u=c.buttonView,d=u.arrowView;return Iu(c,l,{enableActiveItemFocusOnDropdownOpen:!0}),u.set({label:wp(a,o.label),class:null,tooltip:!0}),d.unbind("label"),d.set({label:a}),u.bind("icon").toMany(l,"isOn",((...e)=>{const t=e.findIndex(gp);return t<0?o.icon:l[t].icon})),u.bind("label").toMany(l,"isOn",((...e)=>{const t=e.findIndex(gp);return wp(a,t<0?o.label:l[t].label)})),u.bind("isOn").toMany(l,"isOn",((...e)=>e.some(gp))),u.bind("class").toMany(l,"isOn",((...e)=>e.some(gp)?"ck-splitbutton_flatten":void 0)),u.on("execute",(()=>{l.some((({isOn:e})=>e))?c.isOpen=!c.isOpen:o.fire("execute")})),c.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some(gp))),this.listenTo(c,"execute",(()=>{this.editor.editing.view.focus()})),c}))}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(bp(t),(i=>{const n=this.editor.commands.get("imageStyle"),o=new Bn(i);return o.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(n,"isEnabled"),o.bind("isOn").to(n,"value",(e=>e===t)),o.on("execute",this._executeCommand.bind(this,t)),o}))}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function pp(e,t){for(const i of e)t[i.title]&&(i.title=t[i.title]);return e}function bp(e){return`imageStyle:${e}`}function wp(e,t){return(e?e+": ":"")+t}class vp{_definitions=new Set;get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach((e=>this._definitions.add(e))):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",((e,t,i)=>{if(!i.consumable.test(t.item,"attribute:linkHref"))return;if(!t.item.is("selection")&&!i.schema.isInline(t.item))return;const n=i.writer,o=n.document.selection;for(const e of this._definitions){const s=n.createAttributeElement("a",e.attributes,{priority:5});e.classes&&n.addClass(e.classes,s);for(const t in e.styles)n.setStyle(t,e.styles[t],s);n.setCustomProperty("link",!0,s),e.callback(t.attributeNewValue)?t.item.is("selection")?n.wrap(o.getFirstRange(),s):n.wrap(i.mapper.toViewRange(t.range),s):n.unwrap(i.mapper.toViewRange(t.range),s)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",((e,t,{writer:i,mapper:n})=>{const o=n.toViewElement(t.item),s=Array.from(o.getChildren()).find((e=>e.is("element","a")));if(s)for(const e of this._definitions){const n=si(e.attributes);if(e.callback(t.attributeNewValue)){for(const[e,t]of n)"class"===e?i.addClass(t,s):i.setAttribute(e,t,s);e.classes&&i.addClass(e.classes,s);for(const t in e.styles)i.setStyle(t,e.styles[t],s)}else{for(const[e,t]of n)"class"===e?i.removeClass(t,s):i.removeAttribute(e,s);e.classes&&i.removeClass(e.classes,s);for(const t in e.styles)i.removeStyle(t,s)}}}))}}}const yp=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,_p=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,kp=/^((\w+:(\/{2,})?)|(\W))/i,Cp=["https?","ftps?","mailto"],xp="Ctrl+K";function Ap(e,{writer:t}){const i=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,i),i}function Tp(e,t=Cp){const i=String(e),n=t.join("|");return function(e,t){return!!e.replace(yp,"").match(t)}(i,new RegExp(`${"^(?:(?:):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))".replace("",n)}`,"i"))?i:"#"}function Ep(e,t){return!!e&&t.checkAttribute(e.name,"linkHref")}function Sp(e,t){const i=(n=e,_p.test(n)?"mailto:":t);var n;const o=!!i&&!Pp(e);return e&&o?i+e:e}function Pp(e){return kp.test(e)}function Ip(e){let t="";for(const i of e.getItems()){if(!i.is("$text")&&!i.is("$textProxy"))return;t+=i.data}return t}class Vp extends cd{manualDecorators=new Xt;automaticDecorators=new vp;restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement()||Zt(t.getSelectedBlocks());Ep(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={},i){const n=this.editor.model,o=n.document.selection,s=[],r=[];for(const e in t)t[e]?s.push(e):r.push(e);n.change((t=>{const a=i=>{t.setAttribute("linkHref",e,i),s.forEach((e=>t.setAttribute(e,!0,i))),r.forEach((e=>t.removeAttribute(e,i)))},l=(o,s)=>{const r=Ip(o);if(!r)return o;let l=i;if(l||(l=s&&s==r?e:r),l!=r){const e=t.createDocumentFragment();for(const i of o.getItems()){const n=i;t.append(t.createText(n.data,n.getAttributes()),e)}const i=t.createRangeIn(e),s=function(e,t){const i=w(e,t),n={equal:0,insert:0,delete:0},o=[];let s="",r="";for(const a of[...i,null])"insert"==a?r+=t[n.equal+n.insert]:"delete"==a?s+=e[n.equal+n.delete]:(s.length||r.length)&&(o.push({offset:n.equal,actual:s,expected:r}),s="",r=""),a&&n[a]++;return o}(r,l);let c=0;for(const{offset:e,actual:o,expected:r}of s){const s=e+c,l=t.createRange(i.start.getShiftedBy(s),i.start.getShiftedBy(s+o.length)),u=Op(l,i).getAttributes(),d=Array.from(u).filter((([e])=>n.schema.getAttributeProperties(e).isFormatting)),h=t.createText(r,d);a(h),t.remove(l),t.insert(h,l.start),c+=r.length}return n.insertContent(e,o),t.createRange(o.start,o.start.getShiftedBy(l.length))}},c=e=>{const{plugins:i}=this.editor;if(t.setSelection(e.end),i.has("TwoStepCaretMovement"))i.get("TwoStepCaretMovement")._handleForwardMovement();else for(const e of["linkHref",...s,...r])t.removeSelectionAttribute(e)};if(o.isCollapsed){const r=o.getFirstPosition();if(o.hasAttribute("linkHref")){const e=o.getAttribute("linkHref"),t=Eh(r,"linkHref",e,n),i=l(t,e);a(i||t),i&&c(i)}else if(""!==e){const a=si(o.getAttributes());a.set("linkHref",e),s.forEach((e=>{a.set(e,!0)})),c(n.insertContent(t.createText(i||e,a),r))}}else{const e=Array.from(o.getRanges()),i=n.schema.getValidRanges(e,"linkHref"),s=[];for(const e of o.getSelectedBlocks())n.schema.checkAttribute(e,"linkHref")&&s.push(t.createRangeOn(e));const r=s.slice();for(const e of i)this._isRangeToUpdate(e,s)&&r.push(e);const c=e.map((e=>({start:Pl.fromPosition(e.start,"toPrevious"),end:Pl.fromPosition(e.end,"toNext")})));for(let e of r)e=l(e,(e.start.textNode||e.start.nodeAfter).getAttribute("linkHref"))||e,a(e);t.setSelection(c.map((e=>{const t=e.start.toPosition(),i=e.end.toPosition();return e.start.detach(),e.end.detach(),n.createRange(t,i)})))}}))}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,n=i.getSelectedElement();return Ep(n,t.schema)?n.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}}function Op(e,t){if(!e.isCollapsed)return Zt(e.getItems());const i=e.start;return i.textNode?i.textNode:!i.nodeBefore||i.isEqual(t.start)?i.nodeAfter:i.nodeBefore}class Rp extends cd{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();Ep(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,n=e.commands.get("link");t.change((e=>{const o=i.isCollapsed?[Eh(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const t of o)if(e.removeAttribute("linkHref",t),n)for(const i of n.manualDecorators)e.removeAttribute(i.id,t)}))}}class Lp extends(G()){id;defaultValue;label;attributes;classes;styles;constructor({id:e,label:t,attributes:i,classes:n,styles:o,defaultValue:s}){super(),this.id=e,this.set("value",void 0),this.defaultValue=s,this.label=t,this.attributes=i,this.classes=n,this.styles=o}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}const Bp="automatic",Mp=/^(https?:)?\/\//;class Np extends ad{_linkOpeners=[];static get pluginName(){return"LinkEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[wh,nh,Qd]}constructor(e){super(e),e.config.define("link",{allowCreatingEmptyLinks:!1,addTargetToExternalLinks:!1,toolbar:["linkPreview","|","editLink","linkProperties","unlink"]})}init(){const e=this.editor,t=this.editor.config.get("link.allowedProtocols");e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:Ap}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,i)=>Ap(Tp(e,t),i)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new Vp(e)),e.commands.add("unlink",new Rp(e));const i=function(e,t){const i={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach((e=>("label"in e&&i[e.label]&&(e.label=i[e.label]),e))),t}(e.t,function(e){const t=[];if(e)for(const[n,o]of Object.entries(e)){const e=Object.assign({},o,{id:`link${i=n,function(e){return e.substring(0,1).toUpperCase()+e.substring(1)}(Ah(i))}`});t.push(e)}var i;return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(i.filter((e=>e.mode===Bp))),this._enableManualDecorators(i.filter((e=>"manual"===e.mode))),e.plugins.get(wh).registerAttribute("linkHref"),Ph(e,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableSelectionAttributesFixer(),this._enableClipboardIntegration()}_registerLinkOpener(e){this._linkOpeners.push(e)}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:Bp,callback:e=>!!e&&Mp.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(e),i.length&&t.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach((e=>{t.model.schema.extend("$text",{allowAttributes:e.id});const n=new Lp(e);i.add(n),t.conversion.for("downcast").attributeToElement({model:n.id,view:(e,{writer:t,schema:i},{item:o})=>{if((o.is("selection")||i.isInline(o))&&e){const e=t.createAttributeElement("a",n.attributes,{priority:5});n.classes&&t.addClass(n.classes,e);for(const i in n.styles)t.setStyle(i,n.styles[i],e);return t.setCustomProperty("link",!0,e),e}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...n._createPattern()},model:{key:n.id}})}))}_enableLinkOpen(){const e=this.editor,t=e.editing.view.document,i=e=>{var t;this._linkOpeners.some((t=>t(e)))||(t=e,window.open(t,"_blank","noopener"))};this.listenTo(t,"click",((e,t)=>{if(!(r.isMac?t.domEvent.metaKey:t.domEvent.ctrlKey))return;let n=t.domTarget;if("a"!=n.tagName.toLowerCase()&&(n=n.closest("a")),!n)return;const o=n.getAttribute("href");o&&(e.stop(),t.preventDefault(),i(o))}),{context:"$capture"}),this.listenTo(t,"keydown",((t,n)=>{const o=e.commands.get("link").value;o&&n.keyCode===Rt.enter&&n.altKey&&(t.stop(),i(o))}))}_enableSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;this.listenTo(t,"change:attribute",((i,{attributeKeys:n})=>{n.includes("linkHref")&&!t.hasAttribute("linkHref")&&e.change((t=>{var i;!function(e,t){e.removeSelectionAttribute("linkHref");for(const i of t)e.removeSelectionAttribute(i)}(t,(i=e.schema,i.getDefinition("$text").allowAttributes.filter((e=>e.startsWith("link")))))}))}))}_enableClipboardIntegration(){const e=this.editor,t=e.model,i=this.editor.config.get("link.defaultProtocol");i&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",((e,n)=>{t.change((e=>{const t=e.createRangeIn(n.content);for(const n of t.getItems())if(n.hasAttribute("linkHref")){const t=Sp(n.getAttribute("linkHref"),i);e.setAttribute("linkHref",t,n)}}))}))}}const Fp='',Dp='';class zp extends Bn{constructor(e){super(e);const t=this.bindTemplate;this.set({href:void 0,withText:!0}),this.extendTemplate({attributes:{class:["ck-link-toolbar__preview"],href:t.to("href"),target:"_blank",rel:"noopener noreferrer"},on:{click:t.to((e=>{if(this.href){const t=()=>e.preventDefault();this.fire("navigate",this.href,t)}}))}}),this.template.tag="a"}}class Hp extends Hi{focusTracker=new ei;keystrokes=new oi;backButtonView;saveButtonView;displayedTextInputView;urlInputView;children;providersListChildren;_validators;_focusables=new wi;_focusCycler;constructor(e,t){super(e),this._validators=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.displayedTextInputView=this._createDisplayedTextInput(),this.urlInputView=this._createUrlInput(),this.providersListChildren=this.createCollection(),this.children=this.createCollection([this._createHeaderView()]),this._createFormChildren(),this.listenTo(this.providersListChildren,"add",(()=>{this.stopListening(this.providersListChildren,"add"),this.children.add(this._createProvidersListView())})),this._focusCycler=new Nn({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-link-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),vf({view:this}),[this.urlInputView,this.saveButtonView,...this.providersListChildren,this.backButtonView,this.displayedTextInputView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null}_createBackButton(){const e=this.locale.t,t=new Bn(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:cm,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new Bn(this.locale);return t.set({label:e("Insert"),tooltip:!1,withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Rn(this.locale,{label:e("Link")});return t.children.add(this.backButtonView,0),t}_createProvidersListView(){const e=new Cu(this.locale);return e.extendTemplate({attributes:{class:["ck-link-form__providers-list"]}}),e.items.bindTo(this.providersListChildren).using((e=>{const t=new dn(this.locale);return t.children.add(e),t})),e}_createDisplayedTextInput(){const e=this.locale.t,t=new yf(this.locale,Af);return t.label=e("Displayed text"),t.class="ck-labeled-field-view_full-width",t}_createUrlInput(){const e=this.locale.t,t=new yf(this.locale,Af);return t.fieldView.inputMode="url",t.label=e("Link URL"),t.class="ck-labeled-field-view_full-width",t}_createFormChildren(){this.children.add(new wf(this.locale,{children:[this.displayedTextInputView],class:["ck-form__row_large-top-padding"]})),this.children.add(new wf(this.locale,{children:[this.urlInputView,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding","ck-form__row_large-bottom-padding"]}))}get url(){const{element:e}=this.urlInputView.fieldView;return e?e.value.trim():null}}class Up extends Hi{focusTracker=new ei;keystrokes=new oi;backButtonView;listView;listChildren;emptyListInformation;children;_focusables=new wi;_focusCycler;constructor(e){super(e),this.listChildren=this.createCollection(),this.backButtonView=this._createBackButton(),this.listView=this._createListView(),this.emptyListInformation=this._createEmptyLinksListItemView(),this.children=this.createCollection([this._createHeaderView(),this.emptyListInformation]),this.set("title",""),this.set("emptyListPlaceholder",""),this.set("hasItems",!1),this.listenTo(this.listChildren,"change",(()=>{this.hasItems=this.listChildren.length>0})),this.on("change:hasItems",((e,t,i)=>{i?(this.children.remove(this.emptyListInformation),this.children.add(this.listView)):(this.children.remove(this.listView),this.children.add(this.emptyListInformation))})),this.keystrokes.set("Esc",((e,t)=>{this.fire("cancel"),t()})),this._focusCycler=new Nn({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-providers"],tabindex:"-1"},children:this.children})}render(){super.render(),[this.listView,this.backButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createListView(){const e=new Cu(this.locale);return e.extendTemplate({attributes:{class:["ck-link-providers__list"]}}),e.items.bindTo(this.listChildren).using((e=>{const t=new dn(this.locale);return t.children.add(e),t})),e}_createBackButton(){const e=this.locale.t,t=new Bn(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:cm,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createHeaderView(){const e=new Rn(this.locale);return e.bind("label").to(this,"title"),e.children.add(this.backButtonView,0),e}_createEmptyLinksListItemView(){const e=new Hi(this.locale);return e.setTemplate({tag:"p",attributes:{class:["ck","ck-link__empty-list-info"]},children:[{text:this.bindTemplate.to("emptyListPlaceholder")}]}),e}}class $p extends Hi{focusTracker=new ei;keystrokes=new oi;backButtonView;children;listChildren;_focusables=new wi;_focusCycler;constructor(e){super(e),this.backButtonView=this._createBackButton(),this.listChildren=this.createCollection(),this.children=this.createCollection([this._createHeaderView(),this._createListView()]),this._focusCycler=new Nn({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-properties"],tabindex:"-1"},children:this.children}),this.keystrokes.set("Esc",((e,t)=>{this.fire("back"),t()}))}render(){super.render(),[...this.listChildren,this.backButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBackButton(){const e=this.locale.t,t=new Bn(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:cm,tooltip:!0}),t.delegate("execute").to(this,"back"),t}_createHeaderView(){const e=this.locale.t,t=new Rn(this.locale,{label:e("Link properties")});return t.children.add(this.backButtonView,0),t}_createListView(){const e=new Cu(this.locale);return e.extendTemplate({attributes:{class:["ck-link__list"]}}),e.items.bindTo(this.listChildren).using((e=>{const t=new dn(this.locale);return t.children.add(e),t})),e}}class qp extends Bn{arrowView;constructor(e){super(e),this.set({withText:!0}),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{class:["ck-link__button"]}})}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new en;return e.content=um,e}}const jp="link-ui";class Wp extends ad{toolbarView=null;formView=null;linkProviderItemsView=null;propertiesView=null;_balloon;_linksProviders=new Xt;static get requires(){return[hm,Np]}static get pluginName(){return"LinkUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=this.editor.t;this.set("selectedLinkableText",void 0),e.editing.view.addObserver(bc),this._balloon=e.plugins.get(hm),this._registerComponents(),this._registerEditingOpeners(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:jp,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:jp,view:(e,{writer:t})=>{if(!e.markerRange.isCollapsed)return null;const i=t.createUIElement("span");return t.addClass(["ck-fake-link-selection","ck-fake-link-selection_collapsed"],i),i}}),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Create link"),keystroke:xp},{label:t("Move out of a link"),keystroke:[["arrowleft","arrowleft"],["arrowright","arrowright"]]}]})}destroy(){super.destroy(),this.propertiesView&&this.propertiesView.destroy(),this.formView&&this.formView.destroy(),this.toolbarView&&this.toolbarView.destroy(),this.linkProviderItemsView&&this.linkProviderItemsView.destroy()}registerLinksListProvider(e){const t=this._linksProviders.filter((t=>(t.order||0)<=(e.order||0))).length;this._linksProviders.add(e,t)}_createViews(){const e=this.editor.commands.get("link");this.toolbarView=this._createToolbarView(),this.formView=this._createFormView(),e.manualDecorators.length&&(this.propertiesView=this._createPropertiesView()),this._enableUserBalloonInteractions()}_createToolbarView(){const e=this.editor,t=new Hu(e.locale),i=e.commands.get("link");t.class="ck-link-toolbar";let n=e.config.get("link.toolbar");return i.manualDecorators.length||(n=n.filter((e=>"linkProperties"!==e))),t.fillFromConfig(n,e.ui.componentFactory),t.keystrokes.set("Esc",((e,t)=>{this._hideUI(),t()})),t.keystrokes.set(xp,((e,t)=>{this._addFormView(),t()})),e.ui.addToolbar(t,{isContextual:!0,beforeFocus:()=>{this._getSelectedLinkElement()&&!this._isToolbarVisible&&this._showUI(!0)},afterBlur:()=>{this._hideUI(!1)}}),t}_createFormView(){const e=this.editor,t=e.locale.t,i=e.commands.get("link"),n=e.config.get("link.defaultProtocol"),o=new(bf(Hp))(e.locale,function(e){const t=e.t,i=e.config.get("link.allowCreatingEmptyLinks");return[e=>{if(!i&&!e.url.length)return t("Link URL must not be empty.")}]}(e));return o.displayedTextInputView.bind("isEnabled").to(this,"selectedLinkableText",(e=>void 0!==e)),o.urlInputView.bind("isEnabled").to(i,"isEnabled"),o.saveButtonView.bind("isEnabled").to(i,"isEnabled"),o.saveButtonView.bind("label").to(i,"value",(e=>t(e?"Update":"Insert"))),this.listenTo(o,"submit",(()=>{if(o.isValid()){const t=Sp(o.urlInputView.fieldView.element.value,n),i=o.displayedTextInputView.fieldView.element.value;e.execute("link",t,this._getDecoratorSwitchesState(),i!==this.selectedLinkableText?i:void 0),this._closeFormView()}})),this.listenTo(o.urlInputView,"change:errorText",(()=>{e.ui.update()})),this.listenTo(o,"cancel",(()=>{this._closeFormView()})),o.keystrokes.set("Esc",((e,t)=>{this._closeFormView(),t()})),o.providersListChildren.bindTo(this._linksProviders).using((e=>this._createLinksListProviderButton(e))),o}_createLinkProviderListView(e){return e.getListItems().map((({href:e,label:t,icon:i})=>{const n=new Bn;return n.set({label:t,icon:i,tooltip:!1,withText:!0}),n.on("execute",(()=>{this.formView.resetFormStatus(),this.formView.urlInputView.fieldView.value=e,this.editor.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()})),n}))}_createLinkProviderItemsView(e){const t=this.editor,i=t.locale.t,n=new Up(t.locale),{emptyListPlaceholder:o,label:s}=e;return n.emptyListPlaceholder=o||i("No links available"),n.title=s,this.listenTo(n,"cancel",(()=>{t.editing.view.focus(),this._removeLinksProviderView(),this.formView.focus()})),n}_createPropertiesView(){const e=this.editor,t=this.editor.commands.get("link"),i=new(bf($p))(e.locale);return this.listenTo(i,"back",(()=>{e.editing.view.focus(),this._removePropertiesView()})),i.listChildren.bindTo(t.manualDecorators).using((i=>{const n=new Au(e.locale);return n.set({label:i.label,withText:!0}),n.bind("isOn").toMany([i,t],"value",((e,t)=>void 0===t&&void 0===e?!!i.defaultValue:!!e)),n.on("execute",(()=>{i.set("value",!n.isOn),e.execute("link",t.value,this._getDecoratorSwitchesState())})),n})),i}_getDecoratorSwitchesState(){const e=this.editor.commands.get("link");return Array.from(e.manualDecorators).reduce(((t,i)=>{const n=void 0===e.value&&void 0===i.value?i.defaultValue:i.value;return{...t,[i.id]:!!n}}),{})}_registerEditingOpeners(){this.editor.plugins.get(Np)._registerLinkOpener((e=>{const t=this._getLinkProviderLinkByHref(e);if(!t)return!1;const{item:i,provider:n}=t;return!!n.navigate&&n.navigate(i)}))}_registerComponents(){const e=this.editor;e.ui.componentFactory.add("link",(()=>{const e=this._createButton(Bn);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add("menuBar:link",(()=>{const e=this._createButton(Yu);return e.set({role:"menuitemcheckbox"}),e})),e.ui.componentFactory.add("linkPreview",(t=>{const i=new zp(t),n=e.config.get("link.allowedProtocols"),o=e.commands.get("link"),s=t.t;i.bind("isEnabled").to(o,"value",(e=>!!e)),i.bind("href").to(o,"value",(e=>e&&Tp(e,n)));const r=e=>{if(!e)return i.label=void 0,i.icon=void 0,void(i.tooltip=s("Open link in new tab"));const t=this._getLinkProviderLinkByHref(e);if(t){const{label:e,tooltip:n,icon:o}=t.item;i.label=e,i.tooltip=n||!1,i.icon=o}else i.label=e,i.icon=void 0,i.tooltip=s("Open link in new tab")};return r(o.value),this.listenTo(o,"change:value",((e,t,i)=>{r(i)})),this.listenTo(i,"navigate",((e,t,i)=>{const n=this._getLinkProviderLinkByHref(t);if(!n)return;const{provider:o,item:s}=n,{navigate:r}=o;r&&r(s)&&(e.stop(),i())})),i})),e.ui.componentFactory.add("unlink",(t=>{const i=e.commands.get("unlink"),n=new Bn(t),o=t.t;return n.set({label:o("Unlink"),icon:'',tooltip:!0}),n.bind("isEnabled").to(i),this.listenTo(n,"execute",(()=>{e.execute("unlink"),this._hideUI()})),n})),e.ui.componentFactory.add("editLink",(t=>{const i=e.commands.get("link"),n=new Bn(t),o=t.t;return n.set({label:o("Edit link"),icon:Fp,tooltip:!0}),n.bind("isEnabled").to(i),this.listenTo(n,"execute",(()=>{this._addFormView()})),n})),e.ui.componentFactory.add("linkProperties",(t=>{const i=e.commands.get("link"),n=new Bn(t),o=t.t;return n.set({label:o("Link properties"),icon:'\n',tooltip:!0}),n.bind("isEnabled").to(i,"isEnabled",i,"value",i,"manualDecorators",((e,t,i)=>e&&!!t&&i.length>0)),this.listenTo(n,"execute",(()=>{this._addPropertiesView()})),n}))}_createLinksListProviderButton(e){const t=this.editor.locale,i=new qp(t);return i.set({label:e.label}),this.listenTo(i,"execute",(()=>{this._showLinksProviderView(e)})),i}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("link"),o=new e(t.locale),s=i.t;return o.set({label:s("Link"),icon:Dp,keystroke:xp,isToggleable:!0}),o.bind("isEnabled").to(n,"isEnabled"),o.bind("isOn").to(n,"value",(e=>!!e)),this.listenTo(o,"execute",(()=>{t.editing.view.scrollToTheSelection(),this._showUI(!0),this._getSelectedLinkElement()&&this._addFormView()})),o}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),e.keystrokes.set(xp,((t,i)=>{i(),e.commands.get("link").isEnabled&&(e.editing.view.scrollToTheSelection(),this._showUI(!0))}))}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",((e,t)=>{this._isToolbarVisible&&!this.toolbarView.focusTracker.isFocused&&(this.toolbarView.focus(),t())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((e,t)=>{this._isUIVisible&&(this._hideUI(),t())})),mn({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>{this._hideUI(!1)}})}_addToolbarView(){this.toolbarView||this._createViews(),this._isToolbarInPanel||this._balloon.add({view:this.toolbarView,position:this._getBalloonPositionData(),balloonClassName:"ck-toolbar-container"})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this.formView.resetFormStatus(),this.formView.backButtonView.isVisible=e.isEnabled&&!!e.value,this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this.selectedLinkableText=this._getSelectedLinkableText(),this.formView.displayedTextInputView.fieldView.value=this.selectedLinkableText||"",this.formView.urlInputView.fieldView.value=e.value||"",this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions()}_addPropertiesView(){this.propertiesView||this._createViews(),this._arePropertiesInPanel||(this.propertiesView.disableCssTransitions(),this._balloon.add({view:this.propertiesView,position:this._getBalloonPositionData()}),this.propertiesView.enableCssTransitions(),this.propertiesView.focus())}_showLinksProviderView(e){this.linkProviderItemsView&&this._removeLinksProviderView(),this.linkProviderItemsView=this._createLinkProviderItemsView(e),this._addLinkProviderItemsView(e)}_addLinkProviderItemsView(e){this.linkProviderItemsView.listChildren.clear(),this.linkProviderItemsView.listChildren.addMany(this._createLinkProviderListView(e)),this._balloon.add({view:this.linkProviderItemsView,position:this._getBalloonPositionData()}),this.linkProviderItemsView.focus()}_closeFormView(){const e=this.editor.commands.get("link");this.selectedLinkableText=void 0,void 0!==e.value?this._removeFormView():this._hideUI()}_removePropertiesView(){this._arePropertiesInPanel&&this._balloon.remove(this.propertiesView)}_removeLinksProviderView(){this._isLinksListInPanel&&this._balloon.remove(this.linkProviderItemsView)}_removeFormView(e=!0){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this.formView.displayedTextInputView.fieldView.reset(),this.formView.urlInputView.fieldView.reset(),this._balloon.remove(this.formView),e&&this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._isToolbarVisible?this._addFormView():this._addToolbarView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addToolbarView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(e=!0){const t=this.editor;this._isUIInPanel&&(this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e&&t.editing.view.focus(),this._removeLinksProviderView(),this._removePropertiesView(),this._removeFormView(e),this._isToolbarInPanel&&this._balloon.remove(this.toolbarView),this._hideFakeVisualSelection())}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedLinkElement(),n=s();const o=()=>{const e=this._getSelectedLinkElement(),t=s();i&&!e||!i&&t!==n?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=e,n=t};function s(){return t.selection.focus.getAncestors().reverse().find((e=>e.is("element")))}this.listenTo(e.ui,"update",o),this.listenTo(this._balloon,"change:visibleView",o)}get _arePropertiesInPanel(){return!!this.propertiesView&&this._balloon.hasView(this.propertiesView)}get _isLinksListInPanel(){return!!this.linkProviderItemsView&&this._balloon.hasView(this.linkProviderItemsView)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _isToolbarInPanel(){return!!this.toolbarView&&this._balloon.hasView(this.toolbarView)}get _isPropertiesVisible(){return!!this.propertiesView&&this._balloon.visibleView===this.propertiesView}get _isFormVisible(){return!!this.formView&&this._balloon.visibleView==this.formView}get _isToolbarVisible(){return!!this.toolbarView&&this._balloon.visibleView===this.toolbarView}get _isUIInPanel(){return this._arePropertiesInPanel||this._isLinksListInPanel||this._isFormInPanel||this._isToolbarInPanel}get _isUIVisible(){return this._isPropertiesVisible||this._isLinksListInPanel||this._isFormVisible||this._isToolbarVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=e.document;if(this.editor.model.markers.has(jp)){const t=this.editor.editing.mapper.markerNameToElements(jp);if(t){const i=Array.from(t),n=e.createRange(e.createPositionBefore(i[0]),e.createPositionAfter(i[i.length-1]));return{target:e.domConverter.viewRangeToDom(n)}}}return{target:()=>{const i=this._getSelectedLinkElement();return i?e.domConverter.mapViewToDom(i):e.domConverter.viewRangeToDom(t.selection.getFirstRange())}}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,i=t.getSelectedElement();if(t.isCollapsed||i&&qh(i))return Gp(t.getFirstPosition());{const i=t.getFirstRange().getTrimmed(),n=Gp(i.start),o=Gp(i.end);return n&&n==o&&e.createRangeIn(n).getTrimmed().isEqual(i)?n:null}}_getSelectedLinkableText(){const e=this.editor.model,t=this.editor.editing,i=this._getSelectedLinkElement();if(!i)return Ip(e.document.selection.getFirstRange());const n=t.view.createRangeOn(i);return Ip(t.mapper.toModelRange(n))}_getLinkProviderLinkByHref(e){if(!e)return null;for(const t of this._linksProviders){const i=t.getItem?t.getItem(e):t.getListItems().find((t=>t.href===e));if(i)return{provider:t,item:i}}return null}_showFakeVisualSelection(){const e=this.editor.model;e.change((t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(jp))t.updateMarker(jp,{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition((({item:t})=>!e.schema.isContent(t)),{boundaries:i});t.addMarker(jp,{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker(jp,{usingOperation:!1,affectsData:!1,range:i})}))}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(jp)&&e.change((e=>{e.removeMarker(jp)}))}}function Gp(e){return e.getAncestors().find((e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t}))||null}const Kp=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63}))|localhost)(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i");class Jp extends ad{static get requires(){return[gh,Np]}static get pluginName(){return"AutoLink"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.model.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling(),this._enablePasteLinking()}_expandLinkRange(e,t){return t.textNode&&t.textNode.hasAttribute("linkHref")?Eh(t,"linkHref",t.textNode.getAttribute("linkHref"),e):null}_selectEntireLinks(e,t){const i=this.editor.model,n=i.document.selection,o=n.getFirstPosition(),s=n.getLastPosition();let r=t.getJoined(this._expandLinkRange(i,o)||t);r&&(r=r.getJoined(this._expandLinkRange(i,s)||t)),r&&(r.start.isBefore(o)||r.end.isAfter(s))&&e.setSelection(r)}_enablePasteLinking(){const e=this.editor,t=e.model,i=t.document.selection,n=e.plugins.get("ClipboardPipeline"),o=e.commands.get("link");n.on("inputTransformation",((e,n)=>{if(!this.isEnabled||!o.isEnabled||i.isCollapsed||"paste"!==n.method)return;if(i.rangeCount>1)return;const s=i.getFirstRange(),r=n.dataTransfer.getData("text/plain");if(!r)return;const a=r.match(Kp);a&&a[2]===r&&(t.change((e=>{this._selectEntireLinks(e,s),o.execute(r)})),e.stop())}),{priority:"high"})}_enableTypingHandling(){const e=this.editor,t=new bh(e.model,(e=>{let t=e;if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(t))return;t=t.slice(0,-1),"!.:,;?".includes(t[t.length-1])&&(t=t.slice(0,-1));const i=Yp(t);return i?{url:i,removedTrailingCharacters:e.length-t.length}:void 0}));t.on("matched:data",((t,i)=>{const{batch:n,range:o,url:s,removedTrailingCharacters:r}=i;if(!n.isTyping)return;const a=o.end.getShiftedBy(-r),l=a.getShiftedBy(-s.length),c=e.model.createRange(l,a);this._applyAutoLink(s,c)})),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition();let i;i=e.parent.previousSibling?.is("element")?t.createRangeIn(e.parent.previousSibling):t.createRange(t.createPositionAt(e.parent,0),e),this._checkAndApplyAutoLinkOnRange(i)}))}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition(),i=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(i)}))}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:n}=ph(e,t),o=Yp(i);if(o){const e=t.createRange(n.end.getShiftedBy(-o.length),n.end);this._applyAutoLink(o,e)}}_applyAutoLink(e,t){const i=this.editor.model,n=Sp(e,this.editor.config.get("link.defaultProtocol"));this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}(t,i)&&Pp(n)&&!function(e){const t=e.start.nodeAfter;return!!t&&t.hasAttribute("linkHref")}(t)&&this._persistAutoLink(n,t)}_persistAutoLink(e,t){const i=this.editor.model,n=this.editor.plugins.get("Delete");i.enqueueChange((o=>{o.setAttribute("linkHref",e,t),i.enqueueChange((()=>{n.requestUndoOnBackspace()}))}))}}function Yp(e){const t=Kp.exec(e);return t?t[2]:null}class Qp{_startElement;_referenceIndent;_isForward;_includeSelf;_sameAttributes;_sameIndent;_lowerIndent;_higherIndent;constructor(e,t){this._startElement=e,this._referenceIndent=e.getAttribute("listIndent"),this._isForward="forward"==t.direction,this._includeSelf=!!t.includeSelf,this._sameAttributes=zt(t.sameAttributes||[]),this._sameIndent=!!t.sameIndent,this._lowerIndent=!!t.lowerIndent,this._higherIndent=!!t.higherIndent}static first(e,t){return Zt(new this(e,t)[Symbol.iterator]())}*[Symbol.iterator](){const e=[];for(const{node:t}of new Xp(this._getStartNode(),this._isForward?"forward":"backward")){const i=t.getAttribute("listIndent");if(ithis._referenceIndent){if(!this._higherIndent)continue;if(!this._isForward){e.push(t);continue}}else{if(!this._sameIndent){if(this._higherIndent){e.length&&(yield*e,e.length=0);break}continue}if(this._sameAttributes.some((e=>t.getAttribute(e)!==this._startElement.getAttribute(e))))break}e.length&&(yield*e,e.length=0),yield t}}_getStartNode(){return this._includeSelf?this._startElement:this._isForward?this._startElement.nextSibling:this._startElement.previousSibling}}class Xp{_node;_isForward;_previousNodesByIndent=[];_previous=null;_previousNodeIndent=null;constructor(e,t="forward"){this._node=e,this._isForward="forward"===t}[Symbol.iterator](){return this}next(){if(!tb(this._node))return{done:!0,value:void 0};const e=this._node.getAttribute("listIndent");let t=null;if(this._previous){const i=this._previousNodeIndent;e>i?this._previousNodesByIndent[i]=this._previous:ee.getAttribute("listItemId")!=t))}function gb(e){return Array.from(e).filter((e=>"$graveyard"!==e.root.rootName)).sort(((e,t)=>e.index-t.index))}function fb(e){const t=e.document.selection.getSelectedElement();return t&&e.schema.isObject(t)&&e.schema.isBlock(t)?t:null}function pb(e,t){return t.checkChild(e.parent,"listItem")&&t.checkChild(e,"$text")&&!t.isObject(e)}function bb(e){return"numbered"==e||"customNumbered"==e}function wb(e,t,i){return nb(t,{direction:"forward"}).pop().index>e.index?ub(e,t,i):[]}class vb extends cd{_direction;constructor(e,t){super(e),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=yb(e.document.selection);e.change((e=>{const i=[];mb(t)&&!sb(t[0])?("forward"==this._direction&&i.push(...db(t,e)),i.push(...cb(t[0],e))):"forward"==this._direction?i.push(...db(t,e,{expand:!0})):i.push(...function(e,t){const i=ab(e=zt(e)),n=new Set,o=Math.min(...i.map((e=>e.getAttribute("listIndent")))),s=new Map;for(const e of i)s.set(e,Qp.first(e,{lowerIndent:!0}));for(const e of i){if(n.has(e))continue;n.add(e);const i=e.getAttribute("listIndent")-1;if(i<0)hb(e,t);else{if(e.getAttribute("listIndent")==o){const i=wb(e,s.get(e),t);for(const e of i)n.add(e);if(i.length)continue}t.setAttribute("listIndent",i,e)}}return gb(n)}(t,e));for(const t of i){if(!t.hasAttribute("listType"))continue;const i=Qp.first(t,{sameIndent:!0});i&&e.setAttribute("listType",i.getAttribute("listType"),t)}this._fireAfterExecute(i)}))}_fireAfterExecute(e){this.fire("afterExecute",gb(new Set(e)))}_checkEnabled(){let e=yb(this.editor.model.document.selection),t=e[0];if(!t)return!1;if("backward"==this._direction)return!0;if(mb(e)&&!sb(e[0]))return!0;e=ab(e),t=e[0];const i=Qp.first(t,{sameIndent:!0});return!!i&&i.getAttribute("listType")==t.getAttribute("listType")}}function yb(e){const t=Array.from(e.getSelectedBlocks()),i=t.findIndex((e=>!tb(e)));return-1!=i&&(t.length=i),t}class _b extends cd{type;_listWalkerOptions;constructor(e,t,i={}){super(e),this.type=t,this._listWalkerOptions=i.multiLevel?{higherIndent:!0,lowerIndent:!0,sameAttributes:[]}:void 0}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,n=fb(t),o=Array.from(i.selection.getSelectedBlocks()).filter((e=>t.schema.checkAttribute(e,"listType")||pb(e,t.schema))),s=void 0!==e.forceValue?!e.forceValue:this.value;t.change((r=>{if(s){const e=o[o.length-1],t=nb(e,{direction:"forward"}),i=[];t.length>1&&i.push(...cb(t[1],r)),i.push(...hb(o,r)),i.push(...function(e,t){const i=[];let n=Number.POSITIVE_INFINITY;for(const{node:o}of new Xp(e.nextSibling)){const e=o.getAttribute("listIndent");if(0==e)break;e{const{firstElement:s,lastElement:r}=this._getMergeSubjectElements(i,e),a=s.getAttribute("listIndent")||0,l=r.getAttribute("listIndent"),c=r.getAttribute("listItemId");if(a!=l){const e=(u=r,Array.from(new Qp(u,{direction:"forward",higherIndent:!0})));n.push(...db([r,...e],o,{indentBy:a-l,expand:a{const t=cb(this._getStartBlock(),e);this._fireAfterExecute(t)}))}_fireAfterExecute(e){this.fire("afterExecute",gb(new Set(e)))}_checkEnabled(){const e=this.editor.model.document.selection,t=this._getStartBlock();return e.isCollapsed&&tb(t)&&!sb(t)}_getStartBlock(){const e=this.editor.model.document.selection.getFirstPosition().parent;return"before"==this._direction?e:e.nextSibling}}class xb extends ad{static get pluginName(){return"ListItemBoldIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[Mv]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(Mv);e.plugins.has("BoldEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.registerFormatAttribute("bold","listItemBold"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemBold",setAttributeOnDowncast(e,t,i,n){t&&(e.addClass("ck-list-marker-bold",i),!r.isSafari||n&&n.dataPipeline||e.setStyle("--ck-content-list-marker-dummy-bold","0",i))}}))}afterInit(){const e=this.editor,t=e.model;e.plugins.has("BoldEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.schema.extend("$listItem",{allowAttributes:"listItemBold"}),t.schema.setAttributeProperties("listItemBold",{isFormatting:!0}),t.schema.addAttributeCheck((e=>{if(!e.last.getAttribute("listItemId"))return!1}),"listItemBold"),e.conversion.for("upcast").attributeToAttribute({model:"listItemBold",view:{name:"li",classes:"ck-list-marker-bold"}}))}}class Ab extends ad{static get pluginName(){return"ListItemItalicIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[Mv]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(Mv);e.plugins.has("ItalicEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.registerFormatAttribute("italic","listItemItalic"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemItalic",setAttributeOnDowncast(e,t,i,n){t&&(e.addClass("ck-list-marker-italic",i),!r.isSafari||n&&n.dataPipeline||e.setStyle("--ck-content-list-marker-dummy-italic","0",i))}}))}afterInit(){const e=this.editor,t=e.model;e.plugins.has("ItalicEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.schema.extend("$listItem",{allowAttributes:"listItemItalic"}),t.schema.setAttributeProperties("listItemItalic",{isFormatting:!0}),t.schema.addAttributeCheck((e=>{if(!e.last.getAttribute("listItemId"))return!1}),"listItemItalic"),e.conversion.for("upcast").attributeToAttribute({model:"listItemItalic",view:{name:"li",classes:"ck-list-marker-italic"}}))}}class Tb extends cd{attributeKey;constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute(this.attributeKey),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value,o=e.batch,s=e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,n):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(i.getRanges(),this.attributeKey,{includeEmptyRanges:!0});for(const t of o){let i=t,o=this.attributeKey;t.isCollapsed&&(i=t.start.parent,o=Yr._getStoreAttributeKey(this.attributeKey)),n?e.setAttribute(o,n,i):e.removeAttribute(o,i)}}};o?t.enqueueChange(o,(e=>{s(e)})):t.change((e=>{s(e)}))}}class Eb extends Bn{constructor(e){super(e);const t=this.bindTemplate;this.set("color",void 0),this.set("hasBorder",!1),this.icon='',this.extendTemplate({attributes:{style:{backgroundColor:t.to("color",(e=>r.isMediaForcedColors?null:e))},class:["ck","ck-color-grid__tile",t.if("hasBorder","ck-color-selector__color-tile_bordered")]}})}render(){super.render(),this.iconView.fillColor="hsl(0, 0%, 100%)"}}function Sb({keystrokeHandler:e,focusTracker:t,gridItems:i,numberOfColumns:n,uiLanguageDirection:o}){const s="number"==typeof n?()=>n:n;function r(e){return n=>{const o=i.find((e=>e.element===t.focusedElement)),s=i.getIndex(o),r=e(s,i);i.get(r).focus(),n.stopPropagation(),n.preventDefault()}}function a(e,t){return e===t-1?0:e+1}function l(e,t){return 0===e?t-1:e-1}e.set("arrowright",r(((e,t)=>"rtl"===o?l(e,t.length):a(e,t.length)))),e.set("arrowleft",r(((e,t)=>"rtl"===o?a(e,t.length):l(e,t.length)))),e.set("arrowup",r(((e,t)=>{let i=e-s();return i<0&&(i=e+s()*Math.floor(t.length/s()),i>t.length-1&&(i-=s())),i}))),e.set("arrowdown",r(((e,t)=>{let i=e+s();return i>t.length-1&&(i=e%s()),i})))}class Pb extends Hi{columns;items;focusTracker;keystrokes;constructor(e,t){super(e);const i=t&&t.colorDefinitions?t.colorDefinitions:[];this.columns=t?.columns||5;const n={gridTemplateColumns:`repeat( ${this.columns}, 1fr)`};this.set("selectedColor",void 0),this.items=this.createCollection(),this.focusTracker=new ei,this.keystrokes=new oi,this.items.on("add",((e,t)=>{t.isOn=t.color===this.selectedColor})),i.forEach((e=>{const t=new Eb;t.set({color:e.color,label:e.label,tooltip:!0,hasBorder:e.options.hasBorder}),t.on("execute",(()=>{this.fire("execute",{value:e.color,hasBorder:e.options.hasBorder,label:e.label})})),this.items.add(t)})),this.setTemplate({tag:"div",children:this.items,attributes:{class:["ck","ck-color-grid"],style:n}}),this.on("change:selectedColor",((e,t,i)=>{for(const e of this.items)e.isOn=e.color===i}))}focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",((e,t)=>{this.focusTracker.add(t.element)})),this.items.on("remove",((e,t)=>{this.focusTracker.remove(t.element)})),this.keystrokes.listenTo(this.element),Sb({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:this.columns,uiLanguageDirection:this.locale?.uiLanguageDirection})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}class Ib extends(G(Xt)){constructor(e){super(e),this.set("isEmpty",!0),this.on("change",(()=>{this.set("isEmpty",0===this.length)}))}add(e,t){return this.find((t=>t.color===e.color))?this:super.add(e,t)}hasColor(e){return!!this.find((t=>t.color===e))}}const Vb='';class Ob extends Hi{items;colorDefinitions;focusTracker;columns;documentColors;documentColorsCount;staticColorsGrid;documentColorsGrid;colorPickerButtonView;removeColorButtonView;_focusables;_documentColorsLabel;_removeButtonLabel;_colorPickerLabel;constructor(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:o,documentColorsCount:s,colorPickerLabel:r,focusTracker:a,focusables:l}){super(e);const c=this.bindTemplate;this.set("isVisible",!0),this.focusTracker=a,this.items=this.createCollection(),this.colorDefinitions=t,this.columns=i,this.documentColors=new Ib,this.documentColorsCount=s,this._focusables=l,this._removeButtonLabel=n,this._colorPickerLabel=r,this._documentColorsLabel=o,this.setTemplate({tag:"div",attributes:{class:["ck-color-grids-fragment",c.if("isVisible","ck-hidden",(e=>!e))]},children:this.items}),this.removeColorButtonView=this._createRemoveColorButton(),this.items.add(this.removeColorButtonView)}updateDocumentColors(e,t){const i=e.document,n=this.documentColorsCount;this.documentColors.clear();for(const o of i.getRoots()){const i=e.createRangeIn(o);for(const e of i.getItems())if(e.is("$textProxy")&&e.hasAttribute(t)&&(this._addColorToDocumentColors(e.getAttribute(t)),this.documentColors.length>=n))return}}updateSelectedColors(){const e=this.documentColorsGrid,t=this.staticColorsGrid,i=this.selectedColor;t.selectedColor=i,e&&(e.selectedColor=i)}render(){if(super.render(),this.staticColorsGrid=this._createStaticColorsGrid(),this.items.add(this.staticColorsGrid),this.documentColorsCount){const e=vi.bind(this.documentColors,this.documentColors),t=new Hi(this.locale);t.setTemplate({tag:"span",attributes:{class:["ck","ck-color-grid__label",e.if("isEmpty","ck-hidden")]},children:[{text:this._documentColorsLabel}]}),this.items.add(t),this.documentColorsGrid=this._createDocumentColorsGrid(),this.items.add(this.documentColorsGrid)}this._createColorPickerButton(),this._addColorSelectorElementsToFocusTracker()}focus(){this.removeColorButtonView.focus()}destroy(){super.destroy()}addColorPickerButton(){this.colorPickerButtonView&&(this.items.add(this.colorPickerButtonView),this.focusTracker.add(this.colorPickerButtonView.element),this._focusables.add(this.colorPickerButtonView))}_addColorSelectorElementsToFocusTracker(){this.focusTracker.add(this.removeColorButtonView.element),this._focusables.add(this.removeColorButtonView),this.staticColorsGrid&&(this.focusTracker.add(this.staticColorsGrid.element),this._focusables.add(this.staticColorsGrid)),this.documentColorsGrid&&(this.focusTracker.add(this.documentColorsGrid.element),this._focusables.add(this.documentColorsGrid))}_createColorPickerButton(){this.colorPickerButtonView=new Bn,this.colorPickerButtonView.set({label:this._colorPickerLabel,withText:!0,icon:'',class:"ck-color-selector__color-picker"}),this.colorPickerButtonView.on("execute",(()=>{this.fire("colorPicker:show")}))}_createRemoveColorButton(){const e=new Bn;return e.set({withText:!0,icon:Vb,label:this._removeButtonLabel}),e.class="ck-color-selector__remove-color",e.on("execute",(()=>{this.fire("execute",{value:null,source:"removeColorButton"})})),e.render(),e}_createStaticColorsGrid(){const e=new Pb(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return e.on("execute",((e,t)=>{this.fire("execute",{value:t.value,source:"staticColorsGrid"})})),e}_createDocumentColorsGrid(){const e=vi.bind(this.documentColors,this.documentColors),t=new Pb(this.locale,{columns:this.columns});return t.extendTemplate({attributes:{class:e.if("isEmpty","ck-hidden")}}),t.items.bindTo(this.documentColors).using((e=>{const t=new Eb;return t.set({color:e.color,hasBorder:e.options?.hasBorder}),e.label&&t.set({label:e.label,tooltip:!0}),t.on("execute",(()=>{this.fire("execute",{value:e.color,source:"documentColorsGrid"})})),t})),this.documentColors.on("change:isEmpty",((e,i,n)=>{n&&(t.selectedColor=null)})),t}_addColorToDocumentColors(e){const t=this.colorDefinitions.find((t=>t.color===e));t?this.documentColors.add(Object.assign({},t)):this.documentColors.add({color:e,label:e,options:{hasBorder:!1}})}}const Rb={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};for(const e in Rb)Object.freeze(Rb[e]);const Lb=Object.freeze(Rb),Bb=function(e){var t,i,n=[],o=1;if("number"==typeof e)return{space:"rgb",values:[e>>>16,(65280&e)>>>8,255&e],alpha:1};if("number"==typeof e)return{space:"rgb",values:[e>>>16,(65280&e)>>>8,255&e],alpha:1};if(e=String(e).toLowerCase(),Lb[e])n=Lb[e].slice(),i="rgb";else if("transparent"===e)o=0,i="rgb",n=[0,0,0];else if("#"===e[0]){var s=e.slice(1),r=s.length;o=1,r<=4?(n=[parseInt(s[0]+s[0],16),parseInt(s[1]+s[1],16),parseInt(s[2]+s[2],16)],4===r&&(o=parseInt(s[3]+s[3],16)/255)):(n=[parseInt(s[0]+s[1],16),parseInt(s[2]+s[3],16),parseInt(s[4]+s[5],16)],8===r&&(o=parseInt(s[6]+s[7],16)/255)),n[0]||(n[0]=0),n[1]||(n[1]=0),n[2]||(n[2]=0),i="rgb"}else if(t=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(e)){var a=t[1],l="cmyk"===(i=a.replace(/a$/,""))?4:"gray"===i?1:3;n=t[2].trim().split(/\s*[,\/]\s*|\s+/),"color"===i&&(i=n.shift()),o=(n=n.map((function(e,t){if("%"===e[e.length-1])return e=parseFloat(e)/100,3===t?e:"rgb"===i?255*e:"h"===i[0]?100*e:"l"!==i[0]||t?"lab"===i?125*e:"lch"===i?t<2?150*e:360*e:"o"!==i[0]||t?"oklab"===i?.4*e:"oklch"===i?t<2?.4*e:360*e:e:e:100*e;if("h"===i[t]||2===t&&"h"===i[i.length-1]){if(void 0!==Mb[e])return Mb[e];if(e.endsWith("deg"))return parseFloat(e);if(e.endsWith("turn"))return 360*parseFloat(e);if(e.endsWith("grad"))return 360*parseFloat(e)/400;if(e.endsWith("rad"))return 180*parseFloat(e)/Math.PI}return"none"===e?0:parseFloat(e)}))).length>l?n.pop():1}else/[0-9](?:\s|\/|,)/.test(e)&&(n=e.match(/([0-9]+)/g).map((function(e){return parseFloat(e)})),i=e.match(/([a-z])/gi)?.join("")?.toLowerCase()||"rgb");return{space:i,values:n,alpha:o}};var Mb={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};const Nb={};for(const e of Object.keys(Lb))Nb[Lb[e]]=e;const Fb={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},Db=Fb,zb=(6/29)**3;function Hb(e){const t=e>.0031308?1.055*e**(1/2.4)-.055:12.92*e;return Math.min(Math.max(0,t),1)}function Ub(e){return e>.04045?((e+.055)/1.055)**2.4:e/12.92}for(const e of Object.keys(Fb)){if(!("channels"in Fb[e]))throw new Error("missing channels property: "+e);if(!("labels"in Fb[e]))throw new Error("missing channel labels property: "+e);if(Fb[e].labels.length!==Fb[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:i}=Fb[e];delete Fb[e].channels,delete Fb[e].labels,Object.defineProperty(Fb[e],"channels",{value:t}),Object.defineProperty(Fb[e],"labels",{value:i})}function $b(e,t){return function(i){return t(e(i))}}function qb(e,t){const i=[t[e].parent,e];let n=Db[t[e].parent][e],o=t[e].parent;for(;t[o].parent;)i.unshift(t[o].parent),n=$b(Db[t[o].parent][o],n),o=t[o].parent;return n.conversion=i,n}Fb.rgb.hsl=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,o=Math.min(t,i,n),s=Math.max(t,i,n),r=s-o;let a,l;switch(s){case o:a=0;break;case t:a=(i-n)/r;break;case i:a=2+(n-t)/r;break;case n:a=4+(t-i)/r}a=Math.min(60*a,360),a<0&&(a+=360);const c=(o+s)/2;return l=s===o?0:c<=.5?r/(s+o):r/(2-s-o),[a,100*l,100*c]},Fb.rgb.hsv=function(e){let t,i,n,o,s;const r=e[0]/255,a=e[1]/255,l=e[2]/255,c=Math.max(r,a,l),u=c-Math.min(r,a,l),d=function(e){return(c-e)/6/u+.5};if(0===u)o=0,s=0;else{switch(s=u/c,t=d(r),i=d(a),n=d(l),c){case r:o=n-i;break;case a:o=1/3+t-n;break;case l:o=2/3+i-t}o<0?o+=1:o>1&&(o-=1)}return[360*o,100*s,100*c]},Fb.rgb.hwb=function(e){const t=e[0],i=e[1];let n=e[2];const o=Fb.rgb.hsl(e)[0],s=1/255*Math.min(t,Math.min(i,n));return n=1-1/255*Math.max(t,Math.max(i,n)),[o,100*s,100*n]},Fb.rgb.oklab=function(e){const t=Ub(e[0]/255),i=Ub(e[1]/255),n=Ub(e[2]/255),o=Math.cbrt(.4122214708*t+.5363325363*i+.0514459929*n),s=Math.cbrt(.2119034982*t+.6806995451*i+.1073969566*n),r=Math.cbrt(.0883024619*t+.2817188376*i+.6299787005*n);return[100*(.2104542553*o+.793617785*s-.0040720468*r),100*(1.9779984951*o-2.428592205*s+.4505937099*r),100*(.0259040371*o+.7827717662*s-.808675766*r)]},Fb.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,o=Math.min(1-t,1-i,1-n);return[100*((1-t-o)/(1-o)||0),100*((1-i-o)/(1-o)||0),100*((1-n-o)/(1-o)||0),100*o]},Fb.rgb.keyword=function(e){const t=Nb[e];if(t)return t;let i,n=Number.POSITIVE_INFINITY;for(const t of Object.keys(Lb)){const r=(s=Lb[t],((o=e)[0]-s[0])**2+(o[1]-s[1])**2+(o[2]-s[2])**2);rzb?i**(1/3):7.787*i+16/116,n=n>zb?n**(1/3):7.787*n+16/116,o=o>zb?o**(1/3):7.787*o+16/116,[116*n-16,500*(i-n),200*(n-o)]},Fb.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;let o,s;if(0===i)return s=255*n,[s,s,s];const r=n<.5?n*(1+i):n+i-n*i,a=2*n-r,l=[0,0,0];for(let e=0;e<3;e++)o=t+1/3*-(e-1),o<0&&o++,o>1&&o--,s=6*o<1?a+6*(r-a)*o:2*o<1?r:3*o<2?a+(r-a)*(2/3-o)*6:a,l[e]=255*s;return l},Fb.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,n=e[2]/100,o=i;const s=Math.max(n,.01);return n*=2,i*=n<=1?n:2-n,o*=s<=1?s:2-s,[t,100*(0===n?2*o/(s+o):2*i/(n+i)),(n+i)/2*100]},Fb.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let n=e[2]/100;const o=Math.floor(t)%6,s=t-Math.floor(t),r=255*n*(1-i),a=255*n*(1-i*s),l=255*n*(1-i*(1-s));switch(n*=255,o){case 0:return[n,l,r];case 1:return[a,n,r];case 2:return[r,n,l];case 3:return[r,a,n];case 4:return[l,r,n];case 5:return[n,r,a]}},Fb.hsv.hsl=function(e){const t=e[0],i=e[1]/100,n=e[2]/100,o=Math.max(n,.01);let s,r;r=(2-i)*n;const a=(2-i)*o;return s=i*o,s/=a<=1?a:2-a,s=s||0,r/=2,[t,100*s,100*r]},Fb.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,n=e[2]/100;const o=i+n;let s;o>1&&(i/=o,n/=o);const r=Math.floor(6*t),a=1-n;s=6*t-r,1&r&&(s=1-s);const l=i+s*(a-i);let c,u,d;switch(r){default:case 6:case 0:c=a,u=l,d=i;break;case 1:c=l,u=a,d=i;break;case 2:c=i,u=a,d=l;break;case 3:c=i,u=l,d=a;break;case 4:c=l,u=i,d=a;break;case 5:c=a,u=i,d=l}return[255*c,255*u,255*d]},Fb.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,o=e[3]/100;return[255*(1-Math.min(1,t*(1-o)+o)),255*(1-Math.min(1,i*(1-o)+o)),255*(1-Math.min(1,n*(1-o)+o))]},Fb.xyz.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100;let o,s,r;return o=3.2404542*t+-1.5371385*i+-.4985314*n,s=-.969266*t+1.8760108*i+.041556*n,r=.0556434*t+-.2040259*i+1.0572252*n,o=Hb(o),s=Hb(s),r=Hb(r),[255*o,255*s,255*r]},Fb.xyz.lab=function(e){let t=e[0],i=e[1],n=e[2];return t/=95.047,i/=100,n/=108.883,t=t>zb?t**(1/3):7.787*t+16/116,i=i>zb?i**(1/3):7.787*i+16/116,n=n>zb?n**(1/3):7.787*n+16/116,[116*i-16,500*(t-i),200*(i-n)]},Fb.xyz.oklab=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,o=Math.cbrt(.8189330101*t+.3618667424*i-.1288597137*n),s=Math.cbrt(.0329845436*t+.9293118715*i+.0361456387*n),r=Math.cbrt(.0482003018*t+.2643662691*i+.633851707*n);return[100*(.2104542553*o+.793617785*s-.0040720468*r),100*(1.9779984951*o-2.428592205*s+.4505937099*r),100*(.0259040371*o+.7827717662*s-.808675766*r)]},Fb.oklab.oklch=function(e){return Fb.lab.lch(e)},Fb.oklab.xyz=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,o=(.999999998*t+.396337792*i+.215803758*n)**3,s=(1.000000008*t-.105561342*i-.063854175*n)**3,r=(1.000000055*t-.089484182*i-1.291485538*n)**3;return[100*(1.227013851*o-.55779998*s+.281256149*r),100*(-.040580178*o+1.11225687*s-.071676679*r),100*(-.076381285*o-.421481978*s+1.58616322*r)]},Fb.oklab.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,o=(t+.3963377774*i+.2158037573*n)**3,s=(t-.1055613458*i-.0638541728*n)**3,r=(t-.0894841775*i-1.291485548*n)**3;return[255*Hb(4.0767416621*o-3.3077115913*s+.2309699292*r),255*Hb(-1.2684380046*o+2.6097574011*s-.3413193965*r),255*Hb(-.0041960863*o-.7034186147*s+1.707614701*r)]},Fb.oklch.oklab=function(e){return Fb.lch.lab(e)},Fb.lab.xyz=function(e){let t,i,n;i=(e[0]+16)/116,t=e[1]/500+i,n=i-e[2]/200;const o=i**3,s=t**3,r=n**3;return i=o>zb?o:(i-16/116)/7.787,t=s>zb?s:(t-16/116)/7.787,n=r>zb?r:(n-16/116)/7.787,t*=95.047,i*=100,n*=108.883,[t,i,n]},Fb.lab.lch=function(e){const t=e[0],i=e[1],n=e[2];let o;return o=360*Math.atan2(n,i)/2/Math.PI,o<0&&(o+=360),[t,Math.sqrt(i*i+n*n),o]},Fb.lch.lab=function(e){const t=e[0],i=e[1],n=e[2]/360*2*Math.PI;return[t,i*Math.cos(n),i*Math.sin(n)]},Fb.rgb.ansi16=function(e,t=null){const[i,n,o]=e;let s=null===t?Fb.rgb.hsv(e)[2]:t;if(s=Math.round(s/50),0===s)return 30;let r=30+(Math.round(o/255)<<2|Math.round(n/255)<<1|Math.round(i/255));return 2===s&&(r+=60),r},Fb.hsv.ansi16=function(e){return Fb.rgb.ansi16(Fb.hsv.rgb(e),e[2])},Fb.rgb.ansi256=function(e){const t=e[0],i=e[1],n=e[2];return t>>4==i>>4&&i>>4==n>>4?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)},Fb.ansi16.rgb=function(e){let t=(e=e[0])%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const i=.5*(Math.trunc(e>50)+1);return[(1&t)*i*255,(t>>1&1)*i*255,(t>>2&1)*i*255]},Fb.ansi256.rgb=function(e){if((e=e[0])>=232){const t=10*(e-232)+8;return[t,t,t]}let t;return e-=16,[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},Fb.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".slice(t.length)+t},Fb.hex.rgb=function(e){const t=e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!t)return[0,0,0];let i=t[0];3===t[0].length&&(i=[...i].map((e=>e+e)).join(""));const n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,255&n]},Fb.rgb.hcg=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,o=Math.max(Math.max(t,i),n),s=Math.min(Math.min(t,i),n),r=o-s;let a;return a=r<=0?0:o===t?(i-n)/r%6:o===i?2+(n-t)/r:4+(t-i)/r,a/=6,a%=1,[360*a,100*r,100*(r<1?s/(1-r):0)]},Fb.hsl.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=i<.5?2*t*i:2*t*(1-i);let o=0;return n<1&&(o=(i-.5*n)/(1-n)),[e[0],100*n,100*o]},Fb.hsv.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=t*i;let o=0;return n<1&&(o=(i-n)/(1-n)),[e[0],100*n,100*o]},Fb.hcg.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;if(0===i)return[255*n,255*n,255*n];const o=[0,0,0],s=t%1*6,r=s%1,a=1-r;let l=0;switch(Math.floor(s)){case 0:o[0]=1,o[1]=r,o[2]=0;break;case 1:o[0]=a,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=r;break;case 3:o[0]=0,o[1]=a,o[2]=1;break;case 4:o[0]=r,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=a}return l=(1-i)*n,[255*(i*o[0]+l),255*(i*o[1]+l),255*(i*o[2]+l)]},Fb.hcg.hsv=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);let n=0;return i>0&&(n=t/i),[e[0],100*n,100*i]},Fb.hcg.hsl=function(e){const t=e[1]/100,i=e[2]/100*(1-t)+.5*t;let n=0;return i>0&&i<.5?n=t/(2*i):i>=.5&&i<1&&(n=t/(2*(1-i))),[e[0],100*n,100*i]},Fb.hcg.hwb=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);return[e[0],100*(i-t),100*(1-i)]},Fb.hwb.hcg=function(e){const t=e[1]/100,i=1-e[2]/100,n=i-t;let o=0;return n<1&&(o=(i-n)/(1-n)),[e[0],100*n,100*o]},Fb.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},Fb.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},Fb.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},Fb.gray.hsl=function(e){return[0,0,e[0]]},Fb.gray.hsv=Fb.gray.hsl,Fb.gray.hwb=function(e){return[0,100,e[0]]},Fb.gray.cmyk=function(e){return[0,0,0,e[0]]},Fb.gray.lab=function(e){return[e[0],0,0]},Fb.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".slice(i.length)+i},Fb.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};const jb=function(e){const t=function(e){const t=function(){const e={},t=Object.keys(Db);for(let{length:i}=t,n=0;n0;){const e=i.pop(),n=Object.keys(Db[e]);for(let{length:o}=n,s=0;s1&&(t=i),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}function Jb(e){const t=function(...t){const i=t[0];if(null==i)return i;i.length>1&&(t=i);const n=e(t);if("object"==typeof n)for(let{length:e}=n,t=0;te>i?i:eMath.round(i*e)/i;Math.PI;const tw=e=>("#"===e[0]&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?ew(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:8===e.length?ew(parseInt(e.substring(6,8),16)/255,2):1}),iw=e=>{const{h:t,s:i,l:n}=(({h:e,s:t,v:i,a:n})=>{const o=(200-t)*i/100;return{h:ew(e),s:ew(o>0&&o<200?t*i/100/(o<=100?o:200-o)*100:0),l:ew(o/2),a:ew(n,2)}})(e);return`hsl(${t}, ${i}%, ${n}%)`},nw=e=>{const t=e.toString(16);return t.length<2?"0"+t:t},ow=(e,t)=>{if(e===t)return!0;for(const i in e)if(e[i]!==t[i])return!1;return!0},sw={},rw=e=>{let t=sw[e];return t||(t=document.createElement("template"),t.innerHTML=e,sw[e]=t),t},aw=(e,t,i)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))};let lw=!1;const cw=e=>"touches"in e,uw=(e,t)=>{const i=cw(t)?t.touches[0]:t,n=e.el.getBoundingClientRect();aw(e.el,"move",e.getMove({x:Zb((i.pageX-(n.left+window.pageXOffset))/n.width),y:Zb((i.pageY-(n.top+window.pageYOffset))/n.height)}))};class dw{constructor(e,t,i,n){const o=rw(`
`);e.appendChild(o.content.cloneNode(!0));const s=e.querySelector(`[part=${t}]`);s.addEventListener("mousedown",this),s.addEventListener("touchstart",this),s.addEventListener("keydown",this),this.el=s,this.xy=n,this.nodes=[s.firstChild,s]}set dragging(e){const t=e?document.addEventListener:document.removeEventListener;t(lw?"touchmove":"mousemove",this),t(lw?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!(e=>!(lw&&!cw(e)||(lw||(lw=cw(e)),0)))(e)||!lw&&0!=e.button)return;this.el.focus(),uw(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),uw(this,e);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":((e,t)=>{const i=t.keyCode;i>40||e.xy&&i<37||i<33||(t.preventDefault(),aw(e.el,"move",e.getMove({x:39===i?.01:37===i?-.01:34===i?.05:33===i?-.05:35===i?1:36===i?-1:0,y:40===i?.01:38===i?-.01:0},!0)))})(this,e)}}style(e){e.forEach(((e,t)=>{for(const i in e)this.nodes[t].style.setProperty(i,e[i])}))}}class hw extends dw{constructor(e){super(e,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}update({h:e}){this.h=e,this.style([{left:e/360*100+"%",color:iw({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${ew(e)}`)}getMove(e,t){return{h:t?Zb(this.h+360*e.x,0,360):360*e.x}}}class mw extends dw{constructor(e){super(e,"saturation",'aria-label="Color"',!0)}update(e){this.hsva=e,this.style([{top:100-e.v+"%",left:`${e.s}%`,color:iw(e)},{"background-color":iw({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${ew(e.s)}%, Brightness ${ew(e.v)}%`)}getMove(e,t){return{s:t?Zb(this.hsva.s+100*e.x,0,100):100*e.x,v:t?Zb(this.hsva.v-100*e.y,0,100):Math.round(100-100*e.y)}}}const gw=Symbol("same"),fw=Symbol("color"),pw=Symbol("hsva"),bw=Symbol("update"),ww=Symbol("parts"),vw=Symbol("css"),yw=Symbol("sliders");class _w extends HTMLElement{static get observedAttributes(){return["color"]}get[vw](){return[':host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}',"[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}","[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}"]}get[yw](){return[mw,hw]}get color(){return this[fw]}set color(e){if(!this[gw](e)){const t=this.colorModel.toHsva(e);this[bw](t),this[fw]=e}}constructor(){super();const e=rw(``),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[ww]=this[yw].map((e=>new e(t)))}connectedCallback(){if(this.hasOwnProperty("color")){const e=this.color;delete this.color,this.color=e}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(e,t,i){const n=this.colorModel.fromAttr(i);this[gw](n)||(this.color=n)}handleEvent(e){const t=this[pw],i={...t,...e.detail};let n;this[bw](i),ow(i,t)||this[gw](n=this.colorModel.fromHsva(i))||(this[fw]=n,aw(this,"color-changed",{value:n}))}[gw](e){return this.color&&this.colorModel.equal(e,this.color)}[bw](e){this[pw]=e,this[ww].forEach((t=>t.update(e)))}}const kw={defaultColor:"#000",toHsva:e=>(({r:e,g:t,b:i,a:n})=>{const o=Math.max(e,t,i),s=o-Math.min(e,t,i),r=s?o===e?(t-i)/s:o===t?2+(i-e)/s:4+(e-t)/s:0;return{h:ew(60*(r<0?r+6:r)),s:ew(o?s/o*100:0),v:ew(o/255*100),a:n}})(tw(e)),fromHsva:({h:e,s:t,v:i})=>(({r:e,g:t,b:i,a:n})=>{const o=n<1?nw(ew(255*n)):"";return"#"+nw(e)+nw(t)+nw(i)+o})((({h:e,s:t,v:i,a:n})=>{e=e/360*6,t/=100,i/=100;const o=Math.floor(e),s=i*(1-t),r=i*(1-(e-o)*t),a=i*(1-(1-e+o)*t),l=o%6;return{r:ew(255*[i,r,s,s,a,i][l]),g:ew(255*[a,i,i,r,s,s][l]),b:ew(255*[s,s,a,i,i,r][l]),a:ew(n,2)}})({h:e,s:t,v:i,a:1})),equal:(e,t)=>e.toLowerCase()===t.toLowerCase()||ow(tw(e),tw(t)),fromAttr:e=>e};class Cw extends _w{get colorModel(){return kw}}class xw extends Hi{hexInputRow;_debounceColorPickerEvent;_config;constructor(e,t={}){super(e),this.set({color:"",_hexColor:""}),this.hexInputRow=this._createInputRow();const i=this.createCollection();t.hideInput||i.add(this.hexInputRow),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker"],tabindex:-1},children:i}),this._config=t,this._debounceColorPickerEvent=Wi((e=>{this.set("color",e),this.fire("colorSelected",{color:this.color})}),150,{leading:!0}),this.on("set:color",((e,t,i)=>{e.return=Qb(i,this._config.format||"hsl")})),this.on("change:color",(()=>{this._hexColor=Aw(this.color)})),this.on("change:_hexColor",(()=>{document.activeElement!==this.picker&&this.picker.setAttribute("color",this._hexColor),Aw(this.color)!=Aw(this._hexColor)&&(this.color=this._hexColor)}))}render(){var e,t;if(super.render(),e="hex-color-picker",t=Cw,void 0===customElements.get(e)&&customElements.define(e,t),this.picker=n.document.createElement("hex-color-picker"),this.picker.setAttribute("class","hex-color-picker"),this.picker.setAttribute("tabindex","-1"),this._createSlidersView(),this.element){this.hexInputRow.element?this.element.insertBefore(this.picker,this.hexInputRow.element):this.element.appendChild(this.picker);const e=document.createElement("style");e.textContent='[role="slider"]:focus [part$="pointer"] {border: 1px solid #fff;outline: 1px solid var(--ck-color-focus-border);box-shadow: 0 0 0 2px #fff;}',this.picker.shadowRoot.appendChild(e)}this.picker.addEventListener("color-changed",(e=>{const t=e.detail.value;this._debounceColorPickerEvent(t)}))}focus(){!this._config.hideInput&&(r.isGecko||r.isiOS||r.isSafari||r.isBlink)&&this.hexInputRow.children.get(1).focus(),this.slidersView.first.focus()}_createSlidersView(){const e=[...this.picker.shadowRoot.children].filter((e=>"slider"===e.getAttribute("role"))).map((e=>new Tw(e)));this.slidersView=this.createCollection(),e.forEach((e=>{this.slidersView.add(e)}))}_createInputRow(){const e=this._createColorInput();return new Sw(this.locale,e)}_createColorInput(){const e=new yf(this.locale,Af),{t}=this.locale;return e.set({label:t("HEX"),class:"color-picker-hex-input"}),e.fieldView.bind("value").to(this,"_hexColor",(t=>e.isFocused?e.fieldView.value:t.startsWith("#")?t.substring(1):t)),e.fieldView.on("input",(()=>{const t=e.fieldView.element.value;if(t){const e=Pw(t);e&&this._debounceColorPickerEvent(e)}})),e}isValid(){const{t:e}=this.locale;return!!this._config.hideInput||(this.resetValidationStatus(),!!this.hexInputRow.getParsedColor()||(this.hexInputRow.inputView.errorText=e('Please enter a valid color (e.g. "ff0000").'),!1))}resetValidationStatus(){this.hexInputRow.inputView.errorText=null}}function Aw(e){let t=function(e){if(!e)return"";const t=Xb(e);return t?"hex"===t.space?t.hexValue:Qb(e,"hex"):"#000"}(e);return t||(t="#000"),4===t.length&&(t="#"+[t[1],t[1],t[2],t[2],t[3],t[3]].join("")),t.toLowerCase()}class Tw extends Hi{constructor(e){super(),this.element=e}focus(){this.element.focus()}}class Ew extends Hi{constructor(e){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__hash-view"]},children:"#"})}}class Sw extends Hi{children;inputView;constructor(e,t){super(e),this.inputView=t,this.children=this.createCollection([new Ew,this.inputView]),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__row"]},children:this.children})}getParsedColor(){return Pw(this.inputView.fieldView.element.value)}}function Pw(e){if(!e)return null;const t=e.trim().replace(/^#/,"");return[3,4,6,8].includes(t.length)&&/^(([0-9a-fA-F]{2}){3,4}|([0-9a-fA-F]){3,4})$/.test(t)?`#${t}`:null}class Iw extends Hi{items;colorPickerView;saveButtonView;cancelButtonView;actionBarView;focusTracker;keystrokes;_focusables;_colorPickerViewConfig;constructor(e,{focusTracker:t,focusables:i,keystrokes:n,colorPickerViewConfig:o}){super(e),this.items=this.createCollection(),this.focusTracker=t,this.keystrokes=n,this.set("isVisible",!1),this.set("selectedColor",void 0),this._focusables=i,this._colorPickerViewConfig=o;const s=this.bindTemplate,{saveButtonView:r,cancelButtonView:a}=this._createActionButtons();this.saveButtonView=r,this.cancelButtonView=a,this.actionBarView=this._createActionBarView({saveButtonView:r,cancelButtonView:a}),this.setTemplate({tag:"div",attributes:{class:["ck-color-picker-fragment",s.if("isVisible","ck-hidden",(e=>!e))]},children:this.items})}render(){super.render();const e=new xw(this.locale,{...this._colorPickerViewConfig});this.colorPickerView=e,this.colorPickerView.render(),this.selectedColor&&(e.color=this.selectedColor),this.listenTo(this,"change:selectedColor",((t,i,n)=>{e.color=n})),this.items.add(this.colorPickerView),this.items.add(this.actionBarView),this._addColorPickersElementsToFocusTracker(),this._stopPropagationOnArrowsKeys(),this._executeOnEnterPress(),this._executeUponColorChange()}destroy(){super.destroy()}focus(){this.colorPickerView.focus()}resetValidationStatus(){this.colorPickerView.resetValidationStatus()}_executeOnEnterPress(){this.keystrokes.set("enter",(e=>{this.isVisible&&this.focusTracker.focusedElement!==this.cancelButtonView.element&&this.colorPickerView.isValid()&&(this.fire("execute",{value:this.selectedColor}),e.stopPropagation(),e.preventDefault())}))}_stopPropagationOnArrowsKeys(){const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}_addColorPickersElementsToFocusTracker(){for(const e of this.colorPickerView.slidersView)this.focusTracker.add(e.element),this._focusables.add(e);const e=this.colorPickerView.hexInputRow.children.get(1);e.element&&(this.focusTracker.add(e.element),this._focusables.add(e)),this.focusTracker.add(this.saveButtonView.element),this._focusables.add(this.saveButtonView),this.focusTracker.add(this.cancelButtonView.element),this._focusables.add(this.cancelButtonView)}_createActionBarView({saveButtonView:e,cancelButtonView:t}){const i=new Hi,n=this.createCollection();return n.add(e),n.add(t),i.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector_action-bar"]},children:n}),i}_createActionButtons(){const e=this.locale,t=e.t,i=new Bn(e),n=new Bn(e);return i.set({icon:Tu,class:"ck-button-save",type:"button",withText:!1,label:t("Accept")}),n.set({icon:On,class:"ck-button-cancel",type:"button",withText:!1,label:t("Cancel")}),i.on("execute",(()=>{this.colorPickerView.isValid()&&this.fire("execute",{source:"colorPickerSaveButton",value:this.selectedColor})})),n.on("execute",(()=>{this.fire("colorPicker:cancel")})),{saveButtonView:i,cancelButtonView:n}}_executeUponColorChange(){this.colorPickerView.on("colorSelected",((e,t)=>{this.fire("execute",{value:t.color,source:"colorPicker"}),this.set("selectedColor",t.color)}))}}class Vw extends Hi{focusTracker;keystrokes;items;colorGridsFragmentView;colorPickerFragmentView;_focusCycler;_focusables;_colorPickerViewConfig;constructor(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:o,documentColorsCount:s,colorPickerLabel:r,colorPickerViewConfig:a}){super(e),this.items=this.createCollection(),this.focusTracker=new ei,this.keystrokes=new oi,this._focusables=new wi,this._colorPickerViewConfig=a,this._focusCycler=new Nn({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.colorGridsFragmentView=new Ob(e,{colors:t,columns:i,removeButtonLabel:n,documentColorsLabel:o,documentColorsCount:s,colorPickerLabel:r,focusTracker:this.focusTracker,focusables:this._focusables}),this.colorPickerFragmentView=new Iw(e,{focusables:this._focusables,focusTracker:this.focusTracker,keystrokes:this.keystrokes,colorPickerViewConfig:a}),this.set("_isColorGridsFragmentVisible",!0),this.set("_isColorPickerFragmentVisible",!1),this.set("selectedColor",void 0),this.colorGridsFragmentView.bind("isVisible").to(this,"_isColorGridsFragmentVisible"),this.colorPickerFragmentView.bind("isVisible").to(this,"_isColorPickerFragmentVisible"),this.on("change:selectedColor",((e,t,i)=>{this.colorGridsFragmentView.set("selectedColor",i),this.colorPickerFragmentView.set("selectedColor",i)})),this.colorGridsFragmentView.on("change:selectedColor",((e,t,i)=>{this.set("selectedColor",i)})),this.colorPickerFragmentView.on("change:selectedColor",((e,t,i)=>{this.set("selectedColor",i)})),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector"]},children:this.items})}render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}appendUI(){this._appendColorGridsFragment(),this._colorPickerViewConfig&&this._appendColorPickerFragment()}showColorPickerFragment(){this.colorPickerFragmentView.colorPickerView&&!this._isColorPickerFragmentVisible&&(this._isColorPickerFragmentVisible=!0,this.colorPickerFragmentView.focus(),this.colorPickerFragmentView.resetValidationStatus(),this._isColorGridsFragmentVisible=!1)}showColorGridsFragment(){this._isColorGridsFragmentVisible||(this._isColorGridsFragmentVisible=!0,this.colorGridsFragmentView.focus(),this._isColorPickerFragmentVisible=!1)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}updateDocumentColors(e,t){this.colorGridsFragmentView.updateDocumentColors(e,t)}updateSelectedColors(){this.colorGridsFragmentView.updateSelectedColors()}_appendColorGridsFragment(){this.items.length||(this.items.add(this.colorGridsFragmentView),this.colorGridsFragmentView.delegate("execute").to(this),this.colorGridsFragmentView.delegate("colorPicker:show").to(this))}_appendColorPickerFragment(){2!==this.items.length&&(this.items.add(this.colorPickerFragmentView),this.colorGridsFragmentView.colorPickerButtonView&&this.colorGridsFragmentView.colorPickerButtonView.on("execute",(()=>{this.showColorPickerFragment()})),this.colorGridsFragmentView.addColorPickerButton(),this.colorPickerFragmentView.delegate("execute").to(this),this.colorPickerFragmentView.delegate("colorPicker:cancel").to(this))}}const Ow="fontSize",Rw="fontFamily",Lw="fontColor",Bw="fontBackgroundColor";function Mw(e,t){const i={model:{key:e,values:[]},view:{},upcastAlso:{}};for(const e of t)i.model.values.push(e.model),i.view[e.model]=e.view,e.upcastAlso&&(i.upcastAlso[e.model]=e.upcastAlso);return i}function Nw(e){return t=>t.getStyle(e).replace(/\s/g,"")}function Fw(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class Dw extends Tb{constructor(e){super(e,Rw)}}function zw(e){return e.map(Uw).filter((e=>void 0!==e))}function Hw(e){return e.replace(/["']/g,"").split(",").map((e=>e.trim()))}function Uw(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=Hw(e),i=t[0],n=t.map($w).join(", ");return{title:i,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}(e):void 0}function $w(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class qw extends ad{static get pluginName(){return"FontFamilyEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(Rw,{options:["default","Arial, Helvetica, sans-serif","Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Rw}),e.model.schema.setAttributeProperties(Rw,{isFormatting:!0,copyOnEnter:!0});const t=zw(e.config.get("fontFamily.options")).filter((e=>e.model)),i=Mw(Rw,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(Rw,new Dw(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:Rw,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:Rw,value:e=>e.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:Rw,value:e=>e.getAttribute("face")}})}}const jw='';class Ww extends ad{static get pluginName(){return"FontFamilyUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(Rw),o=t("Font Family"),s=function(e,t){const i=new Xt;for(const n of e){const e={type:"button",model:new sf({commandName:Rw,commandParam:n.model,label:n.title,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(e=>e===n.model||!(!e||!n.model)&&Hw(e)[0].toLowerCase()===Hw(n.model)[0].toLowerCase())),n.view&&"string"!=typeof n.view&&n.view.styles&&e.model.set("labelStyle",`font-family: ${n.view.styles["font-family"]}`),i.add(e)}return i}(i,n);e.ui.componentFactory.add(Rw,(t=>{const i=Pu(t);return Ou(i,s,{role:"menu",ariaLabel:o}),i.buttonView.set({label:o,icon:jw,tooltip:!0}),i.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),i.bind("isEnabled").to(n),this.listenTo(i,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),i})),e.ui.componentFactory.add(`menuBar:${Rw}`,(t=>{const i=new Gu(t);i.buttonView.set({label:o,icon:jw}),i.bind("isEnabled").to(n);const r=new Ku(t);for(const n of s){const o=new hn(t,i),s=new Yu(t);s.set({role:"menuitemradio",isToggleable:!0}),s.bind(...Object.keys(n.model)).to(n.model),s.delegate("execute").to(i),s.on("execute",(()=>{e.execute(n.model.commandName,{value:n.model.commandParam}),e.editing.view.focus()})),o.children.add(s),r.items.add(o)}return i.panelView.children.add(r),i}))}_getLocalizedOptions(){const e=this.editor,t=e.t;return zw(e.config.get(Rw).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class Gw extends ad{static get requires(){return[qw,Ww]}static get pluginName(){return"FontFamily"}static get isOfficialPlugin(){return!0}}class Kw extends Tb{constructor(e){super(e,Ow)}}function Jw(e){return e.map((e=>function(e){if("number"==typeof e&&(e=String(e)),"object"==typeof e&&((t=e).title&&t.model&&t.view))return Qw(e);var t;const i=function(e){return"string"==typeof e?Yw[e]:Yw[e.model]}(e);return i?Qw(i):"default"===e?{model:void 0,title:"Default"}:function(e){let t;if("object"==typeof e){if(!e.model)throw new x("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}(e)?void 0:function(e){return"string"==typeof e&&(e={title:e,model:`${parseFloat(e)}px`}),e.view={name:"span",styles:{"font-size":e.model}},Qw(e)}(e)}(e))).filter((e=>void 0!==e))}const Yw={get tiny(){return{title:"Tiny",model:"tiny",view:{name:"span",classes:"text-tiny",priority:7}}},get small(){return{title:"Small",model:"small",view:{name:"span",classes:"text-small",priority:7}}},get big(){return{title:"Big",model:"big",view:{name:"span",classes:"text-big",priority:7}}},get huge(){return{title:"Huge",model:"huge",view:{name:"span",classes:"text-huge",priority:7}}}};function Qw(e){return e.view&&"string"!=typeof e.view&&!e.view.priority&&(e.view.priority=7),e}const Xw=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class Zw extends ad{static get pluginName(){return"FontSizeEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(Ow,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Ow}),e.model.schema.setAttributeProperties(Ow,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=Jw(this.editor.config.get("fontSize.options")).filter((e=>e.model)),n=Mw(Ow,i);t?(this._prepareAnyValueConverters(n),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(Ow,new Kw(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter((e=>!Rc(String(e))&&!Bc(String(e))));if(i.length)throw new x("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:Ow,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:Ow,value:e=>e.getStyle("font-size")},view:{name:"span",styles:{"font-size":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{size:/^[+-]?\d{1,3}$/}},model:{key:Ow,value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let n=parseInt(t,10);i&&(n=3+n);const o=Xw.length-1,s=Math.min(Math.max(n,0),o);return Xw[s]}}})}}const ev='';class tv extends ad{static get pluginName(){return"FontSizeUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(Ow),o=t("Font Size"),s=function(e,t){const i=new Xt;for(const n of e){const e={type:"button",model:new sf({commandName:Ow,commandParam:n.model,label:n.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};n.view&&"string"!=typeof n.view&&(n.view.styles&&e.model.set("labelStyle",`font-size:${n.view.styles["font-size"]}`),n.view.classes&&e.model.set("class",`${e.model.class} ${n.view.classes}`)),e.model.bind("isOn").to(t,"value",(e=>e===n.model)),i.add(e)}return i}(i,n);e.ui.componentFactory.add(Ow,(t=>{const i=Pu(t);return Ou(i,s,{role:"menu",ariaLabel:o}),i.buttonView.set({label:o,icon:ev,tooltip:!0}),i.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),i.bind("isEnabled").to(n),this.listenTo(i,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),i})),e.ui.componentFactory.add(`menuBar:${Ow}`,(t=>{const i=new Gu(t);i.buttonView.set({label:o,icon:ev}),i.bind("isEnabled").to(n);const r=new Ku(t);for(const n of s){const o=new hn(t,i),s=new Yu(t);s.set({role:"menuitemradio",isToggleable:!0}),s.bind(...Object.keys(n.model)).to(n.model),s.delegate("execute").to(i),s.on("execute",(()=>{e.execute(n.model.commandName,{value:n.model.commandParam}),e.editing.view.focus()})),o.children.add(s),r.items.add(o)}return i.panelView.children.add(r),i}))}_getLocalizedOptions(){const e=this.editor,t=e.t,i={Default:t("Default"),Tiny:t("Tiny"),Small:t("Small"),Big:t("Big"),Huge:t("Huge")};return Jw(e.config.get(Ow).options).map((e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class iv extends ad{static get requires(){return[Zw,tv]}static get pluginName(){return"FontSize"}static get isOfficialPlugin(){return!0}normalizeSizeOptions(e){return Jw(e)}}class nv extends Tb{constructor(e){super(e,Lw)}}class ov extends ad{static get pluginName(){return"FontColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(Lw,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:Lw,value:Nw("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:Lw,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:Lw,view:Fw("color")}),e.commands.add(Lw,new nv(e)),e.model.schema.extend("$text",{allowAttributes:Lw}),e.model.schema.setAttributeProperties(Lw,{isFormatting:!0,copyOnEnter:!0})}}function sv(e,t){const i=e.t,n={Black:i("Black"),"Dim grey":i("Dim grey"),Grey:i("Grey"),"Light grey":i("Light grey"),White:i("White"),Red:i("Red"),Orange:i("Orange"),Yellow:i("Yellow"),"Light green":i("Light green"),Green:i("Green"),Aquamarine:i("Aquamarine"),Turquoise:i("Turquoise"),"Light blue":i("Light blue"),Blue:i("Blue"),Purple:i("Purple")};return t.map((e=>{const t=n[e.label];return t&&t!=e.label&&(e.label=t),e}))}function rv(e){return e.map(av).filter((e=>!!e))}function av(e){return"string"==typeof e?{model:e,label:e,hasBorder:!1,view:{name:"span",styles:{color:e}}}:{model:e.color,label:e.label||e.color,hasBorder:void 0!==e.hasBorder&&e.hasBorder,view:{name:"span",styles:{color:`${e.color}`}}}}class lv extends ad{commandName;componentName;icon;dropdownLabel;columns;constructor(e,{commandName:t,componentName:i,icon:n,dropdownLabel:o}){super(e),this.commandName=t,this.componentName=i,this.icon=n,this.dropdownLabel=o,this.columns=e.config.get(`${this.componentName}.columns`)}init(){const e=this.editor,t=e.locale,i=t.t,n=e.commands.get(this.commandName),o=e.config.get(this.componentName),s=sv(t,rv(o.colors)),r=o.documentColors,a=!1!==o.colorPicker;e.ui.componentFactory.add(this.componentName,(t=>{const l=Pu(t);let c=!1;const u=function({dropdownView:e,colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerViewConfig:a}){const l=e.locale,c=new Vw(l,{colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:s,documentColorsCount:r,colorPickerViewConfig:a});return e.colorSelectorView=c,e.panelView.children.add(c),c}({dropdownView:l,colors:s.map((e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}}))),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==r?i("Document colors"):"",documentColorsCount:void 0===r?this.columns:r,colorPickerViewConfig:!!a&&(o.colorPicker||{})});return u.bind("selectedColor").to(n,"value"),l.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),l.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),l.bind("isEnabled").to(n),u.on("execute",((t,i)=>{l.isOpen&&e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),"colorPicker"!==i.source&&e.editing.view.focus(),"colorPickerSaveButton"===i.source&&(l.isOpen=!1)})),u.on("colorPicker:show",(()=>{this._undoStepBatch=e.model.createBatch()})),u.on("colorPicker:cancel",(()=>{this._undoStepBatch.operations.length&&(l.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()})),l.on("change:isOpen",((t,i,n)=>{c||(c=!0,l.colorSelectorView.appendUI()),n&&(0!==r&&u.updateDocumentColors(e.model,this.componentName),u.updateSelectedColors(),u.showColorGridsFragment())})),Lu(l,(()=>l.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find((e=>e.isOn)))),l})),e.ui.componentFactory.add(`menuBar:${this.componentName}`,(t=>{const o=new Gu(t);o.buttonView.set({label:this.dropdownLabel,icon:this.icon}),o.bind("isEnabled").to(n);let a=!1;const l=new Vw(t,{colors:s.map((e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}}))),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==r?i("Document colors"):"",documentColorsCount:void 0===r?this.columns:r,colorPickerViewConfig:!1});return l.bind("selectedColor").to(n,"value"),l.delegate("execute").to(o),l.on("execute",((t,i)=>{e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),e.editing.view.focus()})),o.on("change:isOpen",((t,i,n)=>{a||(a=!0,l.appendUI()),n&&(0!==r&&l.updateDocumentColors(e.model,this.componentName),l.updateSelectedColors(),l.showColorGridsFragment())})),o.panelView.children.add(l),o}))}}class cv extends lv{constructor(e){const t=e.locale.t;super(e,{commandName:Lw,componentName:Lw,icon:'',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class uv extends ad{static get requires(){return[ov,cv]}static get pluginName(){return"FontColor"}static get isOfficialPlugin(){return!0}}class dv extends Tb{constructor(e){super(e,Bw)}}class hv extends ad{static get pluginName(){return"FontBackgroundColorEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define(Bw,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),e.data.addStyleProcessorRules(Jc),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:Bw,value:Nw("background-color")}}),e.conversion.for("downcast").attributeToElement({model:Bw,view:Fw("background-color")}),e.commands.add(Bw,new dv(e)),e.model.schema.extend("$text",{allowAttributes:Bw}),e.model.schema.setAttributeProperties(Bw,{isFormatting:!0,copyOnEnter:!0})}}class mv extends lv{constructor(e){const t=e.locale.t;super(e,{commandName:Bw,componentName:Bw,icon:'',dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class gv extends ad{static get requires(){return[hv,mv]}static get pluginName(){return"FontBackgroundColor"}static get isOfficialPlugin(){return!0}}class fv extends ad{static get pluginName(){return"ListItemFontSizeIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[Mv]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(Mv);if(!e.plugins.has("FontSizeEditing")||!this.editor.config.get("list.enableListItemMarkerFormatting"))return;const n=Jw(e.config.get("fontSize.options"));t.registerFormatAttribute("fontSize","listItemFontSize"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemFontSize",setAttributeOnDowncast(e,t,i,o){if(t){const s=n.find((e=>e.model==t));s&&s.view&&"string"!=typeof s.view?s.view.styles?(e.addClass("ck-list-marker-font-size",i),e.setStyle("--ck-content-list-marker-font-size",s.view.styles["font-size"],i)):s.view.classes&&(e.addClass(`ck-list-marker-font-size-${t}`,i),!r.isSafari||o&&o.dataPipeline||e.setStyle("--ck-content-list-marker-dummy-font-size","0",i)):(e.addClass("ck-list-marker-font-size",i),e.setStyle("--ck-content-list-marker-font-size",t,i))}}})}afterInit(){const e=this.editor,t=e.model;if(!e.plugins.has("FontSizeEditing")||!this.editor.config.get("list.enableListItemMarkerFormatting"))return;t.schema.extend("$listItem",{allowAttributes:"listItemFontSize"}),t.schema.setAttributeProperties("listItemFontSize",{isFormatting:!0}),t.schema.addAttributeCheck((e=>{if(!e.last.getAttribute("listItemId"))return!1}),"listItemFontSize"),e.conversion.for("upcast").elementToAttribute({model:{key:"listItemFontSize",value:e=>e.getStyle("--ck-content-list-marker-font-size")},view:{name:"li",classes:"ck-list-marker-font-size",styles:{"--ck-content-list-marker-font-size":/.*/}}});const i=Jw(e.config.get("fontSize.options"));for(const t of i)t.model&&t.view&&e.conversion.for("upcast").elementToAttribute({model:{key:"listItemFontSize",value:t.model},view:{name:"li",classes:`ck-list-marker-font-size-${t.model}`}})}}class pv extends ad{static get pluginName(){return"ListItemFontColorIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[Mv]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(Mv);e.plugins.has("FontColorEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.registerFormatAttribute("fontColor","listItemFontColor"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemFontColor",setAttributeOnDowncast(e,t,i){t&&(e.addClass("ck-list-marker-color",i),e.setStyle("--ck-content-list-marker-color",t,i))}}))}afterInit(){const e=this.editor,t=e.model;e.plugins.has("FontColorEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.schema.extend("$listItem",{allowAttributes:"listItemFontColor"}),t.schema.setAttributeProperties("listItemFontColor",{isFormatting:!0}),t.schema.addAttributeCheck((e=>{if(!e.last.getAttribute("listItemId"))return!1}),"listItemFontColor"),e.conversion.for("upcast").attributeToAttribute({model:{key:"listItemFontColor",value:e=>e.getStyle("--ck-content-list-marker-color")},view:{name:"li",classes:"ck-list-marker-color",styles:{"--ck-content-list-marker-color":/.*/}}}))}}class bv extends ad{static get pluginName(){return"ListItemFontFamilyIntegration"}static get isOfficialPlugin(){return!0}static get requires(){return[Mv]}init(){const e=this.editor,t=e.plugins.get("ListFormatting"),i=e.plugins.get(Mv);e.plugins.has("FontFamilyEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.registerFormatAttribute("fontFamily","listItemFontFamily"),i.registerDowncastStrategy({scope:"item",attributeName:"listItemFontFamily",setAttributeOnDowncast(e,t,i){t&&(e.addClass("ck-list-marker-font-family",i),e.setStyle("--ck-content-list-marker-font-family",t,i))}}))}afterInit(){const e=this.editor,t=e.model;e.plugins.has("FontFamilyEditing")&&this.editor.config.get("list.enableListItemMarkerFormatting")&&(t.schema.extend("$listItem",{allowAttributes:"listItemFontFamily"}),t.schema.setAttributeProperties("listItemFontFamily",{isFormatting:!0}),t.schema.addAttributeCheck((e=>{if(!e.last.getAttribute("listItemId"))return!1}),"listItemFontFamily"),e.conversion.for("upcast").attributeToAttribute({model:{key:"listItemFontFamily",value:e=>e.getStyle("--ck-content-list-marker-font-family")},view:{name:"li",classes:"ck-list-marker-font-family",styles:{"--ck-content-list-marker-font-family":/.*/}}}))}}class wv extends ad{_loadedFormatting={};static get pluginName(){return"ListFormatting"}static get isOfficialPlugin(){return!0}static get requires(){return[xb,Ab,fv,pv,bv]}constructor(e){super(e),e.config.define("list.enableListItemMarkerFormatting",!0)}afterInit(){this.editor.config.get("list.enableListItemMarkerFormatting")&&this._registerPostfixerForListItemFormatting()}_registerPostfixerForListItemFormatting(){const e=this.editor.model;e.document.registerPostFixer((t=>{const i=e.document.differ.getChanges(),n=new Set;let o=!1;for(const e of i)if("attribute"===e.type)("listItemId"==e.attributeKey||"listType"==e.attributeKey||this._isInlineOrSelectionFormatting(e.attributeKey)||Object.values(this._loadedFormatting).includes(e.attributeKey))&&(tb(e.range.start.nodeAfter)?n.add(e.range.start.nodeAfter):tb(e.range.start.parent)&&n.add(e.range.start.parent));else if(tb(e.position.nodeAfter)&&n.add(e.position.nodeAfter),tb(e.position.nodeBefore)&&n.add(e.position.nodeBefore),tb(e.position.parent)&&n.add(e.position.parent),"insert"==e.type&&"$text"!=e.name){const i=t.createRangeIn(e.position.nodeAfter);for(const e of i.getItems())tb(e)&&n.add(e)}for(const i of n){const n=vv(e,i,Object.keys(this._loadedFormatting));for(const[e,s]of Object.entries(n)){const n=this._loadedFormatting[e];(s&&_v(t,i,n,s)||!s&&kv(t,i,n))&&(o=!0)}}return o}))}registerFormatAttribute(e,t){this._loadedFormatting[e]=t}_isInlineOrSelectionFormatting(e){return e.replace(/^selection:/,"")in this._loadedFormatting}}function vv(e,t,i){return sb(t)?yv(e,t,i):yv(e,ib(t)[0],i)}function yv(e,t,i){if(!function(e){return["numbered","bulleted","customNumbered","customBulleted"].includes(e.getAttribute("listType"))}(t)||e.schema.isLimit(t))return Object.fromEntries(i.map((e=>[e])));if(t.isEmpty)return Object.fromEntries(i.map((e=>[e,t.getAttribute(`selection:${e}`)])));const n=new Set(i),o={},s=e.createRangeIn(t).getWalker({ignoreElementEnd:!0});for(const{item:t}of s){for(const i of n)if(e.schema.checkAttribute(t,i)){const e=t.getAttribute(i);void 0===e?(n.delete(i),o[i]=void 0):void 0===o[i]?o[i]=e:o[i]!==e&&(n.delete(i),o[i]=void 0)}else i in o||(o[i]=void 0);if(!n.size)break;e.schema.isLimit(t)&&s.jumpTo(e.createPositionAfter(t))}return o}function _v(e,t,i,n){const o=ib(t);let s=!1;for(const t of o)t.hasAttribute(i)&&t.getAttribute(i)===n||(e.setAttribute(i,n,t),s=!0);return s}function kv(e,t,i){const n=ib(t);let o=!1;for(const t of n)t.hasAttribute(i)&&(e.removeAttribute(i,t),o=!0);return o}class Cv extends ad{static get pluginName(){return"ListUtils"}static get isOfficialPlugin(){return!0}expandListBlocksToCompleteList(e){return lb(e)}isFirstBlockOfListItem(e){return sb(e)}isListItemBlock(e){return tb(e)}expandListBlocksToCompleteItems(e,t={}){return ab(e,t)}isNumberedListType(e){return bb(e)}}function xv(e){return e.is("element","ol")||e.is("element","ul")}function Av(e){return e.is("element","li")}function Tv(e,t,i,n=Pv(i,t)){return e.createAttributeElement(Sv(i),null,{priority:2*t/100-100,id:n})}function Ev(e,t,i){return e.createAttributeElement("li",null,{priority:(2*t+1)/100-100,id:i})}function Sv(e){return"numbered"==e||"customNumbered"==e?"ol":"ul"}function Pv(e,t){return`list-${e}-${t}`}function Iv(e,t,i){const n=e.nodeBefore;if(tb(n)){let e=n;for(const{node:o}of new Xp(e,"backward")){if(e=o,i.has(e))return;if(i.add(e),t.has(n))return}t.add(e)}else{const i=e.nodeAfter;tb(i)&&t.add(i)}}function Vv(e,t,i,{dataPipeline:n}={}){const o=function(e,t){const i=t.filter((e=>!1===e.consume)).map((e=>e.attributeName));return(t,n)=>{const o=[];for(const n of e)t.hasAttribute(n)&&!i.includes(n)&&o.push(`attribute:${n}`);return!!o.every((e=>!1!==n.test(t,e)))&&(o.forEach((e=>n.consume(t,e))),!0)}}(e,t);return(s,r,a)=>{const{writer:l,mapper:c,consumable:u}=a,d=r.item;if(!e.includes(r.attributeKey))return;if(!o(d,u))return;const h={...a.options,dataPipeline:n},m=function(e,t,i,n){const o=i.createRangeOn(e),s=t.toViewRange(o).getTrimmed().getWalker();for(const{item:e}of s)if(e.is("element")&&e.getCustomProperty("listItemMarker"))s.jumpTo(n.createPositionAfter(e));else if(e.is("element")&&!e.getCustomProperty("listItemWrapper"))return e}(d,c,i,l);Rv(m,l,c),function(e,t){let i=e.parent;for(;i.is("attributeElement")&&["ul","ol","li"].includes(i.name);){const n=i.parent;t.unwrap(t.createRangeOn(e),i),i=n}}(m,l);const g=function(e,t,i,n,{dataPipeline:o}){let s=n.createRangeOn(t);if(!sb(e))return s;for(const r of i){if("itemMarker"!=r.scope)continue;const i=r.createElement(n,e,{dataPipeline:o});if(!i)continue;if(n.setCustomProperty("listItemMarker",!0,i),r.canInjectMarkerIntoElement&&r.canInjectMarkerIntoElement(e)?n.insert(n.createPositionAt(t,0),i):(n.insert(s.start,i),s=n.createRange(n.createPositionBefore(i),n.createPositionAfter(t))),!r.createWrapperElement||!r.canWrapElement)continue;const a=r.createWrapperElement(n,e,{dataPipeline:o});n.setCustomProperty("listItemWrapper",!0,a),r.canWrapElement(e)?s=n.wrap(s,a):(s=n.wrap(n.createRangeOn(i),a),s=n.createRange(s.start,n.createPositionAfter(t)))}return s}(d,m,t,l,h);!function(e,t,i,n,o){if(!e.hasAttribute("listIndent"))return;const s=e.getAttribute("listIndent");let r=e;for(let e=s;e>=0;e--){const s=Ev(n,e,r.getAttribute("listItemId")),a=Tv(n,e,r.getAttribute("listType"));for(const e of i)"list"!=e.scope&&"item"!=e.scope||!r.hasAttribute(e.attributeName)||e.setAttributeOnDowncast(n,r.getAttribute(e.attributeName),"list"==e.scope?a:s,o,r);if(t=n.wrap(t,s),t=n.wrap(t,a),0==e)break;if(r=Qp.first(r,{lowerIndent:!0}),!r)break}}(d,g,t,l,h)}}function Ov(e,{dataPipeline:t}={}){return(i,{writer:n})=>{if(!Lv(i,e))return null;if(!t)return n.createContainerElement("span",{class:"ck-list-bogus-paragraph"});const o=n.createContainerElement("p");return n.setCustomProperty("dataPipeline:transparentRendering",!0,o),o}}function Rv(e,t,i){for(;e.parent.is("attributeElement")&&e.parent.getCustomProperty("listItemWrapper");)t.unwrap(t.createRangeOn(e),e.parent);const n=[];o(t.createPositionBefore(e).getWalker({direction:"backward"})),o(t.createRangeIn(e).getWalker());for(const e of n)t.remove(e);function o(e){for(const{item:t}of e){if(t.is("element")&&i.toModelElement(t))break;t.is("element")&&t.getCustomProperty("listItemMarker")&&n.push(t)}}}function Lv(e,t,i=ib(e)){if(!tb(e))return!1;for(const i of e.getAttributeKeys())if(!i.startsWith("selection:")&&"htmlEmptyBlock"!=i&&!t.includes(i))return!1;return i.length<2}const Bv=["listType","listIndent","listItemId"];class Mv extends ad{_downcastStrategies=[];static get pluginName(){return"ListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Bh,gh,Cv,Qd,wv]}constructor(e){super(e),e.config.define("list.multiBlock",!0)}init(){const e=this.editor,t=e.model,i=e.config.get("list.multiBlock");if(e.plugins.has("LegacyListEditing"))throw new x("list-feature-conflict",this,{conflictPlugin:"LegacyListEditing"});t.schema.register("$listItem",{allowAttributes:Bv}),i?(t.schema.extend("$container",{allowAttributesOf:"$listItem"}),t.schema.extend("$block",{allowAttributesOf:"$listItem"}),t.schema.extend("$blockObject",{allowAttributesOf:"$listItem"})):t.schema.register("listItem",{inheritAllFrom:"$block",allowAttributesOf:"$listItem"});for(const e of Bv)t.schema.setAttributeProperties(e,{copyOnReplace:!0});e.commands.add("numberedList",new _b(e,"numbered")),e.commands.add("bulletedList",new _b(e,"bulleted")),e.commands.add("customNumberedList",new _b(e,"customNumbered",{multiLevel:!0})),e.commands.add("customBulletedList",new _b(e,"customBulleted",{multiLevel:!0})),e.commands.add("indentList",new vb(e,"forward")),e.commands.add("outdentList",new vb(e,"backward")),e.commands.add("splitListItemBefore",new Cb(e,"before")),e.commands.add("splitListItemAfter",new Cb(e,"after")),i&&(e.commands.add("mergeListItemBackward",new kb(e,"backward")),e.commands.add("mergeListItemForward",new kb(e,"forward"))),this._setupDeleteIntegration(),this._setupEnterIntegration(),this._setupTabIntegration(),this._setupClipboardIntegration(),this._setupAccessibilityIntegration(),this._setupListItemIdConversionStrategy()}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList"),{priority:"high"}),i&&i.registerChildCommand(e.get("outdentList"),{priority:"lowest"}),this._setupModelPostFixing(),this._setupConversion()}registerDowncastStrategy(e){this._downcastStrategies.push(e)}getListAttributeNames(){return[...Bv,...this._downcastStrategies.map((e=>e.attributeName))]}_setupDeleteIntegration(){const e=this.editor,t=e.commands.get("mergeListItemBackward"),i=e.commands.get("mergeListItemForward");this.listenTo(e.editing.view.document,"delete",((n,o)=>{const s=e.model.document.selection;fb(e.model)||e.model.change((()=>{const r=s.getFirstPosition();if(s.isCollapsed&&"backward"==o.direction){if(!r.isAtStart)return;const i=r.parent;if(!tb(i))return;if(Qp.first(i,{sameAttributes:"listType",sameIndent:!0})||0!==i.getAttribute("listIndent")){if(!t||!t.isEnabled)return;t.execute({shouldMergeOnBlocksContentLevel:Nv(e.model,"backward")})}else rb(i)||e.execute("splitListItemAfter"),e.execute("outdentList");o.preventDefault(),n.stop()}else{if(s.isCollapsed&&!s.getLastPosition().isAtEnd)return;if(!i||!i.isEnabled)return;i.execute({shouldMergeOnBlocksContentLevel:Nv(e.model,"forward")}),o.preventDefault(),n.stop()}}))}),{context:"li"})}_setupEnterIntegration(){const e=this.editor,t=e.model,i=e.commands,n=i.get("enter");this.listenTo(e.editing.view.document,"enter",((i,n)=>{const o=t.document,s=o.selection.getFirstPosition().parent;if(o.selection.isCollapsed&&tb(s)&&s.isEmpty&&!n.isSoft){const t=sb(s),o=rb(s);t&&o?(e.execute("outdentList"),n.preventDefault(),i.stop()):t&&!o?(e.execute("splitListItemAfter"),n.preventDefault(),i.stop()):o&&(e.execute("splitListItemBefore"),n.preventDefault(),i.stop())}}),{context:"li"}),this.listenTo(n,"afterExecute",(()=>{const t=i.get("splitListItemBefore");t.refresh(),t.isEnabled&&2===ib(e.model.document.selection.getLastPosition().parent).length&&t.execute()}))}_setupTabIntegration(){const e=this.editor;this.listenTo(e.editing.view.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"li"})}_setupConversion(){const e=this.editor,t=e.model,i=this.getListAttributeNames(),n=e.config.get("list.multiBlock"),o=n?"paragraph":"listItem";e.conversion.for("upcast").elementToElement({view:"li",model:(e,{writer:t})=>t.createElement(o,{listType:""})}).elementToElement({view:"p",model:(e,{writer:t})=>e.parent&&e.parent.is("element","li")?t.createElement(o,{listType:""}):null,converterPriority:"high"}).add((e=>{e.on("element:li",((e,t,i)=>{const{writer:n,schema:o}=i;if(!t.modelRange)return;const s=Array.from(t.modelRange.getItems({shallow:!0})).filter((e=>o.checkAttribute(e,"listItemId")));if(!s.length)return;const r=t.viewItem.getAttribute("data-list-item-id")||eb.next();i.consumable.consume(t.viewItem,{attributes:"data-list-item-id"});const a=function(e){let t=0,i=e.parent;for(;i;){if(Av(i))t++;else{const e=i.previousSibling;e&&Av(e)&&t++}i=i.parent}return t}(t.viewItem);let l=t.viewItem.parent&&t.viewItem.parent.is("element","ol")?"numbered":"bulleted";const c=s[0].getAttribute("listType");c&&(l=c);const u={listItemId:r,listIndent:a,listType:l};for(const e of s)e.hasAttribute("listItemId")||n.setAttributes(u,e);s.length>1&&s[1].getAttribute("listItemId")!=u.listItemId&&i.keepEmptyElement(s[0])}))})),n||e.conversion.for("downcast").elementToElement({model:"listItem",view:"p"}),e.conversion.for("editingDowncast").elementToElement({model:o,view:Ov(i),converterPriority:"high"}).add((e=>{var n;e.on("attribute",Vv(i,this._downcastStrategies,t)),e.on("remove",(n=t.schema,(e,t,i)=>{const{writer:o,mapper:s}=i,r=e.name.split(":")[1];if(!n.checkAttribute(r,"listItemId"))return;const a=s.toViewPosition(t.position),l=t.position.getShiftedBy(t.length),c=s.toViewPosition(l,{isPhantom:!0}),u=o.createRange(a,c).getTrimmed().end.nodeBefore;u&&Rv(u,o,s)}))})),e.conversion.for("dataDowncast").elementToElement({model:o,view:Ov(i,{dataPipeline:!0}),converterPriority:"high"}).add((e=>{e.on("attribute",Vv(i,this._downcastStrategies,t,{dataPipeline:!0}))}));const s=(r=this._downcastStrategies,a=e.editing.view,(e,t)=>{if(t.modelPosition.offset>0)return;const i=t.modelPosition.parent;if(!tb(i))return;if(!r.some((e=>"itemMarker"==e.scope&&e.canInjectMarkerIntoElement&&e.canInjectMarkerIntoElement(i))))return;const n=t.mapper.toViewElement(i),o=a.createRangeIn(n),s=o.getWalker();let l=o.start;for(const{item:e}of s){if(e.is("element")&&t.mapper.toModelElement(e)||e.is("$textProxy"))break;e.is("element")&&e.getCustomProperty("listItemMarker")&&(l=a.createPositionAfter(e),s.skip((({previousPosition:e})=>!e.isEqual(l))))}t.viewPosition=l});var r,a;e.editing.mapper.on("modelToViewPosition",s),e.data.mapper.on("modelToViewPosition",s),this.listenTo(t.document,"change:data",function(e,t,i,n){return()=>{const n=e.document.differ.getChanges(),r=[],a=new Set,l=new Set,c=new Set;for(const e of n)if("insert"==e.type&&"$text"!=e.name)Iv(e.position,a,c),e.attributes.has("listItemId")?l.add(e.position.nodeAfter):Iv(e.position.getShiftedBy(e.length),a,c);else if("remove"==e.type&&e.attributes.has("listItemId"))Iv(e.position,a,c);else if("attribute"==e.type){const t=e.range.start.nodeAfter;i.includes(e.attributeKey)?(Iv(e.range.start,a,c),null===e.attributeNewValue?(Iv(e.range.start.getShiftedBy(1),a,c),s(t)&&r.push(t)):l.add(t)):tb(t)&&s(t)&&r.push(t)}for(const e of a.values())r.push(...o(e,l));for(const e of new Set(r))t.reconvertItem(e)};function o(e,t){const n=[],o=new Set,a=[];for(const{node:l,previous:c}of new Xp(e)){if(o.has(l))continue;const e=l.getAttribute("listIndent");c&&ei.includes(e)))),modelElement:l};const u=nb(l,{direction:"forward"});for(const e of u)o.add(e),(s(e,u)||r(e,a,t))&&n.push(e)}return n}function s(e,o){const s=t.mapper.toViewElement(e);if(!s)return!1;if(function(e){for(e=e.parent;e.is("attributeElement")&&["ol","ul","li"].includes(e.name);)e=e.parent;return!(!e.getCustomProperty("$structureSlotParent")||t.mapper.toModelElement(e))}(s))return!0;if(n.fire("checkElement",{modelElement:e,viewElement:s}))return!0;if(!e.is("element","paragraph")&&!e.is("element","listItem"))return!1;const r=Lv(e,i,o);return!(!r||!s.is("element","p"))||!(r||!s.is("element","span"))}function r(e,i,o){if(o.has(e))return!1;const s=t.mapper.toViewElement(e);let r=i.length-1;for(let e=s.parent;!e.is("editableElement");e=e.parent){const t=Av(e),o=xv(e);if(!o&&!t)continue;const s="checkAttributes:"+(t?"item":"list");if(n.fire(s,{viewElement:e,modelAttributes:i[r].modelAttributes,modelReferenceElement:i[r].modelElement}))break;if(o&&(r--,r<0))return!1}return!0}}(t,e.editing,i,this),{priority:"high"}),this.on("checkAttributes:item",((e,{viewElement:t,modelAttributes:i})=>{t.id!=i.listItemId&&(e.return=!0,e.stop())})),this.on("checkAttributes:list",((e,{viewElement:t,modelAttributes:i})=>{t.name==Sv(i.listType)&&t.id==Pv(i.listType,i.listIndent)||(e.return=!0,e.stop())}))}_setupModelPostFixing(){const e=this.editor.model,t=this.getListAttributeNames();e.document.registerPostFixer((i=>function(e,t,i,n){const o=e.document.differ.getChanges(),s=new Set,r=new Set,a=n.editor.config.get("list.multiBlock");let l=!1;for(const n of o){if("insert"==n.type&&"$text"!=n.name){const o=n.position.nodeAfter;if(!e.schema.checkAttribute(o,"listItemId"))for(const e of Array.from(o.getAttributeKeys()))i.includes(e)&&(t.removeAttribute(e,o),l=!0);Iv(n.position,r,s),n.attributes.has("listItemId")||Iv(n.position.getShiftedBy(n.length),r,s);for(const{item:t,previousPosition:i}of e.createRangeIn(o))tb(t)&&Iv(i,r,s)}else"remove"==n.type?Iv(n.position,r,s):"attribute"==n.type&&i.includes(n.attributeKey)&&(Iv(n.range.start,r,s),null===n.attributeNewValue&&Iv(n.range.start.getShiftedBy(1),r,s));if(!a&&"attribute"==n.type&&Bv.includes(n.attributeKey)){const e=n.range.start.nodeAfter;null===n.attributeNewValue&&e&&e.is("element","listItem")?(t.rename(e,"paragraph"),l=!0):null===n.attributeOldValue&&e&&e.is("element")&&"listItem"!=e.name&&(t.rename(e,"listItem"),l=!0)}}const c=new Set;for(const e of r.values())l=n.fire("postFixer",{listNodes:new Zp(e),listHead:e,writer:t,seenIds:c})||l;return l}(e,i,t,this))),this.on("postFixer",((e,{listNodes:t,writer:i})=>{e.return=function(e,t){let i=0,n=-1,o=null,s=!1;for(const{node:r}of e){const e=r.getAttribute("listIndent");if(e>i){let a;null===o?(o=e-i,a=i):(o>e&&(o=e),a=e-o),a>n+1&&(a=n+1),t.setAttribute("listIndent",a,r),s=!0,n=a}else o=null,i=e+1,n=e}return s}(t,i)||e.return}),{priority:"high"}),this.on("postFixer",((e,{listNodes:t,writer:i,seenIds:n})=>{e.return=function(e,t,i){const n=new Set;let o=!1;for(const{node:s}of e){if(n.has(s))continue;let e=s.getAttribute("listType"),r=s.getAttribute("listItemId");if(t.has(r)&&(r=eb.next()),t.add(r),s.is("element","listItem"))s.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,s),o=!0);else for(const t of nb(s,{direction:"forward"}))n.add(t),t.getAttribute("listType")!=e&&(r=eb.next(),e=t.getAttribute("listType")),t.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,t),o=!0)}return o}(t,n,i)||e.return}),{priority:"high"})}_setupClipboardIntegration(){const e=this.editor.model,t=this.editor.plugins.get("ClipboardPipeline");this.listenTo(e,"insertContent",function(e){return(t,[i,n])=>{const o=i.is("documentFragment")?Array.from(i.getChildren()):[i];if(!o.length)return;const s=(n?e.createSelection(n):e.document.selection).getFirstPosition();let r;if(tb(s.parent))r=s.parent;else{if(!tb(s.nodeBefore)||!tb(s.nodeAfter))return;r=s.nodeBefore}e.change((e=>{const t=r.getAttribute("listType"),i=r.getAttribute("listIndent"),n=o[0].getAttribute("listIndent")||0,s=Math.max(i-n,0);for(const i of o){const n=tb(i);r.is("element","listItem")&&i.is("element","paragraph")&&e.rename(i,"listItem"),e.setAttributes({listIndent:(n?i.getAttribute("listIndent"):0)+s,listItemId:n?i.getAttribute("listItemId"):eb.next(),listType:t},i)}}))}}(e),{priority:"high"}),this.listenTo(t,"outputTransformation",((t,i)=>{e.change((e=>{const t=Array.from(i.content.getChildren()),n=t[t.length-1];if(t.length>1&&n.is("element")&&n.isEmpty&&t.slice(0,-1).every(tb)&&e.remove(n),"copy"==i.method||"cut"==i.method){const t=Array.from(i.content.getChildren());mb(t)&&hb(t,e)}}))}))}_setupAccessibilityIntegration(){const e=this.editor,t=e.t;e.accessibility.addKeystrokeInfoGroup({id:"list",label:t("Keystrokes that can be used in a list"),keystrokes:[{label:t("Increase list item indent"),keystroke:"Tab"},{label:t("Decrease list item indent"),keystroke:"Shift+Tab"}]})}_setupListItemIdConversionStrategy(){this.registerDowncastStrategy({scope:"item",attributeName:"listItemId",setAttributeOnDowncast(e,t,i,n){n&&(n.skipListItemIds||n.isClipboardPipeline)||e.setAttribute("data-list-item-id",t,i)}})}}function Nv(e,t){const i=e.document.selection;if(!i.isCollapsed)return!fb(e);if("forward"===t)return!0;const n=i.getFirstPosition().parent,o=n.previousSibling;return!e.schema.isObject(o)&&(!!o.isEmpty||mb([n,o]))}function Fv(e,t,i,n){e.ui.componentFactory.add(t,(()=>{const o=Dv(Bn,e,t,i,n);return o.set({tooltip:!0,isToggleable:!0}),o})),e.ui.componentFactory.add(`menuBar:${t}`,(()=>{const o=Dv(Yu,e,t,i,n);return o.set({role:"menuitemcheckbox",isToggleable:!0}),o}))}function Dv(e,t,i,n,o){const s=t.commands.get(i),r=new e(t.locale);return r.set({label:n,icon:o}),r.bind("isOn","isEnabled").to(s,"value","isEnabled"),r.on("execute",(()=>{t.execute(i),t.editing.view.focus()})),r}const zv='',Hv='';class Uv extends ad{static get pluginName(){return"ListUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.t;this.editor.ui.componentFactory.has("numberedList")||Fv(this.editor,"numberedList",e("Numbered List"),zv),this.editor.ui.componentFactory.has("bulletedList")||Fv(this.editor,"bulletedList",e("Bulleted List"),Hv)}}class $v extends cd{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);this.isEnabled=!!t,t&&t.hasAttribute("resizedWidth")?this.value={width:t.getAttribute("resizedWidth"),height:null}:this.value=null}execute(e){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils"),o=n.getClosestSelectedImageElement(i.document.selection);this.value={width:e.width,height:null},o&&i.change((t=>{t.setAttribute("resizedWidth",e.width,o),t.removeAttribute("resizedHeight",o),n.setImageNaturalSizeAttributes(o)}))}}class qv extends ad{static get requires(){return[gf]}static get pluginName(){return"ImageResizeEditing"}static get licenseFeatureCode(){return"IR"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:custom",value:"custom",icon:"custom"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}init(){const e=this.editor,t=new $v(e);this._registerConverters("imageBlock"),this._registerConverters("imageInline"),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}afterInit(){this._registerSchema()}_registerSchema(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&(e.extend("imageBlock",{allowAttributes:["resizedWidth","resizedHeight"]}),e.setAttributeProperties("resizedWidth",{isFormatting:!0}),e.setAttributeProperties("resizedHeight",{isFormatting:!0})),this.editor.plugins.has("ImageInlineEditing")&&(e.extend("imageInline",{allowAttributes:["resizedWidth","resizedHeight"]}),e.setAttributeProperties("resizedWidth",{isFormatting:!0}),e.setAttributeProperties("resizedHeight",{isFormatting:!0}))}_registerConverters(e){const t=this.editor,i=t.plugins.get("ImageUtils");t.conversion.for("downcast").add((t=>t.on(`attribute:resizedWidth:${e}`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewElement(t.item);null!==t.attributeNewValue?(n.setStyle("width",t.attributeNewValue,o),n.addClass("image_resized",o)):(n.removeStyle("width",o),n.removeClass("image_resized",o))})))),t.conversion.for("dataDowncast").attributeToAttribute({model:{name:e,key:"resizedHeight"},view:e=>({key:"style",value:{height:e}})}),t.conversion.for("editingDowncast").add((t=>t.on(`attribute:resizedHeight:${e}`,((t,n,o)=>{if(!o.consumable.consume(n.item,t.name))return;const s=o.writer,r=o.mapper.toViewElement(n.item),a="imageInline"===e?i.findViewImgElement(r):r;null!==n.attributeNewValue?s.setStyle("height",n.attributeNewValue,a):s.removeStyle("height",a)})))),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{width:/.+/}},model:{key:"resizedWidth",value:e=>hf(e)?null:e.getStyle("width")}}),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{height:/.+/}},model:{key:"resizedHeight",value:e=>hf(e)?null:e.getStyle("height")}}),t.conversion.for("upcast").add((t=>{t.on("element:"+("imageBlock"===e?"figure":"img"),((e,t,i)=>{i.consumable.consume(t.viewItem,{classes:["image_resized"]})}))}))}}const jv=(()=>({small:'',medium:'',large:'',custom:'',original:''}))();class Wv extends ad{static get requires(){return[qv]}static get pluginName(){return"ImageResizeButtons"}static get isOfficialPlugin(){return!0}_resizeUnit;constructor(e){super(e),this._resizeUnit=e.config.get("image.resizeUnit")}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const e of t)this._registerImageResizeButton(e);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:n,icon:o}=e;t.ui.componentFactory.add(i,(i=>{const s=new Bn(i),r=t.commands.get("resizeImage"),a=this._getOptionLabelValue(e,!0);if(!jv[o])throw new x("imageresizebuttons-missing-icon",t,e);if(s.set({label:a,icon:jv[o],tooltip:a,isToggleable:!0}),s.bind("isEnabled").to(this),t.plugins.has("ImageCustomResizeUI")&&Gv(e)){const e=t.plugins.get("ImageCustomResizeUI");this.listenTo(s,"execute",(()=>{e._showForm(this._resizeUnit)}))}else{const e=n?n+this._resizeUnit:null;s.bind("isOn").to(r,"value",r,"isEnabled",Kv(e)),this.listenTo(s,"execute",(()=>{t.execute("resizeImage",{width:e})}))}return s}))}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,n=e.find((e=>!e.value)),o=o=>{const s=t.commands.get("resizeImage"),r=Pu(o,yu),a=r.buttonView,l=i("Resize image");return a.set({tooltip:l,commandValue:n.value,icon:jv.medium,isToggleable:!0,label:this._getOptionLabelValue(n),withText:!0,class:"ck-resize-image-button",ariaLabel:l,ariaLabelledBy:void 0}),a.bind("label").to(s,"value",(e=>e&&e.width?e.width:this._getOptionLabelValue(n))),r.bind("isEnabled").to(this),Ou(r,(()=>this._getResizeDropdownListItemDefinitions(e,s)),{ariaLabel:i("Image resize list"),role:"menu"}),this.listenTo(r,"execute",(e=>{"onClick"in e.source?e.source.onClick():(t.execute(e.source.commandName,{width:e.source.commandValue}),t.editing.view.focus())})),r};t.ui.componentFactory.add("resizeImage",o),t.ui.componentFactory.add("imageResize",o)}_getOptionLabelValue(e,t=!1){const i=this.editor.t;return e.label?e.label:t?Gv(e)?i("Custom image size"):e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):Gv(e)?i("Custom"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const{editor:i}=this,n=new Xt,o=e.map((e=>Gv(e)?{...e,valueWithUnits:"custom"}:e.value?{...e,valueWithUnits:`${e.value}${this._resizeUnit}`}:{...e,valueWithUnits:null}));for(const e of o){let s=null;if(i.plugins.has("ImageCustomResizeUI")&&Gv(e)){const n=i.plugins.get("ImageCustomResizeUI");s={type:"button",model:new sf({label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null,onClick:()=>{n._showForm(this._resizeUnit)}})};const r=Object.values(o).map((e=>e.valueWithUnits));s.model.bind("isOn").to(t,"value",t,"isEnabled",Jv(r))}else s={type:"button",model:new sf({commandName:"resizeImage",commandValue:e.valueWithUnits,label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null})},s.model.bind("isOn").to(t,"value",t,"isEnabled",Kv(e.valueWithUnits));s.model.bind("isEnabled").to(t,"isEnabled"),n.add(s)}return n}}function Gv(e){return"custom"===e.value}function Kv(e){return(t,i)=>!(void 0===t||!i)&&(null===e&&t===e||null!==t&&t.width===e)}function Jv(e){return(t,i)=>!e.some((e=>Kv(e)(t,i)))}const Yv="image_resized";class Qv extends ad{static get requires(){return[_m,gf]}static get pluginName(){return"ImageResizeHandles"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils");t.addObserver(Lf),this.listenTo(t.document,"imageLoaded",((n,o)=>{if(!o.target.matches("figure.image.ck-widget > img,figure.image.ck-widget > picture > img,figure.image.ck-widget > a > img,figure.image.ck-widget > a > picture > img,span.image-inline.ck-widget > img,span.image-inline.ck-widget > picture > img"))return;const s=e.editing.view.domConverter,r=s.domToView(o.target),a=i.getImageWidgetFromImageView(r);let l=this.editor.plugins.get(_m).getResizerByViewElement(a);if(l)return void l.redraw();const c=e.editing.mapper,u=c.toModelElement(a);l=e.plugins.get(_m).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:u,viewElement:a,editor:e,getHandleHost:e=>e.querySelector("img"),getResizeHost:()=>s.mapViewToDom(c.toViewElement(u)),isCentered:()=>"alignCenter"==u.getAttribute("imageStyle"),onCommit(i){t.change((e=>{e.removeClass(Yv,a)})),e.execute("resizeImage",{width:i})}}),l.on("updateSize",(()=>{a.hasClass(Yv)||t.change((e=>{e.addClass(Yv,a)}));const e="imageInline"===u.name?r:a;e.getStyle("height")&&t.change((t=>{t.removeStyle("height",e)}))})),l.bind("isEnabled").to(this)}))}}function Xv(e){if(!e)return null;const[,t,i]=e.trim().match(/([.,\d]+)(%|px)$/)||[],n=Number.parseFloat(t);return Number.isNaN(n)?null:{value:n,unit:i}}function Zv(e,t,i){return"px"===i?{value:t.value,unit:"px"}:{value:t.value/e*100,unit:"%"}}function ey(e){const{editing:t}=e,i=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);if(!i)return null;const n=t.mapper.toViewElement(i);return{model:i,view:n,dom:t.view.domConverter.mapViewToDom(n)}}class ty extends Hi{focusTracker;keystrokes;unit;backButtonView;saveButtonView;labeledInput;children;_focusables;_focusCycler;_validators;constructor(e,t,i){super(e),this.focusTracker=new ei,this.keystrokes=new oi,this.unit=t,this.backButtonView=this._createBackButton(),this.saveButtonView=this._createSaveButton(),this.labeledInput=this._createLabeledInputView(),this.children=this.createCollection([this._createHeaderView()]),this.children.add(new wf(e,{children:[this.labeledInput,this.saveButtonView],class:["ck-form__row_with-submit","ck-form__row_large-top-padding"]})),this._focusables=new wi,this._validators=i,this.keystrokes.set("Esc",((e,t)=>{this.fire("cancel"),t()})),this._focusCycler=new Nn({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-image-custom-resize-form","ck-responsive-form"],tabindex:"-1"},children:this.children})}render(){super.render(),vf({view:this}),[this.backButtonView,this.labeledInput,this.saveButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createBackButton(){const e=this.locale.t,t=new Bn(this.locale);return t.set({class:"ck-button-back",label:e("Back"),icon:cm,tooltip:!0}),t.delegate("execute").to(this,"cancel"),t}_createSaveButton(){const e=this.locale.t,t=new Bn(this.locale);return t.set({label:e("Save"),withText:!0,type:"submit",class:"ck-button-action ck-button-bold"}),t}_createHeaderView(){const e=this.locale.t,t=new Rn(this.locale,{label:e("Image Resize")});return t.children.add(this.backButtonView,0),t}_createLabeledInputView(){const e=this.locale.t,t=new yf(this.locale,Tf);return t.label=e("Resize image (in %0)",this.unit),t.class="ck-labeled-field-view_full-width",t.fieldView.set({step:.1}),t}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.labeledInput.errorText=t,!1}return!0}resetFormStatus(){this.labeledInput.errorText=null}get rawSize(){const{element:e}=this.labeledInput.fieldView;return e?e.value:null}get parsedSize(){const{rawSize:e}=this;if(null===e)return null;const t=Number.parseFloat(e);return Number.isNaN(t)?null:t}get sizeWithUnits(){const{parsedSize:e,unit:t}=this;return null===e?null:`${e}${t}`}}class iy extends ad{_balloon;_form;static get requires(){return[hm]}static get pluginName(){return"ImageCustomResizeUI"}static get isOfficialPlugin(){return!0}destroy(){super.destroy(),this._form&&this._form.destroy()}_createForm(e){const t=this.editor;this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(bf(ty))(t.locale,e,function(e){const t=e.t;return[e=>""===e.rawSize.trim()?t("The value must not be empty."):null===e.parsedSize?t("The value should be a plain number."):void 0]}(t)),this._form.render(),this.listenTo(this._form,"submit",(()=>{this._form.isValid()&&(t.execute("resizeImage",{width:this._form.sizeWithUnits}),this._hideForm(!0))})),this.listenTo(this._form.labeledInput,"change:errorText",(()=>{t.ui.update()})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),mn({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(e){if(this._isVisible)return;this._form||this._createForm(e);const t=this.editor,i=this._form.labeledInput;this._form.disableCssTransitions(),this._form.resetFormStatus(),this._isInBalloon||this._balloon.add({view:this._form,position:Pf(t)});const n=function(e,t){const i=ey(e);if(!i)return null;const n=Xv(i.model.getAttribute("resizedWidth")||null);return n?n.unit===t?n:Zv(Xh(i.dom),{unit:"px",value:new Ze(i.dom).width},t):null}(t,e),o=n?n.value.toFixed(1):"",s=function(e,t){const i=ey(e);if(!i)return null;const n=Xh(i.dom),o=Xv(window.getComputedStyle(i.dom).minWidth)||{value:1,unit:"px"};return{unit:t,lower:Math.max(.1,Zv(n,o,t).value),upper:"px"===t?n:100}}(t,e);i.fieldView.value=i.fieldView.element.value=o,s&&Object.assign(i.fieldView,{min:s.lower.toFixed(1),max:Math.ceil(s.upper).toFixed(1)}),this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}const ny=["left","right","center","justify"];function oy(e){return ny.includes(e)}function sy(e,t){return"rtl"==t.contentLanguageDirection?"right"===e:"left"===e}function ry(e){const t=e.map((e=>{let t;return t="string"==typeof e?{name:e}:e,t})).filter((e=>{const t=ny.includes(e.name);return t||A("alignment-config-name-not-recognized",{option:e}),t})),i=t.filter((e=>Boolean(e.className))).length;if(i&&i{const o=n.slice(i+1);if(o.some((e=>e.name==t.name)))throw new x("alignment-config-name-already-defined",{option:t,configuredOptions:e});if(t.className&&o.some((e=>e.className==t.className)))throw new x("alignment-config-classname-already-defined",{option:t,configuredOptions:e})})),t}const ay="alignment";class ly extends cd{refresh(){const e=this.editor.locale,t=Zt(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=Boolean(t)&&this._canBeAligned(t),this.isEnabled&&t.hasAttribute("alignment")?this.value=t.getAttribute("alignment"):this.value="rtl"===e.contentLanguageDirection?"right":"left"}execute(e={}){const t=this.editor,i=t.locale,n=t.model,o=n.document,s=e.value;n.change((e=>{const t=Array.from(o.selection.getSelectedBlocks()).filter((e=>this._canBeAligned(e))),n=t[0].getAttribute("alignment");sy(s,i)||n===s||!s?function(e,t){for(const i of e)t.removeAttribute(ay,i)}(t,e):function(e,t,i){for(const n of e)t.setAttribute(ay,i,n)}(t,e,s)}))}_canBeAligned(e){return this.editor.model.schema.checkAttribute(e,ay)}}class cy extends ad{static get pluginName(){return"AlignmentEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("alignment",{options:ny.map((e=>({name:e})))})}init(){const e=this.editor,t=e.locale,i=e.model.schema,n=ry(e.config.get("alignment.options")).filter((e=>oy(e.name)&&!sy(e.name,t))),o=n.some((e=>!!e.className));i.extend("$block",{allowAttributes:"alignment"}),e.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),o?e.conversion.attributeToAttribute(function(e){const t={};for(const i of e)t[i.name]={key:"class",value:i.className};return{model:{key:"alignment",values:e.map((e=>e.name))},view:t}}(n)):e.conversion.for("downcast").attributeToAttribute(function(e){const t={};for(const{name:i}of e)t[i]={key:"style",value:{"text-align":i}};return{model:{key:"alignment",values:e.map((e=>e.name))},view:t}}(n));const s=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"style",value:{"text-align":i}},model:{key:"alignment",value:i}});return t}(n);for(const t of s)e.conversion.for("upcast").attributeToAttribute(t);const r=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"align",value:i},model:{key:"alignment",value:i}});return t}(n);for(const t of r)e.conversion.for("upcast").attributeToAttribute(t);e.commands.add("alignment",new ly(e))}}const uy='',dy='',hy='',my=(()=>new Map([["left",Nu],["right",uy],["center",dy],["justify",hy]]))();class gy extends ad{get localizedOptionTitles(){const e=this.editor.t;return{left:e("Align left"),right:e("Align right"),center:e("Align center"),justify:e("Justify")}}static get pluginName(){return"AlignmentUI"}static get isOfficialPlugin(){return!0}init(){const e=ry(this.editor.config.get("alignment.options"));e.map((e=>e.name)).filter(oy).forEach((e=>this._addButton(e))),this._addToolbarDropdown(e),this._addMenuBarMenu(e)}_addButton(e){this.editor.ui.componentFactory.add(`alignment:${e}`,(t=>this._createButton(t,e)))}_createButton(e,t,i={}){const n=this.editor,o=n.commands.get("alignment"),s=new Bn(e);return s.set({label:this.localizedOptionTitles[t],icon:my.get(t),tooltip:!0,isToggleable:!0,...i}),s.bind("isEnabled").to(o),s.bind("isOn").to(o,"value",(e=>e===t)),this.listenTo(s,"execute",(()=>{n.execute("alignment",{value:t}),n.editing.view.focus()})),s}_addToolbarDropdown(e){const t=this.editor;t.ui.componentFactory.add("alignment",(i=>{const n=Pu(i),o="rtl"===i.uiLanguageDirection?"w":"e",s=i.t;Iu(n,(()=>e.map((e=>this._createButton(i,e.name,{tooltipPosition:o})))),{enableActiveItemFocusOnDropdownOpen:!0,isVertical:!0,ariaLabel:s("Text alignment toolbar")}),n.buttonView.set({label:s("Text alignment"),tooltip:!0}),n.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const r="rtl"===i.contentLanguageDirection?my.get("right"):my.get("left"),a=t.commands.get("alignment");return n.buttonView.bind("icon").to(a,"value",(e=>my.get(e)||r)),n.bind("isEnabled").to(a,"isEnabled"),this.listenTo(n,"execute",(()=>{t.editing.view.focus()})),n}))}_addMenuBarMenu(e){const t=this.editor;t.ui.componentFactory.add("menuBar:alignment",(i=>{const n=t.commands.get("alignment"),o=i.t,s=new Gu(i),r=new Ku(i);s.bind("isEnabled").to(n),r.set({ariaLabel:o("Text alignment"),role:"menu"}),s.buttonView.set({label:o("Text alignment")});for(const o of e){const e=new hn(i,s),a=new Yu(i);a.delegate("execute").to(s),a.set({label:this.localizedOptionTitles[o.name],icon:my.get(o.name),role:"menuitemcheckbox",isToggleable:!0}),a.on("execute",(()=>{t.execute("alignment",{value:o.name}),t.editing.view.focus()})),a.bind("isOn").to(n,"value",(e=>e===o.name)),a.bind("isEnabled").to(n,"isEnabled"),e.children.add(a),r.items.add(e)}return s.panelView.children.add(r),s}))}}function fy(e){const t=parseFloat(e);return e.endsWith("pt")?by(96*t/72):e.endsWith("pc")?by(12*t*96/72):e.endsWith("in")?by(96*t):e.endsWith("cm")?by(96*t/2.54):e.endsWith("mm")?by(t/10*96/2.54):e}function py(e){return void 0!==e&&e.endsWith("px")}function by(e){return Math.round(e)+"px"}function wy(e){const t=e.element.previousSibling;if(!t){const t=e.element.parent;return vy(t)&&(!t.previousSibling||vy(t.previousSibling))}return vy(t)}function vy(e){return e.is("element","ol")||e.is("element","ul")}function yy(e,t){const i=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),n=/mso-level-number-format:([^;]{0,100});/gi,o=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,s=new RegExp(`@list\\s+l${e.id}:level\\d\\s*{[^{]*mso-level-text:"%\\d\\\\.`,"gi"),r=new RegExp(`@list l${e.id}:level\\d\\s*{[^{]*mso-level-number-format:`,"gi"),a=s.exec(t),l=r.exec(t),c=a&&!l,u=i.exec(t);let d="decimal",h="ol",m=null;if(u&&u[1]){const t=n.exec(u[1]);if(t&&t[1]&&(d=t[1].trim(),h="bullet"!==d&&"image"!==d?"ol":"ul"),"bullet"===d){const t=function(e){if("li"==e.name&&"ul"==e.parent.name&&e.parent.hasAttribute("type"))return e.parent.getAttribute("type");const t=function(e){if(e.getChild(0).is("$text"))return null;for(const t of e.getChildren()){if(!t.is("element","span"))continue;const e=t.getChild(0);if(e)return e.is("$text")?e:e.getChild(0)}return null}(e);if(!t)return null;const i=t._data;return"o"===i?"circle":"·"===i?"disc":"§"===i?"square":null}(e.element);t&&(d=t)}else{const e=o.exec(u[1]);e&&e[1]&&(m=parseInt(e[1]))}c&&(h="ol")}return{type:h,startIndex:m,style:_y(d),isLegalStyleList:c}}function _y(e){if(e.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(e){case"alpha-upper":return"upper-alpha";case"alpha-lower":return"lower-alpha";case"roman-upper":return"upper-roman";case"roman-lower":return"lower-roman";case"circle":case"disc":case"square":return e;default:return null}}function ky(e,t,i){const n=t.createElement(e.type);return e.style&&t.setStyle("list-style-type",e.style,n),e.startIndex&&e.startIndex>1&&t.setAttribute("start",e.startIndex,n),e.isLegalStyleList&&i&&t.addClass("legal-list",n),n}function Cy(e){const t=e.getStyle("mso-list");if(void 0===t)return{};const i=t.match(/(^|\s{1,100})l(\d+)/i),n=t.match(/\s{0,100}lfo(\d+)/i),o=t.match(/\s{0,100}level(\d+)/i);return i&&n&&o?{id:i[2],order:n[1],indent:parseInt(o[1])}:{indent:1}}function xy(e,t){const i=new co({name:"span",styles:{"mso-list":"Ignore"}}),n=t.createRangeIn(e);for(const e of n)"elementStart"===e.type&&i.match(e.item)&&t.remove(e.item)}function Ay(e){const t=e.getStyle("margin-left");return void 0===t||t.endsWith("px")?t:fy(t)}function Ty(e,t){for(const i of t.createRangeIn(e).getItems())i.is("element","table")&&("0px"===i.getStyle("width")&&t.removeStyle("width",i),"0"===i.getAttribute("width")&&t.removeAttribute("width",i))}function Ey(e,t){const i=[],n=[];for(const{item:o}of e.createRangeIn(t))if(o.is("element")&&o.getStyle("mso-footnote-id")){i.unshift(o);const{nextSibling:e}=o;e?.is("$text")&&e.data.startsWith(" ")&&n.unshift(e)}for(const t of i)e.remove(t);for(const t of n){const i=t.data.substring(1);if(i.length>0){const n=t.parent,o=n.getChildIndex(t),s=e.createText(i);e.remove(t),e.insertChild(o,s,n)}else e.remove(t)}return t}function Sy(e,t){const i=e.createElement("sup",{class:"footnote"}),n=e.createElement("a",{id:`ref-${t}`,href:`#${t}`});return e.appendChild(n,i),i}function Py(e,t){const i=e.createElement("li",{id:t,class:"footnote-definition"}),n=e.createElement("a",{href:`#ref-${t}`,class:"footnote-backlink"}),o=e.createElement("div",{class:"footnote-content"});return e.appendChild(e.createText("^"),n),e.appendChild(n,i),e.appendChild(o,i),{listItem:i,content:o}}const Iy=//i,Vy=/xmlns:o="urn:schemas-microsoft-com/i;class Oy{document;hasMultiLevelListPlugin;hasTablePropertiesPlugin;hasExtendedTableBlockAlignment;constructor(e,t=!1,i=!1,n=!1){this.document=e,this.hasMultiLevelListPlugin=t,this.hasTablePropertiesPlugin=i,this.hasExtendedTableBlockAlignment=n}isActive(e){return Iy.test(e)||Vy.test(e)}execute(e){const t=new _c(this.document),{body:i,stylesString:n}=e._parsedData;!function(e,t){const i=[];for(const n of t.createRangeIn(e)){const e=n.item;e.is("element","a")&&!e.hasAttribute("href")&&(e.hasAttribute("id")||e.hasAttribute("name"))&&i.push(e)}for(const e of i){const i=e.parent.getChildIndex(e)+1,n=e.getChildren();t.insertChild(i,n,e.parent)}}(i,t),function(e,t,i){if(!e.childCount)return;const n=new _c(e.document),o=function(e,t){const i=t.createRangeIn(e),n=[],o=new Set;for(const e of i.getItems()){if(!e.is("element")||!e.name.match(/^(p|h\d+|li|div)$/))continue;let t=Ay(e);if(void 0===t||0!=parseFloat(t)||Array.from(e.getClassNames()).find((e=>e.startsWith("MsoList")))||(t=void 0),e.hasStyle("mso-list")&&"none"!==e.getStyle("mso-list")||void 0!==t&&o.has(t)){const i=Cy(e);n.push({element:e,id:i.id,order:i.order,indent:i.indent,marginLeft:t}),void 0!==t&&o.add(t)}else o.clear()}return n}(e,n);if(!o.length)return;const s={},r=[];for(const e of o)if(void 0!==e.indent){wy(e)||(r.length=0);const o=`${e.id}:${e.indent}`,a=Math.min(e.indent-1,r.length);if(ar.length-1||r[a].listElement.name!=l.type){0==a&&"ol"==l.type&&void 0!==e.id&&s[o]&&(l.startIndex=s[o]);const t=ky(l,n,i);if(py(e.marginLeft)&&(0==a||py(r[a-1].marginLeft))){let i=e.marginLeft;a>0&&(i=by(parseFloat(i)-parseFloat(r[a-1].marginLeft))),n.setStyle("padding-left",i,t)}if(0==r.length){const i=e.element.parent,o=i.getChildIndex(e.element)+1;n.insertChild(o,t,i)}else{const e=r[a-1].listItemElements;n.appendChild(t,e[e.length-1])}r[a]={...e,listElement:t,listItemElements:[]},0==a&&void 0!==e.id&&(s[o]=l.startIndex||1)}}const l="li"==e.element.name?e.element:n.createElement("li");n.appendChild(l,r[a].listElement),r[a].listItemElements.push(l),0==a&&void 0!==e.id&&s[o]++,e.element!=l&&n.appendChild(e.element,l),xy(e.element,n),n.removeStyle("text-indent",e.element),n.removeStyle("margin-left",e.element)}else{const t=r.find((t=>t.marginLeft==e.marginLeft));if(t){const i=t.listItemElements;n.appendChild(e.element,i[i.length-1]),n.removeStyle("margin-left",e.element)}else r.length=0}}(i,n,this.hasMultiLevelListPlugin),function(e,t){if(!e.childCount)return;const i=new _c(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new co({name:/v:(.+)/}),o=[];for(const e of i){if("elementStart"!=e.type)continue;const t=e.item,i=t.previousSibling,s=i&&i.is("element")?i.name:null,r=["Chart"],a=n.match(t),l=t.getAttribute("o:gfxdata"),c="v:shapetype"===s,u=l&&r.some((e=>t.getAttribute("id").includes(e)));a&&l&&!c&&!u&&o.push(e.item.getAttribute("id"))}return o}(e,i);!function(e,t,i){const n=i.createRangeIn(t),o=new co({name:"img"}),s=[];for(const t of n)if(t.item.is("element")&&o.match(t.item)){const i=t.item,n=i.getAttribute("v:shapes")?i.getAttribute("v:shapes").split(" "):[];n.length&&n.every((t=>e.indexOf(t)>-1))?s.push(i):i.getAttribute("src")||s.push(i)}for(const e of s)i.remove(e)}(n,e,i),function(e,t,i){const n=i.createRangeIn(t),o=[];for(const t of n)if("elementStart"==t.type&&t.item.is("element","v:shape")){const i=t.item.getAttribute("id");if(e.includes(i))continue;s(t.item.parent.getChildren(),i)||o.push(t.item)}for(const e of o){const t={src:r(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const n=i.createElement("img",t);i.insertChild(e.index+1,n,e.parent)}function s(e,t){for(const i of e)if(i.is("element")){if("img"==i.name&&i.getAttribute("v:shapes")==t)return!0;if(s(i.getChildren(),t))return!0}return!1}function r(e){for(const t of e.getChildren())if(t.is("element")&&t.getAttribute("src"))return t.getAttribute("src")}}(n,e,i),function(e,t){const i=t.createRangeIn(e),n=new co({name:/v:(.+)/}),o=[];for(const e of i)"elementStart"==e.type&&n.match(e.item)&&o.push(e.item);for(const e of o)t.remove(e)}(e,i);const o=function(e,t){const i=t.createRangeIn(e),n=new co({name:"img"}),o=[];let s=0;for(const e of i)e.item.is("element")&&n.match(e.item)&&(e.item.getAttribute("src").startsWith("file://")&&o.push({element:e.item,imageIndex:s}),s++);return o}(e,i);o.length&&function(e,t,i){for(let o=0;oString.fromCharCode(parseInt(e,16)))).join(""))}`;i.setAttribute("src",e,s)}}var n}(o,function(e){if(!e)return[];const t=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,i=new RegExp("(?:("+t.source+"))([\\da-fA-F\\s]+)\\}","g"),n=e.match(i),o=[];if(n)for(const e of n){let i=!1;e.includes("\\pngblip")?i="image/png":e.includes("\\jpegblip")&&(i="image/jpeg"),i&&o.push({hex:e.replace(t,"").replace(/[^\da-fA-F]/g,""),type:i})}return o}(t),i)}(i,e.dataTransfer.getData("text/rtf")),function(e,t,i=!1,n=!1){for(const o of t.createRangeIn(e).getItems()){if(!o.is("element","table")&&!o.is("element","td")&&!o.is("element","th"))continue;if(i&&n&&o.is("element","table")){const e=o.parent?.is("element","div")?o.parent:null,i=o.parent?.parent?.is("element","div")?o.parent.parent:null,n=e??i;n&&"center"===n.getAttribute("align")&&!o.getAttribute("align")?(t.setStyle("margin-left","auto",o),t.setStyle("margin-right","auto",o)):n&&"right"===n.getAttribute("align")&&!o.getAttribute("align")?(t.setStyle("margin-left","auto",o),t.setStyle("margin-right","0",o)):n||o.getAttribute("align")||(t.setStyle("margin-left","0",o),t.setStyle("margin-right","auto",o))}const e=["left","top","right","bottom"];if(e.every((e=>!o.hasStyle(`border-${e}-style`))))t.setStyle("border-style","none",o);else for(const i of e)o.hasStyle(`border-${i}-style`)||t.setStyle(`border-${i}-style`,"none",o);const s=["width","height",...e.map((e=>`border-${e}-width`)),...e.map((e=>`padding-${e}`))];for(const e of s)o.hasStyle(e)&&t.setStyle(e,fy(o.getStyle(e)),o)}}(i,t,this.hasTablePropertiesPlugin,this.hasExtendedTableBlockAlignment),Ty(i,t),function(e,t){const i=new Map,n=new Map;let o=null;for(const{item:s}of t.createRangeIn(e))if(s.is("element"))if("footnote-list"!==s.getStyle("mso-element")){if(s.hasStyle("mso-footnote-id")){const e=s.findAncestor("element",(e=>"footnote"===e.getStyle("mso-element")));if(e){const t=e.getAttribute("id");n.set(t,e)}else{const e=s.getStyle("mso-footnote-id");i.set(e,s)}}}else o=s;if(!i.size||!o)return;const s=function(e){return e.createElement("ol",{class:"footnotes"})}(t);t.replace(o,s);for(const[e,o]of i){const i=n.get(e);if(!i)continue;t.replace(o,Sy(t,e));const r=Py(t,e);Ey(t,i);for(const e of i.getChildren()){let i=e;e.is("element")&&(i=t.clone(e,!0)),t.appendChild(i,r.content)}t.appendChild(r.listItem,s)}}(i,t),function(e){const t=[],i=new _c(e.document);for(const{item:n}of i.createRangeIn(e))if(n.is("element")){for(const e of n.getClassNames())/\bmso/gi.exec(e)&&i.removeClass(e,n);for(const e of n.getStyleNames())/\bmso/gi.exec(e)&&i.removeStyle(e,n);(n.is("element","w:sdt")||n.is("element","w:sdtpr")&&n.isEmpty||n.is("element","o:p")&&n.isEmpty)&&t.push(n)}for(const e of t){const t=e.parent,n=t.getChildIndex(e);i.insertChild(n,e.getChildren(),t),i.remove(e)}}(i),e.content=i}}function Ry(e,t,i,{blockElements:n,inlineObjectElements:o}){let s=i.createPositionAt(e,"forward"==t?"after":"before");return s=s.getLastMatchingPosition((({item:e})=>e.is("element")&&!n.includes(e.name)&&!o.includes(e.name)),{direction:t}),"forward"==t?s.nodeAfter:s.nodeBefore}function Ly(e,t){return!!e&&e.is("element")&&t.includes(e.name)}function By(e){let t=e;for(;t;){if(t.is("element")){const e=t.getStyle?.("white-space");if("pre-wrap"===e)return!0}t=t.parent}return!1}function My(e,t,i){const{parent:n,data:o}=e,s=o.replaceAll("\t"," ".repeat(i)),r=n.getChildIndex(e);t.remove(e),t.insertChild(r,t.createText(s),n)}const Ny=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class Fy{document;constructor(e){this.document=e}isActive(e){return Ny.test(e)}execute(e){const t=new _c(this.document),{body:i}=e._parsedData;!function(e,t){for(const i of e.getChildren())if(i.is("element","b")&&"normal"===i.getStyle("font-weight")){const n=e.getChildIndex(i);t.remove(i),t.insertChild(n,i.getChildren(),e)}}(i,t),function(e,t){for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","li")){const i=e.getChild(0);i&&i.is("element","p")&&t.unwrapElement(i)}}}(i,t),function(e,t){const i=new ts(t.document.stylesProcessor),n=new Ds(i,{renderingMode:"data"}),o=n.blockElements,s=n.inlineObjectElements,r=[];for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","br")){const i=Ry(e,"forward",t,{blockElements:o,inlineObjectElements:s}),n=Ry(e,"backward",t,{blockElements:o,inlineObjectElements:s}),a=Ly(i,o);(Ly(n,o)||a)&&r.push(e)}}for(const e of r)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(i,t),function(e,t){const i=new Set;for(const n of t.createRangeIn(e).getItems())n.is("view:$textProxy")&&n.data.includes("\t")&&By(n.parent)&&i.add(n.textNode);for(const e of i)My(e,t,8)}(i,t),e.content=i}}const Dy=/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length)))}function Uy(e,t){const i=(i,n,o)=>{if(!o.consumable.consume(n.item,i.name))return;const s=n.attributeNewValue,r=o.writer,a=o.mapper.toViewElement(n.item),l=[...a.getChildren()].find((e=>e.getCustomProperty("media-content")));r.remove(l);const c=e.getMediaViewElement(r,s,t);r.insert(r.createPositionAt(a,0),c)};return e=>{e.on("attribute:url:media",i)}}function $y(e,t,i,n){return e.createContainerElement("figure",{class:"media"},[t.getMediaViewElement(e,i,n),e.createSlot()])}function qy(e){const t=e.getSelectedElement();return t&&t.is("element","media")?t:null}function jy(e,t,i,n){e.change((o=>{const s=o.createElement("media",{url:t});e.insertObject(s,i,null,{setSelection:"on",findOptimalPosition:n?"auto":void 0})}))}class Wy extends cd{refresh(){const e=this.editor.model,t=e.document.selection,i=qy(t);this.value=i?i.getAttribute("url"):void 0,this.isEnabled=function(e){const t=e.getSelectedElement();return!!t&&"media"===t.name}(t)||function(e,t){let i=Yh(e,t).start.parent;return i.isEmpty&&!t.schema.isLimit(i)&&(i=i.parent),t.schema.checkChild(i,"media")}(t,e)}execute(e){const t=this.editor.model,i=t.document.selection,n=qy(i);n?t.change((t=>{t.setAttribute("url",e,n)})):jy(t,e,i,!0)}}class Gy{locale;providerDefinitions;constructor(e,t){const i=t.providers,n=t.extraProviders||[],o=new Set(t.removeProviders),s=i.concat(n).filter((e=>{const t=e.name;return t?!o.has(t):(A("media-embed-no-provider-name",{provider:e}),!1)}));this.locale=e,this.providerDefinitions=s}hasMedia(e){return!!this._getMedia(e)}getMediaViewElement(e,t,i){return this._getMedia(t).getViewElement(e,i)}_getMedia(e){if(!e)return new Ky(this.locale);e=e.trim();for(const t of this.providerDefinitions){const i=t.html,n=zt(t.url);for(const t of n){const n=this._getUrlMatches(e,t);if(n)return new Ky(this.locale,e,n,i)}}return null}_getUrlMatches(e,t){let i=e.match(t);if(i)return i;let n=e.replace(/^https?:\/\//,"");return i=n.match(t),i||(n=n.replace(/^www\./,""),i=n.match(t),i||null)}}class Ky{url;_locale;_match;_previewRenderer;constructor(e,t,i,n){this.url=this._getValidUrl(t),this._locale=e,this._match=i,this._previewRenderer=n}getViewElement(e,t){const i={};let n;if(t.renderForEditingView||t.renderMediaPreview&&this.url&&this._previewRenderer){this.url&&(i["data-oembed-url"]=this.url),t.renderForEditingView&&(i.class="ck-media__wrapper");const o=this._getPreviewHtml(t);n=e.createRawElement("div",i,((e,t)=>{t.setContentOf(e,o)}))}else this.url&&(i.url=this.url),n=e.createEmptyElement(t.elementName,i);return e.setCustomProperty("media-content",!0,n),n}_getPreviewHtml(e){return this._previewRenderer?this._previewRenderer(this._match):this.url&&e.renderForEditingView?this._getPlaceholderHtml():""}_getPlaceholderHtml(){const e=new en,t=this._locale.t;return e.content='',e.viewBox="0 0 64 42",new vi({tag:"div",attributes:{class:"ck ck-reset_all ck-media__placeholder"},children:[{tag:"div",attributes:{class:"ck-media__placeholder__icon"},children:[e]},{tag:"a",attributes:{class:"ck-media__placeholder__url",target:"_blank",rel:"noopener noreferrer",href:this.url,"data-cke-tooltip-text":t("Open media in new tab")},children:[{tag:"span",attributes:{class:"ck-media__placeholder__url__text"},children:[this.url]}]}]}).render().outerHTML}_getValidUrl(e){return e?e.match(/^https?/)?e:"https://"+e:null}}class Jy extends ad{static get pluginName(){return"MediaEmbedEditing"}static get isOfficialPlugin(){return!0}registry;constructor(e){super(e),e.config.define("mediaEmbed",{elementName:"oembed",providers:[{name:"dailymotion",url:[/^dailymotion\.com\/video\/(\w+)/,/^dai.ly\/(\w+)/],html:e=>`
`},{name:"spotify",url:[/^open\.spotify\.com\/(artist\/\w+)/,/^open\.spotify\.com\/(album\/\w+)/,/^open\.spotify\.com\/(track\/\w+)/],html:e=>`
`},{name:"youtube",url:[/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)(?:&t=(\d+))?/,/^(?:m\.)?youtube\.com\/shorts\/([\w-]+)(?:\?t=(\d+))?/,/^(?:m\.)?youtube\.com\/v\/([\w-]+)(?:\?t=(\d+))?/,/^youtube\.com\/embed\/([\w-]+)(?:\?start=(\d+))?/,/^youtu\.be\/([\w-]+)(?:\?t=(\d+))?/],html:e=>{const t=e[1],i=e[2];return`
`}},{name:"vimeo",url:[/^vimeo\.com\/(\d+)/,/^vimeo\.com\/[^/]+\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/album\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/channels\/[^/]+\/(\d+)/,/^vimeo\.com\/groups\/[^/]+\/videos\/(\d+)/,/^vimeo\.com\/ondemand\/[^/]+\/(\d+)/,/^player\.vimeo\.com\/video\/(\d+)/],html:e=>`
`},{name:"instagram",url:[/^instagram\.com\/p\/(\w+)/,/^instagram\.com\/reel\/(\w+)/]},{name:"twitter",url:[/^twitter\.com/,/^x\.com/]},{name:"googleMaps",url:[/^google\.com\/maps/,/^goo\.gl\/maps/,/^maps\.google\.com/,/^maps\.app\.goo\.gl/]},{name:"flickr",url:/^flickr\.com/},{name:"facebook",url:/^facebook\.com/}]}),this.registry=new Gy(e.locale,e.config.get("mediaEmbed"))}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion,o=e.config.get("mediaEmbed.previewsInData"),s=e.config.get("mediaEmbed.elementName"),r=this.registry;e.commands.add("mediaEmbed",new Wy(e)),t.register("media",{inheritAllFrom:"$blockObject",allowAttributes:["url"]}),n.for("dataDowncast").elementToStructure({model:"media",view:(e,{writer:t})=>{const i=e.getAttribute("url");return $y(t,r,i,{elementName:s,renderMediaPreview:!!i&&o})}}),n.for("dataDowncast").add(Uy(r,{elementName:s,renderMediaPreview:o})),n.for("editingDowncast").elementToStructure({model:"media",view:(e,{writer:t})=>{const n=e.getAttribute("url");return function(e,t,i){return t.setCustomProperty("media",!0,e),jh(e,t,{label:i})}($y(t,r,n,{elementName:s,renderForEditingView:!0}),t,i("media widget"))}}),n.for("editingDowncast").add(Uy(r,{elementName:s,renderForEditingView:!0})),n.for("upcast").elementToElement({view:e=>["oembed",s].includes(e.name)&&e.getAttribute("url")?{name:!0}:null,model:(e,{writer:t})=>{const i=e.getAttribute("url");return r.hasMedia(i)?t.createElement("media",{url:i}):null}}).elementToElement({view:{name:"div",attributes:{"data-oembed-url":!0}},model:(e,{writer:t})=>{const i=e.getAttribute("data-oembed-url");return r.hasMedia(i)?t.createElement("media",{url:i}):null}}).add((e=>{e.on("element:figure",((e,t,i)=>{if(!i.consumable.consume(t.viewItem,{name:!0,classes:"media"}))return;const{modelRange:n,modelCursor:o}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=n,t.modelCursor=o,Zt(n.getItems())||i.consumable.revert(t.viewItem,{name:!0,classes:"media"})}))}))}}const Yy=/^(?:http(s)?:\/\/)?[\w-]+\.[\w-.~:/?#[\]@!$&'()*+,;=%]+$/;class Qy extends ad{static get requires(){return[Mm,gh,Xm]}static get pluginName(){return"AutoMediaEmbed"}static get isOfficialPlugin(){return!0}_timeoutId;_positionToInsert;constructor(e){super(e),this._timeoutId=null,this._positionToInsert=null}init(){const e=this.editor,t=e.model.document,i=e.plugins.get("ClipboardPipeline");this.listenTo(i,"inputTransformation",(()=>{const e=t.selection.getFirstRange(),i=Pl.fromPosition(e.start);i.stickiness="toPrevious";const n=Pl.fromPosition(e.end);n.stickiness="toNext",t.once("change:data",(()=>{this._embedMediaBetweenPositions(i,n),i.detach(),n.detach()}),{priority:"high"})})),e.commands.get("undo").on("execute",(()=>{this._timeoutId&&(n.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)}),{priority:"high"})}_embedMediaBetweenPositions(e,t){const i=this.editor,o=i.plugins.get(Jy).registry,s=new jr(e,t),r=s.getWalker({ignoreElementEnd:!0});let a="";for(const e of r)e.item.is("$textProxy")&&(a+=e.item.data);a=a.trim(),a.match(Yy)&&o.hasMedia(a)&&i.commands.get("mediaEmbed").isEnabled?(this._positionToInsert=Pl.fromPosition(e),this._timeoutId=n.window.setTimeout((()=>{i.model.change((e=>{this._timeoutId=null,e.remove(s),s.detach();let t=null;"$graveyard"!==this._positionToInsert.root.rootName&&(t=this._positionToInsert),jy(i.model,a,t,!1),this._positionToInsert.detach(),this._positionToInsert=null})),i.plugins.get(gh).requestUndoOnBackspace()}),100)):s.detach()}}class Xy extends Hi{focusTracker;keystrokes;urlInputView;_validators;_urlInputViewInfoDefault;_urlInputViewInfoTip;constructor(e,t){super(t),this.focusTracker=new ei,this.keystrokes=new oi,this.set("mediaURLInputValue",""),this.urlInputView=this._createUrlInput(),this._validators=e,this.setTemplate({tag:"form",attributes:{class:["ck","ck-media-form","ck-responsive-form"],tabindex:"-1"},children:[this.urlInputView]})}render(){super.render(),vf({view:this}),this.focusTracker.add(this.urlInputView.element),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.urlInputView.focus()}get url(){return this.urlInputView.fieldView.element.value.trim()}set url(e){this.urlInputView.fieldView.value=e.trim()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null,this.urlInputView.infoText=this._urlInputViewInfoDefault}_createUrlInput(){const e=this.locale.t,t=new yf(this.locale,Af),i=t.fieldView;return this._urlInputViewInfoDefault=e("Paste the media URL in the input."),this._urlInputViewInfoTip=e("Tip: Paste the URL into the content to embed faster."),t.label=e("Media URL"),t.infoText=this._urlInputViewInfoDefault,i.inputMode="url",i.on("input",(()=>{t.infoText=i.element.value?this._urlInputViewInfoTip:this._urlInputViewInfoDefault,this.mediaURLInputValue=i.element.value.trim()})),t}}class Zy extends ad{static get requires(){return[Jy,eg]}static get pluginName(){return"MediaEmbedUI"}static get isOfficialPlugin(){return!0}_formView;init(){const e=this.editor;e.ui.componentFactory.add("mediaEmbed",(()=>{const e=this.editor.locale.t,t=this._createDialogButton(Bn);return t.tooltip=!0,t.label=e("Insert media"),t})),e.ui.componentFactory.add("menuBar:mediaEmbed",(()=>{const e=this.editor.locale.t,t=this._createDialogButton(Yu);return t.label=e("Media"),t}))}_createDialogButton(e){const t=this.editor,i=new e(t.locale),n=t.commands.get("mediaEmbed"),o=this.editor.plugins.get("Dialog");return i.icon='',i.bind("isEnabled").to(n,"isEnabled"),i.on("execute",(()=>{"mediaEmbed"===o.id?o.hide():this._showDialog()})),i}_showDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.commands.get("mediaEmbed"),n=e.locale.t,o=void 0!==i.value;if(!this._formView){const t=e.plugins.get(Jy).registry;this._formView=new(bf(Xy))(function(e,t){return[t=>{if(!t.url.length)return e("The URL must not be empty.")},i=>{if(!t.hasMedia(i.url))return e("This media URL is not supported.")}]}(e.t,t),e.locale),this._formView.on("submit",(()=>this._handleSubmitForm()))}t.show({id:"mediaEmbed",title:n("Media embed"),content:this._formView,isModal:!0,onShow:()=>{this._formView.url=i.value||"",this._formView.resetFormStatus(),this._formView.urlInputView.fieldView.select()},actionButtons:[{label:n("Cancel"),withText:!0,onExecute:()=>t.hide()},{label:n(o?"Save":"Insert"),class:"ck-button-action",withText:!0,onExecute:()=>this._handleSubmitForm()}]})}_handleSubmitForm(){const e=this.editor,t=e.plugins.get("Dialog");this._formView.isValid()&&(e.execute("mediaEmbed",this._formView.url),t.hide(),e.editing.view.focus())}}const e_="removeFormat";class t_ extends ad{static get pluginName(){return"RemoveFormatUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add(e_,(()=>{const e=this._createButton(Bn);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add(`menuBar:${e_}`,(()=>this._createButton(Yu)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get(e_),o=new e(t.locale),s=i.t;return o.set({label:s("Remove Format"),icon:''}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{t.execute(e_),t.editing.view.focus()})),o}}class i_ extends cd{_customAttributesHandlers=[];refresh(){const e=this.editor.model;this.isEnabled=!!Zt(this._getFormattingItems(e.document.selection))}execute(){const e=this.editor.model;e.change((t=>{for(const i of this._getFormattingItems(e.document.selection))if(i.is("selection"))for(const e of this._getFormattingAttributes(i))t.removeSelectionAttribute(e);else{const e=t.createRangeOn(i);for(const n of this._getFormattingAttributes(i))this._removeFormatting(n,i,e,t)}}))}registerCustomAttribute(e,t){this._customAttributesHandlers.push({isFormatting:e,removeFormatting:t})}_removeFormatting(e,t,i,n){let o=!1;for(const{isFormatting:s,removeFormatting:r}of this._customAttributesHandlers)s(e,t)&&(r(e,i,n),o=!0);o||n.removeAttribute(e,i)}*_getFormattingItems(e){const t=this.editor.model,i=t.schema,n=e=>!!Zt(this._getFormattingAttributes(e));for(const o of e.getRanges())for(const e of o.getItems())i.isBlock(e)&&o.end.isTouching(t.createPositionAt(e,0))||n(e)&&(yield e);for(const t of e.getSelectedBlocks())n(t)&&(yield t);n(e)&&(yield e)}*_getFormattingAttributes(e){const t=this.editor.model.schema;for(const[i]of e.getAttributes()){for(const{isFormatting:t}of this._customAttributesHandlers)t(i,e)&&(yield i);const n=t.getAttributeProperties(i);n&&n.isFormatting&&(yield i)}}}class n_ extends ad{static get pluginName(){return"RemoveFormatEditing"}static get licenseFeatureCode(){return"RF"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}init(){const e=this.editor;e.commands.add("removeFormat",new i_(e))}}function o_(e,t){const{modelAttribute:i,styleName:n,attributeName:o,attributeType:s,viewElement:r,defaultValue:a,shouldUpcast:l=()=>!0,reduceBoxSides:c=!1}=t;e.for("upcast").attributeToAttribute({view:{name:r,styles:{[n]:/[\s\S]+/}},model:{key:i,value:(e,t,i)=>{if(!l(e))return;const o=l_(a,"",i),s=e.getNormalizedStyle(n),r=c?c_(s):s;if(o!==r)return r;t.consumable.consume(e,{styles:n})}}}),o&&e.for("upcast").attributeToAttribute({view:{name:r,attributes:{[o]:/.+/}},model:{key:i,value:(e,t,i)=>{if("figure"==e.name||e.hasStyle(n)||"table"==e.name&&"figure"==e.parent.name&&e.parent.hasStyle(n))return;const r=l_(a,"",i);let l=e.getAttribute(o);if(l&&"length"==s){const e=parseFloat(l);l=isNaN(e)?r:e+(l.includes("%")?"%":"px")}if(r!==l)return l;t.consumable.consume(e,{attributes:o})}}})}function s_(e,t,i,n){const{conversion:o}=e;o.for("upcast").add((e=>e.on("element:"+t,((e,t,o)=>{if(!t.modelRange)return;const s=["border-top-width","border-top-color","border-top-style","border-bottom-width","border-bottom-color","border-bottom-style","border-right-width","border-right-color","border-right-style","border-left-width","border-left-color","border-left-style"].filter((e=>t.viewItem.hasStyle(e)));if(!s.length)return;const r={styles:s};if(!o.consumable.test(t.viewItem,r))return;const a=[...t.modelRange.getItems({shallow:!0})].pop(),l=a.findAncestor("table",{includeSelf:!0});let c=n;l&&"layout"==l.getAttribute("tableType")&&(c={style:"none",color:"",width:""}),o.consumable.consume(t.viewItem,r);const u={style:t.viewItem.getNormalizedStyle("border-style"),color:t.viewItem.getNormalizedStyle("border-color"),width:t.viewItem.getNormalizedStyle("border-width")},d={style:c_(u.style),color:c_(u.color),width:c_(u.width)};d.style!==c.style&&o.writer.setAttribute(i.style,d.style,a),d.color!==c.color&&o.writer.setAttribute(i.color,d.color,a),d.width!==c.width&&o.writer.setAttribute(i.width,d.width,a)})))),e.config.get("experimentalFlags.upcastTableBorderZeroAttributes")&&o.for("upcast").add((e=>{e.on(`element:${t}`,((e,t,n)=>{const{modelRange:o,viewItem:s}=t,r=s.is("element","table")?s:s.findAncestor("table");if(!n.consumable.test(r,{attributes:"border"}))return;if("0"!==r.getAttribute("border"))return;const a=o?.start?.nodeAfter;a&&!Object.values(i).some((e=>a.hasAttribute(e)))&&(n.writer.setAttribute(i.style,"none",a),s.is("element","table")&&n.consumable.consume(s,{attributes:"border"}))}))}))}function r_(e,t){const{modelElement:i,modelAttribute:n,styleName:o}=t;e.for("downcast").attributeToAttribute({model:{name:i,key:n},view:e=>({key:"style",value:{[o]:e}})})}function a_(e,t){const{modelAttribute:i,styleName:n}=t;e.for("downcast").add((e=>e.on(`attribute:${i}:table`,((e,t,i)=>{const{item:o,attributeNewValue:s}=t,{mapper:r,writer:a}=i;if(!i.consumable.consume(t.item,e.name))return;const l=[...r.toViewElement(o).getChildren()].find((e=>e.is("element","table")));s?a.setStyle(n,s,l):a.removeStyle(n,l)}))))}function l_(e,t,i){const n=i.modelRange&&Zt(i.modelRange.getItems({shallow:!0})),o=n&&n.is("element")&&n.findAncestor("table",{includeSelf:!0});return o&&"layout"===o.getAttribute("tableType")?t:e}function c_(e){if(!e)return;const t=["top","right","bottom","left"];if(!t.every((t=>e[t])))return e;const i=e.top;return t.every((t=>e[t]===i))?i:e}const u_="table-style-align-left",d_="table-style-align-center",h_="table-style-align-right",m_="table-style-block-align-left",g_="table-style-block-align-right",f_=[{view:{name:/^(table|figure)$/,styles:{float:/^(left|none|right)$/}},getAlign:e=>{let t=e.getStyle("float");return"none"===t&&(t="center"),t},getConsumables(e){const t=e.getStyle("float"),i=["float"];return"left"===t&&e.hasStyle("margin-right")?i.push("margin-right"):"right"===t&&e.hasStyle("margin-left")&&i.push("margin-left"),{styles:i}}},{view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"auto"}},getAlign:()=>"center",getConsumables:()=>({styles:["margin-left","margin-right"]})},{view:{name:/^(table|figure)$/,key:"class",value:"table-style-align-left"},getAlign:()=>"left",getConsumables:()=>({classes:u_})},{view:{name:/^(table|figure)$/,key:"class",value:h_},getAlign:()=>"right",getConsumables:()=>({classes:h_})},{view:{name:/^(table|figure)$/,key:"class",value:d_},getAlign:()=>"center",getConsumables:()=>({classes:d_})},{view:{name:/^(table|figure)$/,key:"class",value:m_},getAlign:()=>"blockLeft",getConsumables:()=>({classes:m_})},{view:{name:/^(table|figure)$/,key:"class",value:g_},getAlign:()=>"blockRight",getConsumables:()=>({classes:g_})},{view:{name:/^(table|figure)$/,styles:{"margin-left":"0","margin-right":"auto"}},getAlign:()=>"blockLeft",getConsumables:()=>({styles:["margin-left","margin-right"]})},{view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"0"}},getAlign:()=>"blockRight",getConsumables:()=>({styles:["margin-left","margin-right"]})},{view:{name:"table",attributes:{align:/^(left|center|right)$/}},getAlign:e=>e.getAttribute("align"),getConsumables:()=>({attributes:"align"})}],p_={center:{align:"center",style:"margin-left: auto; margin-right: auto;",className:"table-style-align-center"},left:{align:"left",style:"float: left;",className:"table-style-align-left"},right:{align:"right",style:"float: right;",className:"table-style-align-right"},blockLeft:{align:void 0,style:"margin-left: 0; margin-right: auto;",className:m_},blockRight:{align:void 0,style:"margin-left: auto; margin-right: 0;",className:g_}};class b_{_table;_startRow;_endRow;_startColumn;_endColumn;_includeAllSlots;_skipRows;_row;_rowIndex;_column;_cellIndex;_spannedCells;_nextCellAtColumn;_jumpedToStartRow=!1;constructor(e,t={}){this._table=e,this._startRow=void 0!==t.row?t.row:t.startRow||0,this._endRow=void 0!==t.row?t.row:t.endRow,this._startColumn=void 0!==t.column?t.column:t.startColumn||0,this._endColumn=void 0!==t.column?t.column:t.endColumn,this._includeAllSlots=!!t.includeAllSlots,this._skipRows=new Set,this._row=0,this._rowIndex=0,this._column=0,this._cellIndex=0,this._spannedCells=new Map,this._nextCellAtColumn=-1}[Symbol.iterator](){return this}next(){this._canJumpToStartRow()&&this._jumpToNonSpannedRowClosestToStartRow();const e=this._table.getChild(this._rowIndex);if(!e||this._isOverEndRow())return{done:!0,value:void 0};if(!e.is("element","tableRow"))return this._rowIndex++,this.next();if(this._isOverEndColumn())return this._advanceToNextRow();let t=null;const i=this._getSpanned();if(i)this._includeAllSlots&&!this._shouldSkipSlot()&&(t=this._formatOutValue(i.cell,i.row,i.column));else{const i=e.getChild(this._cellIndex);if(!i)return this._advanceToNextRow();const n=parseInt(i.getAttribute("colspan")||"1"),o=parseInt(i.getAttribute("rowspan")||"1");(n>1||o>1)&&this._recordSpans(i,o,n),this._shouldSkipSlot()||(t=this._formatOutValue(i)),this._nextCellAtColumn=this._column+n}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,t||this.next()}skipRow(e){this._skipRows.add(e)}_advanceToNextRow(){return this._row++,this._rowIndex++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return void 0!==this._endRow&&this._row>this._endRow}_isOverEndColumn(){return void 0!==this._endColumn&&this._column>this._endColumn}_formatOutValue(e,t=this._row,i=this._column){return{done:!1,value:new w_(this,e,t,i)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._rowthis._endColumn;return e||t||i||n}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,i){const n={cell:e,row:this._row,column:this._column};for(let e=this._row;e0&&!this._jumpedToStartRow}_jumpToNonSpannedRowClosestToStartRow(){const e=this._getRowLength(0);for(let t=this._startRow;!this._jumpedToStartRow;t--)e===this._getRowLength(t)&&(this._row=t,this._rowIndex=t,this._jumpedToStartRow=!0)}_getRowLength(e){return[...this._table.getChild(e).getChildren()].reduce(((e,t)=>e+parseInt(t.getAttribute("colspan")||"1")),0)}}class w_{cell;row;column;cellAnchorRow;cellAnchorColumn;_cellIndex;_rowIndex;_table;constructor(e,t,i,n){this.cell=t,this.row=e._row,this.column=e._column,this.cellAnchorRow=i,this.cellAnchorColumn=n,this._cellIndex=e._cellIndex,this._rowIndex=e._rowIndex,this._table=e._table}get isAnchor(){return this.row===this.cellAnchorRow&&this.column===this.cellAnchorColumn}get cellWidth(){return parseInt(this.cell.getAttribute("colspan")||"1")}get cellHeight(){return parseInt(this.cell.getAttribute("rowspan")||"1")}get rowIndex(){return this._rowIndex}getPositionBefore(){return this._table.root.document.model.createPositionAt(this._table.getChild(this.row),this._cellIndex)}}function v_(e,t,i,n,o=1){null!=t&&null!=o&&t>o?n.setAttribute(e,t,i):n.removeAttribute(e,i)}function y_(e,t,i={}){const n=e.createElement("tableCell",i);return e.insertElement("paragraph",n),e.insert(n,t),n}function __(e,t){const i=t.parent.parent,n=parseInt(i.getAttribute("headingColumns")||"0"),{column:o}=e.getCellLocation(t);return!!n&&o0&&v_("headingRows",s-i,e,o,0);const r=parseInt(t.getAttribute("headingColumns")||"0");r>0&&v_("headingColumns",r-n,e,o,0)}(a,e,n,o,i),a}function E_(e,t,i=0){const n=[],o=new b_(e,{startRow:i,endRow:t-1});for(const e of o){const{row:i,cellHeight:o}=e;i1&&(a.rowspan=l);const c=parseInt(e.getAttribute("colspan")||"1");c>1&&(a.colspan=c);const u=s+r,d=[...new b_(o,{startRow:s,endRow:u,includeAllSlots:!0})];let h,m=null;for(const t of d){const{row:n,column:o,cell:s}=t;s===e&&void 0===h&&(h=o),void 0!==h&&h===o&&n===u&&(m=y_(i,t.getPositionBefore(),a))}return v_("rowspan",r,e,i),m}function P_(e,t){const i=[],n=new b_(e);for(const e of n){const{column:n,cellWidth:o}=e;n1&&(s.colspan=r);const a=parseInt(e.getAttribute("rowspan")||"1");a>1&&(s.rowspan=a);const l=y_(n,n.createPositionAfter(e),s);return v_("colspan",o,e,n),l}function V_(e,t,i,n,o,s){const r=parseInt(e.getAttribute("colspan")||"1"),a=parseInt(e.getAttribute("rowspan")||"1");i+r-1>o&&v_("colspan",o-i+1,e,s,1),t+a-1>n&&v_("rowspan",n-t+1,e,s,1)}function O_(e,t){const i=t.getColumns(e),n=new Array(i).fill(0);for(const{column:t}of new b_(e))n[t]++;const o=n.reduce(((e,t,i)=>t?e:[...e,i]),[]);if(o.length>0){const i=o[o.length-1];return t.removeColumns(e,{at:i}),!0}return!1}function R_(e,t){const i=[],n=t.getRows(e);for(let t=0;t0){const n=i[i.length-1];return t.removeRows(e,{at:n}),!0}return!1}function L_(e,t){O_(e,t)||R_(e,t)}function B_(e,t){const i=Array.from(new b_(e,{startColumn:t.firstColumn,endColumn:t.lastColumn,row:t.lastRow}));if(i.every((({cellHeight:e})=>1===e)))return t.lastRow;const n=i[0].cellHeight-1;return t.lastRow+n}function M_(e,t){const i=Array.from(new b_(e,{startRow:t.firstRow,endRow:t.lastRow,column:t.lastColumn}));if(i.every((({cellWidth:e})=>1===e)))return t.lastColumn;const n=i[0].cellWidth-1;return t.lastColumn+n}function N_(e){for(const t of e.getChildren())if(t.is("element","table"))return t}function F_(e){return t=>{t.on(`element:${e}`,((e,t,{writer:i})=>{if(!t.modelRange)return;const n=t.modelRange.start.nodeAfter,o=i.createPositionAt(n,0);if(t.viewItem.isEmpty)return void i.insertElement("paragraph",o);const s=Array.from(n.getChildren());if(s.every((e=>e.is("element","$marker")))){const e=i.createElement("paragraph");i.insert(e,i.createPositionAt(n,0));for(const t of s)i.move(i.createRangeOn(t),i.createPositionAt(e,"end"))}}),{priority:"low"})}}function D_(e){if(!e||!z(e))return e;const{top:t,right:i,bottom:n,left:o}=e;return t==i&&i==n&&n==o?t:void 0}function z_(e,t){const i=parseFloat(e);return Number.isNaN(i)||String(i)!==String(e)?e:`${i}${t}`}function H_(e,t={}){const i={borderStyle:"none",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",...e};return t.includeAlignmentProperty&&!i.alignment&&(i.alignment="center"),t.includePaddingProperty&&!i.padding&&(i.padding=""),t.includeVerticalAlignmentProperty&&!i.verticalAlignment&&(i.verticalAlignment="middle"),t.includeHorizontalAlignmentProperty&&!i.horizontalAlignment&&(i.horizontalAlignment=t.isRightToLeftContent?"right":"left"),i}function U_(e,t){return H_({borderStyle:"double",borderColor:"hsl(0, 0%, 70%)",borderWidth:"1px",...e},t)}function $_(e,t){return H_({borderStyle:"solid",borderColor:"hsl(0, 0%, 75%)",borderWidth:"1px",...e},t)}function q_(e,t){return(i,{writer:n})=>{const o=i.getAttribute("headingRows")||0,s=n.createContainerElement("table",null,[]),r=n.createContainerElement("figure",{class:"table"},s);o>0&&n.insert(n.createPositionAt(s,"end"),n.createContainerElement("thead",null,n.createSlot((e=>e.is("element","tableRow")&&e.indexe.is("element","tableRow")&&e.index>=o))));for(const{positionOffset:e,filter:i}of t.additionalSlots)n.insert(n.createPositionAt(s,e),n.createSlot(i));return n.insert(n.createPositionAt(s,"after"),n.createSlot((e=>!e.is("element","tableRow")&&!t.additionalSlots.some((({filter:t})=>t(e)))))),t.asWidget?function(e,t){return t.setCustomProperty("table",!0,e),jh(e,t,{hasSelectionHandle:!0})}(r,n):r}}function j_(e){return(i,{writer:n})=>{if(e.cellTypeEnabled?.())return t(n,"header"===i.getAttribute("tableCellType")?"th":"td");const o=i.parent,s=o.parent,r=s.getChildIndex(o),a=new b_(s,{row:r}),l=s.getAttribute("headingRows")||0,c=s.getAttribute("headingColumns")||0;let u=null;for(const e of a)if(e.cell==i){u=t(n,e.row{if(!t.parent.is("element","tableCell"))return null;if(!G_(t))return null;if(e.asWidget)return i.createContainerElement("span",{class:"ck-table-bogus-paragraph"});{const e=i.createContainerElement("p");return i.setCustomProperty("dataPipeline:transparentRendering",!0,e),e}}}function G_(e){return 1==e.parent.childCount&&!function(e){for(const t of e.getAttributeKeys())if(!t.startsWith("selection:")&&"htmlEmptyBlock"!=t)return!0;return!1}(e)}function K_(e){return(t,i)=>{const n=e.plugins.has("PlainTableOutput"),o=i.options.isClipboardPipeline,s=e.config.get("experimentalFlags.useExtendedTableBlockAlignment");return n||s&&o?function(e,t,i){const n=t.writer,o=e.getAttribute("headingRows")||0,s=n.createSlot((e=>e.is("element","tableRow")&&e.indexe.is("element","tableRow")&&e.index>=o)),a=n.createSlot((e=>!e.is("element","tableRow"))),l=n.createContainerElement("thead",null,s),c=n.createContainerElement("tbody",null,r),u=[];o&&u.push(l),o{const o=e.plugins.has("PlainTableOutput"),s=n.isClipboardPipeline,r=e.config.get("experimentalFlags.useExtendedTableBlockAlignment");return(o||r&&s)&&"table"===t.parent.name?i.createContainerElement("caption"):null}}class Y_ extends cd{refresh(){const e=this.editor.model,t=e.document.selection,i=e.schema;this.isEnabled=function(e,t){const i=e.getFirstPosition().parent,n=i===i.root?i:i.parent;return t.checkChild(n,"table")}(t,i)}execute(e={}){const t=this.editor,i=t.model,n=t.plugins.get("TableUtils"),o=t.config.get("table.defaultHeadings.rows"),s=t.config.get("table.defaultHeadings.columns");void 0===e.headingRows&&o&&(e.headingRows=o),void 0===e.headingColumns&&s&&(e.headingColumns=s),i.change((t=>{const o=n.createTable(t,e);i.insertObject(o,null,null,{findOptimalPosition:"auto"}),t.setSelection(t.createPositionAt(o.getNodeByPath([0,0,0]),0))}))}}class Q_ extends cd{order;constructor(e,t={}){super(e),this.order=t.order||"below"}refresh(){const e=this.editor.model.document.selection,t=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=t}execute(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("TableUtils"),n="above"===this.order,o=i.getSelectionAffectedTableCells(t),s=i.getRowIndexes(o),r=n?s.first:s.last,a=o[0].findAncestor("table");i.insertRows(a,{at:n?r:r+1,copyStructureFromAbove:!n})}}class X_ extends cd{order;constructor(e,t={}){super(e),this.order=t.order||"right"}refresh(){const e=this.editor.model.document.selection,t=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=t}execute(){const e=this.editor,t=e.model.document.selection,i=e.plugins.get("TableUtils"),n="left"===this.order,o=i.getSelectionAffectedTableCells(t),s=i.getColumnIndexes(o),r=n?s.first:s.last,a=o[0].findAncestor("table");i.insertColumns(a,{columns:1,at:n?r:r+1})}}class Z_ extends cd{direction;constructor(e,t={}){super(e),this.direction=t.direction||"horizontally"}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=1===e.length}execute(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];"horizontally"===this.direction?e.splitCellHorizontally(t,2):e.splitCellVertically(t,2)}}class ek extends cd{direction;isHorizontal;constructor(e,t){super(e),this.direction=t.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}refresh(){const e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){const e=this.editor.model,t=e.document,i=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(t.selection)[0],n=this.value,o=this.direction;e.change((e=>{const t="right"==o||"down"==o,s=t?i:n,r=t?n:i,a=r.parent;!function(e,t,i){tk(e)||(tk(t)&&i.remove(i.createRangeIn(t)),i.move(i.createRangeIn(e),i.createPositionAt(t,"end"))),i.remove(e)}(r,s,e);const l=this.isHorizontal?"colspan":"rowspan",c=parseInt(i.getAttribute(l)||"1"),u=parseInt(n.getAttribute(l)||"1");e.setAttribute(l,c+u,s),e.setSelection(e.createRangeIn(s));const d=this.editor.plugins.get("TableUtils");L_(a.findAncestor("table"),d)}))}_getMergeableCell(){const e=this.editor.model.document,t=this.editor.plugins.get("TableUtils"),i=t.getTableCellsContainingSelection(e.selection)[0];if(!i)return;const n=this.isHorizontal?function(e,t,i){const n=e.parent.parent,o="right"==t?e.nextSibling:e.previousSibling,s=(n.getAttribute("headingColumns")||0)>0;if(!o)return;const r="right"==t?e:o,a="right"==t?o:e,{column:l}=i.getCellLocation(r),{column:c}=i.getCellLocation(a),u=parseInt(r.getAttribute("colspan")||"1"),d=__(i,r),h=__(i,a);return s&&d!=h?void 0:l+u===c?o:void 0}(i,this.direction,t):function(e,t,i){const n=e.parent,o=n.parent,s=o.getChildIndex(n);if("down"==t&&s===i.getRows(o)-1||"up"==t&&0===s)return null;const r=parseInt(e.getAttribute("rowspan")||"1"),a=o.getAttribute("headingRows")||0;if(a&&("down"==t&&s+r===a||"up"==t&&s===a))return null;const l=parseInt(e.getAttribute("rowspan")||"1"),c="down"==t?s+l:s,u=[...new b_(o,{endRow:c})],d=u.find((t=>t.cell===e)).column,h=u.find((({row:e,cellHeight:i,column:n})=>n===d&&("down"==t?e===c:c===e+i)));return h&&h.cell?h.cell:null}(i,this.direction,t);if(!n)return;const o=this.isHorizontal?"rowspan":"colspan",s=parseInt(i.getAttribute(o)||"1");return parseInt(n.getAttribute(o)||"1")===s?n:void 0}}function tk(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}class ik extends cd{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),i=t[0];if(i){const n=i.findAncestor("table"),o=e.getRows(n)-1,s=e.getRowIndexes(t),r=0===s.first&&s.last===o;this.isEnabled=!r}else this.isEnabled=!1}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),i=t.getSelectionAffectedTableCells(e.document.selection),n=t.getRowIndexes(i),o=i[0],s=o.findAncestor("table"),r=t.getCellLocation(o).column;e.change((e=>{const i=n.last-n.first+1;t.removeRows(s,{at:n.first,rows:i});const o=function(e,t,i,n){const o=e.getChild(Math.min(t,n-1));let s=o.getChild(0),r=0;for(const e of o.getChildren()){if(r>i)return s;s=e,r+=parseInt(e.getAttribute("colspan")||"1")}return s}(s,n.first,r,t.getRows(s));e.setSelection(e.createPositionAt(o,0))}))}}class nk extends cd{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),i=t[0];if(i){const n=i.findAncestor("table"),o=e.getColumns(n),{first:s,last:r}=e.getColumnIndexes(t);this.isEnabled=r-se.cell===t)).column,last:o.find((e=>e.cell===i)).column},r=function(e,t,i,n){return parseInt(i.getAttribute("colspan")||"1")>1?i:t.previousSibling||i.nextSibling?i.nextSibling||t.previousSibling:n.first?e.reverse().find((({column:e})=>ee>n.last)).cell}(o,t,i,s);this.editor.model.change((t=>{const i=s.last-s.first+1;e.removeColumns(n,{at:s.first,columns:i}),t.setSelection(t.createPositionAt(r,0))}))}}class ok extends cd{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,i=e.getSelectionAffectedTableCells(t.document.selection);if(0===i.length)return this.isEnabled=!1,void(this.value=!1);const n=i[0].findAncestor("table");this.isEnabled=t.schema.checkAttribute(n,"headingRows"),this.value=i.every((e=>this._isInHeading(e,e.parent.parent)))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),i=this.editor.model,n=t.getSelectionAffectedTableCells(i.document.selection),o=n[0].findAncestor("table"),{first:s,last:r}=t.getRowIndexes(n),a=this.value?s:r+1,l=o.getAttribute("headingRows")||0;i.change((e=>{if(a){const t=E_(o,a,a>l?l:0);for(const{cell:i}of t)S_(i,a,e)}t.setHeadingRowsCount(e,o,a)}))}_isInHeading(e,t){const i=parseInt(t.getAttribute("headingRows")||"0");return!!i&&e.parent.index__(e,t)))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),i=this.editor.model,n=t.getSelectionAffectedTableCells(i.document.selection),o=n[0].findAncestor("table"),{first:s,last:r}=t.getColumnIndexes(n),a=this.value?s:r+1;i.change((e=>{if(a){const t=P_(o,a);for(const{cell:i,column:n}of t)I_(i,n,a,e)}t.setHeadingColumnsCount(e,o,a)}))}}function rk(e){const t=function(e){if(e.is("element","tableColumnGroup"))return e;const t=e.getChildren();return Array.from(t).find((e=>e.is("element","tableColumnGroup")))}(e);return t?Array.from(t.getChildren()):[]}class ak extends ad{static get pluginName(){return"TableUtils"}static get isOfficialPlugin(){return!0}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,i=t.parent,n=i.getChildIndex(t),o=new b_(i,{row:n});for(const{cell:t,row:i,column:n}of o)if(t===e)return{row:i,column:n}}createTable(e,t){const i=e.createElement("table"),n=t.rows||2,o=t.columns||2;return lk(e,i,0,n,o),t.headingRows&&this.setHeadingRowsCount(e,i,Math.min(t.headingRows,n)),t.headingColumns&&this.setHeadingColumnsCount(e,i,Math.min(t.headingColumns,o)),i}insertRows(e,t={}){const i=this.editor.model,n=t.at||0,o=t.rows||1,s=void 0!==t.copyStructureFromAbove,r=t.copyStructureFromAbove?n-1:n,a=A_(this.editor),l=this.getRows(e),c=this.getColumns(e);if(n>l)throw new x("tableutils-insertrows-insert-out-of-range",this,{options:t});i.change((t=>{let i=e.getAttribute("headingRows")||0;const u=e.getAttribute("headingColumns")||0;if(i>n&&(i+=o,this.setHeadingRowsCount(t,e,i,{shallow:!0})),!s&&(0===n||n===l)){const s=lk(t,e,n,o,c);if(a)for(let e=0;e0){const o=y_(t,l,r>1?{colspan:r}:void 0);a&&(n+s{const i=e.getAttribute("headingRows")||0;let r=e.getAttribute("headingColumns");no-1)throw new x("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});i.change((t=>{const i={first:s,last:r},{cellsToMove:n,cellsToTrim:o}=function(e,{first:t,last:i}){const n=new Map,o=[];for(const{row:s,column:r,cellHeight:a,cell:l}of new b_(e,{endRow:i})){const e=s+a-1;if(s>=t&&s<=i&&e>i){const e=a-(i-s+1);n.set(r,{cell:l,rowspan:e})}if(s=t){let n;n=e>=i?i-t+1:e-t+1,o.push({cell:l,rowspan:a-n})}}return{cellsToMove:n,cellsToTrim:o}}(e,i);n.size&&function(e,t,i,n){const o=[...new b_(e,{includeAllSlots:!0,row:t})],s=e.getChild(t);let r;for(const{column:e,cell:t,isAnchor:a}of o)if(i.has(e)){const{cell:t,rowspan:o}=i.get(e),a=r?n.createPositionAfter(r):n.createPositionAt(s,0);n.move(n.createRangeOn(t),a),v_("rowspan",o,t,n),r=t}else a&&(r=t)}(e,r+1,n,t);for(let i=r;i>=s;i--)t.remove(e.getChild(i));for(const{rowspan:e,cell:i}of o)v_("rowspan",e,i,t);if(function(e,{first:t,last:i},n){const o=e.getAttribute("headingRows")||0;t{!function(e,t,i){const n=e.getAttribute("headingColumns")||0;if(n&&t.first=n;o--){for(const{cell:i,column:n,cellWidth:s}of[...new b_(e)])n<=o&&s>1&&n+s>o?v_("colspan",s-1,i,t):n===o&&t.remove(i);if(i[o]){const e=0===o?i[1]:i[o-1],n=parseFloat(i[o].getAttribute("columnWidth")),s=parseFloat(e.getAttribute("columnWidth"));t.remove(i[o]),t.setAttribute("columnWidth",n+s+"%",e)}}if(R_(e,this)||O_(e,this),A_(this.editor)){let i=e.getAttribute("headingColumns")||0;const n=this.getColumns(e);for(;i{if(s>1){const{newCellsSpan:n,updatedSpan:r}=uk(s,t);v_("colspan",r,e,i);const a={};n>1&&(a.colspan=n),o>1&&(a.rowspan=o),ck(s>t?t-1:s-1,i,i.createPositionAfter(e),a)}if(st===e)),c=a.filter((({cell:t,cellWidth:i,column:n})=>t!==e&&n===l||nl));for(const{cell:e,cellWidth:t}of c)i.setAttribute("colspan",t+r,e);const u={};o>1&&(u.rowspan=o),ck(r,i,i.createPositionAfter(e),u);const d=n.getAttribute("headingColumns")||0;d>l&&v_("headingColumns",d+r,n,i)}}))}splitCellHorizontally(e,t=2){const i=this.editor.model,n=e.parent,o=n.parent,s=o.getChildIndex(n),r=parseInt(e.getAttribute("rowspan")||"1"),a=parseInt(e.getAttribute("colspan")||"1");i.change((i=>{if(r>1){const n=[...new b_(o,{startRow:s,endRow:s+r-1,includeAllSlots:!0})],{newCellsSpan:l,updatedSpan:c}=uk(r,t);v_("rowspan",c,e,i);const{column:u}=n.find((({cell:t})=>t===e)),d={};l>1&&(d.rowspan=l),a>1&&(d.colspan=a);let h=0;for(const e of n){const{column:t,row:n}=e,o=t===u;h>=l&&o&&(h=0),n>=s+c&&o&&(h||ck(1,i,e.getPositionBefore(),d),h++)}}if(rs){const e=o+n;i.setAttribute("rowspan",e,t)}const c={};a>1&&(c.colspan=a),lk(i,o,s+1,n,1,c);const u=o.getAttribute("headingRows")||0;u>s&&v_("headingRows",u+n,o,i)}}))}getColumns(e){return[...e.getChild(0).getChildren()].filter((e=>e.is("element","tableCell"))).reduce(((e,t)=>e+parseInt(t.getAttribute("colspan")||"1")),0)}getRows(e){return Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0)}createTableWalker(e,t={}){return new b_(e,t)}getSelectedTableCells(e){const t=[];for(const i of this.sortRanges(e.getRanges())){const e=i.getContainedElement();e&&e.is("element","tableCell")&&t.push(e)}return t}setHeadingRowsCount(e,t,i,n={}){const{shallow:o,resetFormerHeadingCells:s=!0,autoExpand:r=!0}=n,a=t.getAttribute("headingRows")||0;if(i!==a&&(v_("headingRows",i,t,e,0),!o&&A_(this.editor))){for(const{cell:n,row:o,column:s}of new b_(t,{endRow:i-1}))hk({table:t,writer:e,cell:n,row:o,column:s});if(s&&ia){const n=this.getRows(t);for(;ia){const n=this.getColumns(t);for(;ie.parent.index));return this._getFirstLastIndexesObject(t)}getColumnIndexes(e){const t=e[0].findAncestor("table"),i=[...new b_(t)].filter((t=>e.includes(t.cell))).map((e=>e.column));return this._getFirstLastIndexesObject(i)}isSelectionRectangular(e){if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;const t=new Set,i=new Set;let n=0;for(const o of e){const{row:e,column:s}=this.getCellLocation(o),r=parseInt(o.getAttribute("rowspan"))||1,a=parseInt(o.getAttribute("colspan"))||1;t.add(e),i.add(s),r>1&&t.add(e+r-1),a>1&&i.add(s+a-1),n+=r*a}const o=function(e,t){const i=Array.from(e.values()),n=Array.from(t.values());return(Math.max(...i)-Math.min(...i)+1)*(Math.max(...n)-Math.min(...n)+1)}(t,i);return o==n}sortRanges(e){return Array.from(e).sort(dk)}_getFirstLastIndexesObject(e){const t=e.sort(((e,t)=>e-t));return{first:t[0],last:t[t.length-1]}}_areCellInTheSameTableSection(e){const t=e[0].findAncestor("table"),i=this.getRowIndexes(e),n=parseInt(t.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(i,n))return!1;const o=this.getColumnIndexes(e),s=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(o,s)}_areIndexesInSameSection({first:e,last:t},i){return e=s&&n>=r?e.removeAttribute("tableCellType",o):e.setAttribute("tableCellType","header",o)}class mk extends cd{refresh(){const e=this.editor.plugins.get(ak),t=e.getSelectedTableCells(this.editor.model.document.selection);this.isEnabled=e.isSelectionRectangular(t)}execute(){const e=this.editor.model,t=this.editor.plugins.get(ak);e.change((i=>{const n=t.getSelectedTableCells(e.document.selection),o=n.shift(),{mergeWidth:s,mergeHeight:r}=function(e,t,i){let n=0,o=0;for(const e of t){const{row:t,column:s}=i.getCellLocation(e);n=pk(e,s,n,"colspan"),o=pk(e,t,o,"rowspan")}const{row:s,column:r}=i.getCellLocation(e);return{mergeWidth:n-r,mergeHeight:o-s}}(o,n,t);v_("colspan",s,o,i),v_("rowspan",r,o,i);for(const e of n)gk(e,o,i);L_(o.findAncestor("table"),t),i.setSelection(o,"in")}))}}function gk(e,t,i){fk(e)||(fk(t)&&i.remove(i.createRangeIn(t)),i.move(i.createRangeIn(e),i.createPositionAt(t,"end"))),i.remove(e)}function fk(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}function pk(e,t,i,n){const o=parseInt(e.getAttribute(n)||"1");return Math.max(i,t+o)}class bk extends cd{constructor(e){super(e),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),i=t.getSelectionAffectedTableCells(e.document.selection),n=t.getRowIndexes(i),o=i[0].findAncestor("table"),s=[];for(let t=n.first;t<=n.last;t++)for(const i of o.getChild(t).getChildren())s.push(e.createRangeOn(i));e.change((e=>{e.setSelection(s)}))}}class wk extends cd{constructor(e){super(e),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,i=e.getSelectionAffectedTableCells(t.document.selection),n=i[0],o=i.pop(),s=n.findAncestor("table"),r=e.getCellLocation(n),a=e.getCellLocation(o),l=Math.min(r.column,a.column),c=Math.max(r.column,a.column),u=[];for(const e of new b_(s,{startColumn:l,endColumn:c}))u.push(t.createRangeOn(e.cell));t.change((e=>{e.setSelection(u)}))}}function vk(e,t){let i=!1;const n=function(e){const t=parseInt(e.getAttribute("headingRows")||"0"),i=Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0),n=[];for(const{row:o,cell:s,cellHeight:r}of new b_(e)){if(r<2)continue;const e=oe){const t=e-o;n.push({cell:s,rowspan:t})}}return n}(e);if(n.length){i=!0;for(const e of n)v_("rowspan",e.rowspan,e.cell,t,1)}return i}function yk(e,t){let i=!1;const n=function(e){const t=new Array(e.childCount).fill(0);for(const{rowIndex:i}of new b_(e,{includeAllSlots:!0}))t[i]++;return t}(e),o=[];for(const[t,i]of n.entries())!i&&e.getChild(t).is("element","tableRow")&&o.push(t);if(o.length){i=!0;for(const i of o.reverse())t.remove(e.getChild(i)),n.splice(i,1)}const s=n.filter(((t,i)=>e.getChild(i).is("element","tableRow"))),r=s[0];if(!s.every((e=>e===r))){const n=s.reduce(((e,t)=>t>e?t:e),0);for(const[o,r]of s.entries()){const s=n-r;if(s){for(let i=0;ie.is("$text")));for(const e of i)t.wrap(t.createRangeOn(e),"paragraph");return!!i.length}function Ak(e){return!!e.position.parent.is("element","tableCell")&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)}function Tk(e,t){if(!e.is("element","paragraph"))return!1;const i=t.toViewElement(e);return!!i&&G_(e)!==i.is("element","span")}class Ek extends ad{_additionalSlots;static get pluginName(){return"TableEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[ak]}constructor(e){super(e),this._additionalSlots=[]}init(){const e=this.editor,t=e.model,i=t.schema,n=e.conversion,o=e.plugins.get(ak);i.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),i.register("tableRow",{allowIn:"table",isLimit:!0}),i.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),n.for("upcast").add((e=>{e.on("element:figure",((e,t,i)=>{if(!i.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const n=N_(t.viewItem);if(!n||!i.consumable.test(n,{name:!0}))return;i.consumable.consume(t.viewItem,{name:!0,classes:"table"});const o=i.convertItem(n,t.modelCursor),s=Zt(o.modelRange.getItems());if(!s||!s.is("element","table"))return i.consumable.revert(t.viewItem,{name:!0,classes:"table"}),void(o.modelRange&&!o.modelRange.isCollapsed&&(t.modelRange=o.modelRange,t.modelCursor=o.modelCursor));i.convertChildren(t.viewItem,i.writer.createPositionAt(s,"end")),i.updateConversionResult(s,t)}))})),n.for("upcast").add((e=>{e.on("element:table",((e,t,i)=>{const n=t.viewItem;if(!i.consumable.test(n,{name:!0}))return;const{rows:o,headingRows:s,headingColumns:r}=function(e){let t,i=!0;const n=[],o=[];let s;for(const t of Array.from(e.getChildren())){if("tbody"!==t.name&&"thead"!==t.name&&"tfoot"!==t.name)continue;"thead"!==t.name||s||(i=!0,s=t);const e=Array.from(t.getChildren()).filter((e=>e.is("element","tr")));let r=null;for(const a of e){const e=Array.from(a.getChildren()).filter((e=>e.is("element","td")||e.is("element","th")));s&&t===s||"tbody"===t.name&&e.length>0&&(null===r||e.length===r)&&e.every((e=>e.is("element","th")))&&i?(n.push(a),i=!0):(o.push(a),i=!1),r=Math.max(r||0,e.length)}}const r=function(e){let t=new Map,i=0;const n=e.map((e=>{const n=[],o=Array.from(e.getChildren()).filter((e=>"th"===e.name||"td"===e.name)),s=new Map;for(;o.length||n.length0)n.push(e.cell);else{const e=o.shift();if(!e){n.push(null);continue}{const t=parseInt(e.getAttribute("colspan")||"1"),i=parseInt(e.getAttribute("rowspan")||"1");for(let o=0;o1&&s.set(n.length,{cell:e,remaining:i-1}),n.push(e)}}}for(const[e,i]of t.entries())i.remaining-=1,i.remaining>0&&!s.has(e)&&s.set(e,i);return t=s,i=Math.max(i,n.length),n}));for(const e of n)for(;e.lengthi.convertItem(e,i.writer.createPositionAt(l,"end")))),i.convertChildren(n,i.writer.createPositionAt(l,"end")),l.isEmpty){const e=i.writer.createElement("tableRow");i.writer.insert(e,i.writer.createPositionAt(l,"end")),y_(i.writer,i.writer.createPositionAt(e,"end"))}i.updateConversionResult(l,t)}}))})),n.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:q_(o,{asWidget:!0,additionalSlots:this._additionalSlots})}),n.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:q_(o,{additionalSlots:this._additionalSlots})}),n.for("upcast").elementToElement({model:"tableRow",view:"tr"}),n.for("upcast").add((e=>{e.on("element:tr",((e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()}),{priority:"high"})})),n.for("downcast").elementToElement({model:"tableRow",view:(e,{writer:t})=>e.isEmpty?t.createEmptyElement("tr"):t.createContainerElement("tr")}),n.for("upcast").elementToElement({model:"tableCell",view:"td"}),n.for("upcast").elementToElement({model:"tableCell",view:"th"}),n.for("upcast").add(F_("td")),n.for("upcast").add(F_("th")),n.for("editingDowncast").elementToElement({model:"tableCell",view:j_({asWidget:!0,cellTypeEnabled:()=>A_(this.editor)})}),n.for("dataDowncast").elementToElement({model:"tableCell",view:j_({cellTypeEnabled:()=>A_(this.editor)})}),n.for("editingDowncast").elementToElement({model:"paragraph",view:W_({asWidget:!0}),converterPriority:"high"}),n.for("dataDowncast").elementToElement({model:"paragraph",view:W_(),converterPriority:"high"}),n.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),n.for("upcast").attributeToAttribute({model:{key:"colspan",value:Sk("colspan")},view:"colspan"}),n.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),n.for("upcast").attributeToAttribute({model:{key:"rowspan",value:Sk("rowspan")},view:"rowspan"}),this._addPlainTableOutputConverters(),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.config.define("table.showHiddenBorders",!0),e.config.get("table.showHiddenBorders")&&e.editing.view.change((t=>{for(const i of e.editing.view.document.roots)t.addClass("ck-table-show-hidden-borders",i)})),e.commands.add("insertTable",new Y_(e)),e.commands.add("insertTableRowAbove",new Q_(e,{order:"above"})),e.commands.add("insertTableRowBelow",new Q_(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new X_(e,{order:"left"})),e.commands.add("insertTableColumnRight",new X_(e,{order:"right"})),e.commands.add("removeTableRow",new ik(e)),e.commands.add("removeTableColumn",new nk(e)),e.commands.add("splitTableCellVertically",new Z_(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new Z_(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new mk(e)),e.commands.add("mergeTableCellRight",new ek(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new ek(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new ek(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new ek(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new sk(e)),e.commands.add("setTableRowHeader",new ok(e)),e.commands.add("selectTableRow",new bk(e)),e.commands.add("selectTableColumn",new wk(e)),function(e){e.document.registerPostFixer((t=>function(e,t){const i=t.document.differ.getChanges();let n=!1;const o=new Set;for(const t of i){let i=null;"insert"==t.type&&"table"==t.name&&(i=t.position.nodeAfter),"insert"!=t.type&&"remove"!=t.type||"tableRow"!=t.name&&"tableCell"!=t.name||(i=t.position.findAncestor("table")),_k(t)&&(i=t.range.start.findAncestor("table")),i&&!o.has(i)&&(n=vk(i,e)||n,n=yk(i,e)||n,o.add(i))}return n}(t,e)))}(t),function(e){e.document.registerPostFixer((t=>function(e,t){const i=t.document.differ.getChanges();let n=!1;for(const t of i)"insert"==t.type&&"table"==t.name&&(n=kk(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableRow"==t.name&&(n=Ck(t.position.nodeAfter,e)||n),"insert"==t.type&&"tableCell"==t.name&&(n=xk(t.position.nodeAfter,e)||n),"remove"!=t.type&&"insert"!=t.type||!Ak(t)||(n=xk(t.position.parent,e)||n);return n}(t,e)))}(t),this.listenTo(t.document,"change:data",(()=>{A_(e)||function(e,t){const i=e.document.differ;for(const e of i.getChanges()){let i,n=!1;if("attribute"==e.type){const t=e.range.start.nodeAfter;if(!t||!t.is("element","table"))continue;if("headingRows"!=e.attributeKey&&"headingColumns"!=e.attributeKey)continue;i=t,n="headingRows"==e.attributeKey}else"tableRow"!=e.name&&"tableCell"!=e.name||(i=e.position.findAncestor("table"),n="tableRow"==e.name);if(!i)continue;const o=i.getAttribute("headingRows")||0,s=i.getAttribute("headingColumns")||0,r=new b_(i);for(const e of r){const i=e.rowTk(e,t.mapper)));for(const e of i)t.reconvertItem(e)}}(t,e.editing)}))}registerAdditionalSlot(e){this._additionalSlots.push(e)}_addPlainTableOutputConverters(){const e=this.editor;e.conversion.for("dataDowncast").elementToStructure({model:"table",view:K_(e),converterPriority:"high"}),e.plugins.has("TableCaptionEditing")&&e.conversion.for("dataDowncast").elementToElement({model:"caption",view:J_(e),converterPriority:"high"}),e.plugins.has("TablePropertiesEditing")&&function(e){const t={"border-width":"tableBorderWidth","border-color":"tableBorderColor","border-style":"tableBorderStyle","background-color":"tableBackgroundColor"};for(const[i,n]of Object.entries(t))e.conversion.for("dataDowncast").add((t=>t.on(`attribute:${n}:table`,((t,n,o)=>{const{item:s,attributeNewValue:r}=n,{mapper:a,writer:l}=o,c=e.plugins.has("PlainTableOutput"),u=o.options.isClipboardPipeline,d=e.config.get("experimentalFlags.useExtendedTableBlockAlignment");if(!(c||d&&u))return;if(!o.consumable.consume(s,t.name))return;const h=a.toViewElement(s);r?l.setStyle(i,r,h):l.removeStyle(i,h)}),{priority:"high"})))}(e)}}function Sk(e){return t=>{const i=parseInt(t.getAttribute(e));return Number.isNaN(i)||i<=0?null:i}}const Pk='';class Ik extends Hi{items;keystrokes;focusTracker;constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new oi,this.focusTracker=new ei,this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",((e,t)=>`${t} × ${e}`)),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":t.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck","ck-insert-table-dropdown__label"],"aria-hidden":!0},children:[{text:t.to("label")}]}],on:{mousedown:t.to((e=>{e.preventDefault()})),click:t.to((()=>{this.fire("execute")}))}}),this.on("boxover",((e,t)=>{const{row:i,column:n}=t.target.dataset;this.items.get(10*(parseInt(i,10)-1)+(parseInt(n,10)-1)).focus()})),this.focusTracker.on("change:focusedElement",((e,t,i)=>{if(!i)return;const{row:n,column:o}=i.dataset;this.set({rows:parseInt(n),columns:parseInt(o)})})),this.on("change:columns",(()=>this._highlightGridBoxes())),this.on("change:rows",(()=>this._highlightGridBoxes()))}render(){super.render(),Sb({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection});for(const e of this.items)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}reset(){this.set({rows:1,columns:1})}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map(((i,n)=>{const o=Math.floor(n/10){const n=e.commands.get("insertTable"),o=Pu(i);let s;return o.bind("isEnabled").to(n),o.buttonView.set({icon:Pk,label:t("Insert table"),tooltip:!0}),o.on("change:isOpen",(()=>{s||(s=new Ik(i),o.panelView.children.add(s),s.delegate("execute").to(o),o.on("execute",(()=>{e.execute("insertTable",{rows:s.rows,columns:s.columns}),e.editing.view.focus()})))})),o})),e.ui.componentFactory.add("menuBar:insertTable",(i=>{const n=e.commands.get("insertTable"),o=new Gu(i),s=new Ik(i);return s.delegate("execute").to(o),o.on("change:isOpen",((e,t,i)=>{i||s.reset()})),s.on("execute",(()=>{e.execute("insertTable",{rows:s.rows,columns:s.columns}),e.editing.view.focus()})),o.buttonView.set({label:t("Table"),icon:Pk}),o.panelView.children.add(s),o.bind("isEnabled").to(n),o})),e.ui.componentFactory.add("tableColumn",(e=>{const n=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:i?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:i?"insertTableColumnRight":"insertTableColumnLeft",label:t("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:t("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:t("Select column")}}];return this._prepareDropdown(t("Column"),'',n,e)})),e.ui.componentFactory.add("tableRow",(e=>{const i=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:t("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:t("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:t("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:t("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:t("Select row")}}];return this._prepareDropdown(t("Row"),'',i,e)})),e.ui.componentFactory.add("mergeTableCells",(e=>{const n=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:i?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:i?"mergeTableCellLeft":"mergeTableCellRight",label:t("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:t("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:t("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(t("Merge cells"),'',n,e)}))}_prepareDropdown(e,t,i,n){const o=this.editor,s=Pu(n),r=this._fillDropdownWithListOptions(s,i);return s.buttonView.set({label:e,icon:t,tooltip:!0}),s.bind("isEnabled").toMany(r,"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(s,"execute",(e=>{o.execute(e.source.commandName),e.source instanceof Au||o.editing.view.focus()})),s}_prepareMergeSplitButtonDropdown(e,t,i,n){const o=this.editor,s=Pu(n,xu),r="mergeTableCells",a=o.commands.get(r),l=this._fillDropdownWithListOptions(s,i);return s.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),s.bind("isEnabled").toMany([a,...l],"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(s.buttonView,"execute",(()=>{o.execute(r),o.editing.view.focus()})),this.listenTo(s,"execute",(e=>{o.execute(e.source.commandName),o.editing.view.focus()})),s}_fillDropdownWithListOptions(e,t){const i=this.editor,n=[],o=new Xt;for(const e of t)Ok(e,i,n,o);return Ou(e,o),n}}function Ok(e,t,i,n){if("button"===e.type||"switchbutton"===e.type){const n=e.model=new sf(e.model),{commandName:o,bindIsOn:s}=e.model,r=t.commands.get(o);i.push(r),n.set({commandName:o}),n.bind("isEnabled").to(r),s&&n.bind("isOn").to(r,"value"),n.set({withText:!0})}n.add(e)}class Rk extends ad{static get pluginName(){return"TableSelection"}static get isOfficialPlugin(){return!0}static get requires(){return[ak,ak]}init(){const e=this.editor,t=e.model,i=e.editing.view;this.listenTo(t,"deleteContent",((e,t)=>this._handleDeleteContent(e,t)),{priority:"high"}),this.listenTo(i.document,"insertText",((e,t)=>this._handleInsertTextEvent(e,t)),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=this.editor.plugins.get(ak),t=this.editor.model.document.selection,i=e.getSelectedTableCells(t);return 0==i.length?null:i}getSelectionAsFragment(){const e=this.editor.plugins.get(ak),t=this.getSelectedTableCells();return t?this.editor.model.change((i=>{const n=i.createDocumentFragment(),{first:o,last:s}=e.getColumnIndexes(t),{first:r,last:a}=e.getRowIndexes(t),l=t[0].findAncestor("table");let c=a,u=s;if(e.isSelectionRectangular(t)){const e={firstColumn:o,lastColumn:s,firstRow:r,lastRow:a};c=B_(l,e),u=M_(l,e)}const d=T_(l,{startRow:r,startColumn:o,endRow:c,endColumn:u},i);return i.insert(d,n,0),n})):null}setCellSelection(e,t){const i=this._getCellsToSelect(e,t);this.editor.model.change((e=>{e.setSelection(i.cells.map((t=>e.createRangeOn(t))),{backward:i.backward})}))}getFocusCell(){const e=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return e&&e.is("element","tableCell")?e:null}getAnchorCell(){const e=Zt(this.editor.model.document.selection.getRanges()).getContainedElement();return e&&e.is("element","tableCell")?e:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add((e=>e.on("selection",((e,i,n)=>{const o=n.writer;!function(e){for(const i of t)e.removeClass("ck-editor__editable_selected",i);t.clear()}(o);const s=this.getSelectedTableCells();if(!s)return;for(const e of s){const i=n.mapper.toViewElement(e);o.addClass("ck-editor__editable_selected",i),t.add(i)}const r=n.mapper.toViewElement(s[s.length-1]);o.setSelection(r,0)}),{priority:"lowest"})))}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",(()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change((i=>{const n=i.createPositionAt(t[0],0),o=e.model.schema.getNearestSelectionRange(n);i.setSelection(o)}))}}))}_handleDeleteContent(e,t){const i=this.editor.plugins.get(ak),n=t[0],o=t[1],s=this.editor.model,r=!o||"backward"==o.direction,a=i.getSelectedTableCells(n);a.length&&(e.stop(),s.change((e=>{const t=a[r?a.length-1:0];s.change((e=>{for(const t of a)s.deleteContent(e.createSelection(t,"in"))}));const i=s.schema.getNearestSelectionRange(e.createPositionAt(t,0));n.is("documentSelection")?e.setSelection(i):n.setTo(i)})))}_handleInsertTextEvent(e,t){const i=this.editor,n=this.getSelectedTableCells();if(!n)return;const o=i.editing.view,s=i.editing.mapper,r=n.map((e=>o.createRangeOn(s.toViewElement(e))));t.selection=o.createSelection(r),t.preventDefault()}_getCellsToSelect(e,t){const i=this.editor.plugins.get("TableUtils"),n=i.getCellLocation(e),o=i.getCellLocation(t),s=Math.min(n.row,o.row),r=Math.max(n.row,o.row),a=Math.min(n.column,o.column),l=parseInt(t.getAttribute("colspan")||"1")-1,c=Math.max(n.column,o.column+l),u=new Array(r-s+1).fill(null).map((()=>[])),d={startRow:s,endRow:r,startColumn:a,endColumn:c};for(const{row:t,cell:i}of new b_(e.findAncestor("table"),d))u[t-s].push(i);const h=o.rowe.reverse())),{cells:u.flat(),backward:h||m}}}class Lk extends ad{static get pluginName(){return"TableClipboard"}static get isOfficialPlugin(){return!0}static get requires(){return[Yd,Qd,Rk,ak]}init(){const e=this.editor.editing.view.document;this.listenTo(e,"copy",((e,t)=>this._onCopyCut(e,t))),this.listenTo(e,"cut",((e,t)=>this._onCopyCut(e,t))),this._listenToContentInsertion(),this.decorate("_replaceTableSlotCell")}_listenToContentInsertion(){const{editor:e}=this,t=e.plugins.get(Qd),i=e.plugins.get(Rk);let n=!1;t.on("contentInsertion",((e,t)=>{n="paste"===t.method})),this.listenTo(e.model,"insertContent",((e,[t,o])=>{(n||null!==i.getSelectedTableCells())&&this._onInsertContent(e,t,o)}),{priority:"high"}),t.on("contentInsertion",(()=>{n=!1}),{priority:"lowest"})}_onCopyCut(e,t){const i=this.editor.editing.view,n=this.editor.plugins.get(Rk),o=this.editor.plugins.get(Yd);n.getSelectedTableCells()&&("cut"!=e.name||this.editor.model.canEditAt(this.editor.model.document.selection))&&(t.preventDefault(),e.stop(),this.editor.model.enqueueChange({isUndoable:"cut"===e.name},(()=>{const s=o._copySelectedFragmentWithMarkers(e.name,this.editor.model.document.selection,(()=>n.getSelectionAsFragment()));i.document.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:this.editor.data.toView(s),method:e.name})})))}_onInsertContent(e,t,i){if(i&&!i.is("documentSelection"))return;const n=this.editor.model,o=this.editor.plugins.get(ak),s=this.editor.plugins.get(Yd),r=this.getTableIfOnlyTableInContent(t,n);if(!r)return;const a=o.getSelectionAffectedTableCells(n.document.selection);a.length?(e.stop(),t.is("documentFragment")?s._pasteMarkersIntoTransformedElement(t.markers,(e=>this._replaceSelectedCells(r,a,e))):this.editor.model.change((e=>{this._replaceSelectedCells(r,a,e)}))):L_(r,o)}_replaceSelectedCells(e,t,i){const n=this.editor.plugins.get(ak),o={width:n.getColumns(e),height:n.getRows(e)},s=function(e,t,i,n){const o=e[0].findAncestor("table"),s=n.getColumnIndexes(e),r=n.getRowIndexes(e),a={firstColumn:s.first,lastColumn:s.last,firstRow:r.first,lastRow:r.last},l=1===e.length;return l&&(a.lastRow+=t.height-1,a.lastColumn+=t.width-1,function(e,t,i,n){const o=n.getColumns(e),s=n.getRows(e);i>o&&n.insertColumns(e,{at:o,columns:i-o}),t>s&&n.insertRows(e,{at:s,rows:t-s})}(o,a.lastRow+1,a.lastColumn+1,n)),l||!n.isSelectionRectangular(e)?function(e,t,i){const{firstRow:n,lastRow:o,firstColumn:s,lastColumn:r}=t,a={first:n,last:o},l={first:s,last:r};Mk(e,s,a,i),Mk(e,r+1,a,i),Bk(e,n,l,i),Bk(e,o+1,l,i,n)}(o,a,i):(a.lastRow=B_(o,a),a.lastColumn=M_(o,a)),a}(t,o,i,n),r=s.lastRow-s.firstRow+1,a=s.lastColumn-s.firstColumn+1;e=T_(e,{startRow:0,startColumn:0,endRow:Math.min(r,o.height)-1,endColumn:Math.min(a,o.width)-1},i);const l=t[0].findAncestor("table"),c=this._replaceSelectedCellsWithPasted(e,o,l,s,i);if(this.editor.plugins.get("TableSelection").isEnabled){const e=n.sortRanges(c.map((e=>i.createRangeOn(e))));i.setSelection(e)}else i.setSelection(c[0],0);return l}_replaceSelectedCellsWithPasted(e,t,i,n,o){const{width:s,height:r}=t,a=function(e,t,i){const n=new Array(i).fill(null).map((()=>new Array(t).fill(null)));for(const{column:t,row:i,cell:o}of new b_(e))n[i][t]=o;return n}(e,s,r),l=[...new b_(i,{startRow:n.firstRow,endRow:n.lastRow,startColumn:n.firstColumn,endColumn:n.lastColumn,includeAllSlots:!0})],c=[];let u;for(const e of l){const{row:t,column:i}=e;i===n.firstColumn&&(u=e.getPositionBefore());const l=t-n.firstRow,d=i-n.firstColumn,h=a[l%r][d%s],m=h?o.cloneElement(h):null,g=this._replaceTableSlotCell(e,m,u,o);g&&(V_(g,t,i,n.lastRow,n.lastColumn,o),c.push(g),u=o.createPositionAfter(g))}const d=parseInt(i.getAttribute("headingRows")||"0"),h=parseInt(i.getAttribute("headingColumns")||"0"),m=n.firstRowNk(e,t,i))).map((({cell:e})=>S_(e,t,n)))}function Mk(e,t,i,n){if(t<1)return;const o=P_(e,t).filter((({row:e,cellHeight:t})=>Nk(e,t,i)));return o.map((({cell:e,column:i})=>I_(e,i,t,n)))}function Nk(e,t,i){const n=e+t-1,{first:o,last:s}=i;return e>=o&&e<=s||e=o}class Fk extends ad{static get pluginName(){return"TableKeyboard"}static get isOfficialPlugin(){return!0}static get requires(){return[Rk,ak]}init(){const e=this.editor,t=e.editing.view.document,i=e.t;this.listenTo(t,"arrowKey",((...e)=>this._onArrowKey(...e)),{context:"table"}),this.listenTo(t,"tab",((...e)=>this._handleTabOnSelectedTable(...e)),{context:"figure"}),this.listenTo(t,"tab",((...e)=>this._handleTab(...e)),{context:["th","td"]}),e.accessibility.addKeystrokeInfoGroup({id:"table",label:i("Keystrokes that can be used in a table cell"),keystrokes:[{label:i("Move the selection to the next cell"),keystroke:"Tab"},{label:i("Move the selection to the previous cell"),keystroke:"Shift+Tab"},{label:i("Insert a new table row (when in the last cell of a table)"),keystroke:"Tab"},{label:i("Navigate through the table"),keystroke:[["arrowup"],["arrowright"],["arrowdown"],["arrowleft"]]}]})}_handleTabOnSelectedTable(e,t){const i=this.editor.model.document.selection.getSelectedElement();i&&i.is("element","table")&&t.stopPropagation()}_handleTab(e,t){const i=this.editor,n=this.editor.plugins.get(ak),o=this.editor.plugins.get("TableSelection"),s=i.model.document.selection,r=!t.shiftKey;let a=n.getTableCellsContainingSelection(s)[0];if(a||(a=o.getFocusCell()),!a)return;t.stopPropagation();const l=a.parent,c=l.parent,u=c.getChildIndex(l),d=l.getChildIndex(a)===l.childCount-1,h=u===n.getRows(c)-1;r&&h&&d&&i.execute("insertTableRowBelow")}_onArrowKey(e,t){const i=this.editor,n=Ft(t.keyCode,i.locale.contentLanguageDirection);this._handleArrowKeys(n,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const i=this.editor.plugins.get(ak),n=this.editor.plugins.get("TableSelection"),o=this.editor.model,s=o.document.selection,r=["right","down"].includes(e),a=i.getSelectedTableCells(s);if(a.length){let i;return i=t?n.getFocusCell():r?a[a.length-1]:a[0],this._navigateFromCellInDirection(i,e,t),!0}const l=s.focus.findAncestor("tableCell");if(!l)return!1;if(!s.isCollapsed)if(t){if(s.isBackward==r&&!s.containsEntireContent(l))return!1}else{const e=s.getSelectedElement();if(!e||!o.schema.isObject(e))return!1}return!!this._isSelectionAtCellEdge(s,l,r)&&(this._navigateFromCellInDirection(l,e,t),!0)}_isSelectionAtCellEdge(e,t,i){const n=this.editor.model,o=this.editor.model.schema,s=i?e.getLastPosition():e.getFirstPosition();if(!o.getLimitElement(s).is("element","tableCell"))return n.createPositionAt(t,i?"end":0).isTouching(s);const r=n.createSelection(s);return n.modifySelection(r,{direction:i?"forward":"backward"}),s.isEqual(r.focus)}_navigateFromCellInDirection(e,t,i=!1){const n=this.editor.model,o=e.findAncestor("table"),s=[...new b_(o,{includeAllSlots:!0})],{row:r,column:a}=s[s.length-1],l=s.find((({cell:t})=>t==e));let{row:c,column:u}=l;switch(t){case"left":u--;break;case"up":c--;break;case"right":u+=l.cellWidth;break;case"down":c+=l.cellHeight}if(c<0||c>r||u<0&&c<=0||u>a&&c>=r)return void n.change((e=>{e.setSelection(e.createRangeOn(o))}));u<0?(u=i?0:a,c--):u>a&&(u=i?a:0,c++);const d=s.find((e=>e.row==c&&e.column==u)).cell,h=["right","down"].includes(t),m=this.editor.plugins.get("TableSelection");if(i&&m.isEnabled){const t=m.getAnchorCell()||e;m.setCellSelection(t,d)}else{const e=n.createPositionAt(d,h?0:"end");n.change((t=>{t.setSelection(e)}))}}}class Dk extends er{domEventType=["mousemove","mouseleave"];onDomEvent(e){this.fire(e.type,e)}}class zk extends ad{static get pluginName(){return"TableMouse"}static get isOfficialPlugin(){return!0}static get requires(){return[Rk,ak]}init(){this.editor.editing.view.addObserver(Dk),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(ak);let i=!1;const n=e.plugins.get(Rk);this.listenTo(e.editing.view.document,"mousedown",((o,s)=>{const r=e.model.document.selection;if(!this.isEnabled||!n.isEnabled)return;if(!s.domEvent.shiftKey)return;const a=n.getAnchorCell()||t.getTableCellsContainingSelection(r)[0];if(!a)return;const l=this._getModelTableCellFromDomEvent(s);l&&Hk(a,l)&&(i=!0,n.setCellSelection(a,l),s.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{i=!1})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{i&&e.stop()}),{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,i,n=!1,o=!1;const s=e.plugins.get(Rk);this.listenTo(e.editing.view.document,"mousedown",((e,i)=>{this.isEnabled&&s.isEnabled&&(i.domEvent.shiftKey||i.domEvent.ctrlKey||i.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(i)))})),this.listenTo(e.editing.view.document,"mousemove",((e,r)=>{if(!r.domEvent.buttons)return;if(!t)return;const a=this._getModelTableCellFromDomEvent(r);a&&Hk(t,a)&&(i=a,n||i==t||(n=!0)),n&&(o=!0,s.setCellSelection(t,i),r.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{n=!1,o=!1,t=null,i=null})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{o&&e.stop()}),{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,i=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(i).parent.findAncestor("tableCell",{includeSelf:!0})}}function Hk(e,t){return e.parent.parent==t.parent.parent}function Uk(e){return $k(e)||qk(e)}function $k(e){const t=e.getSelectedElement();return t&&jk(t)?t:null}function qk(e){const t=e.getFirstPosition();if(!t)return null;let i=t.parent;for(;i;){if(i.is("element")&&jk(i))return i;i=i.parent}return null}function jk(e){return e.is("element")&&!!e.getCustomProperty("table")&&qh(e)}class Wk extends cd{attributeName;_defaultValue;_defaultContentTableValue;_defaultLayoutTableValue;constructor(e,t,i){super(e),this.attributeName=t,this._defaultContentTableValue=i,this._defaultLayoutTableValue="tableBorderStyle"===t?"none":void 0}refresh(){const e=C_(this.editor.model.document.selection);this._defaultValue=e&&"layout"===e.getAttribute("tableType")?this._defaultLayoutTableValue:this._defaultContentTableValue,this.isEnabled=!!e,this.value=this._getValue(e)}execute(e={}){const t=this.editor.model,i=t.document.selection,{value:n,batch:o}=e,s=C_(i),r=this._getValueToSet(n);t.enqueueChange(o,(e=>{r?e.setAttribute(this.attributeName,r,s):e.removeAttribute(this.attributeName,s)}))}_getValue(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}}class Gk extends Wk{constructor(e,t){super(e,"tableBackgroundColor",t)}}class Kk extends Wk{constructor(e,t){super(e,"tableBorderColor",t)}_getValue(e){if(!e)return;const t=D_(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class Jk extends Wk{constructor(e,t){super(e,"tableBorderStyle",t)}_getValue(e){if(!e)return;const t=D_(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class Yk extends Wk{constructor(e,t){super(e,"tableBorderWidth",t)}_getValue(e){if(!e)return;const t=D_(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=z_(e,"px");if(t!==this._defaultValue)return t}}class Qk extends Wk{constructor(e,t){super(e,"tableWidth",t)}_getValueToSet(e){if((e=z_(e,"px"))!==this._defaultValue)return e}}class Xk extends Wk{constructor(e,t){super(e,"tableHeight",t)}_getValueToSet(e){if((e=z_(e,"px"))!==this._defaultValue)return e}}class Zk extends Wk{constructor(e,t){super(e,"tableAlignment",t)}}class eC extends ad{static get pluginName(){return"TablePropertiesEditing"}static get licenseFeatureCode(){return"TCP"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}static get requires(){return[Ek]}init(){const e=this.editor,t=e.model.schema,i=e.conversion;e.config.define("table.tableProperties.defaultProperties",{});const n=U_(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),o=!1!==e.config.get("table.tableProperties.alignment.useInlineStyles");if(e.data.addStyleProcessorRules(ru),e.data.addStyleProcessorRules(Yc),function(e,t){const{conversion:i}=e,{schema:n}=e.model,o={width:"tableBorderWidth",color:"tableBorderColor",style:"tableBorderStyle"};n.extend("table",{allowAttributes:Object.values(o)});for(const e of Object.values(o))n.setAttributeProperties(e,{isFormatting:!0});s_(e,"table",o,t),a_(i,{modelAttribute:o.color,styleName:"border-color"}),a_(i,{modelAttribute:o.style,styleName:"border-style"}),a_(i,{modelAttribute:o.width,styleName:"border-width"})}(e,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableBorderColor",new Kk(e,n.borderColor)),e.commands.add("tableBorderStyle",new Jk(e,n.borderStyle)),e.commands.add("tableBorderWidth",new Yk(e,n.borderWidth)),e.config.get("experimentalFlags.useExtendedTableBlockAlignment")?function(e,t,i,n){e.extend("table",{allowAttributes:["tableAlignment"]}),e.setAttributeProperties("tableAlignment",{isFormatting:!0}),t.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment",values:["left","center","right","blockLeft","blockRight"]},view:{left:n?{key:"style",value:{float:"left","margin-right":"var(--ck-content-table-style-spacing, 1.5em)"}}:{key:"class",value:u_},right:n?{key:"style",value:{float:"right","margin-left":"var(--ck-content-table-style-spacing, 1.5em)"}}:{key:"class",value:h_},center:n?{key:"style",value:{"margin-left":"auto","margin-right":"auto"}}:{key:"class",value:d_},blockLeft:n?{key:"style",value:{"margin-left":"0","margin-right":"auto"}}:{key:"class",value:m_},blockRight:n?{key:"style",value:{"margin-left":"auto","margin-right":"0"}}:{key:"class",value:g_}},converterPriority:"high"}),f_.forEach((e=>{t.for("upcast").attributeToAttribute({view:e.view,model:{key:"tableAlignment",value:(t,n,o)=>{if(function(e){return"figure"==e.name&&!e.hasClass("table")}(t))return;const s=l_(i,"",o),r=e.getAlign(t),a=e.getConsumables(t);return n.consumable.consume(t,a),r!==s?r:void 0}}})})),t.for("upcast").add(function(e){return t=>{t.on("element:div",((t,i,n)=>{if(!n.consumable.test(i.viewItem,{name:!0,attributes:"align"}))return;const o=N_(i.viewItem);if(!o||!n.consumable.test(o,{name:!0}))return;n.consumable.consume(i.viewItem,{name:!0,attributes:"align"});const s=n.convertItem(o,i.modelCursor),r=Zt(s.modelRange.getItems());if(!r||!r.is("element","table"))return n.consumable.revert(i.viewItem,{name:!0,attributes:"align"}),void(s.modelRange&&!s.modelRange.isCollapsed&&(i.modelRange=s.modelRange,i.modelCursor=s.modelCursor));const a=function(e,t,i){if(e)switch(e){case"right":return"right"===t?"right":"left"===t?"left":"blockRight";case"center":return"center";case"left":return void 0===t?"blockLeft":"left";default:return i}}(i.viewItem.getAttribute("align"),o.getAttribute("align"),l_(e,"",i));a&&n.writer.setAttribute("tableAlignment",a,r),n.convertChildren(i.viewItem,n.writer.createPositionAt(r,"end")),n.updateConversionResult(r,i)}))}}(i))}(t,i,n.alignment,o):function(e,t,i){e.extend("table",{allowAttributes:["tableAlignment"]}),e.setAttributeProperties("tableAlignment",{isFormatting:!0}),t.for("downcast").attributeToAttribute({model:{name:"table",key:"tableAlignment",values:["left","center","right"]},view:{left:{key:"style",value:{float:"left"}},right:{key:"style",value:{float:"right"}},center:(e,t,i)=>({key:"style",value:"layout"!==i.item.getAttribute("tableType")?{float:"none"}:{"margin-left":"auto","margin-right":"auto"}})},converterPriority:"high"}),t.for("upcast").attributeToAttribute({view:{name:/^(table|figure)$/,styles:{float:/^(left|none|right)$/}},model:{key:"tableAlignment",value:(e,t,n)=>{if("figure"==e.name&&!e.hasClass("table"))return;const o=l_(i,"",n);let s=e.getStyle("float");if("none"===s&&(s="center"),s!==o)return s;t.consumable.consume(e,{styles:"float"})}}}).attributeToAttribute({view:{name:/^(table|figure)$/,styles:{"margin-left":"auto","margin-right":"auto"}},model:{key:"tableAlignment",value:(e,t,n)=>{if("figure"==e.name&&!e.hasClass("table"))return;const o="center";if(o!==l_(i,"",n))return o;t.consumable.consume(e,{styles:["margin-left","margin-right"]})}}}).attributeToAttribute({view:{name:"table",attributes:{align:/^(left|center|right)$/}},model:{key:"tableAlignment",value:(e,t,n)=>{const o=l_(i,"",n),s=e.getAttribute("align");if(s!==o)return s;t.consumable.consume(e,{attributes:"align"})}}})}(t,i,n.alignment),e.commands.add("tableAlignment",new Zk(e,n.alignment)),nC(t,i,{modelAttribute:"tableWidth",styleName:"width",attributeName:"width",attributeType:"length",defaultValue:n.width}),e.commands.add("tableWidth",new Qk(e,n.width)),nC(t,i,{modelAttribute:"tableHeight",styleName:"height",attributeName:"height",attributeType:"length",defaultValue:n.height}),e.commands.add("tableHeight",new Xk(e,n.height)),e.data.addStyleProcessorRules(Jc),function(e,t,i){const{modelAttribute:n}=i;e.extend("table",{allowAttributes:[n]}),e.setAttributeProperties(n,{isFormatting:!0}),o_(t,{viewElement:"table",...i}),a_(t,i)}(t,i,{modelAttribute:"tableBackgroundColor",styleName:"background-color",attributeName:"bgcolor",attributeType:"color",defaultValue:n.backgroundColor}),e.commands.add("tableBackgroundColor",new Gk(e,n.backgroundColor)),e.config.get("experimentalFlags.useExtendedTableBlockAlignment")){const t=e.editing.view.document;this.listenTo(t,"clipboardOutput",((t,i)=>{e.editing.view.change((e=>{for(const{item:t}of e.createRangeIn(i.content))tC(t,e);i.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(i.content))}))}),{priority:"lowest"})}}}function tC(e,t){if(!e.is("element","table"))return;const i=e.getAttribute("align"),n=e.getStyle("float"),o=e.getStyle("margin-left"),s=e.getStyle("margin-right");i&&"center"===i||n&&"right"===n&&i&&"right"===i?iC(t,i,e):void 0===n&&"auto"===o&&"0"===s&&iC(t,"right",e)}function iC(e,t,i){const n=e.createPositionBefore(i),o=e.createContainerElement("div",{align:t},i);e.insert(n,o)}function nC(e,t,i){const{modelAttribute:n}=i;e.extend("table",{allowAttributes:[n]}),e.setAttributeProperties(n,{isFormatting:!0}),o_(t,{viewElement:/^(table|figure)$/,shouldUpcast:e=>!("table"==e.name&&"figure"==e.parent.name||"figure"==e.name&&!e.hasClass("table")),...i}),r_(t,{modelElement:"table",...i})}class oC extends Hi{options;focusTracker;focusCycler;_focusables;dropdownView;inputView;keystrokes;_stillTyping;constructor(e,t){super(e),this.set("value",""),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isEmpty",!0),this.options=t,this.focusTracker=new ei,this._focusables=new wi,this.dropdownView=this._createDropdownView(),this.inputView=this._createInputTextView(),this.keystrokes=new oi,this._stillTyping=!1,this.focusCycler=new Nn({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-input-color"]},children:[this.dropdownView,this.inputView]}),this.on("change:value",((e,t,i)=>this._setInputValue(i)))}render(){super.render(),[this.inputView,this.dropdownView.buttonView].forEach((e=>{this.focusTracker.add(e.element),this._focusables.add(e)})),this.keystrokes.listenTo(this.element)}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createDropdownView(){const e=this.locale,t=e.t,i=this.bindTemplate,n=this._createColorSelector(e),o=Pu(e),s=new Hi;return s.setTemplate({tag:"span",attributes:{class:["ck","ck-input-color__button__preview"],style:{backgroundColor:i.to("value")}},children:[{tag:"span",attributes:{class:["ck","ck-input-color__button__preview__no-color-indicator",i.if("value","ck-hidden",(e=>""!=e))]}}]}),o.buttonView.extendTemplate({attributes:{class:"ck-input-color__button"}}),o.buttonView.children.add(s),o.buttonView.label=t("Color picker"),o.buttonView.tooltip=!0,o.panelPosition="rtl"===e.uiLanguageDirection?"se":"sw",o.panelView.children.add(n),o.bind("isEnabled").to(this,"isReadOnly",(e=>!e)),o.on("change:isOpen",((e,t,i)=>{i&&(n.updateSelectedColors(),n.showColorGridsFragment())})),o}_createInputTextView(){const e=this.locale,t=new Cf(e);return t.extendTemplate({on:{blur:t.bindTemplate.to("blur")}}),t.value=this.value,t.bind("isReadOnly","hasError").to(this),this.bind("isFocused","isEmpty").to(t),t.on("input",(()=>{const e=t.element.value,i=this.options.colorDefinitions.find((t=>e===t.label));this._stillTyping=!0,this.value=i&&i.color||e})),t.on("blur",(()=>{this._stillTyping=!1,this._setInputValue(t.element.value)})),t.delegate("input").to(this),t}_createColorSelector(e){const t=e.t,i=this.options.defaultColorValue||"",n=t(i?"Restore default":"Remove color"),o=new Vw(e,{colors:this.options.colorDefinitions,columns:this.options.columns,removeButtonLabel:n,colorPickerLabel:t("Color picker"),colorPickerViewConfig:!1!==this.options.colorPickerConfig&&{...this.options.colorPickerConfig,hideInput:!0}});o.appendUI(),o.on("execute",((e,t)=>{"colorPickerSaveButton"!==t.source?(this.value=t.value||i,this.fire("input"),"colorPicker"!==t.source&&(this.dropdownView.isOpen=!1)):this.dropdownView.isOpen=!1}));let s=this.value;return o.on("colorPicker:cancel",(()=>{this.value=s,this.fire("input"),this.dropdownView.isOpen=!1})),o.colorGridsFragmentView.colorPickerButtonView.on("execute",(()=>{s=this.value})),o.bind("selectedColor").to(this,"value"),o}_setInputValue(e){if(!this._stillTyping){const t=sC(e),i=this.options.colorDefinitions.find((e=>t===sC(e.color)));this.inputView.value=i?i.label:e||""}}}function sC(e){return e.replace(/([(,])\s+/g,"$1").replace(/^\s+|\s+(?=[),\s]|$)/g,"").replace(/,|\s/g," ")}const rC=e=>""===e;function aC(e){return{none:e("None"),solid:e("Solid"),dotted:e("Dotted"),dashed:e("Dashed"),double:e("Double"),groove:e("Groove"),ridge:e("Ridge"),inset:e("Inset"),outset:e("Outset")}}function lC(e){return e('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".')}function cC(e){return e('The value is invalid. Try "10px" or "2em" or simply "2".')}function uC(e){return e=e.trim().toLowerCase(),rC(e)||Pc(e)}function dC(e){return e=e.trim(),rC(e)||bC(e)||Rc(e)||Bc(e)}function hC(e){return e=e.trim(),rC(e)||bC(e)||Rc(e)}function mC(e,t){const i=new Xt,n=aC(e.t);for(const o in n){const s={type:"button",model:new sf({_borderStyleValue:o,label:n[o],role:"menuitemradio",withText:!0})};"none"===o?s.model.bind("isOn").to(e,"borderStyle",(e=>"none"===t?!e:e===o)):s.model.bind("isOn").to(e,"borderStyle",(e=>e===o)),i.add(s)}return i}function gC(e){const{view:t,icons:i,toolbar:n,labels:o,propertyName:s,nameToValue:r,defaultValue:a}=e;for(const e in o){const l=new Bn(t.locale);l.set({role:"radio",isToggleable:!0,label:o[e],icon:i[e],tooltip:o[e]});const c=r?r(e):e;l.bind("isOn").to(t,s,(e=>{let t=e;return""===e&&a&&(t=a),c===t})),l.on("execute",(()=>{!a&&c&&t[s]===c?t[s]=void 0:t[s]=c})),n.items.add(l)}}const fC=[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}];function pC(e){return(t,i,n)=>{const o=new oC(t.locale,{colorDefinitions:(s=e.colorConfig,s.map((e=>({color:e.model,label:e.label,options:{hasBorder:e.hasBorder}})))),columns:e.columns,defaultColorValue:e.defaultColorValue,colorPickerConfig:e.colorPickerConfig});var s;return o.inputView.set({id:i,ariaDescribedById:n}),o.bind("isReadOnly").to(t,"isEnabled",(e=>!e)),o.bind("hasError").to(t,"errorText",(e=>!!e)),o.on("input",(()=>{t.errorText=null})),t.bind("isEmpty","isFocused").to(o),o}}function bC(e){const t=parseFloat(e);return!Number.isNaN(t)&&e===String(t)}class wC extends Hi{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;widthInput;heightInput;alignmentToolbar;saveButtonView;cancelButtonView;_focusables;_focusCycler;constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",backgroundColor:"",width:"",height:"",alignment:""}),this.options=t;const{borderStyleDropdown:i,borderWidthInput:n,borderColorInput:o,borderRowLabel:s}=this._createBorderFields(),{backgroundRowLabel:r,backgroundInput:a}=this._createBackgroundFields(),{widthInput:l,operatorLabel:c,heightInput:u,dimensionsLabel:d}=this._createDimensionFields(),{alignmentToolbar:h,alignmentLabel:m}=this._createAlignmentFields();this.focusTracker=new ei,this.keystrokes=new oi,this.children=this.createCollection(),this.borderStyleDropdown=i,this.borderWidthInput=n,this.borderColorInput=o,this.backgroundInput=a,this.widthInput=l,this.heightInput=u,this.alignmentToolbar=h;const{saveButtonView:g,cancelButtonView:f}=this._createActionButtons();this.saveButtonView=g,this.cancelButtonView=f,this._focusables=new wi,this._focusCycler=new Nn({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new Rn(e,{label:this.t("Table properties")})),this.children.add(new wf(e,{labelView:s,children:[s,i,o,n],class:"ck-table-form__border-row"})),this.children.add(new wf(e,{labelView:r,children:[r,a],class:"ck-table-form__background-row"})),this.children.add(new wf(e,{children:[new wf(e,{labelView:d,children:[d,l,c,u],class:"ck-table-form__dimensions-row"}),new wf(e,{labelView:m,children:[m,h],class:"ck-table-properties-form__alignment-row"})]})),this.children.add(new wf(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),vf({view:this}),[this.borderColorInput,this.backgroundInput].forEach((e=>{this._focusCycler.chain(e.fieldView.focusCycler)})),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.alignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},i=pC({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),n=this.locale,o=this.t,s=o("Style"),r=new du(n);r.text=o("Border");const a=aC(o),l=new yf(n,Ef);l.set({label:s,class:"ck-table-form__border-style"}),l.fieldView.buttonView.set({ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),l.fieldView.buttonView.bind("label").to(this,"borderStyle",(e=>a[e||"none"])),l.fieldView.on("execute",(e=>{this.borderStyle=e.source._borderStyleValue})),l.bind("isEmpty").to(this,"borderStyle",(e=>!e)),Ou(l.fieldView,mC(this,t.style),{role:"menu",ariaLabel:s});const c=new yf(n,Af);c.set({label:o("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",vC),c.fieldView.on("input",(()=>{this.borderWidth=c.fieldView.element.value}));const u=new yf(n,i);return u.set({label:o("Color"),class:"ck-table-form__border-color"}),u.fieldView.bind("value").to(this,"borderColor"),u.bind("isEnabled").to(this,"borderStyle",vC),u.fieldView.on("input",(()=>{this.borderColor=u.fieldView.value})),this.on("change:borderStyle",((e,i,n,o)=>{vC(n)||(this.borderColor="",this.borderWidth=""),vC(o)||(this.borderColor=t.color,this.borderWidth=t.width)})),{borderRowLabel:r,borderStyleDropdown:l,borderColorInput:u,borderWidthInput:c}}_createBackgroundFields(){const e=this.locale,t=this.t,i=new du(e);i.text=t("Background");const n=pC({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),o=new yf(e,n);return o.set({label:t("Color"),class:"ck-table-properties-form__background"}),o.fieldView.bind("value").to(this,"backgroundColor"),o.fieldView.on("input",(()=>{this.backgroundColor=o.fieldView.value})),{backgroundRowLabel:i,backgroundInput:o}}_createDimensionFields(){const e=this.locale,t=this.t,i=new du(e);i.text=t("Dimensions");const n=new yf(e,Af);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",(()=>{this.width=n.fieldView.element.value}));const o=new Hi(e);o.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const s=new yf(e,Af);return s.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),s.fieldView.bind("value").to(this,"height"),s.fieldView.on("input",(()=>{this.height=s.fieldView.element.value})),{dimensionsLabel:i,widthInput:n,operatorLabel:o,heightInput:s}}_createAlignmentFields(){const e=this.locale,t=this.t,i=new du(e);i.text=t("Alignment");const n=new Hu(e);return n.set({role:"radiogroup",isCompact:!0,ariaLabel:t("Table alignment toolbar")}),gC({view:this,icons:{left:tp,center:np,right:op},toolbar:n,labels:this._alignmentLabels,propertyName:"alignment",defaultValue:this.options.defaultTableProperties.alignment}),{alignmentLabel:i,alignmentToolbar:n}}_createActionButtons(){const e=this.locale,t=this.t,i=new Bn(e),n=new Bn(e),o=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.widthInput,this.heightInput];return i.set({label:t("Save"),icon:Tu,class:"ck-button-save",type:"submit",withText:!0}),i.bind("isEnabled").toMany(o,"errorText",((...e)=>e.every((e=>!e)))),n.set({label:t("Cancel"),icon:On,class:"ck-button-cancel",withText:!0}),n.delegate("execute").to(this,"cancel"),{saveButtonView:i,cancelButtonView:n}}get _alignmentLabels(){const e=this.locale,t=this.t,i=t("Align table to the left"),n=t("Center table"),o=t("Align table to the right");return"rtl"===e.uiLanguageDirection?{right:o,center:n,left:i}:{left:i,center:n,right:o}}}function vC(e){return"none"!==e}const yC=(()=>[qi.defaultPositions.northArrowSouth,qi.defaultPositions.northArrowSouthWest,qi.defaultPositions.northArrowSouthEast,qi.defaultPositions.southArrowNorth,qi.defaultPositions.southArrowNorthWest,qi.defaultPositions.southArrowNorthEast,qi.defaultPositions.viewportStickyNorth])();function _C(e,t){const i=e.plugins.get("ContextualBalloon"),n=e.editing.view.document.selection;let o;"cell"===t?qk(n)&&(o=CC(e)):Uk(n)&&(o=kC(e)),o&&i.updatePosition(o)}function kC(e){const t=C_(e.model.document.selection),i=e.editing.mapper.toViewElement(t);return{target:e.editing.view.domConverter.mapViewToDom(i),positions:yC}}function CC(e){const t=e.editing.mapper,i=e.editing.view.domConverter,n=e.model.document.selection;if(n.rangeCount>1)return{target:()=>function(e,t){const i=t.editing.mapper,n=t.editing.view.domConverter,o=Array.from(e).map((e=>{const t=xC(e.start),o=i.toViewElement(t);return new Ze(n.mapViewToDom(o))}));return Ze.getBoundingRect(o)}(n.getRanges(),e),positions:yC};const o=xC(n.getFirstPosition()),s=t.toViewElement(o);return{target:i.mapViewToDom(s),positions:yC}}function xC(e){return e.nodeAfter&&e.nodeAfter.is("element","tableCell")?e.nodeAfter:e.findAncestor("tableCell")}const AC={borderStyle:"tableBorderStyle",borderColor:"tableBorderColor",borderWidth:"tableBorderWidth",backgroundColor:"tableBackgroundColor",width:"tableWidth",height:"tableHeight",alignment:"tableAlignment"};class TC extends ad{_defaultContentTableProperties;_defaultLayoutTableProperties;_balloon;view=null;_viewWithContentTableDefaults=null;_viewWithLayoutTableDefaults=null;_undoStepBatch;_isReady;static get requires(){return[hm]}static get pluginName(){return"TablePropertiesUI"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("table.tableProperties",{borderColors:fC,backgroundColors:fC})}init(){const e=this.editor;this._defaultContentTableProperties=U_(e.config.get("table.tableProperties.defaultProperties"),{includeAlignmentProperty:!0}),this._defaultLayoutTableProperties=H_(),this._balloon=e.plugins.get(hm),e.ui.componentFactory.add("tableProperties",(()=>this._createTablePropertiesButton()))}_createTablePropertiesButton(){const e=this.editor,t=e.t,i=new Bn(e.locale);i.set({label:t("Table properties"),icon:'',tooltip:!0}),this.listenTo(i,"execute",(()=>this._showView()));const n=Object.values(AC).map((t=>e.commands.get(t)));return i.bind("isEnabled").toMany(n,"isEnabled",((...e)=>e.some((e=>e)))),i}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){const t=this.editor,i=t.config.get("table.tableProperties"),n=rv(i.borderColors),o=sv(t.locale,n),s=rv(i.backgroundColors),r=sv(t.locale,s),a=!1!==i.colorPicker,l=new wC(t.locale,{borderColors:o,backgroundColors:r,defaultTableProperties:e,colorPickerConfig:!!a&&(i.colorPicker||{})}),c=t.t;l.render(),this.listenTo(l,"submit",(()=>{this._hideView()})),this.listenTo(l,"cancel",(()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()})),l.keystrokes.set("Esc",((e,t)=>{this._hideView(),t()})),mn({emitter:l,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const u=lC(c),d=cC(c);return l.on("change:borderStyle",this._getPropertyChangeCallback("tableBorderStyle")),l.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:l.borderColorInput,commandName:"tableBorderColor",errorText:u,validator:uC})),l.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:l.borderWidthInput,commandName:"tableBorderWidth",errorText:d,validator:hC})),l.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:l.backgroundInput,commandName:"tableBackgroundColor",errorText:u,validator:uC})),l.on("change:width",this._getValidatedPropertyChangeCallback({viewField:l.widthInput,commandName:"tableWidth",errorText:d,validator:dC})),l.on("change:height",this._getValidatedPropertyChangeCallback({viewField:l.heightInput,commandName:"tableHeight",errorText:d,validator:dC})),l.on("change:alignment",this._getPropertyChangeCallback("tableAlignment")),l}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableBorderStyle");Object.entries(AC).map((([t,i])=>{const n=t,o=this.view===this._viewWithContentTableDefaults?this._defaultContentTableProperties[n]||"":this._defaultLayoutTableProperties[n]||"";return[n,e.get(i).value||o]})).forEach((([e,i])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,i)})),this._isReady=!0}_showView(){const e=this.editor,t=Uk(e.editing.view.document.selection),i=t&&e.editing.mapper.toModelElement(t),n=!i||"layout"!==i.getAttribute("tableType");n&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableProperties):n||this._viewWithLayoutTableDefaults||(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableProperties)),this.view=n?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",(()=>{this._updateView()})),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:kC(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor;Uk(e.editing.view.document.selection)?this._isViewVisible&&_C(e,"table"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,i,n)=>{this._isReady&&this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:i,validator:n,errorText:o}=e,s=Wi((()=>{i.errorText=o}),500);return(e,o,r)=>{s.cancel(),this._isReady&&(n(r)?(this.editor.execute(t,{value:r,batch:this._undoStepBatch}),i.errorText=null):s())}}}class EC extends Hi{options;focusTracker;keystrokes;children;borderStyleDropdown;borderWidthInput;borderColorInput;backgroundInput;paddingInput;widthInput;heightInput;horizontalAlignmentToolbar;verticalAlignmentToolbar;saveButtonView;cancelButtonView;_focusables;_focusCycler;constructor(e,t){super(e),this.set({borderStyle:"",borderWidth:"",borderColor:"",padding:"",backgroundColor:"",width:"",height:"",horizontalAlignment:"",verticalAlignment:""}),this.options=t;const{borderStyleDropdown:i,borderWidthInput:n,borderColorInput:o,borderRowLabel:s}=this._createBorderFields(),{backgroundRowLabel:r,backgroundInput:a}=this._createBackgroundFields(),{widthInput:l,operatorLabel:c,heightInput:u,dimensionsLabel:d}=this._createDimensionFields(),{horizontalAlignmentToolbar:h,verticalAlignmentToolbar:m,alignmentLabel:g}=this._createAlignmentFields();this.focusTracker=new ei,this.keystrokes=new oi,this.children=this.createCollection(),this.borderStyleDropdown=i,this.borderWidthInput=n,this.borderColorInput=o,this.backgroundInput=a,this.paddingInput=this._createPaddingField(),this.widthInput=l,this.heightInput=u,this.horizontalAlignmentToolbar=h,this.verticalAlignmentToolbar=m;const{saveButtonView:f,cancelButtonView:p}=this._createActionButtons();this.saveButtonView=f,this.cancelButtonView=p,this._focusables=new wi,this._focusCycler=new Nn({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.add(new Rn(e,{label:this.t("Cell properties")})),this.children.add(new wf(e,{labelView:s,children:[s,i,o,n],class:"ck-table-form__border-row"})),this.children.add(new wf(e,{labelView:r,children:[r,a],class:"ck-table-form__background-row"})),this.children.add(new wf(e,{children:[new wf(e,{labelView:d,children:[d,l,c,u],class:"ck-table-form__dimensions-row"}),new wf(e,{children:[this.paddingInput],class:"ck-table-cell-properties-form__padding-row"})]})),this.children.add(new wf(e,{labelView:g,children:[g,h,m],class:"ck-table-cell-properties-form__alignment-row"})),this.children.add(new wf(e,{children:[this.saveButtonView,this.cancelButtonView],class:"ck-table-form__action-row"})),this.setTemplate({tag:"form",attributes:{class:["ck","ck-form","ck-table-form","ck-table-cell-properties-form"],tabindex:"-1"},children:this.children})}render(){super.render(),vf({view:this}),[this.borderColorInput,this.backgroundInput].forEach((e=>{this._focusCycler.chain(e.fieldView.focusCycler)})),[this.borderStyleDropdown,this.borderColorInput,this.borderWidthInput,this.backgroundInput,this.widthInput,this.heightInput,this.paddingInput,this.horizontalAlignmentToolbar,this.verticalAlignmentToolbar,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createBorderFields(){const e=this.options.defaultTableCellProperties,t={style:e.borderStyle,width:e.borderWidth,color:e.borderColor},i=pC({colorConfig:this.options.borderColors,columns:5,defaultColorValue:t.color,colorPickerConfig:this.options.colorPickerConfig}),n=this.locale,o=this.t,s=o("Style"),r=new du(n);r.text=o("Border");const a=aC(o),l=new yf(n,Ef);l.set({label:s,class:"ck-table-form__border-style"}),l.fieldView.buttonView.set({ariaLabel:s,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:s}),l.fieldView.buttonView.bind("label").to(this,"borderStyle",(e=>a[e||"none"])),l.fieldView.on("execute",(e=>{this.borderStyle=e.source._borderStyleValue})),l.bind("isEmpty").to(this,"borderStyle",(e=>!e)),Ou(l.fieldView,mC(this,t.style),{role:"menu",ariaLabel:s});const c=new yf(n,Af);c.set({label:o("Width"),class:"ck-table-form__border-width"}),c.fieldView.bind("value").to(this,"borderWidth"),c.bind("isEnabled").to(this,"borderStyle",SC),c.fieldView.on("input",(()=>{this.borderWidth=c.fieldView.element.value}));const u=new yf(n,i);return u.set({label:o("Color"),class:"ck-table-form__border-color"}),u.fieldView.bind("value").to(this,"borderColor"),u.bind("isEnabled").to(this,"borderStyle",SC),u.fieldView.on("input",(()=>{this.borderColor=u.fieldView.value})),this.on("change:borderStyle",((e,i,n,o)=>{SC(n)||(this.borderColor="",this.borderWidth=""),SC(o)||(this.borderColor=t.color,this.borderWidth=t.width)})),{borderRowLabel:r,borderStyleDropdown:l,borderColorInput:u,borderWidthInput:c}}_createBackgroundFields(){const e=this.locale,t=this.t,i=new du(e);i.text=t("Background");const n=pC({colorConfig:this.options.backgroundColors,columns:5,defaultColorValue:this.options.defaultTableCellProperties.backgroundColor,colorPickerConfig:this.options.colorPickerConfig}),o=new yf(e,n);return o.set({label:t("Color"),class:"ck-table-cell-properties-form__background"}),o.fieldView.bind("value").to(this,"backgroundColor"),o.fieldView.on("input",(()=>{this.backgroundColor=o.fieldView.value})),{backgroundRowLabel:i,backgroundInput:o}}_createDimensionFields(){const e=this.locale,t=this.t,i=new du(e);i.text=t("Dimensions");const n=new yf(e,Af);n.set({label:t("Width"),class:"ck-table-form__dimensions-row__width"}),n.fieldView.bind("value").to(this,"width"),n.fieldView.on("input",(()=>{this.width=n.fieldView.element.value}));const o=new Hi(e);o.setTemplate({tag:"span",attributes:{class:["ck-table-form__dimension-operator"]},children:[{text:"×"}]});const s=new yf(e,Af);return s.set({label:t("Height"),class:"ck-table-form__dimensions-row__height"}),s.fieldView.bind("value").to(this,"height"),s.fieldView.on("input",(()=>{this.height=s.fieldView.element.value})),{dimensionsLabel:i,widthInput:n,operatorLabel:o,heightInput:s}}_createPaddingField(){const e=this.locale,t=this.t,i=new yf(e,Af);return i.set({label:t("Padding"),class:"ck-table-cell-properties-form__padding"}),i.fieldView.bind("value").to(this,"padding"),i.fieldView.on("input",(()=>{this.padding=i.fieldView.element.value})),i}_createAlignmentFields(){const e=this.locale,t=this.t,i=new du(e),n={left:Nu,center:dy,right:uy,justify:hy,top:'',middle:'',bottom:''};i.text=t("Table cell text alignment");const o=new Hu(e),s="rtl"===e.contentLanguageDirection;o.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Horizontal text alignment toolbar")}),gC({view:this,icons:n,toolbar:o,labels:this._horizontalAlignmentLabels,propertyName:"horizontalAlignment",nameToValue:e=>{if(s){if("left"===e)return"right";if("right"===e)return"left"}return e},defaultValue:this.options.defaultTableCellProperties.horizontalAlignment});const r=new Hu(e);return r.set({isCompact:!0,role:"radiogroup",ariaLabel:t("Vertical text alignment toolbar")}),gC({view:this,icons:n,toolbar:r,labels:this._verticalAlignmentLabels,propertyName:"verticalAlignment",defaultValue:this.options.defaultTableCellProperties.verticalAlignment}),{horizontalAlignmentToolbar:o,verticalAlignmentToolbar:r,alignmentLabel:i}}_createActionButtons(){const e=this.locale,t=this.t,i=new Bn(e),n=new Bn(e),o=[this.borderWidthInput,this.borderColorInput,this.backgroundInput,this.paddingInput];return i.set({label:t("Save"),icon:Tu,class:"ck-button-save",type:"submit",withText:!0}),i.bind("isEnabled").toMany(o,"errorText",((...e)=>e.every((e=>!e)))),n.set({label:t("Cancel"),icon:On,class:"ck-button-cancel",withText:!0}),n.delegate("execute").to(this,"cancel"),{saveButtonView:i,cancelButtonView:n}}get _horizontalAlignmentLabels(){const e=this.locale,t=this.t,i=t("Align cell text to the left"),n=t("Align cell text to the center"),o=t("Align cell text to the right"),s=t("Justify cell text");return"rtl"===e.uiLanguageDirection?{right:o,center:n,left:i,justify:s}:{left:i,center:n,right:o,justify:s}}get _verticalAlignmentLabels(){const e=this.t;return{top:e("Align cell text to the top"),middle:e("Align cell text to the middle"),bottom:e("Align cell text to the bottom")}}}function SC(e){return"none"!==e}const PC={borderStyle:"tableCellBorderStyle",borderColor:"tableCellBorderColor",borderWidth:"tableCellBorderWidth",height:"tableCellHeight",width:"tableCellWidth",padding:"tableCellPadding",backgroundColor:"tableCellBackgroundColor",horizontalAlignment:"tableCellHorizontalAlignment",verticalAlignment:"tableCellVerticalAlignment"};class IC extends ad{_defaultContentTableCellProperties;_defaultLayoutTableCellProperties;_balloon;view;_viewWithContentTableDefaults;_viewWithLayoutTableDefaults;_undoStepBatch;_isReady;static get requires(){return[hm]}static get pluginName(){return"TableCellPropertiesUI"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("table.tableCellProperties",{borderColors:fC,backgroundColors:fC})}init(){const e=this.editor,t=e.t;this._defaultContentTableCellProperties=$_(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection}),this._defaultLayoutTableCellProperties=H_(void 0,{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection}),this._balloon=e.plugins.get(hm),this.view=null,this._isReady=!1,e.ui.componentFactory.add("tableCellProperties",(i=>{const n=new Bn(i);n.set({label:t("Cell properties"),icon:'',tooltip:!0}),this.listenTo(n,"execute",(()=>this._showView()));const o=Object.values(PC).map((t=>e.commands.get(t)));return n.bind("isEnabled").toMany(o,"isEnabled",((...e)=>e.some((e=>e)))),n}))}destroy(){super.destroy(),this.view&&this.view.destroy()}_createPropertiesView(e){const t=this.editor,i=t.config.get("table.tableCellProperties"),n=rv(i.borderColors),o=sv(t.locale,n),s=rv(i.backgroundColors),r=sv(t.locale,s),a=!1!==i.colorPicker,l=new EC(t.locale,{borderColors:o,backgroundColors:r,defaultTableCellProperties:e,colorPickerConfig:!!a&&(i.colorPicker||{})}),c=t.t;l.render(),this.listenTo(l,"submit",(()=>{this._hideView()})),this.listenTo(l,"cancel",(()=>{this._undoStepBatch.operations.length&&t.execute("undo",this._undoStepBatch),this._hideView()})),l.keystrokes.set("Esc",((e,t)=>{this._hideView(),t()})),mn({emitter:l,activator:()=>this._isViewInBalloon,contextElements:[this._balloon.view.element],callback:()=>this._hideView()});const u=lC(c),d=cC(c);return l.on("change:borderStyle",this._getPropertyChangeCallback("tableCellBorderStyle")),l.on("change:borderColor",this._getValidatedPropertyChangeCallback({viewField:l.borderColorInput,commandName:"tableCellBorderColor",errorText:u,validator:uC})),l.on("change:borderWidth",this._getValidatedPropertyChangeCallback({viewField:l.borderWidthInput,commandName:"tableCellBorderWidth",errorText:d,validator:hC})),l.on("change:padding",this._getValidatedPropertyChangeCallback({viewField:l.paddingInput,commandName:"tableCellPadding",errorText:d,validator:dC})),l.on("change:width",this._getValidatedPropertyChangeCallback({viewField:l.widthInput,commandName:"tableCellWidth",errorText:d,validator:dC})),l.on("change:height",this._getValidatedPropertyChangeCallback({viewField:l.heightInput,commandName:"tableCellHeight",errorText:d,validator:dC})),l.on("change:backgroundColor",this._getValidatedPropertyChangeCallback({viewField:l.backgroundInput,commandName:"tableCellBackgroundColor",errorText:u,validator:uC})),l.on("change:horizontalAlignment",this._getPropertyChangeCallback("tableCellHorizontalAlignment")),l.on("change:verticalAlignment",this._getPropertyChangeCallback("tableCellVerticalAlignment")),l}_fillViewFormFromCommandValues(){const e=this.editor.commands,t=e.get("tableCellBorderStyle");Object.entries(PC).map((([t,i])=>{const n=t,o=this.view===this._viewWithContentTableDefaults?this._defaultContentTableCellProperties[n]||"":this._defaultLayoutTableCellProperties[n]||"";return[t,e.get(i).value||o]})).forEach((([e,i])=>{("borderColor"!==e&&"borderWidth"!==e||"none"!==t.value)&&this.view.set(e,i)})),this._isReady=!0}_showView(){const e=this.editor,t=Uk(e.editing.view.document.selection),i=t&&e.editing.mapper.toModelElement(t),n=!i||"layout"!==i.getAttribute("tableType");n&&!this._viewWithContentTableDefaults?this._viewWithContentTableDefaults=this._createPropertiesView(this._defaultContentTableCellProperties):n||this._viewWithLayoutTableDefaults||(this._viewWithLayoutTableDefaults=this._createPropertiesView(this._defaultLayoutTableCellProperties)),this.view=n?this._viewWithContentTableDefaults:this._viewWithLayoutTableDefaults,this.listenTo(e.ui,"update",(()=>{this._updateView()})),this._fillViewFormFromCommandValues(),this._balloon.add({view:this.view,position:CC(e)}),this._undoStepBatch=e.model.createBatch(),this.view.focus()}_hideView(){const e=this.editor;this.stopListening(e.ui,"update"),this._isReady=!1,this.view.saveButtonView.focus(),this._balloon.remove(this.view),this.editor.editing.view.focus()}_updateView(){const e=this.editor;qk(e.editing.view.document.selection)?this._isViewVisible&&_C(e,"cell"):this._hideView()}get _isViewVisible(){return!!this.view&&this._balloon.visibleView===this.view}get _isViewInBalloon(){return!!this.view&&this._balloon.hasView(this.view)}_getPropertyChangeCallback(e){return(t,i,n)=>{this._isReady&&this.editor.execute(e,{value:n,batch:this._undoStepBatch})}}_getValidatedPropertyChangeCallback(e){const{commandName:t,viewField:i,validator:n,errorText:o}=e,s=Wi((()=>{i.errorText=o}),500);return(e,o,r)=>{s.cancel(),this._isReady&&(n(r)?(this.editor.execute(t,{value:r,batch:this._undoStepBatch}),i.errorText=null):s())}}}class VC extends cd{attributeName;_defaultValue;_defaultContentTableValue;_defaultLayoutTableValue;constructor(e,t,i){switch(super(e),this.attributeName=t,this._defaultContentTableValue=i,t){case"tableCellType":this._defaultLayoutTableValue="data";break;case"tableCellBorderStyle":this._defaultLayoutTableValue="none";break;case"tableCellHorizontalAlignment":this._defaultLayoutTableValue="left";break;case"tableCellVerticalAlignment":this._defaultLayoutTableValue="middle";break;default:this._defaultLayoutTableValue=void 0}}refresh(){const e=this.editor.model.document.selection,t=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e),i=C_(e);this._defaultValue=i&&"layout"===i.getAttribute("tableType")?this._defaultLayoutTableValue:this._defaultContentTableValue,this.isEnabled=!!t.length,this.value=this._getSingleValue(t)}execute(e={}){const{value:t,batch:i}=e,n=this.editor.model,o=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(n.document.selection),s=this._getValueToSet(t);n.enqueueChange(i,(e=>{s?o.forEach((t=>e.setAttribute(this.attributeName,s,t))):o.forEach((t=>e.removeAttribute(this.attributeName,t))),this.fire("afterExecute",{writer:e,tableCells:o,valueToSet:s})}))}_getAttribute(e){if(!e)return;const t=e.getAttribute(this.attributeName);return t!==this._defaultValue?t:void 0}_getValueToSet(e){if(e!==this._defaultValue)return e}_getSingleValue(e){const t=this._getAttribute(e[0]);return e.every((e=>this._getAttribute(e)===t))?t:void 0}}class OC extends VC{constructor(e,t){super(e,"tableCellWidth",t)}_getValueToSet(e){if((e=z_(e,"px"))!==this._defaultValue)return e}}class RC extends ad{static get pluginName(){return"TableCellWidthEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Ek]}init(){const e=this.editor,t=$_(e.config.get("table.tableCellProperties.defaultProperties"));k_(e.model.schema,e.conversion,{modelAttribute:"tableCellWidth",styleName:"width",attributeName:"width",attributeType:"length",defaultValue:t.width}),e.commands.add("tableCellWidth",new OC(e,t.width))}}class LC extends VC{constructor(e,t){super(e,"tableCellPadding",t)}_getAttribute(e){if(!e)return;const t=D_(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=z_(e,"px");if(t!==this._defaultValue)return t}}class BC extends VC{constructor(e,t){super(e,"tableCellHeight",t)}_getValueToSet(e){const t=z_(e,"px");if(t!==this._defaultValue)return t}}class MC extends VC{constructor(e,t){super(e,"tableCellBackgroundColor",t)}}class NC extends VC{constructor(e,t){super(e,"tableCellVerticalAlignment",t)}}class FC extends VC{constructor(e,t){super(e,"tableCellHorizontalAlignment",t)}}class DC extends VC{constructor(e,t){super(e,"tableCellBorderStyle",t)}_getAttribute(e){if(!e)return;const t=D_(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class zC extends VC{constructor(e,t){super(e,"tableCellBorderColor",t)}_getAttribute(e){if(!e)return;const t=D_(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}}class HC extends VC{constructor(e,t){super(e,"tableCellBorderWidth",t)}_getAttribute(e){if(!e)return;const t=D_(e.getAttribute(this.attributeName));return t!==this._defaultValue?t:void 0}_getValueToSet(e){const t=z_(e,"px");if(t!==this._defaultValue)return t}}class UC extends VC{constructor(e){super(e,"tableCellType","data"),this.on("afterExecute",((e,t)=>{const{writer:i,tableCells:n}=t,o=this.editor.plugins.get(ak),s=function(e){const t=new Map;for(const i of e){const e=i.findAncestor("table");t.has(e)||t.set(e,[]),t.get(e).push(i)}return t}(n);$C(o,i,s.keys())}))}refresh(){super.refresh();const e=C_(this.editor.model.document.selection);this.isEnabled&&e&&"layout"===e.getAttribute("tableType")&&(this.isEnabled=!1)}_getAttribute(e){return e?.getAttribute(this.attributeName)||"data"}}function $C(e,t,i){let n=!1;for(const o of i){let i=o.getAttribute("headingRows")||0,s=o.getAttribute("headingColumns")||0;const r=s>i;if(r){const r=qC(e,o,"column",s,i);r!==s&&(e.setHeadingColumnsCount(t,o,r,{shallow:!0}),s=r,n=!0)}const a=qC(e,o,"row",i,s);if(a!==i&&(e.setHeadingRowsCount(t,o,a,{shallow:!0}),i=a,n=!0),!r){const r=qC(e,o,"column",s,i);r!==s&&(e.setHeadingColumnsCount(t,o,r,{shallow:!0}),n=!0)}}return n}function qC(e,t,i,n,o){const s="row"===i?e.getRows(t):e.getColumns(t);let r=n;for(let e=0;e=o&&(a=!0)}if(!s)return Math.min(r,e);a&&(r=Math.max(r,e+1))}return Math.min(r,s)}const jC=/^(top|middle|bottom)$/,WC=/^(left|center|right|justify)$/;class GC extends ad{static get pluginName(){return"TableCellPropertiesEditing"}static get licenseFeatureCode(){return"TCP"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}static get requires(){return[Ek,RC]}init(){const e=this.editor,t=e.model.schema,i=e.conversion;e.config.define("table.tableCellProperties.defaultProperties",{});const n=$_(e.config.get("table.tableCellProperties.defaultProperties"),{includeVerticalAlignmentProperty:!0,includeHorizontalAlignmentProperty:!0,includePaddingProperty:!0,isRightToLeftContent:"rtl"===e.locale.contentLanguageDirection});e.data.addStyleProcessorRules(Yc),function(e,t){const{conversion:i}=e,{schema:n}=e.model,o={width:"tableCellBorderWidth",color:"tableCellBorderColor",style:"tableCellBorderStyle"};n.extend("tableCell",{allowAttributes:Object.values(o)});for(const e of Object.values(o))n.setAttributeProperties(e,{isFormatting:!0});s_(e,"td",o,t),s_(e,"th",o,t),r_(i,{modelElement:"tableCell",modelAttribute:o.style,styleName:"border-style"}),r_(i,{modelElement:"tableCell",modelAttribute:o.color,styleName:"border-color"}),r_(i,{modelElement:"tableCell",modelAttribute:o.width,styleName:"border-width"})}(e,{color:n.borderColor,style:n.borderStyle,width:n.borderWidth}),e.commands.add("tableCellBorderStyle",new DC(e,n.borderStyle)),e.commands.add("tableCellBorderColor",new zC(e,n.borderColor)),e.commands.add("tableCellBorderWidth",new HC(e,n.borderWidth)),k_(t,i,{modelAttribute:"tableCellHeight",styleName:"height",attributeName:"height",attributeType:"length",defaultValue:n.height}),e.commands.add("tableCellHeight",new BC(e,n.height)),e.data.addStyleProcessorRules(au),k_(t,i,{modelAttribute:"tableCellPadding",styleName:"padding",reduceBoxSides:!0,defaultValue:n.padding}),e.commands.add("tableCellPadding",new LC(e,n.padding)),e.data.addStyleProcessorRules(Jc),k_(t,i,{modelAttribute:"tableCellBackgroundColor",styleName:"background-color",attributeName:"bgcolor",attributeType:"color",defaultValue:n.backgroundColor}),e.commands.add("tableCellBackgroundColor",new MC(e,n.backgroundColor)),function(e,t,i){e.extend("tableCell",{allowAttributes:["tableCellHorizontalAlignment"]}),e.setAttributeProperties("tableCellHorizontalAlignment",{isFormatting:!0}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellHorizontalAlignment"},view:e=>({key:"style",value:{"text-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"text-align":WC}},model:{key:"tableCellHorizontalAlignment",value:(e,t,n)=>{const o=l_(i,"left",n),s=e.getStyle("text-align");if(s!==o)return s;t.consumable.consume(e,{styles:"text-align"})}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{align:WC}},model:{key:"tableCellHorizontalAlignment",value:(e,t,n)=>{const o=l_(i,"left",n),s=e.getAttribute("align");if(s!==o)return s;t.consumable.consume(e,{attributes:"align"})}}})}(t,i,n.horizontalAlignment),e.commands.add("tableCellHorizontalAlignment",new FC(e,n.horizontalAlignment)),function(e,t,i){e.extend("tableCell",{allowAttributes:["tableCellVerticalAlignment"]}),e.setAttributeProperties("tableCellVerticalAlignment",{isFormatting:!0}),t.for("downcast").attributeToAttribute({model:{name:"tableCell",key:"tableCellVerticalAlignment"},view:e=>({key:"style",value:{"vertical-align":e}})}),t.for("upcast").attributeToAttribute({view:{name:/^(td|th)$/,styles:{"vertical-align":jC}},model:{key:"tableCellVerticalAlignment",value:(e,t,n)=>{const o=l_(i,"middle",n),s=e.getStyle("vertical-align");if(s!==o)return s;t.consumable.consume(e,{styles:"vertical-align"})}}}).attributeToAttribute({view:{name:/^(td|th)$/,attributes:{valign:jC}},model:{key:"tableCellVerticalAlignment",value:(e,t,n)=>{const o=l_(i,"middle",n),s=e.getAttribute("valign");if(s!==o)return s;t.consumable.consume(e,{attributes:"valign"})}}})}(t,i,n.verticalAlignment),e.commands.add("tableCellVerticalAlignment",new NC(e,n.verticalAlignment)),e.config.get("experimentalFlags.tableCellTypeSupport")&&(function(e){const{model:t,conversion:i,editing:n}=e,{schema:o}=t,s=e.plugins.get(ak);o.extend("tableCell",{allowAttributes:["tableCellType"]}),o.setAttributeProperties("tableCellType",{isFormatting:!0}),o.addAttributeCheck((e=>{const t=Array.from(e).reverse().find((e=>"table"===e.name));if("layout"===t?.getAttribute("tableType"))return!1}),"tableCellType"),i.for("upcast").add((e=>{e.on("element:th",((e,t,i)=>{const{writer:n}=i,{modelRange:o}=t,s=o?.start.nodeAfter;s?.is("element","tableCell")&&n.setAttribute("tableCellType","header",s)})),e.on("element:table",((e,t,i)=>{const{writer:n}=i,{modelRange:o}=t,s=o?.start.nodeAfter;if(s?.is("element","table")&&"layout"===s.getAttribute("tableType"))for(const{cell:e}of new b_(s))if("header"===e.getAttribute("tableCellType")){n.setAttribute("tableType","content",s);break}}),{priority:k.low-1})})),t.document.registerPostFixer((e=>{const i=t.document.differ.getChanges(),n=new Set;for(const e of i){if("attribute"===e.type&&("headingRows"===e.attributeKey||"headingColumns"===e.attributeKey)){const t=e.range.start.nodeAfter;t?.is("element","table")&&"$graveyard"!==t.root.rootName&&n.add(t)}if("attribute"===e.type&&"tableCellType"===e.attributeKey){const t=e.range.start.nodeAfter;if(t?.is("element","tableCell")&&"$graveyard"!==t.root.rootName){const e=t.findAncestor("table");e&&n.add(e)}}if("insert"===e.type&&e.position.nodeAfter)for(const{item:i}of t.createRangeOn(e.position.nodeAfter))if(i.is("element","tableCell")&&i.getAttribute("tableCellType")&&"$graveyard"!==i.root.rootName){const e=i.findAncestor("table");e&&n.add(e)}}return $C(s,e,n)})),t.document.on("change:data",(()=>{const{differ:e}=t.document,i=new Set;for(const t of e.getChanges())if("attribute"===t.type&&"tableCellType"===t.attributeKey){const e=t.range.start.nodeAfter;e.is("element","tableCell")&&i.add(e)}for(const e of i){const t=n.mapper.toViewElement(e),i="header"===e.getAttribute("tableCellType")?"th":"td";t?.name!==i&&n.reconvertItem(e)}}))}(e),e.commands.add("tableCellType",new UC(e)))}}class KC extends ad{static get pluginName(){return"IndentEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.commands.add("indent",new dd(e)),e.commands.add("outdent",new dd(e))}}const JC='',YC='';class QC extends ad{static get pluginName(){return"IndentUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?JC:YC,o="ltr"==t.uiLanguageDirection?YC:JC;this._defineButton("indent",i("Increase indent"),n),this._defineButton("outdent",i("Decrease indent"),o)}_defineButton(e,t,i){const n=this.editor;n.ui.componentFactory.add(e,(()=>{const n=this._createButton(Bn,e,t,i);return n.set({tooltip:!0}),n})),n.ui.componentFactory.add("menuBar:"+e,(()=>this._createButton(Yu,e,t,i)))}_createButton(e,t,i,n){const o=this.editor,s=o.commands.get(t),r=new e(o.locale);return r.set({label:i,icon:n}),r.bind("isEnabled").to(s,"isEnabled"),this.listenTo(r,"execute",(()=>{o.execute(t),o.editing.view.focus()})),r}}class XC extends cd{_indentBehavior;constructor(e,t){super(e),this._indentBehavior=t}refresh(){const e=Zt(this.editor.model.document.selection.getSelectedBlocks());e&&this._isIndentationChangeAllowed(e)?this.isEnabled=this._indentBehavior.checkEnabled(e.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const e=this.editor.model,t=this._getBlocksToChange();e.change((e=>{for(const i of t){const t=i.getAttribute("blockIndent"),n=this._indentBehavior.getNextIndent(t);n?e.setAttribute("blockIndent",n,i):e.removeAttribute("blockIndent",i)}}))}_getBlocksToChange(){const e=this.editor.model.document.selection;return Array.from(e.getSelectedBlocks()).filter((e=>this._isIndentationChangeAllowed(e)))}_isIndentationChangeAllowed(e){const t=this.editor;return!!t.model.schema.checkAttribute(e,"blockIndent")&&(!t.plugins.has("ListUtils")||(!this._indentBehavior.isForward||!t.plugins.get("ListUtils").isListItemBlock(e)))}}class ZC{isForward;offset;unit;constructor(e){this.isForward="forward"===e.direction,this.offset=e.offset,this.unit=e.unit}checkEnabled(e){const t=parseFloat(e||"0");return this.isForward||t>0}getNextIndent(e){const t=parseFloat(e||"0");if(e&&!e.endsWith(this.unit))return this.isForward?this.offset+this.unit:void 0;const i=t+(this.isForward?this.offset:-this.offset);return i>0?i+this.unit:void 0}}class ex{isForward;classes;constructor(e){this.isForward="forward"===e.direction,this.classes=e.classes}checkEnabled(e){const t=this.classes.indexOf(e);return this.isForward?t=0}getNextIndent(e){const t=this.classes.indexOf(e),i=this.isForward?1:-1;return this.classes[t+i]}}const tx=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];class ix extends cd{refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute("highlight"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"highlight")}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value;t.change((e=>{if(i.isCollapsed){const t=i.getFirstPosition();if(i.hasAttribute("highlight")){const i=e=>e.item.hasAttribute("highlight")&&e.item.getAttribute("highlight")===this.value,o=t.getLastMatchingPosition(i,{direction:"backward"}),s=t.getLastMatchingPosition(i),r=e.createRange(o,s);n&&this.value!==n?(t.isEqual(s)||e.setAttribute("highlight",n,r),e.setSelectionAttribute("highlight",n)):(t.isEqual(s)||e.removeAttribute("highlight",r),e.removeSelectionAttribute("highlight"))}else n&&e.setSelectionAttribute("highlight",n)}else{const o=t.schema.getValidRanges(i.getRanges(),"highlight",{includeEmptyRanges:!0});for(const t of o){let i=t,o="highlight";t.isCollapsed&&(i=t.start.parent,o=Yr._getStoreAttributeKey("highlight")),n?e.setAttribute(o,n,i):e.removeAttribute(o,i)}}}))}}class nx extends ad{static get pluginName(){return"HighlightEditing"}static get isOfficialPlugin(){return!0}constructor(e){super(e),e.config.define("highlight",{options:[{model:"yellowMarker",class:"marker-yellow",title:"Yellow marker",color:"var(--ck-content-highlight-marker-yellow)",type:"marker"},{model:"greenMarker",class:"marker-green",title:"Green marker",color:"var(--ck-content-highlight-marker-green)",type:"marker"},{model:"pinkMarker",class:"marker-pink",title:"Pink marker",color:"var(--ck-content-highlight-marker-pink)",type:"marker"},{model:"blueMarker",class:"marker-blue",title:"Blue marker",color:"var(--ck-content-highlight-marker-blue)",type:"marker"},{model:"redPen",class:"pen-red",title:"Red pen",color:"var(--ck-content-highlight-pen-red)",type:"pen"},{model:"greenPen",class:"pen-green",title:"Green pen",color:"var(--ck-content-highlight-pen-green)",type:"pen"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"highlight"});const t=e.config.get("highlight.options");e.conversion.attributeToElement(function(e){const t={model:{key:"highlight",values:[]},view:{}};for(const i of e)t.model.values.push(i.model),t.view[i.model]={name:"mark",classes:i.class};return t}(t)),e.commands.add("highlight",new ix(e))}}class ox extends ad{get localizedOptionTitles(){const e=this.editor.t;return{"Yellow marker":e("Yellow marker"),"Green marker":e("Green marker"),"Pink marker":e("Pink marker"),"Blue marker":e("Blue marker"),"Red pen":e("Red pen"),"Green pen":e("Green pen")}}static get pluginName(){return"HighlightUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.config.get("highlight.options");for(const t of e)this._addHighlighterButton(t);this._addRemoveHighlightButton(),this._addDropdown(e),this._addMenuBarButton(e)}_addRemoveHighlightButton(){const e=this.editor.t,t=this.editor.commands.get("highlight");this._addButton("removeHighlight",e("Remove highlight"),Vb,null,(e=>{e.bind("isEnabled").to(t,"isEnabled")}))}_addHighlighterButton(e){const t=this.editor.commands.get("highlight");this._addButton("highlight:"+e.model,e.title,sx(e.type),e.model,(function(i){i.bind("isEnabled").to(t,"isEnabled"),i.bind("isOn").to(t,"value",(t=>t===e.model)),i.iconView.fillColor=e.color,i.isToggleable=!0}))}_addButton(e,t,i,n,o){const s=this.editor;s.ui.componentFactory.add(e,(e=>{const r=new Bn(e),a=this.localizedOptionTitles[t]?this.localizedOptionTitles[t]:t;return r.set({label:a,icon:i,tooltip:!0}),r.on("execute",(()=>{s.execute("highlight",{value:n}),s.editing.view.focus()})),o(r),r}))}_addDropdown(e){const t=this.editor,i=t.t,n=t.ui.componentFactory,o=e[0],s=e.reduce(((e,t)=>(e[t.model]=t,e)),{});n.add("highlight",(r=>{const a=t.commands.get("highlight"),l=Pu(r,xu),c=l.buttonView;function u(e,t){const i=e&&e!==c.lastExecuted?e:c.lastExecuted;return s[i][t]}return c.set({label:i("Highlight"),tooltip:!0,lastExecuted:o.model,commandValue:o.model,isToggleable:!0}),c.bind("icon").to(a,"value",(e=>sx(u(e,"type")))),c.bind("color").to(a,"value",(e=>u(e,"color"))),c.bind("commandValue").to(a,"value",(e=>u(e,"model"))),c.bind("isOn").to(a,"value",(e=>!!e)),c.delegate("execute").to(l),l.bind("isEnabled").to(a,"isEnabled"),Iu(l,(()=>{const t=e.map((e=>{const t=n.create("highlight:"+e.model);return this.listenTo(t,"execute",(()=>{l.buttonView.set({lastExecuted:e.model})})),t}));return t.push(new fu),t.push(n.create("removeHighlight")),t}),{enableActiveItemFocusOnDropdownOpen:!0,ariaLabel:i("Text highlight toolbar")}),function(e){e.buttonView.actionView.iconView.bind("fillColor").to(e.buttonView,"color")}(l),c.on("execute",(()=>{t.execute("highlight",{value:c.commandValue})})),this.listenTo(l,"execute",(()=>{t.editing.view.focus()})),l}))}_addMenuBarButton(e){const t=this.editor,i=t.t,n=t.commands.get("highlight");t.ui.componentFactory.add("menuBar:highlight",(o=>{const s=new Gu(o);s.buttonView.set({label:i("Highlight"),icon:sx("marker")}),s.bind("isEnabled").to(n),s.buttonView.iconView.fillColor="transparent";const r=new Ku(o);for(const i of e){const e=new hn(o,s),a=new Yu(o);a.set({label:i.title,icon:sx(i.type),role:"menuitemradio",isToggleable:!0}),a.iconView.fillColor=i.color,a.delegate("execute").to(s),a.bind("isOn").to(n,"value",(e=>e===i.model)),a.on("execute",(()=>{t.execute("highlight",{value:i.model}),t.editing.view.focus()})),e.children.add(a),r.items.add(e)}r.items.add(new _u(o));const a=new hn(o,s),l=new Yu(o);return l.set({label:i("Remove highlight"),icon:Vb}),l.delegate("execute").to(s),l.on("execute",(()=>{t.execute("highlight",{value:null}),t.editing.view.focus()})),a.children.add(l),r.items.add(a),s.panelView.children.add(r),s}))}}function sx(e){return"marker"===e?'':''}class rx extends cd{constructor(e){super(e),this.on("execute",(()=>{this.refresh()}),{priority:"highest"})}refresh(){const e=this._getSelectedItems();this.value=this._getValue(e),this.isEnabled=!!e.length}execute(e={}){this.editor.model.change((t=>{const i=this._getSelectedItems(),n=void 0===e.forceValue?!this._getValue(i):e.forceValue;for(const e of i)n?t.setAttribute("todoListChecked",!0,e):t.removeAttribute("todoListChecked",e)}))}_getValue(e){return e.every((e=>e.getAttribute("todoListChecked")))}_getSelectedItems(){const e=this.editor.model,t=e.schema,i=e.document.selection.getFirstRange(),n=i.start.parent,o=[];t.checkAttribute(n,"todoListChecked")&&o.push(...ib(n));for(const e of i.getItems({shallow:!0}))t.checkAttribute(e,"todoListChecked")&&!o.includes(e)&&o.push(...ib(e));return o}}class ax extends er{domEventType=["change"];onDomEvent(e){if(e.target){const t=this.view.domConverter.mapDomToView(e.target);t&&t.is("element","input")&&"checkbox"==t.getAttribute("type")&&t.findAncestor({classes:"todo-list__label"})&&this.fire("todoCheckboxChange",e)}}}const lx=Mt("Ctrl+Enter");class cx extends ad{static get pluginName(){return"TodoListEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Mv]}init(){const e=this.editor,t=e.model,i=e.editing,n=e.plugins.get(Mv),o=e.config.get("list.multiBlock")?"paragraph":"listItem";e.commands.add("todoList",new _b(e,"todo")),e.commands.add("checkTodoList",new rx(e)),i.view.addObserver(ax),t.schema.extend("$listItem",{allowAttributes:"todoListChecked"}),t.schema.addAttributeCheck((e=>{const t=e.last;if(!t.getAttribute("listItemId")||"todo"!=t.getAttribute("listType"))return!1}),"todoListChecked"),e.conversion.for("upcast").add((e=>{e.on("element:input",((e,t,i)=>{const n=t.modelCursor,o=n.parent,s=t.viewItem;if(!i.consumable.test(s,{name:!0}))return;if("checkbox"!=s.getAttribute("type")||!n.isAtStart||!o.hasAttribute("listType"))return;i.consumable.consume(s,{name:!0});const r=i.writer;r.setAttribute("listType","todo",o),t.viewItem.hasAttribute("checked")&&r.setAttribute("todoListChecked",!0,o),t.modelRange=r.createRange(n)})),e.on("element:li",((e,t,i)=>{const{writer:n,schema:o}=i;if(!t.modelRange)return;const s=Array.from(t.modelRange.getItems({shallow:!0})).filter((e=>"todo"===e.getAttribute("listType")&&o.checkAttribute(e,"listItemId"))).reduce(((e,t)=>{const i=t.getAttribute("listItemId");return e.has(i)||e.set(i,ib(t)),e}),new Map);for(const[,e]of s.entries())if(e.some((e=>e.getAttribute("todoListChecked"))))for(const t of e)n.setAttribute("todoListChecked",!0,t)}),{priority:"low"}),e.on("element:label",ux({name:"label",classes:"todo-list__label"})),e.on("element:label",ux({name:"label",classes:["todo-list__label","todo-list__label_without-description"]})),e.on("element:span",ux({name:"span",classes:"todo-list__label__description"})),e.on("element:ul",function(){const e=new co({name:"ul",classes:"todo-list"});return(t,i,n)=>{const o=e.match(i.viewItem);if(!o)return;const s=o.match;s.name=!1,n.consumable.consume(i.viewItem,s)}}())})),e.conversion.for("downcast").elementToElement({model:o,view:(e,{writer:t})=>{if(dx(e,n.getListAttributeNames()))return t.createContainerElement("span",{class:"todo-list__label__description"})},converterPriority:"highest"}),n.registerDowncastStrategy({scope:"list",attributeName:"listType",setAttributeOnDowncast(e,t,i){"todo"==t?e.addClass("todo-list",i):e.removeClass("todo-list",i)}}),n.registerDowncastStrategy({scope:"itemMarker",attributeName:"todoListChecked",createElement(e,t,{dataPipeline:i}){if("todo"!=t.getAttribute("listType"))return null;const n=e.createUIElement("input",{type:"checkbox",...t.getAttribute("todoListChecked")?{checked:"checked"}:null,...i?{disabled:"disabled"}:{tabindex:"-1"}});if(i)return n;const o=e.createContainerElement("span",{contenteditable:"false"},n);return o.getFillerOffset=()=>null,o},canWrapElement:e=>dx(e,n.getListAttributeNames()),createWrapperElement(e,t,{dataPipeline:i}){const o=["todo-list__label"];return dx(t,n.getListAttributeNames())||o.push("todo-list__label_without-description"),e.createAttributeElement(i?"label":"span",{class:o.join(" ")})}}),n.on("checkElement",((e,{modelElement:t,viewElement:i})=>{const o=dx(t,n.getListAttributeNames());i.hasClass("todo-list__label__description")!=o&&(e.return=!0,e.stop())})),n.on("checkElement",((t,{modelElement:i,viewElement:n})=>{const o="todo"==i.getAttribute("listType")&&sb(i);let s=!1;const r=e.editing.view.createPositionBefore(n).getWalker({direction:"backward"});for(const{item:t}of r){if(t.is("element")&&e.editing.mapper.toModelElement(t))break;t.is("element","input")&&"checkbox"==t.getAttribute("type")&&(s=!0)}s!=o&&(t.return=!0,t.stop())})),n.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:n,previousNodeInList:o}of t){if(!o)continue;if(o.getAttribute("listItemId")!=n.getAttribute("listItemId"))continue;const t=o.hasAttribute("todoListChecked"),s=n.hasAttribute("todoListChecked");s&&!t?(i.removeAttribute("todoListChecked",n),e.return=!0):!s&&t&&(i.setAttribute("todoListChecked",!0,n),e.return=!0)}})),t.document.registerPostFixer((e=>{const i=t.document.differ.getChanges();let n=!1;for(const t of i)if("attribute"==t.type&&"listType"==t.attributeKey){const i=t.range.start.nodeAfter;"todo"==t.attributeOldValue&&i.hasAttribute("todoListChecked")&&(e.removeAttribute("todoListChecked",i),n=!0)}else if("insert"==t.type&&"$text"!=t.name)for(const{item:i}of e.createRangeOn(t.position.nodeAfter))i.is("element")&&"todo"!=i.getAttribute("listType")&&i.hasAttribute("todoListChecked")&&(e.removeAttribute("todoListChecked",i),n=!0);return n})),this.listenTo(i.view.document,"keydown",((t,i)=>{Bt(i)===lx&&(e.execute("checkTodoList"),t.stop())}),{priority:"high"}),this.listenTo(i.view.document,"todoCheckboxChange",((e,t)=>{const n=t.target;if(!n||!n.is("element","input"))return;const o=i.view.createPositionAfter(n),s=i.mapper.toModelPosition(o).parent;s&&tb(s)&&"todo"==s.getAttribute("listType")&&this._handleCheckmarkChange(s)})),this.listenTo(i.view.document,"arrowKey",function(e,t){return(i,n)=>{const o=Ft(n.keyCode,t.contentLanguageDirection),s=e.schema,r=e.document.selection;if(!r.isCollapsed)return;const a=r.getFirstPosition(),l=a.parent;if("right"==o&&a.isAtEnd){const t=s.getNearestSelectionRange(e.createPositionAfter(l),"forward");if(!t)return;const o=t.start.parent;o&&tb(o)&&"todo"==o.getAttribute("listType")&&(e.change((e=>e.setSelection(t))),n.preventDefault(),n.stopPropagation(),i.stop())}else if("left"==o&&a.isAtStart&&tb(l)&&"todo"==l.getAttribute("listType")){const t=s.getNearestSelectionRange(e.createPositionBefore(l),"backward");if(!t)return;e.change((e=>e.setSelection(t))),n.preventDefault(),n.stopPropagation(),i.stop()}}}(t,e.locale),{context:"$text"}),this.listenTo(i.mapper,"viewToModelPosition",((e,i)=>{const n=i.viewPosition.parent,o=n.is("attributeElement","li")&&0==i.viewPosition.offset,s=hx(n)&&i.viewPosition.offset<=1,r=n.is("element","span")&&"false"==n.getAttribute("contenteditable")&&hx(n.parent);if(!o&&!s&&!r)return;const a=i.modelPosition.nodeAfter;a&&"todo"==a.getAttribute("listType")&&(i.modelPosition=t.createPositionAt(a,0))}),{priority:"low"}),this._initAriaAnnouncements()}_handleCheckmarkChange(e){const t=this.editor,i=t.model,n=Array.from(i.document.selection.getRanges());i.change((i=>{i.setSelection(e,"end"),t.execute("checkTodoList"),i.setSelection(n)}))}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor;let n=null;t&&e.document.selection.on("change:range",(()=>{const o=e.document.selection.focus.parent,s=mx(n),r=mx(o);s&&!r?t.ariaLiveAnnouncer.announce(i("Leaving a to-do list")):!s&&r&&t.ariaLiveAnnouncer.announce(i("Entering a to-do list")),n=o}))}}function ux(e){const t=new co(e);return(e,i,n)=>{const o=t.match(i.viewItem);o&&n.consumable.consume(i.viewItem,o.match)&&Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor))}}function dx(e,t){return(e.is("element","paragraph")||e.is("element","listItem"))&&"todo"==e.getAttribute("listType")&&sb(e)&&function(e,t){for(const i of e.getAttributeKeys())if(!i.startsWith("selection:")&&!t.includes(i))return!1;return!0}(e,t)}function hx(e){return!!e&&e.is("attributeElement")&&e.hasClass("todo-list__label")}function mx(e){return!(!e||!e.is("element","paragraph")&&!e.is("element","listItem")||"todo"!=e.getAttribute("listType"))}class gx extends ad{static get pluginName(){return"TodoListUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.t;Fv(this.editor,"todoList",e("To-do List"),'')}}function fx(e){const t=e.t,i=e.config.get("codeBlock.languages");for(const e of i)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class=`language-${e.language}`);return i}function px(e,t,i){const n={};for(const o of e)"class"===t?n[o[t].split(" ").shift()]=o[i]:n[o[t]]=o[i];return n}function bx(e){return e.data.match(/^(\s*)/)[0]}function wx(e){const t=e.document.selection,i=[];if(t.isCollapsed)return[t.anchor];const n=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:t}of n){let n=t.is("$textProxy")?t.textNode:t;const o=n.parent;if(!o.is("element","codeBlock")||n.is("element","softBreak"))continue;for(;n.previousSibling&&!n.previousSibling.is("element","softBreak");)n=n.previousSibling;const s=n.is("$text")?n.startOffset+bx(n).length:n.startOffset,r=e.createPositionAt(o,s);i.every((e=>!e.isEqual(r)))&&i.push(r)}return i}function vx(e){const t=Zt(e.getSelectedBlocks());return!!t&&t.is("element","codeBlock")}function yx(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}function _x(e,t,i,n){const o=px(t,"language","label"),s=i.getAttribute("language");if(s in o){return e("enter"===n?"Entering %0 code snippet":"Leaving %0 code snippet",o[s])}return e("enter"===n?"Entering code snippet":"Leaving code snippet")}function kx(e,t){for(e.textNode&&(e=t.createPositionBefore(e.textNode));e.nodeBefore&&!e.nodeBefore.is("element","softBreak");)e=t.createPositionBefore(e.nodeBefore);const i=e.nodeAfter;return i&&i.is("$text")?i:null}class Cx extends cd{_lastLanguage;constructor(e){super(e),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,i=t.model,n=i.document.selection,o=fx(t)[0],s=Array.from(n.getSelectedBlocks()),r=null==e.forceValue?!this.value:e.forceValue,a=function(e,t,i){return e.language?e.language:e.usePreviousLanguageChoice&&t?t:i}(e,this._lastLanguage,o.language);i.change((e=>{r?this._applyCodeBlock(e,s,a):this._removeCodeBlock(e,s)}))}_getValue(){const e=Zt(this.editor.model.document.selection.getSelectedBlocks());return!!e?.is("element","codeBlock")&&e.getAttribute("language")}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=Zt(e.getSelectedBlocks());return!!i&&yx(t,i)}_applyCodeBlock(e,t,i){this._lastLanguage=i;const n=this.editor.model.schema,o=t.filter((e=>yx(n,e)));for(const t of o)e.rename(t,"codeBlock"),e.setAttribute("language",i,t),n.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter((e=>!n.checkChild(t,e))).forEach((t=>e.remove(t)));o.reverse().forEach(((t,i)=>{const n=o[i+1];t.previousSibling===n&&(e.appendElement("softBreak",n),e.merge(e.createPositionBefore(t)))}))}_removeCodeBlock(e,t){const i=t.filter((e=>e.is("element","codeBlock")));for(const t of i){const i=e.createRangeOn(t);for(const t of Array.from(i.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:i}=e.split(e.createPositionBefore(t)),n=i.nodeAfter;e.rename(n,"paragraph"),e.removeAttribute("language",n),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}class xx extends cd{_indentSequence;constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((t=>{const i=wx(e);for(const n of i){const i=t.createText(this._indentSequence);e.insertContent(i,n)}}))}_checkEnabled(){return!!this._indentSequence&&vx(this.editor.model.document.selection)}}class Ax extends cd{_indentSequence;constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((()=>{const t=wx(e);for(const i of t){const t=Tx(e,i,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!vx(e.document.selection)&&wx(e).some((t=>Tx(e,t,this._indentSequence)))}}function Tx(e,t,i){const n=kx(t,e);if(!n)return null;const o=bx(n),s=o.lastIndexOf(i);if(s+i.length!==o.length)return null;if(-1===s)return null;const{parent:r,startOffset:a}=n;return e.createRange(e.createPositionAt(r,a+s),e.createPositionAt(r,a+s+i.length))}function Ex(e,t,i=!1){const n=px(t,"language","class"),o=px(t,"language","label");return(t,s,r)=>{const{writer:a,mapper:l,consumable:c}=r;if(!c.consume(s.item,"insert"))return;const u=s.item.getAttribute("language"),d=l.toViewPosition(e.createPositionBefore(s.item)),h={};i&&(h["data-language"]=o[u],h.spellcheck="false");const m=n[u]?{class:n[u]}:void 0,g=a.createContainerElement("code",m),f=a.createContainerElement("pre",h,g);a.insert(d,f),l.bindElements(s.item,g)}}const Sx="paragraph";class Px extends ad{static get pluginName(){return"CodeBlockEditing"}static get isOfficialPlugin(){return!0}static get requires(){return[Dh]}constructor(e){super(e),e.config.define("codeBlock",{languages:[{language:"plaintext",label:"Plain text"},{language:"c",label:"C"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"diff",label:"Diff"},{language:"go",label:"Go"},{language:"html",label:"HTML"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"php",label:"PHP"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"typescript",label:"TypeScript"},{language:"xml",label:"XML"}],indentSequence:"\t"})}init(){const e=this.editor,t=e.model.schema,i=e.model,n=e.editing.view,o=fx(e);e.commands.add("codeBlock",new Cx(e)),e.commands.add("indentCodeBlock",new xx(e)),e.commands.add("outdentCodeBlock",new Ax(e)),this.listenTo(n.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",disallowChildren:"$inlineObject",allowAttributes:["language"],allowAttributesOf:"$listItem",isBlock:!0}),t.addAttributeCheck(((e,i)=>{const n=e.getItem(e.length-2);if(t.getAttributeProperties(i).isFormatting&&n&&"codeBlock"==n.name)return!1})),e.editing.downcastDispatcher.on("insert:codeBlock",Ex(i,o,!0)),e.data.downcastDispatcher.on("insert:codeBlock",Ex(i,o)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,i,n)=>{if("codeBlock"!==i.item.parent.name)return;const{writer:o,mapper:s,consumable:r}=n;if(!r.consume(i.item,"insert"))return;const a=s.toViewPosition(e.createPositionBefore(i.item));o.insert(a,o.createText("\n"))}}(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const i=px(t,"class","language"),n=t[0].language;return(e,t,o)=>{const s=t.viewItem,r=s.parent;if(!r||!r.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:l}=o;if(!a.test(s,{name:!0}))return;const c=l.createElement("codeBlock"),u=[...s.getClassNames()];u.length||u.push("");for(const e of u){const t=i[e];if(t){a.consume(s,{classes:[e]}),l.setAttribute("language",t,c);break}}c.hasAttribute("language")||l.setAttribute("language",n,c),o.convertChildren(s,c),o.safeInsert(c,t.modelCursor)&&(a.consume(s,{name:!0}),o.updateConversionResult(c,t))}}(0,o)),e.data.upcastDispatcher.on("text",((e,t,{consumable:i,writer:n})=>{let o=t.modelCursor;if(!i.test(t.viewItem))return;if(!o.findAncestor("codeBlock"))return;i.consume(t.viewItem);const s=t.viewItem.data.split("\n").map((e=>n.createText(e))),r=s[s.length-1];for(const e of s)if(n.insert(e,o),o=o.getShiftedBy(e.offsetSize),e!==r){const e=n.createElement("softBreak");n.insert(e,o),o=n.createPositionAfter(e)}t.modelRange=n.createRange(t.modelCursor,o),t.modelCursor=o})),e.data.upcastDispatcher.on("element:pre",((e,t,{consumable:i})=>{const n=t.viewItem;if(n.findAncestor("pre"))return;const o=Array.from(n.getChildren()),s=o.find((e=>e.is("element","code")));if(s)for(const e of o)e!==s&&e.is("$text")&&i.consume(e,{name:!0})}),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,n)=>{let o=i.createRange(i.document.selection.anchor);if(n.targetRanges&&(o=e.editing.mapper.toModelRange(n.targetRanges[0])),!o.start.parent.is("element","codeBlock"))return;const s=n.dataTransfer.getData("text/plain"),r=new _c(e.editing.view.document);n.content=function(e,t){const i=e.createDocumentFragment(),n=t.split("\n"),o=n.reduce(((t,i,o)=>(t.push(i),o{const o=e.model,s=o.document.selection;s.anchor.parent.is("element","codeBlock")&&o.change((e=>{const i=e.createRangeIn(n.content);for(const n of[...i.getItems()])n.is("node")&&!t.checkChild(s.anchor,n)&&e.remove(n)}))})),this.listenTo(i,"getSelectedContent",((e,[n])=>{const o=n.anchor;!n.isCollapsed&&o.parent.is("element","codeBlock")&&o.hasSameParentAs(n.focus)&&i.change((i=>{const s=e.return;if(o.parent.is("element")&&(s.childCount>1||n.containsEntireContent(o.parent))){const t=i.createElement("codeBlock",o.parent.getAttributes());i.append(s,t);const n=i.createDocumentFragment();return i.append(t,n),void(e.return=n)}const r=s.getChild(0);t.checkAttribute(r,"code")&&i.setAttribute("code",!0,r)}))}))}afterInit(){const e=this.editor,t=e.commands,i=t.get("indent"),n=t.get("outdent");i&&i.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),n&&n.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",((t,i)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const i=e.model.document,n=e.editing.view,o=i.selection.getLastPosition(),s=o.nodeAfter;return!(t||!i.selection.isCollapsed||!o.isAtStart)&&(!!Vx(s)&&(e.model.change((t=>{e.execute("enter");const n=i.selection.anchor.parent.previousSibling;t.rename(n,Sx),t.setSelection(n,"in"),e.model.schema.removeDisallowedAttributes([n],t),t.remove(s)})),n.scrollToTheSelection(),!0))}(e,i.isSoft)||function(e,t){const i=e.model,n=i.document,o=e.editing.view,s=n.selection.getLastPosition(),r=s.nodeBefore;let a;if(t||!n.selection.isCollapsed||!s.isAtEnd||!r||!r.previousSibling)return!1;if(Vx(r)&&Vx(r.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling),i.createPositionAfter(r));else if(Ix(r)&&Vx(r.previousSibling)&&Vx(r.previousSibling.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling),i.createPositionAfter(r));else{if(!(Ix(r)&&Vx(r.previousSibling)&&Ix(r.previousSibling.previousSibling)&&r.previousSibling.previousSibling&&Vx(r.previousSibling.previousSibling.previousSibling)))return!1;a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling.previousSibling),i.createPositionAfter(r))}return e.model.change((t=>{t.remove(a),e.execute("enter");const i=n.selection.anchor.parent;t.rename(i,Sx),e.model.schema.removeDisallowedAttributes([i],t)})),o.scrollToTheSelection(),!0}(e,i.isSoft)||function(e){const t=e.model,i=t.document;let n;const o=kx(i.selection.getLastPosition(),t);o&&o.is("$text")&&(n=bx(o)),e.model.change((t=>{e.execute("shiftEnter"),n&&t.insertText(n,i.selection.anchor)}))}(e),i.preventDefault(),t.stop())}),{context:"pre"}),this._initAriaAnnouncements()}_initAriaAnnouncements(){const{model:e,ui:t,t:i}=this.editor,n=fx(this.editor);let o=null;e.document.selection.on("change:range",(()=>{const s=e.document.selection.focus.parent;t&&o!==s&&s.is("element")&&(o&&o.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(_x(i,n,o,"leave")),s.is("element","codeBlock")&&t.ariaLiveAnnouncer.announce(_x(i,n,s,"enter")),o=s)}))}}function Ix(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function Vx(e){return e&&e.is("element","softBreak")}const Ox='';class Rx extends ad{static get pluginName(){return"CodeBlockUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,n=fx(e),o=this._getLanguageListItemDefinitions(n),s=e.commands.get("codeBlock");i.add("codeBlock",(i=>{const n=Pu(i,xu),r=n.buttonView,a=t("Insert code block");return r.set({label:a,tooltip:!0,icon:Ox,isToggleable:!0}),r.bind("isOn").to(s,"value",(e=>!!e)),r.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()})),n.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),n.class="ck-code-block-dropdown",n.bind("isEnabled").to(s),Ou(n,o,{role:"menu",ariaLabel:a}),n})),i.add("menuBar:codeBlock",(i=>{const n=new Gu(i);n.buttonView.set({role:"menuitem",label:t("Code block"),icon:Ox}),n.bind("isEnabled").to(s);const r=new Ku(i);r.set({ariaLabel:t("Insert code block")});for(const t of o){const o=new hn(i,n),a=new Yu(i);a.bind(...Object.keys(t.model)).to(t.model),a.set({isToggleable:!0,role:"menuitemcheckbox"}),a.delegate("execute").to(n),a.on("execute",(()=>{e.execute("codeBlock",{language:t.model._codeBlockLanguage,forceValue:s.value!=t.model._codeBlockLanguage}),e.editing.view.focus()})),o.children.add(a),r.items.add(o)}return n.panelView.children.add(r),n}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new Xt;for(const n of e){const e={type:"button",model:new sf({_codeBlockLanguage:n.language,label:n.label,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(t=>t===e.model._codeBlockLanguage)),i.add(e)}return i}}class Lx extends cd{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute({startIndex:e=1}={}){const t=this.editor.model,i=t.document;let n=Array.from(i.selection.getSelectedBlocks()).filter((e=>tb(e)&&bb(e.getAttribute("listType"))));n=lb(n),t.change((t=>{for(const i of n)t.setAttribute("listStart",e>=0?e:1,i)}))}_getValue(){const e=Zt(this.editor.model.document.selection.getSelectedBlocks());return e&&tb(e)&&bb(e.getAttribute("listType"))?e.getAttribute("listStart"):null}}const Bx={},Mx={},Nx={},Fx=[{listStyle:"disc",typeAttribute:"disc",listType:"bulleted"},{listStyle:"circle",typeAttribute:"circle",listType:"bulleted"},{listStyle:"square",typeAttribute:"square",listType:"bulleted"},{listStyle:"decimal",typeAttribute:"1",listType:"numbered"},{listStyle:"decimal-leading-zero",typeAttribute:null,listType:"numbered"},{listStyle:"lower-roman",typeAttribute:"i",listType:"numbered"},{listStyle:"upper-roman",typeAttribute:"I",listType:"numbered"},{listStyle:"lower-alpha",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-alpha",typeAttribute:"A",listType:"numbered"},{listStyle:"lower-latin",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-latin",typeAttribute:"A",listType:"numbered"}];for(const{listStyle:e,typeAttribute:t,listType:i}of Fx)Bx[e]=i,Mx[e]=t,t&&(Nx[t]=e);function Dx(){return Fx.map((e=>e.listStyle))}function zx(e){return Bx[e]||null}function Hx(e){return Nx[e]||null}function Ux(e){return Mx[e]||null}class $x extends cd{defaultType;_supportedTypes;constructor(e,t,i){super(e),this.defaultType=t,this._supportedTypes=i}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document;t.change((t=>{this._tryToConvertItemsToList(e);let n=Array.from(i.selection.getSelectedBlocks()).filter((e=>e.hasAttribute("listType")));if(n.length){n=lb(n);for(const i of n)t.setAttribute("listStyle",e.type||this.defaultType,i)}}))}isStyleTypeSupported(e){return!this._supportedTypes||this._supportedTypes.includes(e)}_getValue(){const e=Zt(this.editor.model.document.selection.getSelectedBlocks());return tb(e)?e.getAttribute("listStyle"):null}_checkEnabled(){const e=this.editor,t=e.commands.get("numberedList"),i=e.commands.get("bulletedList");return t.isEnabled||i.isEnabled}_tryToConvertItemsToList(e){if(!e.type)return;const t=zx(e.type);if(!t)return;const i=this.editor,n=`${t}List`;i.commands.get(n).value||i.execute(n)}}class qx extends cd{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute(e={}){const t=this.editor.model,i=t.document;let n=Array.from(i.selection.getSelectedBlocks()).filter((e=>tb(e)&&"numbered"==e.getAttribute("listType")));n=lb(n),t.change((t=>{for(const i of n)t.setAttribute("listReversed",!!e.reversed,i)}))}_getValue(){const e=Zt(this.editor.model.document.selection.getSelectedBlocks());return tb(e)&&"numbered"==e.getAttribute("listType")?e.getAttribute("listReversed"):null}}function jx(e){return(t,i,n)=>{const{writer:o,schema:s,consumable:r}=n;if(!1===r.test(i.viewItem,e.viewConsumables))return;i.modelRange||Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor));let a=!1;for(const t of i.modelRange.getItems({shallow:!0}))s.checkAttribute(t,e.attributeName)&&e.appliesToListItem(t)&&(t.hasAttribute(e.attributeName)||(o.setAttribute(e.attributeName,e.getAttributeOnUpcast(i.viewItem),t),a=!0));a&&r.consume(i.viewItem,e.viewConsumables)}}class Wx extends ad{static get pluginName(){return"ListPropertiesUtils"}static get isOfficialPlugin(){return!0}getAllSupportedStyleTypes(){return Dx()}getListTypeFromListStyleType(e){return zx(e)}getListStyleTypeFromTypeAttribute(e){return Hx(e)}getTypeAttributeFromListStyleType(e){return Ux(e)}}function Gx(e){const{startIndex:t,reversed:i,styles:n}=e;return{styles:Kx(n),startIndex:t||!1,reversed:i||!1}}function Kx(e){const t={listTypes:["bulleted","numbered"],useAttribute:!1};return!0===e||(e?Array.isArray(e)||"string"==typeof e?t.listTypes=zt(e):(t.listTypes=e.listTypes?zt(e.listTypes):t.listTypes,t.useAttribute=!!e.useAttribute,e.listStyleTypes&&(t.listStyleTypes=e.listStyleTypes)):t.listTypes=[]),t}const Jx="default";class Yx extends ad{static get requires(){return[Mv,Wx]}static get pluginName(){return"ListPropertiesEditing"}static get licenseFeatureCode(){return"LP"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(e){super(e),e.config.define("list.properties",{styles:!0,startIndex:!1,reversed:!1})}init(){const e=this.editor,t=e.model,i=e.plugins.get(Mv),n=function(e){const t=[],i=Gx(e);if(e.styles){const e=i.styles.useAttribute;t.push({attributeName:"listStyle",defaultValue:Jx,viewConsumables:{styles:"list-style-type"},addCommand(t){let i=Dx();e&&(i=i.filter((e=>!!Ux(e)))),t.commands.add("listStyle",new $x(t,Jx,i))},appliesToListItem:e=>"numbered"==e.getAttribute("listType")||"bulleted"==e.getAttribute("listType"),hasValidAttribute(e){if(!this.appliesToListItem(e))return!e.hasAttribute("listStyle");if(!e.hasAttribute("listStyle"))return!1;const t=e.getAttribute("listStyle");return t==Jx||zx(t)==e.getAttribute("listType")},setAttributeOnDowncast(t,i,n){if(i&&i!==Jx){if(!e)return void t.setStyle("list-style-type",i,n);{const e=Ux(i);if(e)return void t.setAttribute("type",e,n)}}t.removeStyle("list-style-type",n),t.removeAttribute("type",n)},getAttributeOnUpcast(e){const t=e.getStyle("list-style-type");if(t)return function(e){switch(e){case"lower-alpha":return"lower-latin";case"upper-alpha":return"upper-latin";default:return e}}(t);const i=e.getAttribute("type");return i?Hx(i):Jx}})}return e.reversed&&t.push({attributeName:"listReversed",defaultValue:!1,viewConsumables:{attributes:"reversed"},addCommand(e){e.commands.add("listReversed",new qx(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),hasValidAttribute(e){return this.appliesToListItem(e)==e.hasAttribute("listReversed")},setAttributeOnDowncast(e,t,i){t?e.setAttribute("reversed","reversed",i):e.removeAttribute("reversed",i)},getAttributeOnUpcast:e=>e.hasAttribute("reversed")}),e.startIndex&&t.push({attributeName:"listStart",defaultValue:1,viewConsumables:{attributes:"start"},addCommand(e){e.commands.add("listStart",new Lx(e))},appliesToListItem:e=>bb(e.getAttribute("listType")),hasValidAttribute(e){return this.appliesToListItem(e)==e.hasAttribute("listStart")},setAttributeOnDowncast(e,t,i){0==t||t>1?e.setAttribute("start",t,i):e.removeAttribute("start",i)},getAttributeOnUpcast(e){const t=e.getAttribute("start");return t>=0?t:1}}),t}(e.config.get("list.properties"));for(const o of n)o.addCommand(e),t.schema.extend("$listItem",{allowAttributes:o.attributeName}),i.registerDowncastStrategy({scope:"list",attributeName:o.attributeName,setAttributeOnDowncast(e,t,i){o.setAttributeOnDowncast(e,t,i)}});e.conversion.for("upcast").add((e=>{for(const t of n)e.on("element:ol",jx(t)),e.on("element:ul",jx(t))})),i.on("checkAttributes:list",((e,{viewElement:t,modelAttributes:i,modelReferenceElement:o})=>{for(const s of n)s.appliesToListItem(o)&&s.getAttributeOnUpcast(t)!=i[s.attributeName]&&(e.return=!0,e.stop())})),this.listenTo(e.commands.get("indentList"),"afterExecute",((e,i)=>{t.change((e=>{for(const t of i)for(const i of n)i.appliesToListItem(t)&&e.setAttribute(i.attributeName,i.defaultValue,t)}))})),i.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:o}of t)for(const t of n)t.hasValidAttribute(o)||(t.appliesToListItem(o)?i.setAttribute(t.attributeName,t.defaultValue,o):i.removeAttribute(t.attributeName,o),e.return=!0)})),i.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:o,previousNodeInList:s}of t)if(s&&s.getAttribute("listType")==o.getAttribute("listType"))for(const t of n){const{attributeName:n}=t;if(!t.appliesToListItem(o))continue;const r=s.getAttribute(n);o.getAttribute(n)!=r&&(i.setAttribute(n,r,o),e.return=!0)}}))}}class Qx extends Hi{children;stylesView=null;additionalPropertiesCollapsibleView=null;startIndexFieldView=null;reversedSwitchButtonView=null;focusTracker=new ei;keystrokes=new oi;focusables=new wi;focusCycler;constructor(e,{enabledProperties:t,styleButtonViews:i,styleGridAriaLabel:n}){super(e);const o=["ck","ck-list-properties"];this.children=this.createCollection(),this.focusCycler=new Nn({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),i&&i.length?(this.stylesView=this._createStylesView(i,n),this.children.add(this.stylesView)):o.push("ck-list-properties_without-styles"),(t.startIndex||t.reversed)&&(this._addNumberedListPropertyViews(t),o.push("ck-list-properties_with-numbered-properties")),this.setTemplate({tag:"div",attributes:{class:o},children:this.children})}render(){if(super.render(),this.stylesView){this.focusables.add(this.stylesView),this.focusTracker.add(this.stylesView.element),(this.startIndexFieldView||this.reversedSwitchButtonView)&&(this.focusables.add(this.children.last.buttonView),this.focusTracker.add(this.children.last.buttonView.element));for(const e of this.stylesView.children)this.stylesView.focusTracker.add(e.element);Sb({keystrokeHandler:this.stylesView.keystrokes,focusTracker:this.stylesView.focusTracker,gridItems:this.stylesView.children,numberOfColumns:()=>n.window.getComputedStyle(this.stylesView.element).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}if(this.startIndexFieldView){this.focusables.add(this.startIndexFieldView),this.focusTracker.add(this.startIndexFieldView.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}this.reversedSwitchButtonView&&(this.focusables.add(this.reversedSwitchButtonView),this.focusTracker.add(this.reversedSwitchButtonView.element)),this.keystrokes.listenTo(this.element)}focus(){this.focusCycler.focusFirst()}focusLast(){this.focusCycler.focusLast()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createStylesView(e,t){const i=new Hi(this.locale);return i.children=i.createCollection(),i.children.addMany(e),i.setTemplate({tag:"div",attributes:{"aria-label":t,class:["ck","ck-list-styles-list"]},children:i.children}),i.children.delegate("execute").to(this),i.focus=function(){for(const e of this.children)if(e instanceof Bn&&e.isOn)return void e.focus();this.children.first.focus()},i.focusTracker=new ei,i.keystrokes=new oi,i.render(),i.keystrokes.listenTo(i.element),i}_addNumberedListPropertyViews(e){const t=this.locale.t,i=[];e.startIndex&&(this.startIndexFieldView=this._createStartIndexField(),i.push(this.startIndexFieldView)),e.reversed&&(this.reversedSwitchButtonView=this._createReversedSwitchButton(),i.push(this.reversedSwitchButtonView)),this.stylesView?(this.additionalPropertiesCollapsibleView=new Uf(this.locale,i),this.additionalPropertiesCollapsibleView.set({label:t("List properties"),isCollapsed:!0}),this.additionalPropertiesCollapsibleView.buttonView.bind("isEnabled").toMany(i,"isEnabled",((...e)=>e.some((e=>e)))),this.additionalPropertiesCollapsibleView.buttonView.on("change:isEnabled",((e,t,i)=>{i||(this.additionalPropertiesCollapsibleView.isCollapsed=!0)})),this.children.add(this.additionalPropertiesCollapsibleView)):this.children.addMany(i)}_createStartIndexField(){const e=this.locale.t,t=new yf(this.locale,Tf);return t.set({label:e("Start at"),class:"ck-numbered-list-properties__start-index"}),t.fieldView.set({min:0,step:1,value:1,inputMode:"numeric"}),t.fieldView.on("input",(()=>{const i=t.fieldView.element,n=i.valueAsNumber;Number.isNaN(n)?t.errorText=e("Invalid start index value."):i.checkValidity()?this.fire("listStart",{startIndex:n}):t.errorText=e("Start index must be greater than 0.")})),t}_createReversedSwitchButton(){const e=this.locale.t,t=new Au(this.locale);return t.set({withText:!0,label:e("Reversed order"),class:"ck-numbered-list-properties__reversed-order"}),t.delegate("execute").to(this,"listReversed"),t}}class Xx extends ad{static get pluginName(){return"ListPropertiesUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t,i=e.config.get("list.properties"),n=Gx(i),o=n.styles.listTypes;if(o.includes("bulleted")){const i=[{label:t("Toggle the disc list style"),tooltip:t("Disc"),type:"disc",icon:''},{label:t("Toggle the circle list style"),tooltip:t("Circle"),type:"circle",icon:''},{label:t("Toggle the square list style"),tooltip:t("Square"),type:"square",icon:''}],o=t("Bulleted List"),s=t("Bulleted list styles toolbar"),r="bulletedList";e.ui.componentFactory.add(r,Zx({editor:e,normalizedConfig:n,parentCommandName:r,buttonLabel:o,buttonIcon:Hv,styleGridAriaLabel:s,styleDefinitions:i})),e.ui.componentFactory.add(`menuBar:${r}`,tA({editor:e,normalizedConfig:n,parentCommandName:r,buttonLabel:o,styleGridAriaLabel:s,styleDefinitions:i}))}if(o.includes("numbered")||i.startIndex||i.reversed){const i=[{label:t("Toggle the decimal list style"),tooltip:t("Decimal"),type:"decimal",icon:''},{label:t("Toggle the decimal with leading zero list style"),tooltip:t("Decimal with leading zero"),type:"decimal-leading-zero",icon:''},{label:t("Toggle the lower–roman list style"),tooltip:t("Lower–roman"),type:"lower-roman",icon:''},{label:t("Toggle the upper–roman list style"),tooltip:t("Upper-roman"),type:"upper-roman",icon:''},{label:t("Toggle the lower–latin list style"),tooltip:t("Lower-latin"),type:"lower-latin",icon:''},{label:t("Toggle the upper–latin list style"),tooltip:t("Upper-latin"),type:"upper-latin",icon:''}],s=t("Numbered List"),r=t("Numbered list styles toolbar"),a="numberedList";e.ui.componentFactory.add(a,Zx({editor:e,normalizedConfig:n,parentCommandName:a,buttonLabel:s,buttonIcon:zv,styleGridAriaLabel:r,styleDefinitions:i})),o.includes("numbered")&&e.ui.componentFactory.add(`menuBar:${a}`,tA({editor:e,normalizedConfig:n,parentCommandName:a,buttonLabel:s,styleGridAriaLabel:r,styleDefinitions:i}))}}}function Zx({editor:e,normalizedConfig:t,parentCommandName:i,buttonLabel:n,buttonIcon:o,styleGridAriaLabel:s,styleDefinitions:r}){const a=e.commands.get(i);return l=>{const c=Pu(l,xu),u=c.buttonView;return c.bind("isEnabled").to(a),c.class="ck-list-styles-dropdown",u.on("execute",(()=>{e.execute(i),e.editing.view.focus()})),u.set({label:n,icon:o,tooltip:!0,isToggleable:!0}),u.bind("isOn").to(a,"value",(e=>!!e)),c.once("change:isOpen",(()=>{const n=function({editor:e,normalizedConfig:t,dropdownView:i,parentCommandName:n,styleDefinitions:o,styleGridAriaLabel:s}){const r=e.locale,a={...t,..."numberedList"!=n?{startIndex:!1,reversed:!1}:null},l=n.replace("List","");let c=null;if(t.styles.listTypes.includes(l)){const i=e.commands.get("listStyle"),s=eA({editor:e,parentCommandName:n,listStyleCommand:i}),r=t.styles.listStyleTypes;let a=o;if(r){const e=r[l];e&&(a=o.filter((t=>e.includes(t.type))))}const u=iA(i);c=a.filter(u).map(s)}const u=new Qx(r,{styleGridAriaLabel:s,enabledProperties:a,styleButtonViews:c});if(t.styles.listTypes.includes(l)&&Lu(i,(()=>u.stylesView.children.find((e=>e.isOn)))),a.startIndex){const t=e.commands.get("listStart");u.startIndexFieldView.bind("isEnabled").to(t),u.startIndexFieldView.fieldView.bind("value").to(t),u.on("listStart",((t,i)=>e.execute("listStart",i)))}if(a.reversed){const t=e.commands.get("listReversed");u.reversedSwitchButtonView.bind("isEnabled").to(t),u.reversedSwitchButtonView.bind("isOn").to(t,"value",(e=>!!e)),u.on("listReversed",(()=>{const i=t.value;e.execute("listReversed",{reversed:!i})}))}return u.delegate("execute").to(i),u}({editor:e,normalizedConfig:t,dropdownView:c,parentCommandName:i,styleGridAriaLabel:s,styleDefinitions:r});c.panelView.children.add(n)})),c.on("execute",(()=>{e.editing.view.focus()})),c}}function eA({editor:e,listStyleCommand:t,parentCommandName:i}){const n=e.locale,o=e.commands.get(i);return({label:s,type:r,icon:a,tooltip:l})=>{const c=new Bn(n);return c.set({label:s,icon:a,tooltip:l}),c.bind("isOn").to(t,"value",(e=>e===r)),c.on("execute",(()=>{o.value?t.value===r?e.execute(i):t.value!==r&&e.execute("listStyle",{type:r}):e.model.change((()=>{e.execute("listStyle",{type:r})}))})),c}}function tA({editor:e,normalizedConfig:t,parentCommandName:i,buttonLabel:n,styleGridAriaLabel:o,styleDefinitions:s}){return r=>{const a=new Gu(r),l=e.commands.get(i),c=e.commands.get("listStyle"),u=iA(c),d=eA({editor:e,parentCommandName:i,listStyleCommand:c}),h=t.styles.listStyleTypes;let m=s;if(h){const e=h[l.type];e&&(m=s.filter((t=>e.includes(t.type))))}const g=m.filter(u).map(d),f=new Qx(r,{styleGridAriaLabel:o,enabledProperties:{...t,startIndex:!1,reversed:!1},styleButtonViews:g});return f.delegate("execute").to(a),a.buttonView.set({label:n,icon:"bulletedList"===i?Hv:zv}),a.panelView.children.add(f),a.bind("isEnabled").to(l,"isEnabled"),a.on("execute",(()=>{e.editing.view.focus()})),a}}function iA(e){return"function"==typeof e.isStyleTypeSupported?t=>e.isStyleTypeSupported(t.type):()=>!0}const nA="SourceEditingMode";function oA(e){return function(e){return e.startsWith("<")}(e)?function(e){const t=[{name:"address",isVoid:!1},{name:"article",isVoid:!1},{name:"aside",isVoid:!1},{name:"blockquote",isVoid:!1},{name:"details",isVoid:!1},{name:"dialog",isVoid:!1},{name:"dd",isVoid:!1},{name:"div",isVoid:!1},{name:"dl",isVoid:!1},{name:"dt",isVoid:!1},{name:"fieldset",isVoid:!1},{name:"figcaption",isVoid:!1},{name:"figure",isVoid:!1},{name:"footer",isVoid:!1},{name:"form",isVoid:!1},{name:"h1",isVoid:!1},{name:"h2",isVoid:!1},{name:"h3",isVoid:!1},{name:"h4",isVoid:!1},{name:"h5",isVoid:!1},{name:"h6",isVoid:!1},{name:"header",isVoid:!1},{name:"hgroup",isVoid:!1},{name:"hr",isVoid:!0},{name:"li",isVoid:!1},{name:"main",isVoid:!1},{name:"nav",isVoid:!1},{name:"ol",isVoid:!1},{name:"p",isVoid:!1},{name:"section",isVoid:!1},{name:"table",isVoid:!1},{name:"tbody",isVoid:!1},{name:"td",isVoid:!1},{name:"th",isVoid:!1},{name:"thead",isVoid:!1},{name:"tr",isVoid:!1},{name:"ul",isVoid:!1}],i=t.map((e=>e.name)).join("|"),n=e.replace(new RegExp(``,"g"),"\n$&\n").replace(/]*>/g,"$&\n").split("\n");let o=0,s=!1;return n.map((e=>(s=function(e,t){const i=//.test(e),n=/<\/pre>/.test(e);return(!i||!n)&&(i?"first":n?"last":("first"===t||"middle"===t)&&"middle")}(e,s),e.length||s?function(e,t){return t.some((t=>!t.isVoid&&!!new RegExp(`<${t.name}( .*?)?>`).test(e)))}(e,t)?ci(e,o++):function(e,t){return t.some((t=>new RegExp(``).test(e)))}(e,t)?ci(e,--o):ci(e,"middle"===s||"last"===s?0:o):""))).join("").trimEnd()}(e):e}const sA=/\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;function rA(e,t,i,n){t&&function(e,t,i){if(t.attributes)for(const[n]of Object.entries(t.attributes))e.removeAttribute(n,i);if(t.styles)for(const n of Object.keys(t.styles))e.removeStyle(n,i);t.classes&&e.removeClass(t.classes,i)}(e,t,n),i&&aA(e,i,n)}function aA(e,t,i){if(t.attributes)for(const[n,o]of Object.entries(t.attributes))e.setAttribute(n,o,i);t.styles&&e.setStyle(t.styles,i),t.classes&&e.addClass(t.classes,i)}function lA(e,t,i,n,o){const s=t.getAttribute(i),r={};for(const e of["attributes","styles","classes"]){if(e!=n){s&&s[e]&&(r[e]=s[e]);continue}if("classes"==n){const t=new Set(s&&s.classes||[]);o(t),t.size&&(r[e]=Array.from(t));continue}const t=new Map(Object.entries(s&&s[e]||{}));o(t),t.size&&(r[e]=Object.fromEntries(t))}Object.keys(r).length?t.is("documentSelection")?e.setSelectionAttribute(i,r):e.setAttribute(i,r,t):s&&(t.is("documentSelection")?e.removeSelectionAttribute(i):e.removeAttribute(i,t))}function cA(e,t,i){for(const n of t.getItems({shallow:!0})){const t=n.getAttribute(e);t&&t.attributes&&Object.keys(t.attributes).length?Object.keys(t).length>1&&i.setAttribute(e,{attributes:t.attributes},n):i.removeAttribute(e,n)}}function uA(e){return`html${t=e,function(e){const t=function(e){return Array.from(e.match(sA)??[])}(function(e){return"string"!=typeof e&&(e=Ah(e)),e.replace(/['\u2019]/g,"")}(e).trim());let i="";for(let e=0;ei.writer.createElement(e,{htmlContent:t.getCustomProperty("$rawContent")})}function hA(e,{view:t,isInline:i}){const n=e.t;return(e,{writer:o})=>{const s=n("HTML object"),r=mA(t,e,o),a=e.getAttribute(uA(t));return o.addClass("html-object-embed__content",r),a&&aA(o,a,r),jh(o.createContainerElement(i?"span":"div",{class:"html-object-embed","data-html-object-embed-label":s},r),o,{label:s})}}function mA(e,t,i){return i.createRawElement(e,null,((e,i)=>{i.setContentOf(e,t.getAttribute("htmlContent"))}))}function gA({model:e,view:t},i){return(n,{writer:o,consumable:s})=>{if(!n.hasAttribute(e))return null;const r=o.createContainerElement(t),a=n.getAttribute(e);return s.consume(n,`attribute:${e}`),aA(o,a,r),r.getFillerOffset=()=>null,i?jh(r,o):r}}function fA({priority:e,view:t}){return(i,n)=>{if(!i)return;const{writer:o}=n,s=o.createAttributeElement(t,null,{priority:e});return aA(o,i,s),s}}function pA({view:e},t){return i=>{i.on(`element:${e}`,((e,i,n)=>{if(!i.modelRange||i.modelRange.isCollapsed)return;const o=t.processViewAttributes(i.viewItem,n);o&&n.writer.setAttribute(uA(i.viewItem.name),o,i.modelRange)}),{priority:"low"})}}function bA({view:e,model:t}){return i=>{i.on(`attribute:${uA(e)}:${t}`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:o}=t;rA(i.writer,n,o,i.mapper.toViewElement(t.item))}))}}const wA=[{model:"codeBlock",view:"pre"},{model:"paragraph",view:"p"},{model:"blockQuote",view:"blockquote"},{model:"listItem",view:"li"},{model:"pageBreak",view:"div"},{model:"rawHtml",view:"div"},{model:"table",view:"table"},{model:"tableRow",view:"tr"},{model:"tableCell",view:"td"},{model:"tableCell",view:"th"},{model:"tableColumnGroup",view:"colgroup"},{model:"tableColumn",view:"col"},{model:"caption",view:"caption"},{model:"caption",view:"figcaption"},{model:"imageBlock",view:"img"},{model:"imageInline",view:"img"},{model:"horizontalLine",view:"hr"},{model:"htmlP",view:"p",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlBlockquote",view:"blockquote",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlTable",view:"table",modelSchema:{allowWhere:"$block",isBlock:!0}},{model:"htmlTbody",view:"tbody",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlThead",view:"thead",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlTfoot",view:"tfoot",modelSchema:{allowIn:"htmlTable",isBlock:!1}},{model:"htmlCaption",view:"caption",modelSchema:{allowIn:"htmlTable",allowChildren:"$text",isBlock:!1}},{model:"htmlColgroup",view:"colgroup",modelSchema:{allowIn:"htmlTable",allowChildren:"col",isBlock:!1}},{model:"htmlCol",view:"col",modelSchema:{allowIn:"htmlColgroup",isBlock:!1}},{model:"htmlTr",view:"tr",modelSchema:{allowIn:["htmlTable","htmlThead","htmlTbody"],isLimit:!0}},{model:"htmlTd",view:"td",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlTh",view:"th",modelSchema:{allowIn:"htmlTr",allowContentOf:"$container",isLimit:!0,isBlock:!1}},{model:"htmlFigure",view:"figure",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFigcaption",view:"figcaption",modelSchema:{allowIn:"htmlFigure",allowChildren:"$text",isBlock:!1}},{model:"htmlAddress",view:"address",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlAside",view:"aside",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlMain",view:"main",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDetails",view:"details",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSummary",view:"summary",modelSchema:{allowChildren:["htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6","$text"],allowIn:"htmlDetails",isBlock:!1}},{model:"htmlDiv",view:"div",paragraphLikeModel:"htmlDivParagraph",modelSchema:{inheritAllFrom:"$container"}},{model:"htmlFieldset",view:"fieldset",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlLegend",view:"legend",modelSchema:{allowIn:"htmlFieldset",allowChildren:"$text"}},{model:"htmlHeader",view:"header",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlFooter",view:"footer",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlForm",view:"form",modelSchema:{inheritAllFrom:"$container",isBlock:!0}},{model:"htmlHgroup",view:"hgroup",modelSchema:{allowIn:["$root","$container"],allowChildren:["paragraph","htmlP","htmlH1","htmlH2","htmlH3","htmlH4","htmlH5","htmlH6"],isBlock:!1}},{model:"htmlH1",view:"h1",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH2",view:"h2",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH3",view:"h3",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH4",view:"h4",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH5",view:"h5",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlH6",view:"h6",modelSchema:{inheritAllFrom:"$block"}},{model:"$htmlList",modelSchema:{allowWhere:"$container",allowChildren:["$htmlList","htmlLi"],isBlock:!1}},{model:"htmlDir",view:"dir",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlMenu",view:"menu",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlUl",view:"ul",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlOl",view:"ol",modelSchema:{inheritAllFrom:"$htmlList"}},{model:"htmlLi",view:"li",modelSchema:{allowIn:"$htmlList",allowChildren:"$text",isBlock:!1}},{model:"htmlPre",view:"pre",modelSchema:{inheritAllFrom:"$block"}},{model:"htmlArticle",view:"article",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlSection",view:"section",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlNav",view:"nav",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlDl",view:"dl",modelSchema:{allowWhere:"$container",allowChildren:["htmlDt","htmlDd","htmlDiv"],isBlock:!1}},{model:"htmlDt",view:"dt",modelSchema:{allowChildren:"$block",allowIn:"htmlDiv",isBlock:!1}},{model:"htmlDd",view:"dd",modelSchema:{allowChildren:"$block",allowIn:"htmlDiv",isBlock:!1}},{model:"htmlCenter",view:"center",modelSchema:{inheritAllFrom:"$container",isBlock:!1}},{model:"htmlHr",view:"hr",isEmpty:!0,modelSchema:{inheritAllFrom:"$blockObject"}}],vA=[{model:"htmlLiAttributes",view:"li",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlOlAttributes",view:"ol",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlUlAttributes",view:"ul",appliesToBlock:!0,coupledAttribute:"listItemId"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"table"},{model:"htmlTheadAttributes",view:"thead",appliesToBlock:"table"},{model:"htmlTbodyAttributes",view:"tbody",appliesToBlock:"table"},{model:"htmlFigureAttributes",view:"figure",appliesToBlock:"imageBlock"},{model:"htmlAcronym",view:"acronym",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTt",view:"tt",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlFont",view:"font",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlTime",view:"time",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlVar",view:"var",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBig",view:"big",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSmall",view:"small",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSamp",view:"samp",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlQ",view:"q",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlOutput",view:"output",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlKbd",view:"kbd",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdi",view:"bdi",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlBdo",view:"bdo",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlAbbr",view:"abbr",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlA",view:"a",priority:5,coupledAttribute:"linkHref",attributeProperties:{isFormatting:!0}},{model:"htmlStrong",view:"strong",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlB",view:"b",coupledAttribute:"bold",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlI",view:"i",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlEm",view:"em",coupledAttribute:"italic",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlS",view:"s",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDel",view:"del",coupledAttribute:"strikethrough",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlIns",view:"ins",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlU",view:"u",coupledAttribute:"underline",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSub",view:"sub",coupledAttribute:"subscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSup",view:"sup",coupledAttribute:"superscript",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCode",view:"code",coupledAttribute:"code",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlMark",view:"mark",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlSpan",view:"span",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlCite",view:"cite",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlLabel",view:"label",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlDfn",view:"dfn",attributeProperties:{copyOnEnter:!0,isFormatting:!0}},{model:"htmlObject",view:"object",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlIframe",view:"iframe",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlInput",view:"input",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlButton",view:"button",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlTextarea",view:"textarea",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlSelect",view:"select",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlVideo",view:"video",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlEmbed",view:"embed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlOembed",view:"oembed",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlAudio",view:"audio",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlImg",view:"img",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlCanvas",view:"canvas",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlMeter",view:"meter",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlProgress",view:"progress",isObject:!0,modelSchema:{inheritAllFrom:"$inlineObject"}},{model:"htmlScript",view:"script",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlStyle",view:"style",modelSchema:{allowWhere:["$text","$block"],isInline:!0}},{model:"htmlCustomElement",view:"$customElement",modelSchema:{allowWhere:["$text","$block"],allowAttributesOf:"$inlineObject",isInline:!0}}];class yA extends ad{_definitions=[];static get pluginName(){return"DataSchema"}static get isOfficialPlugin(){return!0}init(){for(const e of wA)this.registerBlockElement(e);for(const e of vA)this.registerInlineElement(e)}registerBlockElement(e){this._definitions.push({...e,isBlock:!0})}registerInlineElement(e){this._definitions.push({...e,isInline:!0})}extendBlockElement(e){this._extendDefinition({...e,isBlock:!0})}extendInlineElement(e){this._extendDefinition({...e,isInline:!0})}getDefinitionsForView(e,t=!1){const i=new Set;for(const n of this._getMatchingViewDefinitions(e)){if(t)for(const e of this._getReferences(n.model))i.add(e);i.add(n)}return i}getDefinitionsForModel(e){return this._definitions.filter((t=>t.model==e))}_getMatchingViewDefinitions(e){return this._definitions.filter((t=>t.view&&function(e,t){return"string"==typeof e?e===t:e instanceof RegExp&&e.test(t)}(e,t.view)))}*_getReferences(e){const t=["inheritAllFrom","inheritTypesFrom","allowWhere","allowContentOf","allowAttributesOf"],i=this._definitions.filter((t=>t.model==e));for(const{modelSchema:n}of i)if(n)for(const i of t)for(const t of zt(n[i]||[])){const i=this._definitions.filter((e=>e.model==t));for(const n of i)t!==e&&(yield*this._getReferences(n.model),yield n)}}_extendDefinition(e){const t=Array.from(this._definitions.entries()).filter((([,t])=>t.model==e.model));if(0!=t.length)for(const[i,n]of t)this._definitions[i]=jt({},n,e,((e,t)=>Array.isArray(e)?e.concat(t):void 0));else this._definitions.push(e)}}class _A extends ad{_dataSchema;_allowedAttributes;_disallowedAttributes;_allowedElements;_disallowedElements;_dataInitialized;_coupledAttributes;constructor(e){super(e),this._dataSchema=e.plugins.get("DataSchema"),this._allowedAttributes=new co,this._disallowedAttributes=new co,this._allowedElements=new Set,this._disallowedElements=new Set,this._dataInitialized=!1,this._coupledAttributes=null,this._registerElementsAfterInit(),this._registerElementHandlers(),this._registerCoupledAttributesPostFixer(),this._registerAssociatedHtmlAttributesPostFixer()}static get pluginName(){return"DataFilter"}static get isOfficialPlugin(){return!0}static get requires(){return[yA,lm]}loadAllowedConfig(e){for(const t of e){const e=t.name||/[\s\S]+/,i=TA(t);this.allowElement(e),i.forEach((e=>this.allowAttributes(e)))}}loadDisallowedConfig(e){for(const t of e){const e=t.name||/[\s\S]+/,i=TA(t);0==i.length?this.disallowElement(e):i.forEach((e=>this.disallowAttributes(e)))}}loadAllowedEmptyElementsConfig(e){for(const t of e)this.allowEmptyElement(t)}allowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))this._addAllowedElement(t),this._coupledAttributes=null}disallowElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!1))this._disallowedElements.add(t.view)}allowEmptyElement(e){for(const t of this._dataSchema.getDefinitionsForView(e,!0))t.isInline&&this._dataSchema.extendInlineElement({...t,allowEmpty:!0})}allowAttributes(e){this._allowedAttributes.add(e)}disallowAttributes(e){this._disallowedAttributes.add(e)}processViewAttributes(e,t){const{consumable:i}=t;return kA(e,this._disallowedAttributes,i),function(e,{attributes:t,classes:i,styles:n}){return t.length||i.length||n.length?{...t.length&&{attributes:CA(e,t)},...n.length&&{styles:xA(e,n)},...i.length&&{classes:i}}:null}(e,kA(e,this._allowedAttributes,i))}_addAllowedElement(e){if(!this._allowedElements.has(e)){if(this._allowedElements.add(e),"appliesToBlock"in e&&"string"==typeof e.appliesToBlock)for(const t of this._dataSchema.getDefinitionsForModel(e.appliesToBlock))t.isBlock&&this._addAllowedElement(t);this._dataInitialized&&this.editor.data.once("set",(()=>{this._fireRegisterEvent(e)}),{priority:k.highest+1})}}_registerElementsAfterInit(){this.editor.data.on("init",(()=>{this._dataInitialized=!0;for(const e of this._allowedElements)this._fireRegisterEvent(e)}),{priority:k.highest+1})}_registerElementHandlers(){this.on("register",((e,t)=>{const i=this.editor.model.schema;if(t.isObject&&!i.isRegistered(t.model))this._registerObjectElement(t);else if(t.isBlock)this._registerBlockElement(t);else{if(!t.isInline)throw new x("data-filter-invalid-definition",null,t);this._registerInlineElement(t)}e.stop()}),{priority:"lowest"})}_registerCoupledAttributesPostFixer(){const e=this.editor.model,t=e.document.selection;e.document.registerPostFixer((t=>{const i=e.document.differ.getChanges();let n=!1;const o=this._getCoupledAttributesMap();for(const e of i){if("attribute"!=e.type||null!==e.attributeNewValue)continue;const i=o.get(e.attributeKey);if(i)for(const{item:o}of e.range.getWalker())for(const e of i)o.hasAttribute(e)&&(t.removeAttribute(e,o),n=!0)}return n})),this.listenTo(t,"change:attribute",((i,{attributeKeys:n})=>{const o=new Set,s=this._getCoupledAttributesMap();for(const e of n){if(t.hasAttribute(e))continue;const i=s.get(e);if(i)for(const e of i)t.hasAttribute(e)&&o.add(e)}0!=o.size&&e.change((e=>{for(const t of o)e.removeSelectionAttribute(t)}))}))}_registerAssociatedHtmlAttributesPostFixer(){const e=this.editor.model;e.document.registerPostFixer((t=>{const i=e.document.differ.getChanges();let n=!1;for(const o of i)if("insert"===o.type&&"$text"!==o.name)for(const i of o.attributes.keys())i.startsWith("html")&&i.endsWith("Attributes")&&(e.schema.checkAttribute(o.name,i)||(t.removeAttribute(i,o.position.nodeAfter),n=!0));return n}))}_getCoupledAttributesMap(){if(this._coupledAttributes)return this._coupledAttributes;this._coupledAttributes=new Map;for(const e of this._allowedElements)if(e.coupledAttribute&&e.model){const t=this._coupledAttributes.get(e.coupledAttribute);t?t.push(e.model):this._coupledAttributes.set(e.coupledAttribute,[e.model])}return this._coupledAttributes}_fireRegisterEvent(e){e.view&&this._disallowedElements.has(e.view)||this.fire(e.view?`register:${e.view}`:"register",e)}_registerObjectElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,{view:o,model:s}=e;i.register(s,e.modelSchema),o&&(i.extend(e.model,{allowAttributes:[uA(o),"htmlContent"]}),t.data.registerRawContentMatcher({name:o}),n.for("upcast").elementToElement({view:o,model:dA(e),converterPriority:k.low+2}),n.for("upcast").add(pA(e,this)),n.for("editingDowncast").elementToStructure({model:{name:s,attributes:[uA(o)]},view:hA(t,e)}),n.for("dataDowncast").elementToElement({model:s,view:(e,{writer:t})=>mA(o,e,t)}),n.for("dataDowncast").add(bA(e)))}_registerBlockElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,{view:o,model:s}=e;if(!i.isRegistered(e.model)){if(!e.modelSchema)return;if(i.register(e.model,e.modelSchema),!o)return;n.for("upcast").elementToElement({model:s,view:o,converterPriority:k.low+2}),n.for("downcast").elementToElement({model:s,view:(t,{writer:i})=>e.isEmpty?i.createEmptyElement(o):i.createContainerElement(o)})}o&&(i.extend(e.model,{allowAttributes:uA(o)}),n.for("upcast").add(pA(e,this)),n.for("downcast").add(bA(e)))}_registerInlineElement(e){const t=this.editor,i=t.model.schema,n=t.conversion,o=e.model;if(!e.appliesToBlock&&(i.extend("$text",{allowAttributes:o}),e.attributeProperties&&i.setAttributeProperties(o,e.attributeProperties),n.for("upcast").add(function({view:e,model:t,allowEmpty:i},n){return t=>{t.on(`element:${e}`,((e,t,s)=>{let r=n.processViewAttributes(t.viewItem,s);if(r||s.consumable.test(t.viewItem,{name:!0})){if(r=r||{},s.consumable.consume(t.viewItem,{name:!0}),t.modelRange||(t=Object.assign(t,s.convertChildren(t.viewItem,t.modelCursor))),i&&t.modelRange.isCollapsed&&Object.keys(r).length){const e=s.writer.createElement("htmlEmptyElement");if(!s.safeInsert(e,t.modelCursor))return;const i=s.getSplitParts(e);return t.modelRange=s.writer.createRange(t.modelRange.start,s.writer.createPositionAfter(i[i.length-1])),s.updateConversionResult(e,t),void o(e,r,s)}for(const e of t.modelRange.getItems())o(e,r,s)}}),{priority:"low"})};function o(e,i,n){if(n.schema.checkAttribute(e,t)){const o=function(e,t){const i=Ht(e);let n="attributes";for(n in t)i[n]="classes"==n?Array.from(new Set([...e[n]||[],...t[n]])):{...e[n],...t[n]};return i}(i,e.getAttribute(t)||{});n.writer.setAttribute(t,o,e)}}}(e,this)),n.for("downcast").attributeToElement({model:o,view:fA(e)}),e.allowEmpty)){if(i.setAttributeProperties(o,{copyFromObject:!1}),!i.isRegistered("htmlEmptyElement")){i.register("htmlEmptyElement",{inheritAllFrom:"$inlineObject"});const e=e=>Array.from(e.getAttributeKeys()).some((e=>e.startsWith("html")));t.model.document.registerPostFixer((i=>{const n=t.model.document.differ.getChanges(),o=new Set;for(const t of n)if("remove"!==t.type){if("attribute"===t.type&&null===t.attributeNewValue)for(const{item:i}of t.range)i.is("element","htmlEmptyElement")&&!e(i)&&o.add(i);if("insert"===t.type&&t.position.nodeAfter){const n=t.position.nodeAfter;for(const{item:t}of i.createRangeOn(n))t.is("element","htmlEmptyElement")&&!e(t)&&o.add(t)}}for(const e of o)i.remove(e);return o.size>0}))}t.data.htmlProcessor.domConverter.registerInlineObjectMatcher((t=>t.name==e.view&&t.isEmpty&&Array.from(t.getAttributeKeys()).length?{name:!0}:null)),n.for("editingDowncast").elementToElement({model:"htmlEmptyElement",view:gA(e,!0)}),n.for("dataDowncast").elementToElement({model:"htmlEmptyElement",view:gA(e)})}}}function kA(e,t,i){const n=t.matchAll(e)||[],o=e.document.stylesProcessor;return n.reduce(((t,{match:n})=>{for(const[s,r]of n.attributes||[])if("style"==s){const n=r,s=o.getRelatedStyles(n).filter((e=>e.split("-").length>n.split("-").length)).sort(((e,t)=>t.split("-").length-e.split("-").length));for(const n of s)i.consume(e,{styles:[n]})&&t.styles.push(n);i.consume(e,{styles:[n]})&&t.styles.push(n)}else if("class"==s){const n=r;i.consume(e,{classes:[n]})&&t.classes.push(n)}else i.consume(e,{attributes:[s]})&&t.attributes.push(s);return t}),{attributes:[],classes:[],styles:[]})}function CA(e,t){const i={};for(const n of t){const t=e.getAttribute(n);void 0!==t&&dt(n)&&(i[n]=t)}return i}function xA(e,t){const i=new Ao(e.document.stylesProcessor);for(const n of t){const t=e.getStyle(n);void 0!==t&&i.set(n,t)}return Object.fromEntries(i.getStylesEntries())}function AA(e,t){const{name:i}=e,n=e[t];return se(n)?Object.entries(n).map((([e,n])=>({name:i,[t]:{[e]:n}}))):Array.isArray(n)?n.map((e=>({name:i,[t]:[e]}))):[e]}function TA(e){const{name:t,attributes:i,classes:n,styles:o}=e,s=[];return i&&s.push(...AA({name:t,attributes:i},"attributes")),n&&s.push(...AA({name:t,classes:n},"classes")),o&&s.push(...AA({name:t,styles:o},"styles")),s}class EA extends ad{static get requires(){return[_A]}static get pluginName(){return"CodeBlockElementSupport"}static get isOfficialPlugin(){return!0}init(){if(!this.editor.plugins.has("CodeBlockEditing"))return;const e=this.editor.plugins.get(_A);e.on("register:pre",((t,i)=>{if("codeBlock"!==i.model)return;const n=this.editor,o=n.model.schema,s=n.conversion;o.extend("codeBlock",{allowAttributes:["htmlPreAttributes","htmlContentAttributes"]}),s.for("upcast").add(function(e){return t=>{t.on("element:code",((t,i,n)=>{const o=i.viewItem,s=o.parent;function r(t,o){const s=e.processViewAttributes(t,n);s&&n.writer.setAttribute(o,s,i.modelRange)}s&&s.is("element","pre")&&(r(s,"htmlPreAttributes"),r(o,"htmlContentAttributes"))}),{priority:"low"})}}(e)),s.for("downcast").add((e=>{e.on("attribute:htmlPreAttributes:codeBlock",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:o}=t,s=i.mapper.toViewElement(t.item).parent;rA(i.writer,n,o,s)})),e.on("attribute:htmlContentAttributes:codeBlock",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:o}=t,s=i.mapper.toViewElement(t.item);rA(i.writer,n,o,s)}))})),t.stop()}))}}class SA extends ad{static get requires(){return[_A]}static get pluginName(){return"DualContentModelElementSupport"}static get isOfficialPlugin(){return!0}init(){this.editor.plugins.get(_A).on("register",((e,t)=>{const i=t,n=this.editor,o=n.model.schema,s=n.conversion;if(!i.paragraphLikeModel)return;if(o.isRegistered(i.model)||o.isRegistered(i.paragraphLikeModel))return;const r={model:i.paragraphLikeModel,view:i.view};o.register(i.model,i.modelSchema),o.register(r.model,{inheritAllFrom:"$block"}),s.for("upcast").elementToElement({view:i.view,model:(e,{writer:t})=>this._hasBlockContent(e)?t.createElement(i.model):t.createElement(r.model),converterPriority:k.low+.5}),s.for("downcast").elementToElement({view:i.view,model:i.model}),this._addAttributeConversion(i),s.for("downcast").elementToElement({view:r.view,model:r.model}),this._addAttributeConversion(r),e.stop()}))}_hasBlockContent(e){const t=this.editor.editing.view,i=t.domConverter.blockElements;for(const n of t.createRangeIn(e).getItems())if(n.is("element")&&i.includes(n.name))return!0;return!1}_addAttributeConversion(e){const t=this.editor,i=t.conversion,n=t.plugins.get(_A);t.model.schema.extend(e.model,{allowAttributes:uA(e.view)}),i.for("upcast").add(pA(e,n)),i.for("downcast").add(bA(e))}}class PA extends ad{static get requires(){return[yA,Bh]}static get pluginName(){return"HeadingElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("HeadingEditing"))return;const t=e.config.get("heading.options");this.registerHeadingElements(e,t)}registerHeadingElements(e,t){const i=e.plugins.get(yA),n=[];for(const e of t)"model"in e&&"view"in e&&(i.registerBlockElement({view:e.view,model:e.model}),n.push(e.model));i.extendBlockElement({model:"htmlHgroup",modelSchema:{allowChildren:n}}),i.extendBlockElement({model:"htmlSummary",modelSchema:{allowChildren:n}})}}function IA(e,t,i){const n=e.createRangeOn(t);for(const{item:e}of n.getWalker())if(e.is("element",i))return e}class VA extends ad{static get requires(){return[_A]}static get pluginName(){return"ImageElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("ImageInlineEditing")&&!e.plugins.has("ImageBlockEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(_A);n.on("register:figure",(()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",((t,i,n)=>{const o=i.viewItem;if(!i.modelRange||!o.hasClass("image"))return;const s=e.processViewAttributes(o,n);s&&n.writer.setAttribute("htmlFigureAttributes",s,i.modelRange)}),{priority:"low"})}}(n))})),n.on("register:img",((o,s)=>{"imageBlock"!==s.model&&"imageInline"!==s.model||(t.isRegistered("imageBlock")&&t.extend("imageBlock",{allowAttributes:["htmlImgAttributes","htmlFigureAttributes","htmlLinkAttributes"]}),t.isRegistered("imageInline")&&t.extend("imageInline",{allowAttributes:["htmlA","htmlImgAttributes"]}),i.for("upcast").add(function(e){return t=>{t.on("element:img",((t,i,n)=>{if(!i.modelRange)return;const o=i.viewItem,s=e.processViewAttributes(o,n);s&&n.writer.setAttribute("htmlImgAttributes",s,i.modelRange)}),{priority:"low"})}}(n)),i.for("downcast").add((e=>{function t(t,i){e.on(`attribute:${i}:imageBlock`,((e,i,n)=>{if(!n.consumable.test(i.item,e.name))return;const{attributeOldValue:o,attributeNewValue:s}=i,r=n.mapper.toViewElement(i.item),a=IA(n.writer,r,t);a&&(rA(n.writer,o,s,a),n.consumable.consume(i.item,e.name))}),{priority:"low"}),"a"===t&&e.on("attribute:linkHref:imageBlock",((e,t,i)=>{if(!i.consumable.consume(t.item,"attribute:htmlLinkAttributes:imageBlock"))return;const n=i.mapper.toViewElement(t.item),o=IA(i.writer,n,"a");aA(i.writer,t.item.getAttribute("htmlLinkAttributes"),o)}),{priority:"low"})}var i;i="htmlImgAttributes",e.on(`attribute:${i}:imageInline`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:o}=t,s=i.mapper.toViewElement(t.item);rA(i.writer,n,o,s)}),{priority:"low"}),t("img","htmlImgAttributes"),t("figure","htmlFigureAttributes"),t("a","htmlLinkAttributes")})),e.plugins.has("LinkImage")&&i.for("upcast").add(function(e,t){const i=t.plugins.get("ImageUtils");return t=>{t.on("element:a",((t,n,o)=>{const s=n.viewItem;if(!i.findViewImgElement(s))return;const r=n.modelCursor.parent;if(!r.is("element","imageBlock"))return;const a=e.processViewAttributes(s,o);a&&o.writer.setAttribute("htmlLinkAttributes",a,r)}),{priority:"low"})}}(n,e)),o.stop())}))}}class OA extends ad{static get requires(){return[_A]}static get pluginName(){return"MediaEmbedElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("MediaEmbed")||e.config.get("mediaEmbed.previewsInData"))return;const t=e.model.schema,i=e.conversion,n=this.editor.plugins.get(_A),o=this.editor.plugins.get(yA),s=e.config.get("mediaEmbed.elementName");o.registerBlockElement({model:"media",view:s}),n.on("register:figure",(()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",((t,i,n)=>{const o=i.viewItem;if(!i.modelRange||!o.hasClass("media"))return;const s=e.processViewAttributes(o,n);s&&n.writer.setAttribute("htmlFigureAttributes",s,i.modelRange)}),{priority:"low"})}}(n))})),n.on(`register:${s}`,((e,o)=>{"media"===o.model&&(t.extend("media",{allowAttributes:[uA(s),"htmlFigureAttributes"]}),i.for("upcast").add(function(e,t){const i=(i,n,o)=>{!function(t,i){const s=e.processViewAttributes(t,o);s&&o.writer.setAttribute(i,s,n.modelRange)}(n.viewItem,uA(t))};return e=>{e.on(`element:${t}`,i,{priority:"low"})}}(n,s)),i.for("dataDowncast").add(function(e){return t=>{function i(e,i){t.on(`attribute:${i}:media`,((t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const{attributeOldValue:o,attributeNewValue:s}=i,r=n.mapper.toViewElement(i.item),a=IA(n.writer,r,e);rA(n.writer,o,s,a)}))}i(e,uA(e)),i("figure","htmlFigureAttributes")}}(s)),e.stop())}))}}class RA extends ad{static get requires(){return[_A]}static get pluginName(){return"ScriptElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(_A);e.on("register:script",((t,i)=>{const n=this.editor,o=n.model.schema,s=n.conversion;o.register("htmlScript",i.modelSchema),o.extend("htmlScript",{allowAttributes:["htmlScriptAttributes","htmlContent"],isContent:!0}),n.data.registerRawContentMatcher({name:"script"}),s.for("upcast").elementToElement({view:"script",model:dA(i)}),s.for("upcast").add(pA(i,e)),s.for("downcast").elementToElement({model:"htmlScript",view:(e,{writer:t})=>mA("script",e,t)}),s.for("downcast").add(bA(i)),t.stop()}))}}const LA=["width","max-width","min-width","height","min-height","max-height"];class BA extends ad{static get requires(){return[_A]}static get pluginName(){return"TableElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("TableEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(_A),o=e.plugins.get("TableUtils");n.on("register:figure",(()=>{i.for("upcast").add(function(e){return t=>{t.on("element:figure",((t,i,n)=>{const o=i.viewItem;if(!i.modelRange||!o.hasClass("table"))return;const s=e.processViewAttributes(o,n);s&&n.writer.setAttribute("htmlFigureAttributes",s,i.modelRange)}),{priority:"low"})}}(n))})),n.on("register:table",((s,r)=>{"table"===r.model&&(t.extend("table",{allowAttributes:["htmlTableAttributes","htmlFigureAttributes","htmlTheadAttributes","htmlTbodyAttributes"]}),i.for("upcast").add(function(e){return t=>{t.on("element:table",((t,i,n)=>{if(!i.modelRange)return;const o=i.viewItem;n.consumable.consume(o,{classes:"table"}),s(o,"htmlTableAttributes");for(const e of o.getChildren())e.is("element","thead")&&s(e,"htmlTheadAttributes"),e.is("element","tbody")&&s(e,"htmlTbodyAttributes");function s(t,o){const s=e.processViewAttributes(t,n);s&&n.writer.setAttribute(o,s,i.modelRange)}}),{priority:"low"})}}(n)),i.for("downcast").add((e=>{function t(t,i){e.on(`attribute:${i}:table`,((e,n,o)=>{if(!o.consumable.test(n.item,e.name))return;const s=o.mapper.toViewElement(n.item),r=IA(o.writer,s,t);if(r)if(o.consumable.consume(n.item,e.name),"htmlTableAttributes"===i&&s!==r){const e=MA(n.attributeOldValue),t=MA(n.attributeNewValue);rA(o.writer,e.tableAttributes,t.tableAttributes,r),rA(o.writer,e.figureAttributes,t.figureAttributes,s)}else rA(o.writer,n.attributeOldValue,n.attributeNewValue,r)}))}t("table","htmlTableAttributes"),t("figure","htmlFigureAttributes"),t("thead","htmlTheadAttributes"),t("tbody","htmlTbodyAttributes")})),e.model.document.registerPostFixer(function(e,t){return i=>{const n=e.document.differ.getChanges();let o=!1;for(const e of n){if("attribute"!=e.type||"headingRows"!=e.attributeKey)continue;const n=e.range.start.nodeAfter,s=n.getAttribute("htmlTheadAttributes"),r=n.getAttribute("htmlTbodyAttributes");s&&!e.attributeNewValue?(i.removeAttribute("htmlTheadAttributes",n),o=!0):r&&e.attributeNewValue==t.getRows(n)&&(i.removeAttribute("htmlTbodyAttributes",n),o=!0)}return o}}(e.model,o)),s.stop())}))}}function MA(e){const t={},i={...e};if(!e||!("styles"in e))return{figureAttributes:t,tableAttributes:i};i.styles={};for(const[n,o]of Object.entries(e.styles))LA.includes(n)?t.styles={...t.styles,[n]:o}:i.styles={...i.styles,[n]:o};return{figureAttributes:t,tableAttributes:i}}class NA extends ad{static get requires(){return[_A]}static get pluginName(){return"StyleElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(_A);e.on("register:style",((t,i)=>{const n=this.editor,o=n.model.schema,s=n.conversion;o.register("htmlStyle",i.modelSchema),o.extend("htmlStyle",{allowAttributes:["htmlStyleAttributes","htmlContent"],isContent:!0}),n.data.registerRawContentMatcher({name:"style"}),s.for("upcast").elementToElement({view:"style",model:dA(i)}),s.for("upcast").add(pA(i,e)),s.for("downcast").elementToElement({model:"htmlStyle",view:(e,{writer:t})=>mA("style",e,t)}),s.for("downcast").add(bA(i)),t.stop()}))}}class FA extends ad{static get requires(){return[_A]}static get pluginName(){return"ListElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("ListEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(_A),o=e.plugins.get("ListEditing"),s=e.plugins.get("ListUtils"),r=["ul","ol","li"];o.registerDowncastStrategy({scope:"item",attributeName:"htmlLiAttributes",setAttributeOnDowncast:aA}),o.registerDowncastStrategy({scope:"list",attributeName:"htmlUlAttributes",setAttributeOnDowncast:aA}),o.registerDowncastStrategy({scope:"list",attributeName:"htmlOlAttributes",setAttributeOnDowncast:aA}),n.on("register",((e,o)=>{if(!r.includes(o.view))return;if(e.stop(),t.checkAttribute("$block","htmlLiAttributes"))return;const s=r.map((e=>uA(e)));t.extend("$listItem",{allowAttributes:s}),i.for("upcast").add((e=>{e.on("element:ul",DA("htmlUlAttributes",n),{priority:"low"}),e.on("element:ol",DA("htmlOlAttributes",n),{priority:"low"}),e.on("element:li",DA("htmlLiAttributes",n),{priority:"low"})}))})),o.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:n,previousNodeInList:o}of t)if(o){if(o.getAttribute("listType")==n.getAttribute("listType")){const t=zA(o.getAttribute("listType")),s=o.getAttribute(t);!cl(n.getAttribute(t),s)&&i.model.schema.checkAttribute(n,t)&&(i.setAttribute(t,s,n),e.return=!0)}if(o.getAttribute("listItemId")==n.getAttribute("listItemId")){const t=o.getAttribute("htmlLiAttributes");!cl(n.getAttribute("htmlLiAttributes"),t)&&i.model.schema.checkAttribute(n,"htmlLiAttributes")&&(i.setAttribute("htmlLiAttributes",t,n),e.return=!0)}}})),o.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:n}of t){const t=n.getAttribute("listType");!s.isNumberedListType(t)&&n.getAttribute("htmlOlAttributes")&&(i.removeAttribute("htmlOlAttributes",n),e.return=!0),s.isNumberedListType(t)&&n.getAttribute("htmlUlAttributes")&&(i.removeAttribute("htmlUlAttributes",n),e.return=!0)}}))}afterInit(){const e=this.editor;if(!e.commands.get("indentList"))return;const t=e.commands.get("indentList");this.listenTo(t,"afterExecute",((t,i)=>{e.model.change((t=>{for(const n of i){const i=zA(n.getAttribute("listType"));e.model.schema.checkAttribute(n,i)&&t.setAttribute(i,{},n)}}))}))}}function DA(e,t){return(i,n,o)=>{const s=n.viewItem;n.modelRange||Object.assign(n,o.convertChildren(n.viewItem,n.modelCursor));const r=t.processViewAttributes(s,o);for(const t of n.modelRange.getItems({shallow:!0}))t.hasAttribute("listItemId")&&(t.hasAttribute("htmlUlAttributes")||t.hasAttribute("htmlOlAttributes")||o.writer.model.schema.checkAttribute(t,e)&&o.writer.setAttribute(e,r||{},t))}}function zA(e){return"numbered"===e||"customNumbered"==e?"htmlOlAttributes":"htmlUlAttributes"}class HA extends ad{static get requires(){return[_A]}static get pluginName(){return"HorizontalLineElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;if(!e.plugins.has("HorizontalLineEditing"))return;const t=e.model.schema,i=e.conversion,n=e.plugins.get(_A);n.on("register:hr",((e,o)=>{"horizontalLine"===o.model&&(t.extend("horizontalLine",{allowAttributes:["htmlHrAttributes"]}),i.for("upcast").add(pA(o,n)),i.for("downcast").add((e=>{e.on("attribute:htmlHrAttributes:horizontalLine",((e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const{attributeOldValue:n,attributeNewValue:o}=t,s=i.mapper.toViewElement(t.item),r=IA(i.writer,s,"hr");r&&(rA(i.writer,n,o,r),i.consumable.consume(t.item,e.name))}),{priority:"low"})})),e.stop())}))}}class UA extends ad{static get requires(){return[_A,yA]}static get pluginName(){return"CustomElementSupport"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.plugins.get(_A),t=this.editor.plugins.get(yA);e.on("register:$customElement",((i,n)=>{i.stop();const o=this.editor,s=o.model.schema,r=o.conversion,a=o.editing.view.domConverter.unsafeElements,l=o.data.htmlProcessor.domConverter.preElements;s.register(n.model,n.modelSchema),s.extend(n.model,{allowAttributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"],isContent:!0}),o.data.htmlProcessor.domConverter.registerRawContentMatcher({name:"template"}),r.for("upcast").elementToElement({view:/.*/,model:(i,s)=>{if("$comment"==i.name)return null;if(!function(e){try{document.createElement(e)}catch{return!1}return!0}(i.name))return null;if(t.getDefinitionsForView(i.name).size)return null;a.includes(i.name)||a.push(i.name),l.includes(i.name)||l.push(i.name);const r=s.writer.createElement(n.model,{htmlElementName:i.name}),c=e.processViewAttributes(i,s);let u;if(c&&s.writer.setAttribute("htmlCustomElementAttributes",c,r),i.is("element","template")&&i.getCustomProperty("$rawContent"))u=i.getCustomProperty("$rawContent");else{const e=new _c(i.document).createDocumentFragment(i),t=o.data.htmlProcessor.domConverter.viewToDom(e),n=t.firstChild;for(;n.firstChild;)t.appendChild(n.firstChild);n.remove(),u=o.data.htmlProcessor.htmlWriter.getHtml(t)}s.writer.setAttribute("htmlContent",u,r);for(const{item:e}of o.editing.view.createRangeIn(i))s.consumable.consume(e,{name:!0});return r},converterPriority:"low"}),r.for("editingDowncast").elementToElement({model:{name:n.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(e,{writer:t})=>{const i=e.getAttribute("htmlElementName"),n=t.createRawElement(i);return e.hasAttribute("htmlCustomElementAttributes")&&aA(t,e.getAttribute("htmlCustomElementAttributes"),n),n}}),r.for("dataDowncast").elementToElement({model:{name:n.model,attributes:["htmlElementName","htmlCustomElementAttributes","htmlContent"]},view:(e,{writer:t})=>{const i=e.getAttribute("htmlElementName"),n=e.getAttribute("htmlContent"),o=t.createRawElement(i,null,((e,t)=>{t.setContentOf(e,n)}));return e.hasAttribute("htmlCustomElementAttributes")&&aA(t,e.getAttribute("htmlCustomElementAttributes"),o),o}})}))}}function*$A(e,t,i){if(t)if(!(Symbol.iterator in t)&&t.is("documentSelection")&&t.isCollapsed)e.schema.checkAttributeInSelection(t,i)&&(yield t);else for(const n of function(e,t,i){return!(Symbol.iterator in t)&&(t.is("node")||t.is("$text")||t.is("$textProxy"))?e.schema.checkAttribute(t,i)?[e.createRangeOn(t)]:[]:e.schema.getValidRanges(e.createSelection(t).getRanges(),i)}(e,t,i))yield*n.getItems({shallow:!0})}function qA(e){const t=e.map((e=>e.replace("+","\\+")));return new RegExp(`^image\\/(${t.join("|")})$`)}function jA(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class WA extends ad{static get pluginName(){return"ImageUploadUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("uploadImage",(()=>this._createToolbarButton())),e.ui.componentFactory.add("imageUpload",(()=>this._createToolbarButton())),e.ui.componentFactory.add("menuBar:uploadImage",(()=>this._createMenuBarButton("standalone"))),e.plugins.has("ImageInsertUI")&&e.plugins.get("ImageInsertUI").registerIntegration({name:"upload",observable:()=>e.commands.get("uploadImage"),buttonViewCreator:()=>this._createToolbarButton(),formViewCreator:()=>this._createDropdownButton(),menuBarButtonViewCreator:e=>this._createMenuBarButton(e?"insertOnly":"insertNested")})}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("uploadImage"),o=t.config.get("image.upload.types"),s=qA(o),r=new e(t.locale),a=i.t;return r.set({acceptedType:o.map((e=>`image/${e}`)).join(","),allowMultipleFiles:!0,label:a("Upload from computer"),icon:''}),r.bind("isEnabled").to(n),r.on("done",((e,i)=>{const n=Array.from(i).filter((e=>s.test(e.type)));n.length&&(t.execute("uploadImage",{file:n}),t.editing.view.focus())})),r}_createToolbarButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this.editor.commands.get("uploadImage"),n=this._createButton(Qu);return n.tooltip=!0,n.bind("label").to(t,"isImageSelected",i,"isAccessAllowed",((t,i)=>e(i?t?"Replace image from computer":"Upload image from computer":"You have no image upload permissions."))),n}_createDropdownButton(){const e=this.editor.locale.t,t=this.editor.plugins.get("ImageInsertUI"),i=this._createButton(Qu);return i.withText=!0,i.bind("label").to(t,"isImageSelected",(t=>e(t?"Replace from computer":"Upload from computer"))),i.on("execute",(()=>{t.dropdownView.isOpen=!1})),i}_createMenuBarButton(e){const t=this.editor.locale.t,i=this._createButton(td);switch(i.withText=!0,e){case"standalone":i.label=t("Image from computer");break;case"insertOnly":i.label=t("Image");break;case"insertNested":i.label=t("From computer")}return i}}class GA extends ad{static get pluginName(){return"ImageUploadProgress"}static get isOfficialPlugin(){return!0}placeholder;constructor(e){super(e),this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",this.uploadStatusChange),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}uploadStatusChange=(e,t,i)=>{const n=this.editor,o=t.item,s=o.getAttribute("uploadId");if(!i.consumable.consume(t.item,e.name))return;const r=n.plugins.get("ImageUtils"),a=n.plugins.get(sg),l=s?t.attributeNewValue:null,c=this.placeholder,u=n.editing.mapper.toViewElement(o),d=i.writer;if("reading"==l)return KA(u,d),void JA(r,c,u,d);if("uploading"==l){const e=a.loaders.get(s);return KA(u,d),void(e?(YA(u,d),function(e,t,i,n){const o=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),o),i.on("change:uploadedPercent",((e,t,i)=>{n.change((e=>{e.setStyle("width",i+"%",o)}))}))}(u,d,e,n.editing.view),function(e,t,i,n){if(n.data){const o=e.findViewImgElement(t);i.setAttribute("src",n.data,o)}}(r,u,d,e)):JA(r,c,u,d))}"complete"==l&&a.loaders.get(s)&&function(e,t,i){const n=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),n),setTimeout((()=>{i.change((e=>e.remove(e.createRangeOn(n))))}),3e3)}(u,d,n.editing.view),function(e,t){XA(e,t,"progressBar")}(u,d),YA(u,d),function(e,t){t.removeClass("ck-appear",e)}(u,d)}}function KA(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function JA(e,t,i,n){i.hasClass("ck-image-upload-placeholder")||n.addClass("ck-image-upload-placeholder",i);const o=e.findViewImgElement(i);o.getAttribute("src")!==t&&n.setAttribute("src",t,o),QA(i,"placeholder")||n.insert(n.createPositionAfter(o),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(n))}function YA(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),XA(e,t,"placeholder")}function QA(e,t){for(const i of e.getChildren())if(i.getCustomProperty(t))return i}function XA(e,t,i){const n=QA(e,i);n&&t.remove(t.createRangeOn(n))}class ZA extends fd{static get pluginName(){return"Notification"}static get isOfficialPlugin(){return!0}init(){this.on("show:warning",((e,t)=>{window.alert(t.message)}),{priority:"lowest"})}showSuccess(e,t={}){this._showNotification({message:e,type:"success",namespace:t.namespace,title:t.title})}showInfo(e,t={}){this._showNotification({message:e,type:"info",namespace:t.namespace,title:t.title})}showWarning(e,t={}){this._showNotification({message:e,type:"warning",namespace:t.namespace,title:t.title})}_showNotification(e){const t=e.namespace?`show:${e.type}:${e.namespace}`:`show:${e.type}`;this.fire(t,{message:e.message,type:e.type,title:e.title||""})}}class eT extends cd{constructor(e){super(e),this.set("isAccessAllowed",!0)}refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(i)}execute(e){const t=zt(e.file),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(i.getAttributes());t.forEach(((e,t)=>{const s=i.getSelectedElement();if(t&&s&&n.isImage(s)){const t=this.editor.model.createPositionAfter(s);this._uploadImage(e,o,t)}else this._uploadImage(e,o)}))}_uploadImage(e,t,i){const n=this.editor,o=n.plugins.get(sg).createLoader(e),s=n.plugins.get("ImageUtils");o&&s.insertImage({...t,uploadId:o.id},i)}}class tT extends ad{static get requires(){return[sg,ZA,Qd,gf]}static get pluginName(){return"ImageUploadEditing"}static get isOfficialPlugin(){return!0}_uploadImageElements;_uploadedImages=new Map;constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const e=this.editor,t=e.model.document,i=e.conversion,o=e.plugins.get(sg),s=e.plugins.get("ImageUtils"),r=e.plugins.get("ClipboardPipeline"),a=qA(e.config.get("image.upload.types")),l=new eT(e);e.commands.add("uploadImage",l),e.commands.add("imageUpload",l),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}).add((e=>e.on("element:img",((e,t,i)=>{if(!i.consumable.test(t.viewItem,{attributes:["data-ck-upload-id"]}))return;const n=t.viewItem.getAttribute("data-ck-upload-id");if(!n)return;const[s]=Array.from(t.modelRange.getItems({shallow:!0})),r=o.loaders.get(n);s&&(i.writer.setAttribute("uploadId",n,s),i.consumable.consume(t.viewItem,{attributes:["data-ck-upload-id"]}),r&&r.data&&i.writer.setAttribute("uploadStatus",r.status,s))}),{priority:"low"}))),this.listenTo(e.editing.view.document,"clipboardInput",((t,i)=>{if(n=i.dataTransfer,Array.from(n.types).includes("text/html")&&""!==n.getData("text/html"))return;var n;const o=Array.from(i.dataTransfer.files).filter((e=>!!e&&a.test(e.type)));if(o.length&&(t.stop(),e.model.change((t=>{i.targetRanges&&t.setSelection(i.targetRanges.map((t=>e.editing.mapper.toModelRange(t)))),e.execute("uploadImage",{file:o})})),!e.commands.get("uploadImage").isAccessAllowed)){const t=e.plugins.get("Notification"),i=e.locale.t;t.showWarning(i("You have no image upload permissions."),{namespace:"image"})}})),this.listenTo(r,"inputTransformation",((t,i)=>{const r=Array.from(e.editing.view.createRangeIn(i.content)).map((e=>e.item)).filter((e=>function(e,t){return!(!e.isInlineImageView(t)||!t.getAttribute("src")||!t.getAttribute("src").match(/^data:image\/\w+;base64,/g)&&!t.getAttribute("src").match(/^blob:/g))}(s,e)&&!e.getAttribute("uploadProcessed"))).map((e=>{return{promise:(t=e,new Promise(((e,i)=>{const o=t.getAttribute("src");fetch(o).then((e=>e.blob())).then((t=>{const i=jA(t,o),n=i.replace("image/",""),s=new File([t],`image.${n}`,{type:i});e(s)})).catch((t=>t&&"TypeError"===t.name?function(e){return function(e){return new Promise(((t,i)=>{const o=n.document.createElement("img");o.addEventListener("load",(()=>{const e=n.document.createElement("canvas");e.width=o.width,e.height=o.height,e.getContext("2d").drawImage(o,0,0),e.toBlob((e=>e?t(e):i()))})),o.addEventListener("error",(()=>i())),o.src=e}))}(e).then((t=>{const i=jA(t,e),n=i.replace("image/","");return new File([t],`image.${n}`,{type:i})}))}(o).then(e).catch(i):i(t)))}))),imageElement:e};var t}));if(!r.length)return;const a=new _c(e.editing.view.document);for(const e of r){a.setAttribute("uploadProcessed",!0,e.imageElement);const t=o.createLoader(e.promise);t&&(a.setAttribute("src","",e.imageElement),a.setAttribute("uploadId",t.id,e.imageElement))}})),e.editing.view.document.on("dragover",((e,t)=>{t.preventDefault()})),t.on("change",(()=>{const i=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),n=new Set;for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter,s="$graveyard"==t.position.root.rootName;for(const t of iT(e,i)){const i=t.getAttribute("uploadId"),r=t.getAttribute("uploadStatus");if(!i||"complete"==r)continue;const a=o.loaders.get(i);a?s?n.has(i)||Array.from(this._uploadImageElements.get(i)).every((e=>"$graveyard"==e.root.rootName))&&a.abort():(n.add(i),this._uploadImageElements.has(i)?this._uploadImageElements.get(i).add(t):this._uploadImageElements.set(i,new Set([t])),"idle"==a.status&&this._readAndUpload(a)):!s&&this._uploadedImages.has(i)&&e.model.enqueueChange({isUndoable:!1},(e=>{e.setAttribute("uploadStatus","complete",t),this.fire("uploadComplete",{data:this._uploadedImages.get(i),imageElement:t})}))}}})),this.on("uploadComplete",((e,{imageElement:t,data:i})=>{const n=i.urls?i.urls:i;this.editor.model.change((e=>{e.setAttribute("src",n.default,t),this._parseAndSetSrcsetAttributeOnImage(n,t,e),s.setImageNaturalSizeAttributes(t)}))}),{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&(e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this._registerConverters("imageBlock")),this.editor.plugins.has("ImageInlineEditing")&&(e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]}),this._registerConverters("imageInline"))}_readAndUpload(e){const t=this.editor,i=t.model,n=t.locale.t,o=t.plugins.get(sg),s=t.plugins.get(ZA),a=t.plugins.get("ImageUtils"),l=this._uploadImageElements;return i.enqueueChange({isUndoable:!1},(t=>{const i=l.get(e.id);for(const e of i)t.setAttribute("uploadStatus","reading",e)})),e.read().then((()=>{const o=e.upload();t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Uploading image"));for(const n of l.get(e.id)){if(r.isSafari){const e=t.editing.mapper.toViewElement(n),i=a.findViewImgElement(e);t.editing.view.once("render",(()=>{if(!i.parent)return;const e=t.editing.view.domConverter.mapViewToDom(i.parent);if(!e)return;const n=e.style.display;e.style.display="none",e._ckHack=e.offsetHeight,e.style.display=n}))}i.enqueueChange({isUndoable:!1},(e=>{e.setAttribute("uploadStatus","uploading",n)}))}return o})).then((o=>{i.enqueueChange({isUndoable:!1},(i=>{for(const t of l.get(e.id))i.setAttribute("uploadStatus","complete",t),this.fire("uploadComplete",{data:o,imageElement:t});t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Image upload complete")),this._uploadedImages.set(e.id,o)})),c()})).catch((o=>{if(t.ui&&t.ui.ariaLiveAnnouncer.announce(n("Error during image upload")),"error"!==e.status&&"aborted"!==e.status)throw o;"error"==e.status&&o&&s.showWarning(o,{title:n("Upload failed"),namespace:"upload"}),i.enqueueChange({isUndoable:!1},(t=>{for(const i of l.get(e.id))"$graveyard"!==i.root.rootName&&t.remove(i)})),c()}));function c(){i.enqueueChange({isUndoable:!1},(t=>{for(const i of l.get(e.id))t.removeAttribute("uploadId",i),t.removeAttribute("uploadStatus",i);l.delete(e.id)})),o.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let n=0;const o=Object.keys(e).filter((e=>{const t=parseInt(e,10);if(!isNaN(t))return n=Math.max(n,t),!0})).map((t=>`${e[t]} ${t}w`)).join(", ");if(""!=o){const e={srcset:o};t.hasAttribute("width")||t.hasAttribute("height")||(e.width=n),i.setAttributes(e,t)}}_registerConverters(e){const{conversion:t,plugins:i}=this.editor,n=i.get(sg),o=i.get(gf);t.for("dataDowncast").add((t=>{t.on(`attribute:uploadId:${e}`,((e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const s=n.loaders.get(t.attributeNewValue);if(!s||!s.data)return null;const r=i.mapper.toViewElement(t.item),a=o.findViewImgElement(r);a&&(i.consumable.consume(t.item,e.name),i.writer.setAttribute("data-ck-upload-id",s.id,a))}))}))}}function iT(e,t){const i=e.plugins.get("ImageUtils");return Array.from(e.model.createRangeOn(t)).filter((e=>i.isImage(e.item))).map((e=>e.item))}class nT extends ad{static get pluginName(){return"ImageUpload"}static get isOfficialPlugin(){return!0}static get requires(){return[tT,WA,GA]}}class oT extends Hi{urlInputView;keystrokes;constructor(e){super(e),this.set("imageURLInputValue",""),this.set("isImageSelected",!1),this.set("isEnabled",!0),this.keystrokes=new oi,this.urlInputView=this._createUrlInputView(),this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-url"],tabindex:"-1"},children:[this.urlInputView,{tag:"div",attributes:{class:["ck","ck-image-insert-url__action-row"]}}]})}render(){super.render(),vf({view:this}),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.keystrokes.destroy()}_createUrlInputView(){const e=this.locale,t=e.t,i=new yf(e,Af);return i.bind("label").to(this,"isImageSelected",(e=>t(e?"Update image URL":"Insert image via URL"))),i.bind("isEnabled").to(this),i.fieldView.inputMode="url",i.fieldView.placeholder="https://example.com/image.png",i.fieldView.bind("value").to(this,"imageURLInputValue",(e=>e||"")),i.fieldView.on("input",(()=>{this.imageURLInputValue=i.fieldView.element.value.trim()})),i}focus(){this.urlInputView.focus()}}class sT extends ad{_imageInsertUI;_formView;static get pluginName(){return"ImageInsertViaUrlUI"}static get isOfficialPlugin(){return!0}static get requires(){return[qf,eg]}init(){this.editor.ui.componentFactory.add("insertImageViaUrl",(()=>this._createToolbarButton())),this.editor.ui.componentFactory.add("menuBar:insertImageViaUrl",(()=>this._createMenuBarButton("standalone")))}afterInit(){this._imageInsertUI=this.editor.plugins.get("ImageInsertUI"),this._imageInsertUI.registerIntegration({name:"url",observable:()=>this.editor.commands.get("insertImage"),buttonViewCreator:()=>this._createToolbarButton(),formViewCreator:()=>this._createDropdownButton(),menuBarButtonViewCreator:e=>this._createMenuBarButton(e?"insertOnly":"insertNested")})}_createInsertUrlButton(e){const t=new e(this.editor.locale);return t.icon='',t.on("execute",(()=>{this._showModal()})),t}_createToolbarButton(){const e=this.editor.locale.t,t=this._createInsertUrlButton(Bn);return t.tooltip=!0,t.bind("label").to(this._imageInsertUI,"isImageSelected",(t=>e(t?"Update image URL":"Insert image via URL"))),t}_createDropdownButton(){const e=this.editor.locale.t,t=this._createInsertUrlButton(Bn);return t.withText=!0,t.bind("label").to(this._imageInsertUI,"isImageSelected",(t=>e(t?"Update image URL":"Insert via URL"))),t}_createMenuBarButton(e){const t=this.editor.locale.t,i=this._createInsertUrlButton(Yu);switch(i.withText=!0,e){case"standalone":i.label=t("Image via URL");break;case"insertOnly":i.label=t("Image");break;case"insertNested":i.label=t("Via URL")}return i}_createInsertUrlView(){const e=this.editor,t=e.locale,i=e.commands.get("replaceImageSource"),n=e.commands.get("insertImage"),o=new oT(t);return o.bind("isImageSelected").to(this._imageInsertUI),o.bind("isEnabled").toMany([n,i],"isEnabled",((...e)=>e.some((e=>e)))),o}_showModal(){const e=this.editor,t=e.locale.t,i=e.plugins.get("Dialog");this._formView||(this._formView=this._createInsertUrlView(),this._formView.on("submit",(()=>this._handleSave())));const n=e.commands.get("replaceImageSource");this._formView.imageURLInputValue=n.value||"",i.show({id:"insertImageViaUrl",title:t("Image via URL"),isModal:!0,content:this._formView,actionButtons:[{label:t("Cancel"),withText:!0,onExecute:()=>i.hide()},{label:this._imageInsertUI.isImageSelected?t("Save"):t("Insert"),class:"ck-button-action",withText:!0,onExecute:()=>this._handleSave()}]})}_handleSave(){this.editor.commands.get("replaceImageSource").isEnabled?this.editor.execute("replaceImageSource",{source:this._formView.imageURLInputValue}):this.editor.execute("insertImage",{source:this._formView.imageURLInputValue}),this.editor.plugins.get("Dialog").hide()}}class rT extends ad{static get pluginName(){return"ImageInsertViaUrl"}static get isOfficialPlugin(){return!0}static get requires(){return[sT,qf]}}function aT(e){return!!e&&e.is("element","table")}function lT(e){for(const t of e.getChildren())if(t.is("element","caption"))return t;return null}function cT(e){const t=e.parent;return"figcaption"==e.name&&t&&t.is("element","figure")&&t.hasClass("table")||"caption"==e.name&&t&&t.is("element","table")?{name:!0}:null}class uT extends cd{refresh(){const e=this.editor,t=C_(e.model.document.selection);this.isEnabled=!!t&&e.model.schema.checkChild(t,"caption"),this.isEnabled?this.value=!!lT(t):this.value=!1}execute({focusCaptionOnShow:e=!1}={}){this.editor.model.change((t=>{this.value?this._hideTableCaption(t):this._showTableCaption(t,e)}))}_showTableCaption(e,t){const i=this.editor.model,n=C_(i.document.selection),o=this.editor.plugins.get("TableCaptionEditing")._getSavedCaption(n)||e.createElement("caption");i.insertContent(o,n,"end"),t&&e.setSelection(o,"in")}_hideTableCaption(e){const t=this.editor.model,i=C_(t.document.selection),n=this.editor.plugins.get("TableCaptionEditing"),o=lT(i);n._saveCaption(i,o),t.deleteContent(e.createSelection(o,"on"))}}class dT extends ad{_savedCaptionsMap=new WeakMap;static get pluginName(){return"TableCaptionEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.editing.view,n=e.t,o=e.config.get("table.tableCaption.useCaptionElement");var s;t.isRegistered("caption")?t.extend("caption",{allowIn:"table"}):t.register("caption",{allowIn:"table",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleTableCaption",new uT(this.editor)),o&&e.plugins.get("TableEditing").registerAdditionalSlot({filter:e=>e.is("element","caption"),positionOffset:"end"}),e.conversion.for("upcast").elementToElement({view:cT,model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>aT(e.parent)?t.createContainerElement(o?"caption":"figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>{if(!aT(e.parent))return null;const s=t.createEditableElement(o?"caption":"figcaption");return t.setCustomProperty("tableCaption",!0,s),s.placeholder=n("Enter table caption"),Yn({view:i,element:s,keepOnFocus:!0}),Jh(s,t)}}),(s=e.model).document.registerPostFixer((e=>function(e,t){const i=t.document.differ.getChanges();let n=!1;for(const t of i){if("insert"!=t.type)continue;const i=t.position.parent;if(i.is("element","table")||"table"==t.name){const o="table"==t.name?t.position.nodeAfter:i,s=Array.from(o.getChildren()).filter((e=>e.is("element","caption"))),r=s.shift();if(!r)continue;for(const t of s)e.move(e.createRangeIn(t),r,"end"),e.remove(t);r.nextSibling&&(e.move(e.createRangeOn(r),o,"end"),n=!0),n=!!s.length||n}}return n}(e,s)))}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?ea.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}}class hT extends ad{static get pluginName(){return"TableCaptionUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view,i=e.t;e.ui.componentFactory.add("toggleTableCaption",(n=>{const o=e.commands.get("toggleTableCaption"),s=new Bn(n);return s.set({icon:Qf,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),s.bind("label").to(o,"value",(e=>i(e?"Toggle caption off":"Toggle caption on"))),this.listenTo(s,"execute",(()=>{if(e.execute("toggleTableCaption",{focusCaptionOnShow:!0}),o.value){const i=function(e){const t=C_(e);return t?lT(t):null}(e.model.document.selection),n=e.editing.mapper.toViewElement(i);if(!n)return;t.scrollToTheSelection(),t.change((e=>{e.addClass("table__caption_highlighted",n)}))}e.editing.view.focus()})),s}))}}function mT(e){if(e.is("$text")||e.is("$textProxy"))return e.data;const t=e;let i="",n=null;for(const e of t.getChildren()){const t=mT(e);n&&n.is("element")&&(i+="\n"),i+=t,n=e}return i}const gT={"(":")","[":"]","{":"}"};class fT extends cd{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"mention")}execute(e){const t=this.editor.model,i=t.document.selection,n="string"==typeof e.mention?{id:e.mention}:e.mention,o=n.id,s=e.range||i.getFirstRange();if(!t.canEditAt(s))return;const r=e.text||o,a=bT({_text:r,id:o},n);if(!o.startsWith(e.marker))throw new x("mentioncommand-incorrect-id",this);t.change((e=>{const n=si(i.getAttributes()),o=new Map(n.entries());o.set("mention",a);const l=t.insertContent(e.createText(r,o),s),c=l.start.nodeBefore,u=l.end.nodeAfter,d=u&&u.is("$text")&&u.data.startsWith(" ");let h=!1;if(c&&u&&c.is("$text")&&u.is("$text")){const e=c.data.slice(-1),t=e in gT,i=t&&u.data.startsWith(gT[e]);h=t&&i}h||d||t.insertContent(e.createText(" ",n),s.start.getShiftedBy(r.length))}))}}class pT extends ad{static get pluginName(){return"MentionEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model,i=t.document;t.schema.extend("$text",{allowAttributes:"mention"}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",attributes:"data-mention",classes:"mention"},model:{key:"mention",value:e=>wT(e)}}),e.conversion.for("downcast").attributeToElement({model:"mention",view:yT}),e.conversion.for("downcast").add(vT),i.registerPostFixer((e=>function(e,t,i){const n=t.differ.getChanges();let o=!1;for(const t of n){if("attribute"==t.type)continue;const n=t.position;if("$text"==t.name){const t=n.textNode&&n.textNode.nextSibling;o=kT(n.textNode,e)||o,o=kT(t,e)||o,o=kT(n.nodeBefore,e)||o,o=kT(n.nodeAfter,e)||o}if("$text"!=t.name&&"insert"==t.type){const t=n.nodeAfter;for(const i of e.createRangeIn(t).getItems())o=kT(i,e)||o}if("insert"==t.type&&i.isInline(t.name)){const t=n.nodeAfter&&n.nodeAfter.nextSibling;o=kT(n.nodeBefore,e)||o,o=kT(t,e)||o}}return o}(e,i,t.schema))),i.registerPostFixer((e=>function(e,t){const i=t.differ.getChanges();let n=!1;for(const t of i)if("attribute"===t.type&&"mention"!=t.attributeKey){const i=t.range.start.nodeBefore,o=t.range.end.nodeAfter;for(const s of[i,o])_T(s)&&s.getAttribute(t.attributeKey)!=t.attributeNewValue&&(e.setAttribute(t.attributeKey,t.attributeNewValue,s),n=!0)}return n}(e,i))),i.registerPostFixer((e=>function(e,t){const i=t.selection,n=i.focus;return!!(i.isCollapsed&&i.hasAttribute("mention")&&function(e){const t=e.isAtStart;return e.nodeBefore&&e.nodeBefore.is("$text")||t}(n))&&(e.removeSelectionAttribute("mention"),!0)}(e,i))),e.commands.add("mention",new fT(e))}}function bT(e,t){return Object.assign({uid:_()},e,t||{})}function wT(e,t){const i=e.getAttribute("data-mention"),n=e.getChild(0);if(n)return bT({id:i,_text:n.data},t)}function vT(e){e.on("attribute:mention",((e,t,i)=>{const n=t.attributeNewValue;if(!t.item.is("$textProxy")||!n)return;const o=t.range.start;(o.textNode||o.nodeAfter).data!=n._text&&i.consumable.consume(t.item,e.name)}),{priority:"highest"})}function yT(e,{writer:t}){if(!e)return;const i={class:"mention","data-mention":e.id},n={id:e.uid,priority:20};return t.createAttributeElement("span",i,n)}function _T(e){return!(!e||!e.is("$text")&&!e.is("$textProxy")||!e.hasAttribute("mention"))&&e.data!=e.getAttribute("mention")._text}function kT(e,t){return!!_T(e)&&(t.removeAttribute("mention",e),!0)}class CT extends Cu{selected;position;constructor(e){super(e),this.extendTemplate({attributes:{class:["ck-mentions"],tabindex:"-1"}})}selectFirst(){this.select(0)}selectNext(){const e=this.selected,t=this.items.getIndex(e);this.select(t+1)}selectPrevious(){const e=this.selected,t=this.items.getIndex(e);this.select(t-1)}select(e){let t=0;e>0&&e{i?(this.domElement.classList.add("ck-on"),this.domElement.classList.remove("ck-off")):(this.domElement.classList.add("ck-off"),this.domElement.classList.remove("ck-on"))})),this.listenTo(this.domElement,"click",(()=>{this.fire("execute")}))}render(){super.render(),this.element=this.domElement}focus(){this.domElement.focus()}}class AT extends dn{item;marker;highlight(){this.children.first.isOn=!0}removeHighlight(){this.children.first.isOn=!1}}const TT=[Rt.arrowup,Rt.arrowdown,Rt.esc],ET=[Rt.enter,Rt.tab];class ST extends ad{_mentionsView;_mentionsConfigurations;_balloon;_items=new Xt;_lastRequested;_requestFeedDebounced;static get pluginName(){return"MentionUI"}static get isOfficialPlugin(){return!0}static get requires(){return[hm]}constructor(e){super(e),this._mentionsView=this._createMentionView(),this._mentionsConfigurations=new Map,this._requestFeedDebounced=Wi(this._requestFeed,100),e.config.define("mention",{feeds:[]})}init(){const e=this.editor,t=e.config.get("mention.commitKeys")||ET,i=TT.concat(t);this._balloon=e.plugins.get(hm),e.editing.view.document.on("keydown",((e,n)=>{var o;o=n.keyCode,i.includes(o)&&this._isUIVisible&&(n.preventDefault(),e.stop(),n.keyCode==Rt.arrowdown&&this._mentionsView.selectNext(),n.keyCode==Rt.arrowup&&this._mentionsView.selectPrevious(),t.includes(n.keyCode)&&this._mentionsView.executeSelected(),n.keyCode==Rt.esc&&this._hideUIAndRemoveMarker())}),{priority:"highest"}),mn({emitter:this._mentionsView,activator:()=>this._isUIVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUIAndRemoveMarker()});const n=e.config.get("mention.feeds");for(const e of n){const{feed:t,marker:i,dropdownLimit:n}=e;if(!RT(i))throw new x("mentionconfig-incorrect-marker",null,{marker:i});const o={marker:i,feedCallback:"function"==typeof t?t.bind(this.editor):OT(t),itemRenderer:e.itemRenderer,dropdownLimit:n};this._mentionsConfigurations.set(i,o)}this._setupTextWatcher(n),this.listenTo(e,"change:isReadOnly",(()=>{this._hideUIAndRemoveMarker()})),this.on("requestFeed:response",((e,t)=>this._handleFeedResponse(t))),this.on("requestFeed:error",(()=>this._hideUIAndRemoveMarker()))}destroy(){super.destroy(),this._mentionsView.destroy()}get _isUIVisible(){return this._balloon.visibleView===this._mentionsView}_createMentionView(){const e=this.editor.locale,t=new CT(e);return t.items.bindTo(this._items).using((i=>{const{item:n,marker:o}=i,{dropdownLimit:s}=this._mentionsConfigurations.get(o),r=s||this.editor.config.get("mention.dropdownLimit")||10;if(t.items.length>=r)return null;const a=new AT(e),l=this._renderItem(n,o);return l.delegate("execute").to(a),a.children.add(l),a.item=n,a.marker=o,a.on("execute",(()=>{t.fire("execute",{item:n,marker:o})})),a})),t.on("execute",((e,t)=>{const i=this.editor,n=i.model,o=t.item,s=t.marker,r=i.model.markers.get("mention"),a=n.createPositionAt(n.document.selection.focus),l=n.createPositionAt(r.getStart()),c=n.createRange(l,a);this._hideUIAndRemoveMarker(),i.execute("mention",{mention:o,text:o.text,marker:s,range:c}),i.editing.view.focus()})),t}_getItemRenderer(e){const{itemRenderer:t}=this._mentionsConfigurations.get(e);return t}_requestFeed(e,t){this._lastRequested=t;const{feedCallback:i}=this._mentionsConfigurations.get(e),n=i(t);n instanceof Promise?n.then((i=>{this._lastRequested==t?this.fire("requestFeed:response",{feed:i,marker:e,feedText:t}):this.fire("requestFeed:discarded",{feed:i,marker:e,feedText:t})})).catch((t=>{this.fire("requestFeed:error",{error:t}),A("mention-feed-callback-error",{marker:e})})):this.fire("requestFeed:response",{feed:n,marker:e,feedText:t})}_setupTextWatcher(e){const t=this.editor,i=e.map((e=>({...e,pattern:VT(e.marker,e.minimumCharacters||0)}))),n=new bh(t.model,function(e){return t=>{const i=IT(e,t);if(!i)return!1;let n=0;0!==i.position&&(n=i.position-1);const o=t.substring(n);return i.pattern.test(o)}}(i));n.on("matched",((e,n)=>{const o=IT(i,n.text),s=t.model.document.selection.focus,r=t.model.createPositionAt(s.parent,o.position);if(function(e){const t=e.textNode&&e.textNode.hasAttribute("mention"),i=e.nodeBefore;return t||i&&i.is("$text")&&i.hasAttribute("mention")}(s)||function(e){const t=e.nodeAfter;return t&&t.is("$text")&&t.hasAttribute("mention")}(r))return void this._hideUIAndRemoveMarker();const a=function(e,t){let i=0;0!==e.position&&(i=e.position-1);const n=VT(e.marker,0);return t.substring(i).match(n)[2]}(o,n.text),l=o.marker.length+a.length,c=s.getShiftedBy(-l),u=s.getShiftedBy(-a.length),d=t.model.createRange(c,u);if(LT(t)){const e=t.model.markers.get("mention");t.model.change((t=>{t.updateMarker(e,{range:d})}))}else t.model.change((e=>{e.addMarker("mention",{range:d,usingOperation:!1,affectsData:!1})}));this._requestFeedDebounced(o.marker,a)})),n.on("unmatched",(()=>{this._hideUIAndRemoveMarker()}));const o=t.commands.get("mention");return n.bind("isEnabled").to(o),n}_handleFeedResponse(e){const{feed:t,marker:i}=e;if(!LT(this.editor))return;this._items.clear();for(const e of t){const t="object"!=typeof e?{id:e,text:e}:e;this._items.add({item:t,marker:i})}const n=this.editor.model.markers.get("mention");this._items.length?this._showOrUpdateUI(n):this._hideUIAndRemoveMarker()}_showOrUpdateUI(e){this._isUIVisible?this._balloon.updatePosition(this._getBalloonPanelPositionData(e,this._mentionsView.position)):this._balloon.add({view:this._mentionsView,position:this._getBalloonPanelPositionData(e,this._mentionsView.position),singleViewMode:!0,balloonClassName:"ck-mention-balloon"}),this._mentionsView.position=this._balloon.view.position,this._mentionsView.selectFirst()}_hideUIAndRemoveMarker(){this._balloon.hasView(this._mentionsView)&&this._balloon.remove(this._mentionsView),LT(this.editor)&&this.editor.model.change((e=>e.removeMarker("mention"))),this._mentionsView.position=void 0}_renderItem(e,t){const i=this.editor;let n,o=e.id;const s=this._getItemRenderer(t);if(s){const t=s(e);"string"!=typeof t?n=new xT(i.locale,t):o=t}if(!n){const e=new Bn(i.locale);e.label=o,e.withText=!0,n=e}return n}_getBalloonPanelPositionData(e,t){const i=this.editor,n=i.editing,o=n.view.domConverter,s=n.mapper;return{target:()=>{let t=e.getRange();"$graveyard"==t.start.root.rootName&&(t=i.model.document.selection.getFirstRange());const n=s.toViewRange(t);return Ze.getDomRangeRects(o.viewRangeToDom(n)).pop()},limiter:()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},positions:PT(t,i.locale.uiLanguageDirection)}}}function PT(e,t){const i={caret_se:e=>({top:e.bottom+3,left:e.right,name:"caret_se",config:{withArrow:!1}}),caret_ne:(e,t)=>({top:e.top-t.height-3,left:e.right,name:"caret_ne",config:{withArrow:!1}}),caret_sw:(e,t)=>({top:e.bottom+3,left:e.right-t.width,name:"caret_sw",config:{withArrow:!1}}),caret_nw:(e,t)=>({top:e.top-t.height-3,left:e.right-t.width,name:"caret_nw",config:{withArrow:!1}})};return Object.prototype.hasOwnProperty.call(i,e)?[i[e]]:"rtl"!==t?[i.caret_se,i.caret_sw,i.caret_ne,i.caret_nw]:[i.caret_sw,i.caret_se,i.caret_nw,i.caret_ne]}function IT(e,t){let i;for(const n of e){const e=t.lastIndexOf(n.marker);e>0&&!t.substring(e-1).match(n.pattern)||(!i||e>=i.position)&&(i={marker:n.marker,position:e,minimumCharacters:n.minimumCharacters,pattern:n.pattern})}return i}function VT(e,t){const i=0==t?"*":`{${t},}`,n=r.features.isRegExpUnicodePropertySupported?"\\p{Ps}\\p{Pi}\"'":"\\(\\[{\"'";return e=e.replace(/[.*+?^${}()\-|[\]\\]/g,"\\$&"),new RegExp(`(?:^|[ ${n}])(${e})(.${i})$`,"u")}function OT(e){return t=>e.filter((e=>("string"==typeof e?e:String(e.id)).toLowerCase().includes(t.toLowerCase())))}function RT(e){return!!e}function LT(e){return e.model.markers.has("mention")}function BT(e){if(e)throw e}var MT=i(849);function NT(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)}function FT(e){return e&&"object"==typeof e?"position"in e||"type"in e?zT(e.position):"start"in e||"end"in e?zT(e):"line"in e||"column"in e?DT(e):"":""}function DT(e){return HT(e&&e.line)+":"+HT(e&&e.column)}function zT(e){return DT(e&&e.start)+"-"+DT(e&&e.end)}function HT(e){return e&&"number"==typeof e?e:1}class UT extends Error{constructor(e,t,i){super(),"string"==typeof t&&(i=t,t=void 0);let n="",o={},s=!1;if(t&&(o="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?n=e:!o.cause&&e&&(s=!0,n=e.message,o.cause=e),!o.ruleId&&!o.source&&"string"==typeof i){const e=i.indexOf(":");-1===e?o.ruleId=i:(o.source=i.slice(0,e),o.ruleId=i.slice(e+1))}if(!o.place&&o.ancestors&&o.ancestors){const e=o.ancestors[o.ancestors.length-1];e&&(o.place=e.position)}const r=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=r?r.column:void 0,this.fatal=void 0,this.file="",this.message=n,this.line=r?r.line:void 0,this.name=FT(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&"string"==typeof o.cause.stack?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}UT.prototype.file="",UT.prototype.name="",UT.prototype.reason="",UT.prototype.message="",UT.prototype.stack="",UT.prototype.column=void 0,UT.prototype.line=void 0,UT.prototype.ancestors=void 0,UT.prototype.cause=void 0,UT.prototype.fatal=void 0,UT.prototype.place=void 0,UT.prototype.ruleId=void 0,UT.prototype.source=void 0;const $T=function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');KT(e);let i,n=0,o=-1,s=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;s--;)if(47===e.codePointAt(s)){if(i){n=s+1;break}}else o<0&&(i=!0,o=s+1);return o<0?"":e.slice(n,o)}if(t===e)return"";let r=-1,a=t.length-1;for(;s--;)if(47===e.codePointAt(s)){if(i){n=s+1;break}}else r<0&&(i=!0,r=s+1),a>-1&&(e.codePointAt(s)===t.codePointAt(a--)?a<0&&(o=s):(a=-1,o=r));return n===o?o=r:o<0&&(o=e.length),e.slice(n,o)},qT=function(e){if(KT(e),0===e.length)return".";let t,i=-1,n=e.length;for(;--n;)if(47===e.codePointAt(n)){if(t){i=n;break}}else t||(t=!0);return i<0?47===e.codePointAt(0)?"/":".":1===i&&47===e.codePointAt(0)?"//":e.slice(0,i)},jT=function(e){KT(e);let t,i=e.length,n=-1,o=0,s=-1,r=0;for(;i--;){const a=e.codePointAt(i);if(47!==a)n<0&&(t=!0,n=i+1),46===a?s<0?s=i:1!==r&&(r=1):s>-1&&(r=-1);else if(t){o=i+1;break}}return s<0||n<0||0===r||1===r&&s===n-1&&s===o+1?"":e.slice(s,n)},WT=function(...e){let t,i=-1;for(;++i2){if(n=o.lastIndexOf("/"),n!==o.length-1){n<0?(o="",s=0):(o=o.slice(0,n),s=o.length-1-o.lastIndexOf("/")),r=l,a=0;continue}}else if(o.length>0){o="",s=0,r=l,a=0;continue}t&&(o=o.length>0?o+"/..":"..",s=2)}else o.length>0?o+="/"+e.slice(r+1,l):o=e.slice(r+1,l),s=l-r-1;r=l,a=0}else 46===i&&a>-1?a++:a=-1}return o}(e,!t);return 0!==i.length||t||(i="."),i.length>0&&47===e.codePointAt(e.length-1)&&(i+="/"),t?"/"+i:i}(t)},GT="/";function KT(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const JT=function(){return"/"};function YT(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}const QT=["history","path","basename","stem","extname","dirname"];class XT{constructor(e){let t;t=e?YT(e)?{path:e}:"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":JT(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i,n=-1;for(;++nt.length;let r;s&&t.push(n);try{r=e.apply(this,t)}catch(e){if(s&&i)throw e;return n(e)}s||(r&&r.then&&"function"==typeof r.then?r.then(o,n):r instanceof Error?n(r):o(r))};function n(e,...n){i||(i=!0,t(e,...n))}function o(e){n(null,e)}}(a,o)(...r):n(null,...r)}}(null,...t)},use:function(i){if("function"!=typeof i)throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}};return t}()}copy(){const e=new oE;let t=-1;for(;++t0){let[n,...s]=t;const r=i[o][1];NT(r)&&NT(n)&&(n=MT(!0,r,n)),i[o]=[e,n,...s]}}}}const sE=(new oE).freeze();function rE(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function aE(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function lE(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function cE(e){if(!NT(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function uE(e,t,i){if(!i)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function dE(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new XT(e)}function hE(e,t){const i=String(e);if("string"!=typeof t)throw new TypeError("Expected character");let n=0,o=i.indexOf(t);for(;-1!==o;)n++,o=i.indexOf(t,o+t.length);return n}const mE=AE(/[A-Za-z]/),gE=AE(/[\dA-Za-z]/),fE=AE(/[#-'*+\--9=?A-Z^-~]/);function pE(e){return null!==e&&(e<32||127===e)}const bE=AE(/\d/),wE=AE(/[\dA-Fa-f]/),vE=AE(/[!-/:-@[-`{-~]/);function yE(e){return null!==e&&e<-2}function _E(e){return null!==e&&(e<0||32===e)}function kE(e){return-2===e||-1===e||32===e}const CE=AE(/\p{P}|\p{S}/u),xE=AE(/\s/);function AE(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}const TE=function(e){if(null==e)return SE;if("function"==typeof e)return EE(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let i=-1;for(;++i":"")+")"})}return u;function u(){let c,u,d,h=PE;if((!t||s(o,a,l[l.length-1]||void 0))&&(h=function(e){return Array.isArray(e)?e:"number"==typeof e?[true,e]:null==e?PE:[e]}(i(o,l)),h[0]===IE))return h;if("children"in o&&o.children){const t=o;if(t.children&&h[0]!==VE)for(u=(n?t.children.length:-1)+r,d=l.concat(t);u>-1&&u0?{type:"text",value:s}:void 0),!1===s?n.lastIndex=i+1:(a!==i&&u.push({type:"text",value:e.value.slice(a,i)}),Array.isArray(s)?u.push(...s):s&&u.push(s),a=i+d[0].length,c=!0),!n.global)break;d=n.exec(e.value)}return c?(a?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let i=t[0],n=i.indexOf(")");const o=hE(e,"(");let s=hE(e,")");for(;-1!==n&&o>s;)e+=i.slice(0,n+1),i=i.slice(n+1),n=i.indexOf(")"),s++;return[e,i]}(i+n);if(!r[0])return!1;const a={type:"link",title:null,url:s+t+r[0],children:[{type:"text",value:t+r[0]}]};return r[1]?[a,{type:"text",value:r[1]}]:a}function WE(e,t,i,n){return!(!GE(n,!0)||/[-\d_]$/.test(i))&&{type:"link",title:null,url:"mailto:"+t+"@"+i,children:[{type:"text",value:t+"@"+i}]}}function GE(e,t){const i=e.input.charCodeAt(e.index-1);return(0===e.index||xE(i)||CE(i))&&(!t||47!==i)}function KE(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}function JE(){this.buffer()}function YE(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function QE(){this.buffer()}function XE(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function ZE(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=KE(this.sliceSerialize(e)).toLowerCase(),i.label=t}function eS(e){this.exit(e)}function tS(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=KE(this.sliceSerialize(e)).toLowerCase(),i.label=t}function iS(e){this.exit(e)}function nS(e,t,i,n){const o=i.createTracker(n);let s=o.move("[^");const r=i.enter("footnoteReference"),a=i.enter("reference");return s+=o.move(i.safe(i.associationId(e),{after:"]",before:s})),a(),r(),s+=o.move("]"),s}function oS(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:function(e,i,n,o){const s=n.createTracker(o);let r=s.move("[^");const a=n.enter("footnoteDefinition"),l=n.enter("label");return r+=s.move(n.safe(n.associationId(e),{before:r,after:"]"})),l(),r+=s.move("]:"),e.children&&e.children.length>0&&(s.shift(4),r+=s.move((t?"\n":" ")+n.indentLines(n.containerFlow(e,s.current()),t?rS:sS))),a(),r},footnoteReference:nS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function sS(e,t,i){return 0===t?e:rS(e,0,i)}function rS(e,t,i){return(i?"":" ")+e}nS.peek=function(){return"["};const aS=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function lS(e){this.enter({type:"delete",children:[]},e)}function cS(e){this.exit(e)}function uS(e,t,i,n){const o=i.createTracker(n),s=i.enter("strikethrough");let r=o.move("~~");return r+=i.containerPhrasing(e,{...o.current(),before:r,after:"~"}),r+=o.move("~~"),s(),r}function dS(e){return e.length}function hS(e){const t="string"==typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:82===t||114===t?114:0}function mS(e,t,i){return">"+(i?"":" ")+e}function gS(e,t){return fS(e,t.inConstruct,!0)&&!fS(e,t.notInConstruct,!1)}function fS(e,t,i){if("string"==typeof t&&(t=[t]),!t||0===t.length)return i;let n=-1;for(;++n",...l.current()})),c+=l.move(">")):(a=i.enter("destinationRaw"),c+=l.move(i.safe(e.url,{before:c,after:e.title?" ":")",...l.current()}))),a(),e.title&&(a=i.enter(`title${s}`),c+=l.move(" "+o),c+=l.move(i.safe(e.title,{before:c,after:o,...l.current()})),c+=l.move(o),a()),c+=l.move(")"),r(),c}function OS(e,t,i,n){const o=e.referenceType,s=i.enter("imageReference");let r=i.enter("label");const a=i.createTracker(n);let l=a.move("![");const c=i.safe(e.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),r();const u=i.stack;i.stack=[],r=i.enter("reference");const d=i.safe(i.associationId(e),{before:l,after:"]",...a.current()});return r(),i.stack=u,s(),"full"!==o&&c&&c===d?"shortcut"===o?l=l.slice(0,-1):l+=a.move("]"):l+=a.move(d+"]"),l}function RS(e,t,i){let n=e.value||"",o="`",s=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(n);)o+="`";for(/[^ \r\n]/.test(n)&&(/^[ \r\n]/.test(n)&&/[ \r\n]$/.test(n)||/^`|`$/.test(n))&&(n=" "+n+" ");++s\u007F]/.test(e.url))}function BS(e,t,i,n){const o=vS(i),s='"'===o?"Quote":"Apostrophe",r=i.createTracker(n);let a,l;if(LS(e,i)){const t=i.stack;i.stack=[],a=i.enter("autolink");let n=r.move("<");return n+=r.move(i.containerPhrasing(e,{before:n,after:">",...r.current()})),n+=r.move(">"),a(),i.stack=t,n}a=i.enter("link"),l=i.enter("label");let c=r.move("[");return c+=r.move(i.containerPhrasing(e,{before:c,after:"](",...r.current()})),c+=r.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=i.enter("destinationLiteral"),c+=r.move("<"),c+=r.move(i.safe(e.url,{before:c,after:">",...r.current()})),c+=r.move(">")):(l=i.enter("destinationRaw"),c+=r.move(i.safe(e.url,{before:c,after:e.title?" ":")",...r.current()}))),l(),e.title&&(l=i.enter(`title${s}`),c+=r.move(" "+o),c+=r.move(i.safe(e.title,{before:c,after:o,...r.current()})),c+=r.move(o),l()),c+=r.move(")"),a(),c}function MS(e,t,i,n){const o=e.referenceType,s=i.enter("linkReference");let r=i.enter("label");const a=i.createTracker(n);let l=a.move("[");const c=i.containerPhrasing(e,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),r();const u=i.stack;i.stack=[],r=i.enter("reference");const d=i.safe(i.associationId(e),{before:l,after:"]",...a.current()});return r(),i.stack=u,s(),"full"!==o&&c&&c===d?"shortcut"===o?l=l.slice(0,-1):l+=a.move("]"):l+=a.move(d+"]"),l}function NS(e){const t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function FS(e){const t=e.options.rule||"*";if("*"!==t&&"-"!==t&&"_"!==t)throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}IS.peek=function(){return"<"},VS.peek=function(){return"!"},OS.peek=function(){return"!"},RS.peek=function(){return"`"},BS.peek=function(e,t,i){return LS(e,i)?"<":"["},MS.peek=function(){return"["};const DS=TE(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function zS(e,t,i,n){const o=function(e){const t=e.options.strong||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}(i),s=i.enter("strong"),r=i.createTracker(n),a=r.move(o+o);let l=r.move(i.containerPhrasing(e,{after:o,before:a,...r.current()}));const c=l.charCodeAt(0),u=kS(n.before.charCodeAt(n.before.length-1),c,o);u.inside&&(l=yS(c)+l.slice(1));const d=l.charCodeAt(l.length-1),h=kS(n.after.charCodeAt(0),d,o);h.inside&&(l=l.slice(0,-1)+yS(d));const m=r.move(o+o);return s(),i.attentionEncodeSurroundingInfo={after:h.outside,before:u.outside},a+l+m}zS.peek=function(e,t,i){return i.options.strong||"*"};const HS={blockquote:function(e,t,i,n){const o=i.enter("blockquote"),s=i.createTracker(n);s.move("> "),s.shift(2);const r=i.indentLines(i.containerFlow(e,s.current()),mS);return o(),r},break:pS,code:function(e,t,i,n){const o=function(e){const t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(i),s=e.value||"",r="`"===o?"GraveAccent":"Tilde";if(bS(e,i)){const e=i.enter("codeIndented"),t=i.indentLines(s,wS);return e(),t}const a=i.createTracker(n),l=o.repeat(Math.max(function(e,t){const i=String(e);let n=i.indexOf(t),o=n,s=0,r=0;if("string"!=typeof t)throw new TypeError("Expected substring");for(;-1!==n;)n===o?++s>r&&(r=s):s=1,o=n+t.length,n=i.indexOf(t,o);return r}(s,o)+1,3)),c=i.enter("codeFenced");let u=a.move(l);if(e.lang){const t=i.enter(`codeFencedLang${r}`);u+=a.move(i.safe(e.lang,{before:u,after:" ",encode:["`"],...a.current()})),t()}if(e.lang&&e.meta){const t=i.enter(`codeFencedMeta${r}`);u+=a.move(" "),u+=a.move(i.safe(e.meta,{before:u,after:"\n",encode:["`"],...a.current()})),t()}return u+=a.move("\n"),s&&(u+=a.move(s+"\n")),u+=a.move(l),c(),u},definition:function(e,t,i,n){const o=vS(i),s='"'===o?"Quote":"Apostrophe",r=i.enter("definition");let a=i.enter("label");const l=i.createTracker(n);let c=l.move("[");return c+=l.move(i.safe(i.associationId(e),{before:c,after:"]",...l.current()})),c+=l.move("]: "),a(),!e.url||/[\0- \u007F]/.test(e.url)?(a=i.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(i.safe(e.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=i.enter("destinationRaw"),c+=l.move(i.safe(e.url,{before:c,after:e.title?" ":"\n",...l.current()}))),a(),e.title&&(a=i.enter(`title${s}`),c+=l.move(" "+o),c+=l.move(i.safe(e.title,{before:c,after:o,...l.current()})),c+=l.move(o),a()),r(),c},emphasis:CS,hardBreak:pS,heading:function(e,t,i,n){const o=Math.max(Math.min(6,e.depth||1),1),s=i.createTracker(n);if(PS(e,i)){const t=i.enter("headingSetext"),n=i.enter("phrasing"),r=i.containerPhrasing(e,{...s.current(),before:"\n",after:"\n"});return n(),t(),r+"\n"+(1===o?"=":"-").repeat(r.length-(Math.max(r.lastIndexOf("\r"),r.lastIndexOf("\n"))+1))}const r="#".repeat(o),a=i.enter("headingAtx"),l=i.enter("phrasing");s.move(r+" ");let c=i.containerPhrasing(e,{before:"# ",after:"\n",...s.current()});return/^[\t ]/.test(c)&&(c=yS(c.charCodeAt(0))+c.slice(1)),c=c?r+" "+c:r,i.options.closeAtx&&(c+=" "+r),l(),a(),c},html:IS,image:VS,imageReference:OS,inlineCode:RS,link:BS,linkReference:MS,list:function(e,t,i,n){const o=i.enter("list"),s=i.bulletCurrent;let r=e.ordered?function(e){const t=e.options.bulletOrdered||".";if("."!==t&&")"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}(i):NS(i);const a=e.ordered?"."===r?")":".":function(e){const t=NS(e),i=e.options.bulletOther;if(!i)return"*"===t?"-":"*";if("*"!==i&&"+"!==i&&"-"!==i)throw new Error("Cannot serialize items with `"+i+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(i===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+i+"`) to be different");return i}(i);let l=!(!t||!i.bulletLastUsed)&&r===i.bulletLastUsed;if(!e.ordered){const t=e.children?e.children[0]:void 0;if("*"!==r&&"-"!==r||!t||t.children&&t.children[0]||"list"!==i.stack[i.stack.length-1]||"listItem"!==i.stack[i.stack.length-2]||"list"!==i.stack[i.stack.length-3]||"listItem"!==i.stack[i.stack.length-4]||0!==i.indexStack[i.indexStack.length-1]||0!==i.indexStack[i.indexStack.length-2]||0!==i.indexStack[i.indexStack.length-3]||(l=!0),FS(i)===r&&t){let t=-1;for(;++t-1?t.start:1)+(!1===i.options.incrementListMarker?0:t.children.indexOf(e))+s);let r=s.length+1;("tab"===o||"mixed"===o&&(t&&"list"===t.type&&t.spread||e.spread))&&(r=4*Math.ceil(r/4));const a=i.createTracker(n);a.move(s+" ".repeat(r-s.length)),a.shift(r);const l=i.enter("listItem"),c=i.indentLines(i.containerFlow(e,a.current()),(function(e,t,i){return t?(i?"":" ".repeat(r))+e:(i?s:s+" ".repeat(r-s.length))+e}));return l(),c},paragraph:function(e,t,i,n){const o=i.enter("paragraph"),s=i.enter("phrasing"),r=i.containerPhrasing(e,n);return s(),o(),r},root:function(e,t,i,n){return(e.children.some((function(e){return DS(e)}))?i.containerPhrasing:i.containerFlow).call(i,e,n)},strong:zS,text:function(e,t,i,n){return i.safe(e.value,n)},thematicBreak:function(e,t,i){const n=(FS(i)+(i.options.ruleSpaces?" ":"")).repeat(function(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(i));return i.options.ruleSpaces?n.slice(0,-1):n}};function US(e){const t=e._align;this.enter({type:"table",align:t.map((function(e){return"none"===e?null:e})),children:[]},e),this.data.inTable=!0}function $S(e){this.exit(e),this.data.inTable=void 0}function qS(e){this.enter({type:"tableRow",children:[]},e)}function jS(e){this.exit(e)}function WS(e){this.enter({type:"tableCell",children:[]},e)}function GS(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,KS));const i=this.stack[this.stack.length-1];i.type,i.value=t,this.exit(e)}function KS(e,t){return"|"===t?t:e}function JS(e){const t=e||{},i=t.tableCellPadding,n=t.tablePipeAlign,o=t.stringLength,s=i?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[\t :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,i){let n=HS.inlineCode(e,t,i);return i.stack.includes("tableCell")&&(n=n.replace(/\|/g,"\\$&")),n},table:function(e,t,i,n){return a(function(e,t,i){const n=e.children;let o=-1;const s=[],r=t.enter("table");for(;++oc&&(c=e[u].length);++sl[s])&&(l[s]=e)}t.push(r)}r[u]=t,a[u]=n}var d;let h=-1;if("object"==typeof n&&"length"in n)for(;++hl[h]&&(l[h]=o),g[h]=o),m[h]=r}r.splice(1,0,m),a.splice(1,0,g),u=-1;const f=[];for(;++uo?0:o+t:t>o?o:t,i=i>0?i:0,n.length<1e4)s=Array.from(n),s.unshift(t,i),e.splice(...s);else for(i&&e.splice(t,i);r0?(ZS(e,e.length,0,t),e):t}const tP={}.hasOwnProperty;function iP(e){const t={};let i=-1;for(;++i0&&!i&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),i}function yP(e,t,i,n){const o=n?n-1:Number.POSITIVE_INFINITY;let s=0;return function(n){return kE(n)?(e.enter(i),r(n)):t(n)};function r(n){return kE(n)&&s++999||93===a&&!s||null===a||91===a||_E(a))return i(a);if(93===a){e.exit("chunkString");const s=e.exit("gfmFootnoteCallString");return o.includes(KE(n.sliceSerialize(s)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(a),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):i(a)}return _E(a)||(s=!0),r++,e.consume(a),92===a?c:l}function c(t){return 91===t||92===t||93===t?(e.consume(t),r++,l):l(t)}}function TP(e,t,i){const n=this,o=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let s,r,a=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),l};function l(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):i(t)}function c(t){if(a>999||93===t&&!r||null===t||91===t||_E(t))return i(t);if(93===t){e.exit("chunkString");const i=e.exit("gfmFootnoteDefinitionLabelString");return s=KE(n.sliceSerialize(i)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),d}return _E(t)||(r=!0),a++,e.consume(t),92===t?u:c}function u(t){return 91===t||92===t||93===t?(e.consume(t),a++,c):c(t)}function d(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),o.includes(s)||o.push(s),yP(e,h,"gfmFootnoteDefinitionWhitespace")):i(t)}function h(e){return t(e)}}function EP(e,t,i){return e.check(_P,t,e.attempt(kP,t,i))}function SP(e){e.exit("gfmFootnoteDefinition")}function PP(e,t,i){const n=[];let o=-1;for(;++o1?n(s):(e.consume(s),r++,a);if(r<2&&!t)return n(s);const c=e.exit("strikethroughSequenceTemporary"),u=_S(s);return c._open=!u||2===u&&Boolean(l),c._close=!l||2===l&&Boolean(u),i(s)}},resolveAll:function(e,t){let i=-1;for(;++i0;)t-=1,i.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];i.push(e.slice()),e.length=0;let n=i.pop();for(;n;){for(const t of n)e.push(t);n=i.pop()}this.map.length=0}}function OP(e,t){let i=!1;const n=[];for(;t-1;){const e=n.events[t][1].type;if("lineEnding"!==e&&"linePrefix"!==e)break;t--}const o=t>-1?n.events[t][1].type:null,s="tableHead"===o||"tableRow"===o?y:a;return s===y&&n.parser.lazy[n.now().line]?i(e):s(e)};function a(t){return e.enter("tableHead"),e.enter("tableRow"),function(e){return 124===e||(o=!0,r+=1),l(e)}(t)}function l(t){return null===t?i(t):yE(t)?r>1?(r=0,n.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),d):i(t):kE(t)?yP(e,l,"whitespace")(t):(r+=1,o&&(o=!1,s+=1),124===t?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),o=!0,l):(e.enter("data"),c(t)))}function c(t){return null===t||124===t||_E(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return 92===t||124===t?(e.consume(t),c):c(t)}function d(t){return n.interrupt=!1,n.parser.lazy[n.now().line]?i(t):(e.enter("tableDelimiterRow"),o=!1,kE(t)?yP(e,h,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):h(t))}function h(t){return 45===t||58===t?g(t):124===t?(o=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),m):v(t)}function m(t){return kE(t)?yP(e,g,"whitespace")(t):g(t)}function g(t){return 58===t?(r+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),f):45===t?(r+=1,f(t)):null===t||yE(t)?w(t):v(t)}function f(t){return 45===t?(e.enter("tableDelimiterFiller"),p(t)):v(t)}function p(t){return 45===t?(e.consume(t),p):58===t?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),b):(e.exit("tableDelimiterFiller"),b(t))}function b(t){return kE(t)?yP(e,w,"whitespace")(t):w(t)}function w(i){return 124===i?h(i):(null===i||yE(i))&&o&&s===r?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(i)):v(i)}function v(e){return i(e)}function y(t){return e.enter("tableRow"),_(t)}function _(i){return 124===i?(e.enter("tableCellDivider"),e.consume(i),e.exit("tableCellDivider"),_):null===i||yE(i)?(e.exit("tableRow"),t(i)):kE(i)?yP(e,_,"whitespace")(i):(e.enter("data"),k(i))}function k(t){return null===t||124===t||_E(t)?(e.exit("data"),_(t)):(e.consume(t),92===t?C:k)}function C(t){return 92===t||124===t?(e.consume(t),k):k(t)}}function LP(e,t){let i,n,o,s=-1,r=!0,a=0,l=[0,0,0,0],c=[0,0,0,0],u=!1,d=0;const h=new VP;for(;++si[2]+1){const t=i[2]+1,n=i[3]-i[2]-1;e.add(t,n,[])}}e.add(i[3]+1,0,[["exit",r,t]])}return void 0!==o&&(s.end=Object.assign({},NP(t.events,o)),e.add(o,0,[["exit",s,t]]),s=void 0),s}function MP(e,t,i,n,o){const s=[],r=NP(t.events,i);o&&(o.end=Object.assign({},r),s.push(["exit",o,t])),n.end=Object.assign({},r),s.push(["exit",n,t]),e.add(i+1,0,s)}function NP(e,t){const i=e[t],n="enter"===i[0]?"start":"end";return i[1][n]}const FP={name:"tasklistCheck",tokenize:function(e,t,i){const n=this;return function(t){return null===n.previous&&n._gfmTasklistFirstContentOfListItem?(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),o):i(t)};function o(t){return _E(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),s):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),s):i(t)}function s(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),r):i(t)}function r(n){return yE(n)?t(n):kE(n)?e.check({tokenize:DP},t,i)(n):i(n)}}};function DP(e,t,i){return yP(e,(function(e){return null===e?i(e):t(e)}),"whitespace")}const zP={};function HP(e){const t=e||zP,i=this.data(),n=i.micromarkExtensions||(i.micromarkExtensions=[]),o=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),s=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);n.push(function(e){return iP([{text:mP},{document:{91:{name:"gfmFootnoteDefinition",tokenize:TP,continuation:{tokenize:EP},exit:SP}},text:{91:{name:"gfmFootnoteCall",tokenize:AP},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:CP,resolveTo:xP}}},IP(e),{flow:{null:{name:"table",tokenize:RP,resolveAll:LP}}},{text:{91:FP}}])}(t)),o.push([{transforms:[qE],enter:{literalAutolink:FE,literalAutolinkEmail:DE,literalAutolinkHttp:DE,literalAutolinkWww:DE},exit:{literalAutolink:$E,literalAutolinkEmail:UE,literalAutolinkHttp:zE,literalAutolinkWww:HE}},{enter:{gfmFootnoteCallString:JE,gfmFootnoteCall:YE,gfmFootnoteDefinitionLabelString:QE,gfmFootnoteDefinition:XE},exit:{gfmFootnoteCallString:ZE,gfmFootnoteCall:eS,gfmFootnoteDefinitionLabelString:tS,gfmFootnoteDefinition:iS}},{canContainEols:["delete"],enter:{strikethrough:lS},exit:{strikethrough:cS}},{enter:{table:US,tableData:WS,tableHeader:WS,tableRow:qS},exit:{codeText:GS,table:$S,tableData:jS,tableHeader:jS,tableRow:jS}},{exit:{taskListCheckValueChecked:YS,taskListCheckValueUnchecked:YS,paragraph:QS}}]),s.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:ME,notInConstruct:NE},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:ME,notInConstruct:NE},{character:":",before:"[ps]",after:"\\/",inConstruct:ME,notInConstruct:NE}]},oS(e),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:aS}],handlers:{delete:uS}},JS(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:XS}}]}}(t))}class UP{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return ethis.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(e,t,i){const n=t||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-n,Number.POSITIVE_INFINITY);return i&&$P(this.left,i),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),$P(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),$P(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(es))return;const i=t.events.length;let o,a,l=i;for(;l--;)if("exit"===t.events[l][0]&&"chunkFlow"===t.events[l][1].type){if(o){a=t.events[l][1].end;break}o=!0}for(b(r),e=i;en;){const n=i[o];t.containerState=n[1],n[0].exit.call(t,e)}i.length=n}function w(){n.write([null]),o=void 0,n=void 0,t.containerState._closeFlow=void 0}}},KP={tokenize:function(e,t,i){return yP(e,e.attempt(this.parser.constructs.document,t,i),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},JP={resolve:function(e){return qP(e),e},tokenize:function(e,t){let i;return function(t){return e.enter("content"),i=e.enter("chunkContent",{contentType:"content"}),n(t)};function n(t){return null===t?o(t):yE(t)?e.check(YP,s,o)(t):(e.consume(t),n)}function o(i){return e.exit("chunkContent"),e.exit("content"),t(i)}function s(t){return e.consume(t),e.exit("chunkContent"),i.next=e.enter("chunkContent",{contentType:"content",previous:i}),i=i.next,n}}},YP={partial:!0,tokenize:function(e,t,i){const n=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),yP(e,o,"linePrefix")};function o(o){if(null===o||yE(o))return i(o);const s=n.events[n.events.length-1];return!n.parser.constructs.disable.null.includes("codeIndented")&&s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(n.parser.constructs.flow,i,t)(o)}}},QP={tokenize:function(e){const t=this,i=e.attempt(_P,(function(n){if(null!==n)return e.enter("lineEndingBlank"),e.consume(n),e.exit("lineEndingBlank"),t.currentConstruct=void 0,i;e.consume(n)}),e.attempt(this.parser.constructs.flowInitial,n,yP(e,e.attempt(this.parser.constructs.flow,n,e.attempt(JP,n)),"linePrefix")));return i;function n(n){if(null!==n)return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),t.currentConstruct=void 0,i;e.consume(n)}}},XP={resolveAll:iI()},ZP=tI("string"),eI=tI("text");function tI(e){return{resolveAll:iI("text"===e?nI:void 0),tokenize:function(t){const i=this,n=this.parser.constructs[e],o=t.attempt(n,s,r);return s;function s(e){return l(e)?o(e):r(e)}function r(e){if(null!==e)return t.enter("data"),t.consume(e),a;t.consume(e)}function a(e){return l(e)?(t.exit("data"),o(e)):(t.consume(e),a)}function l(e){if(null===e)return!0;const t=n[e];let o=-1;if(t)for(;++o=3&&(null===s||yE(s))?(e.exit("thematicBreak"),t(s)):i(s)}function r(t){return t===n?(e.consume(t),o++,r):(e.exit("thematicBreakSequence"),kE(t)?yP(e,s,"whitespace")(t):s(t))}}},sI={continuation:{tokenize:function(e,t,i){const n=this;return n.containerState._closeFlow=void 0,e.check(_P,(function(i){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,yP(e,t,"listItemIndent",n.containerState.size+1)(i)}),(function(i){return n.containerState.furtherBlankLines||!kE(i)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,o(i)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,e.attempt(aI,t,o)(i))}));function o(o){return n.containerState._closeFlow=!0,n.interrupt=void 0,yP(e,e.attempt(sI,t,i),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,i){const n=this,o=n.events[n.events.length-1];let s=o&&"linePrefix"===o[1].type?o[2].sliceSerialize(o[1],!0).length:0,r=0;return function(t){const o=n.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===o?!n.containerState.marker||t===n.containerState.marker:bE(t)){if(n.containerState.type||(n.containerState.type=o,e.enter(o,{_container:!0})),"listUnordered"===o)return e.enter("listItemPrefix"),42===t||45===t?e.check(oI,i,l)(t):l(t);if(!n.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),a(t)}return i(t)};function a(t){return bE(t)&&++r<10?(e.consume(t),a):(!n.interrupt||r<2)&&(n.containerState.marker?t===n.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),l(t)):i(t)}function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||t,e.check(_P,n.interrupt?i:c,e.attempt(rI,d,u))}function c(e){return n.containerState.initialBlankLine=!0,s++,d(e)}function u(t){return kE(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),d):i(t)}function d(i){return n.containerState.size=s+n.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(i)}}},rI={partial:!0,tokenize:function(e,t,i){const n=this;return yP(e,(function(e){const o=n.events[n.events.length-1];return!kE(e)&&o&&"listItemPrefixWhitespace"===o[1].type?t(e):i(e)}),"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},aI={partial:!0,tokenize:function(e,t,i){const n=this;return yP(e,(function(e){const o=n.events[n.events.length-1];return o&&"listItemIndent"===o[1].type&&o[2].sliceSerialize(o[1],!0).length===n.containerState.size?t(e):i(e)}),"listItemIndent",n.containerState.size+1)}},lI={continuation:{tokenize:function(e,t,i){const n=this;return function(t){return kE(t)?yP(e,o,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):o(t)};function o(n){return e.attempt(lI,t,i)(n)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,i){const n=this;return function(t){if(62===t){const i=n.containerState;return i.open||(e.enter("blockQuote",{_container:!0}),i.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),o}return i(t)};function o(i){return kE(i)?(e.enter("blockQuotePrefixWhitespace"),e.consume(i),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(i))}}};function cI(e,t,i,n,o,s,r,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return function(t){return 60===t?(e.enter(n),e.enter(o),e.enter(s),e.consume(t),e.exit(s),d):null===t||32===t||41===t||pE(t)?i(t):(e.enter(n),e.enter(r),e.enter(a),e.enter("chunkString",{contentType:"string"}),g(t))};function d(i){return 62===i?(e.enter(s),e.consume(i),e.exit(s),e.exit(o),e.exit(n),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),h(i))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(a),d(t)):null===t||60===t||yE(t)?i(t):(e.consume(t),92===t?m:h)}function m(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function g(o){return u||null!==o&&41!==o&&!_E(o)?u999||null===d||91===d||93===d&&!a||94===d&&!l&&"_hiddenFootnoteSupport"in r.parser.constructs?i(d):93===d?(e.exit(s),e.enter(o),e.consume(d),e.exit(o),e.exit(n),t):yE(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),u(d))}function u(t){return null===t||91===t||93===t||yE(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),a||(a=!kE(t)),92===t?d:u)}function d(t){return 91===t||92===t||93===t?(e.consume(t),l++,u):u(t)}}function dI(e,t,i,n,o,s){let r;return function(t){return 34===t||39===t||40===t?(e.enter(n),e.enter(o),e.consume(t),e.exit(o),r=40===t?41:t,a):i(t)};function a(i){return i===r?(e.enter(o),e.consume(i),e.exit(o),e.exit(n),t):(e.enter(s),l(i))}function l(t){return t===r?(e.exit(s),a(r)):null===t?i(t):yE(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),yP(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===r||null===t||yE(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?u:c)}function u(t){return t===r||92===t?(e.consume(t),c):c(t)}}function hI(e,t){let i;return function n(o){return yE(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i=!0,n):kE(o)?yP(e,n,i?"linePrefix":"lineSuffix")(o):t(o)}}const mI={name:"definition",tokenize:function(e,t,i){const n=this;let o;return function(t){return e.enter("definition"),function(t){return uI.call(n,e,s,i,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function s(t){return o=KE(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),r):i(t)}function r(t){return _E(t)?hI(e,a)(t):a(t)}function a(t){return cI(e,l,i,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(gI,c,c)(t)}function c(t){return kE(t)?yP(e,u,"whitespace")(t):u(t)}function u(s){return null===s||yE(s)?(e.exit("definition"),n.parser.defined.push(o),t(s)):i(s)}}},gI={partial:!0,tokenize:function(e,t,i){return function(t){return _E(t)?hI(e,n)(t):i(t)};function n(t){return dI(e,o,i,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function o(t){return kE(t)?yP(e,s,"whitespace")(t):s(t)}function s(e){return null===e||yE(e)?t(e):i(e)}}},fI={name:"codeIndented",tokenize:function(e,t,i){const n=this;return function(t){return e.enter("codeIndented"),yP(e,o,"linePrefix",5)(t)};function o(e){const t=n.events[n.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?s(e):i(e)}function s(t){return null===t?a(t):yE(t)?e.attempt(pI,s,a)(t):(e.enter("codeFlowValue"),r(t))}function r(t){return null===t||yE(t)?(e.exit("codeFlowValue"),s(t)):(e.consume(t),r)}function a(i){return e.exit("codeIndented"),t(i)}}},pI={partial:!0,tokenize:function(e,t,i){const n=this;return o;function o(t){return n.parser.lazy[n.now().line]?i(t):yE(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):yP(e,s,"linePrefix",5)(t)}function s(e){const s=n.events[n.events.length-1];return s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(e):yE(e)?o(e):i(e)}}},bI={name:"headingAtx",resolve:function(e,t){let i,n,o=e.length-2,s=3;return"whitespace"===e[s][1].type&&(s+=2),o-2>s&&"whitespace"===e[o][1].type&&(o-=2),"atxHeadingSequence"===e[o][1].type&&(s===o-1||o-4>s&&"whitespace"===e[o-2][1].type)&&(o-=s+1===o?2:4),o>s&&(i={type:"atxHeadingText",start:e[s][1].start,end:e[o][1].end},n={type:"chunkText",start:e[s][1].start,end:e[o][1].end,contentType:"text"},ZS(e,s,o-s+1,[["enter",i,t],["enter",n,t],["exit",n,t],["exit",i,t]])),e},tokenize:function(e,t,i){let n=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),o(t)}(t)};function o(t){return 35===t&&n++<6?(e.consume(t),o):null===t||_E(t)?(e.exit("atxHeadingSequence"),s(t)):i(t)}function s(i){return 35===i?(e.enter("atxHeadingSequence"),r(i)):null===i||yE(i)?(e.exit("atxHeading"),t(i)):kE(i)?yP(e,s,"whitespace")(i):(e.enter("atxHeadingText"),a(i))}function r(t){return 35===t?(e.consume(t),r):(e.exit("atxHeadingSequence"),s(t))}function a(t){return null===t||35===t||_E(t)?(e.exit("atxHeadingText"),s(t)):(e.consume(t),a)}}},wI={name:"setextUnderline",resolveTo:function(e,t){let i,n,o,s=e.length;for(;s--;)if("enter"===e[s][0]){if("content"===e[s][1].type){i=s;break}"paragraph"===e[s][1].type&&(n=s)}else"content"===e[s][1].type&&e.splice(s,1),o||"definition"!==e[s][1].type||(o=s);const r={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[n][1].type="setextHeadingText",o?(e.splice(n,0,["enter",r,t]),e.splice(o+1,0,["exit",e[i][1],t]),e[i][1].end={...e[o][1].end}):e[i][1]=r,e.push(["exit",r,t]),e},tokenize:function(e,t,i){const n=this;let o;return function(t){let r,a=n.events.length;for(;a--;)if("lineEnding"!==n.events[a][1].type&&"linePrefix"!==n.events[a][1].type&&"content"!==n.events[a][1].type){r="paragraph"===n.events[a][1].type;break}return n.parser.lazy[n.now().line]||!n.interrupt&&!r?i(t):(e.enter("setextHeadingLine"),o=t,function(t){return e.enter("setextHeadingLineSequence"),s(t)}(t))};function s(t){return t===o?(e.consume(t),s):(e.exit("setextHeadingLineSequence"),kE(t)?yP(e,r,"lineSuffix")(t):r(t))}function r(n){return null===n||yE(n)?(e.exit("setextHeadingLine"),t(n)):i(n)}}},vI=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],yI=["pre","script","style","textarea"],_I={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,i){const n=this;let o,s,r,a,l;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(a){return 33===a?(e.consume(a),u):47===a?(e.consume(a),s=!0,m):63===a?(e.consume(a),o=3,n.interrupt?t:L):mE(a)?(e.consume(a),r=String.fromCharCode(a),g):i(a)}function u(s){return 45===s?(e.consume(s),o=2,d):91===s?(e.consume(s),o=5,a=0,h):mE(s)?(e.consume(s),o=4,n.interrupt?t:L):i(s)}function d(o){return 45===o?(e.consume(o),n.interrupt?t:L):i(o)}function h(o){return o==="CDATA[".charCodeAt(a++)?(e.consume(o),6===a?n.interrupt?t:T:h):i(o)}function m(t){return mE(t)?(e.consume(t),r=String.fromCharCode(t),g):i(t)}function g(a){if(null===a||47===a||62===a||_E(a)){const l=47===a,c=r.toLowerCase();return l||s||!yI.includes(c)?vI.includes(r.toLowerCase())?(o=6,l?(e.consume(a),f):n.interrupt?t(a):T(a)):(o=7,n.interrupt&&!n.parser.lazy[n.now().line]?i(a):s?p(a):b(a)):(o=1,n.interrupt?t(a):T(a))}return 45===a||gE(a)?(e.consume(a),r+=String.fromCharCode(a),g):i(a)}function f(o){return 62===o?(e.consume(o),n.interrupt?t:T):i(o)}function p(t){return kE(t)?(e.consume(t),p):x(t)}function b(t){return 47===t?(e.consume(t),x):58===t||95===t||mE(t)?(e.consume(t),w):kE(t)?(e.consume(t),b):x(t)}function w(t){return 45===t||46===t||58===t||95===t||gE(t)?(e.consume(t),w):v(t)}function v(t){return 61===t?(e.consume(t),y):kE(t)?(e.consume(t),v):b(t)}function y(t){return null===t||60===t||61===t||62===t||96===t?i(t):34===t||39===t?(e.consume(t),l=t,_):kE(t)?(e.consume(t),y):k(t)}function _(t){return t===l?(e.consume(t),l=null,C):null===t||yE(t)?i(t):(e.consume(t),_)}function k(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||_E(t)?v(t):(e.consume(t),k)}function C(e){return 47===e||62===e||kE(e)?b(e):i(e)}function x(t){return 62===t?(e.consume(t),A):i(t)}function A(t){return null===t||yE(t)?T(t):kE(t)?(e.consume(t),A):i(t)}function T(t){return 45===t&&2===o?(e.consume(t),I):60===t&&1===o?(e.consume(t),V):62===t&&4===o?(e.consume(t),B):63===t&&3===o?(e.consume(t),L):93===t&&5===o?(e.consume(t),R):!yE(t)||6!==o&&7!==o?null===t||yE(t)?(e.exit("htmlFlowData"),E(t)):(e.consume(t),T):(e.exit("htmlFlowData"),e.check(kI,M,E)(t))}function E(t){return e.check(CI,S,M)(t)}function S(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),P}function P(t){return null===t||yE(t)?E(t):(e.enter("htmlFlowData"),T(t))}function I(t){return 45===t?(e.consume(t),L):T(t)}function V(t){return 47===t?(e.consume(t),r="",O):T(t)}function O(t){if(62===t){const i=r.toLowerCase();return yI.includes(i)?(e.consume(t),B):T(t)}return mE(t)&&r.length<8?(e.consume(t),r+=String.fromCharCode(t),O):T(t)}function R(t){return 93===t?(e.consume(t),L):T(t)}function L(t){return 62===t?(e.consume(t),B):45===t&&2===o?(e.consume(t),L):T(t)}function B(t){return null===t||yE(t)?(e.exit("htmlFlowData"),M(t)):(e.consume(t),B)}function M(i){return e.exit("htmlFlow"),t(i)}}},kI={partial:!0,tokenize:function(e,t,i){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),e.attempt(_P,t,i)}}},CI={partial:!0,tokenize:function(e,t,i){const n=this;return function(t){return yE(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):i(t)};function o(e){return n.parser.lazy[n.now().line]?i(e):t(e)}}},xI={partial:!0,tokenize:function(e,t,i){const n=this;return function(t){return null===t?i(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o)};function o(e){return n.parser.lazy[n.now().line]?i(e):t(e)}}},AI={concrete:!0,name:"codeFenced",tokenize:function(e,t,i){const n=this,o={partial:!0,tokenize:function(e,t,i){let o=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r};function r(t){return e.enter("codeFencedFence"),kE(t)?yP(e,l,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter("codeFencedFenceSequence"),c(t)):i(t)}function c(t){return t===s?(o++,e.consume(t),c):o>=a?(e.exit("codeFencedFenceSequence"),kE(t)?yP(e,u,"whitespace")(t):u(t)):i(t)}function u(n){return null===n||yE(n)?(e.exit("codeFencedFence"),t(n)):i(n)}}};let s,r=0,a=0;return function(t){return function(t){const i=n.events[n.events.length-1];return r=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,s=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(t)}(t)};function l(t){return t===s?(a++,e.consume(t),l):a<3?i(t):(e.exit("codeFencedFenceSequence"),kE(t)?yP(e,c,"whitespace")(t):c(t))}function c(i){return null===i||yE(i)?(e.exit("codeFencedFence"),n.interrupt?t(i):e.check(xI,m,w)(i)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),u(i))}function u(t){return null===t||yE(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):kE(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),yP(e,d,"whitespace")(t)):96===t&&t===s?i(t):(e.consume(t),u)}function d(t){return null===t||yE(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(t))}function h(t){return null===t||yE(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===s?i(t):(e.consume(t),h)}function m(t){return e.attempt(o,w,g)(t)}function g(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),f}function f(t){return r>0&&kE(t)?yP(e,p,"linePrefix",r+1)(t):p(t)}function p(t){return null===t||yE(t)?e.check(xI,m,w)(t):(e.enter("codeFlowValue"),b(t))}function b(t){return null===t||yE(t)?(e.exit("codeFlowValue"),p(t)):(e.consume(t),b)}function w(i){return e.exit("codeFenced"),t(i)}}},TI=document.createElement("i");function EI(e){const t="&"+e+";";TI.innerHTML=t;const i=TI.textContent;return(59!==i.charCodeAt(i.length-1)||"semi"===e)&&i!==t&&i}const SI={name:"characterReference",tokenize:function(e,t,i){const n=this;let o,s,r=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),a};function a(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),o=31,s=gE,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,s=wE,c):(e.enter("characterReferenceValue"),o=7,s=bE,c(t))}function c(a){if(59===a&&r){const o=e.exit("characterReferenceValue");return s!==gE||EI(n.sliceSerialize(o))?(e.enter("characterReferenceMarker"),e.consume(a),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):i(a)}return s(a)&&r++1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;const d={...e[i][1].end},h={...e[u][1].start};NI(d,-a),NI(h,a),s={type:a>1?"strongSequence":"emphasisSequence",start:d,end:{...e[i][1].end}},r={type:a>1?"strongSequence":"emphasisSequence",start:{...e[u][1].start},end:h},o={type:a>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[u][1].start}},n={type:a>1?"strong":"emphasis",start:{...s.start},end:{...r.end}},e[i][1].end={...s.start},e[u][1].start={...r.end},l=[],e[i][1].end.offset-e[i][1].start.offset&&(l=eP(l,[["enter",e[i][1],t],["exit",e[i][1],t]])),l=eP(l,[["enter",n,t],["enter",s,t],["exit",s,t],["enter",o,t]]),l=eP(l,PP(t.parser.constructs.insideSpan.null,e.slice(i+1,u),t)),l=eP(l,[["exit",o,t],["enter",r,t],["exit",r,t],["exit",n,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,l=eP(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,ZS(e,i-1,u-i+3,l),u=i+l.length-c-2;break}for(u=-1;++u-1){const e=r[0];"string"==typeof e?r[0]=e.slice(n):r.shift()}s>0&&r.push(e[o].slice(0,s))}return r}(r,e)}function g(){const{_bufferIndex:e,_index:t,line:i,column:o,offset:s}=n;return{_bufferIndex:e,_index:t,line:i,column:o,offset:s}}function f(e){l=void 0,d=e,h=h(e)}function p(e,t){t.restore()}function b(e,t){return function(i,o,s){let r,d,h,m;return Array.isArray(i)?f(i):"tokenize"in i?f([i]):function(e){return function(t){const i=null!==t&&e[t],n=null!==t&&e.null;return f([...Array.isArray(i)?i:i?[i]:[],...Array.isArray(n)?n:n?[n]:[]])(t)}}(i);function f(e){return r=e,d=0,0===e.length?s:p(e[d])}function p(e){return function(i){return m=function(){const e=g(),t=u.previous,i=u.currentConstruct,o=u.events.length,s=Array.from(a);return{from:o,restore:function(){n=e,u.previous=t,u.currentConstruct=i,u.events.length=o,a=s,v()}}}(),h=e,e.partial||(u.currentConstruct=e),e.name&&u.parser.constructs.disable.null.includes(e.name)?w():e.tokenize.call(t?Object.assign(Object.create(u),t):u,c,b,w)(i)}}function b(t){return l=!0,e(h,m),o}function w(e){return l=!0,m.restore(),++d13&&i<32||i>126&&i<160||i>55295&&i<57344||i>64975&&i<65008||!(65535&~i)||65534==(65535&i)||i>1114111?"�":String.fromCodePoint(i)}const tV=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function iV(e){return e.replace(tV,nV)}function nV(e,t,i){if(t)return t;if(35===i.charCodeAt(0)){const e=i.charCodeAt(1),t=120===e||88===e;return eV(i.slice(t?2:1),t?16:10)}return EI(i)||e}const oV={}.hasOwnProperty;function sV(t,i,n){return i&&"object"==typeof i&&(n=i,i=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(w),autolinkProtocol:u,autolinkEmail:u,atxHeading:o(f),blockQuote:o((function(){return{type:"blockquote",children:[]}})),characterEscape:u,characterReference:u,codeFenced:o(g),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:o(g,s),codeText:o((function(){return{type:"inlineCode",value:""}}),s),codeTextData:u,data:u,codeFlowValue:u,definition:o((function(){return{type:"definition",identifier:"",label:null,title:null,url:""}})),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:o((function(){return{type:"emphasis",children:[]}})),hardBreakEscape:o(p),hardBreakTrailing:o(p),htmlFlow:o(b,s),htmlFlowData:u,htmlText:o(b,s),htmlTextData:u,image:o((function(){return{type:"image",title:null,url:"",alt:null}})),label:s,link:o(w),listItem:o((function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}})),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:o(v,(function(){this.data.expectingFirstListItemValue=!0})),listUnordered:o(v),paragraph:o((function(){return{type:"paragraph",children:[]}})),reference:function(){this.data.referenceType="collapsed"},referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:o(f),strong:o((function(){return{type:"strong",children:[]}})),thematicBreak:o((function(){return{type:"thematicBreak"}}))},exit:{atxHeading:a(),atxHeadingSequence:function(e){const t=this.stack[this.stack.length-1];if(!t.depth){const i=this.sliceSerialize(e).length;t.depth=i}},autolink:a(),autolinkEmail:function(e){d.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){d.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:a(),characterEscapeValue:d,characterReferenceMarkerHexadecimal:m,characterReferenceMarkerNumeric:m,characterReferenceValue:function(e){const t=this.sliceSerialize(e),i=this.data.characterReferenceType;let n;i?(n=eV(t,"characterReferenceMarkerNumeric"===i?10:16),this.data.characterReferenceType=void 0):n=EI(t);this.stack[this.stack.length-1].value+=n},characterReference:function(e){this.stack.pop().position.end=rV(e.end)},codeFenced:a((function(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0})),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){const e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){const e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:d,codeIndented:a((function(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")})),codeText:a((function(){const e=this.resume();this.stack[this.stack.length-1].value=e})),codeTextData:d,data:d,definition:a(),definitionDestinationString:function(){const e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.label=t,i.identifier=KE(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){const e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:a(),hardBreakEscape:a(h),hardBreakTrailing:a(h),htmlFlow:a((function(){const e=this.resume();this.stack[this.stack.length-1].value=e})),htmlFlowData:d,htmlText:a((function(){const e=this.resume();this.stack[this.stack.length-1].value=e})),htmlTextData:d,image:a((function(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0})),label:function(){const e=this.stack[this.stack.length-1],t=this.resume(),i=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===i.type){const t=e.children;i.children=t}else i.alt=t},labelText:function(e){const t=this.sliceSerialize(e),i=this.stack[this.stack.length-2];i.label=iV(t),i.identifier=KE(t).toLowerCase()},lineEnding:function(e){const i=this.stack[this.stack.length-1];if(this.data.atHardBreak)return i.children[i.children.length-1].position.end=rV(e.end),void(this.data.atHardBreak=void 0);!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(i.type)&&(u.call(this,e),d.call(this,e))},link:a((function(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0})),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:function(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.label=t,i.identifier=KE(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){const e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){const e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:a((function(){this.data.setextHeadingSlurpLineEnding=void 0})),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:a(),thematicBreak:a()}};aV(t,(e||{}).mdastExtensions||[]);const i={};return function(e){let o={type:"root",children:[]};const a={stack:[o],tokenStack:[],config:t,enter:r,exit:l,buffer:s,resume:c,data:i},u=[];let d=-1;for(;++d0){const e=a.tokenStack[a.tokenStack.length-1];(e[1]||cV).call(a,void 0,e[0])}for(o.position={start:rV(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:rV(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d((e,t)=>{const i=(t,i)=>(e.set(i,t),t),n=o=>{if(e.has(o))return e.get(o);const[s,r]=t[o];switch(s){case 0:case-1:return i(r,o);case 1:{const e=i([],o);for(const t of r)e.push(n(t));return e}case 2:{const e=i({},o);for(const[t,i]of r)e[n(t)]=n(i);return e}case 3:return i(new Date(r),o);case 4:{const{source:e,flags:t}=r;return i(new RegExp(e,t),o)}case 5:{const e=i(new Map,o);for(const[t,i]of r)e.set(n(t),n(i));return e}case 6:{const e=i(new Set,o);for(const t of r)e.add(n(t));return e}case 7:{const{name:e,message:t}=r;return i(new dV[e](t),o)}case 8:return i(BigInt(r),o);case"BigInt":return i(Object(BigInt(r)),o);case"ArrayBuffer":return i(new Uint8Array(r).buffer,r);case"DataView":{const{buffer:e}=new Uint8Array(r);return i(new DataView(e),r)}}return i(new dV[s](r),o)};return n})(new Map,e)(0),mV="",{toString:gV}={},{keys:fV}=Object,pV=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const i=gV.call(e).slice(8,-1);switch(i){case"Array":return[1,mV];case"Object":return[2,mV];case"Date":return[3,mV];case"RegExp":return[4,mV];case"Map":return[5,mV];case"Set":return[6,mV];case"DataView":return[1,i]}return i.includes("Array")?[1,i]:i.includes("Error")?[7,i]:[2,i]},bV=([e,t])=>0===e&&("function"===t||"symbol"===t),wV=(e,{json:t,lossy:i}={})=>{const n=[];return((e,t,i,n)=>{const o=(e,t)=>{const o=n.push(e)-1;return i.set(t,o),o},s=n=>{if(i.has(n))return i.get(n);let[r,a]=pV(n);switch(r){case 0:{let t=n;switch(a){case"bigint":r=8,t=n.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+a);t=null;break;case"undefined":return o([-1],n)}return o([r,t],n)}case 1:{if(a){let e=n;return"DataView"===a?e=new Uint8Array(n.buffer):"ArrayBuffer"===a&&(e=new Uint8Array(n)),o([a,[...e]],n)}const e=[],t=o([r,e],n);for(const t of n)e.push(s(t));return t}case 2:{if(a)switch(a){case"BigInt":return o([a,n.toString()],n);case"Boolean":case"Number":case"String":return o([a,n.valueOf()],n)}if(t&&"toJSON"in n)return s(n.toJSON());const i=[],l=o([r,i],n);for(const t of fV(n))!e&&bV(pV(n[t]))||i.push([s(t),s(n[t])]);return l}case 3:return o([r,n.toISOString()],n);case 4:{const{source:e,flags:t}=n;return o([r,{source:e,flags:t}],n)}case 5:{const t=[],i=o([r,t],n);for(const[i,o]of n)(e||!bV(pV(i))&&!bV(pV(o)))&&t.push([s(i),s(o)]);return i}case 6:{const t=[],i=o([r,t],n);for(const i of n)!e&&bV(pV(i))||t.push(s(i));return i}}const{message:l}=n;return o([r,{name:a,message:l}],n)};return s})(!(t||i),!!t,new Map,n)(e),n},vV="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?hV(wV(e,t)):structuredClone(e):(e,t)=>hV(wV(e,t));function yV(e){const t=[];let i=-1,n=0,o=0;for(;++i55295&&s<57344){const t=e.charCodeAt(i+1);s<56320&&t>56319&&t<57344?(r=String.fromCharCode(s,t),o=1):r="�"}else r=String.fromCharCode(s);r&&(t.push(e.slice(n,i),encodeURIComponent(r)),n=i+o+1,r=""),o&&(i+=o,o=0)}return t.join("")+e.slice(n)}function _V(e,t){const i=[{type:"text",value:"↩"}];return t>1&&i.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),i}function kV(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const CV=AV("end"),xV=AV("start");function AV(e){return function(t){const i=t&&t.position&&t.position[e]||{};if("number"==typeof i.line&&i.line>0&&"number"==typeof i.column&&i.column>0)return{line:i.line,column:i.column,offset:"number"==typeof i.offset&&i.offset>-1?i.offset:void 0}}}function TV(e){const t=xV(e),i=CV(e);if(t&&i)return{start:t,end:i}}function EV(e,t){const i=t.referenceType;let n="]";if("collapsed"===i?n+="[]":"full"===i&&(n+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+n}];const o=e.all(t),s=o[0];s&&"text"===s.type?s.value="["+s.value:o.unshift({type:"text",value:"["});const r=o[o.length-1];return r&&"text"===r.type?r.value+=n:o.push({type:"text",value:n}),o}function SV(e){const t=e.spread;return null==t?e.children.length>1:t}function PV(e){const t=String(e),i=/\r?\n|\r/g;let n=i.exec(t),o=0;const s=[];for(;n;)s.push(IV(t.slice(o,n.index),o>0,!0),n[0]),o=n.index+n[0].length,n=i.exec(t);return s.push(IV(t.slice(o),o>0,!1)),s.join("")}function IV(e,t,i){let n=0,o=e.length;if(t){let t=e.codePointAt(n);for(;9===t||32===t;)n++,t=e.codePointAt(n)}if(i){let t=e.codePointAt(o-1);for(;9===t||32===t;)o--,t=e.codePointAt(o-1)}return o>n?e.slice(n,o):""}const VV={blockquote:function(e,t){const i={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,i),e.applyData(t,i)},break:function(e,t){const i={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,i),[e.applyData(t,i),{type:"text",value:"\n"}]},code:function(e,t){const i=t.value?t.value+"\n":"",n={},o=t.lang?t.lang.split(/\s+/):[];o.length>0&&(n.className=["language-"+o[0]]);let s={type:"element",tagName:"code",properties:n,children:[{type:"text",value:i}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s},delete:function(e,t){const i={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},emphasis:function(e,t){const i={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},footnoteReference:function(e,t){const i="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=String(t.identifier).toUpperCase(),o=yV(n.toLowerCase()),s=e.footnoteOrder.indexOf(n);let r,a=e.footnoteCounts.get(n);void 0===a?(a=0,e.footnoteOrder.push(n),r=e.footnoteOrder.length):r=s+1,a+=1,e.footnoteCounts.set(n,a);const l={type:"element",tagName:"a",properties:{href:"#"+i+"fn-"+o,id:i+"fnref-"+o+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(r)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){const i={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},html:function(e,t){if(e.options.allowDangerousHtml){const i={type:"raw",value:t.value};return e.patch(t,i),e.applyData(t,i)}},imageReference:function(e,t){const i=String(t.identifier).toUpperCase(),n=e.definitionById.get(i);if(!n)return EV(e,t);const o={src:yV(n.url||""),alt:t.alt};null!==n.title&&void 0!==n.title&&(o.title=n.title);const s={type:"element",tagName:"img",properties:o,children:[]};return e.patch(t,s),e.applyData(t,s)},image:function(e,t){const i={src:yV(t.url)};null!==t.alt&&void 0!==t.alt&&(i.alt=t.alt),null!==t.title&&void 0!==t.title&&(i.title=t.title);const n={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,n),e.applyData(t,n)},inlineCode:function(e,t){const i={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,i);const n={type:"element",tagName:"code",properties:{},children:[i]};return e.patch(t,n),e.applyData(t,n)},linkReference:function(e,t){const i=String(t.identifier).toUpperCase(),n=e.definitionById.get(i);if(!n)return EV(e,t);const o={href:yV(n.url||"")};null!==n.title&&void 0!==n.title&&(o.title=n.title);const s={type:"element",tagName:"a",properties:o,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)},link:function(e,t){const i={href:yV(t.url)};null!==t.title&&void 0!==t.title&&(i.title=t.title);const n={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},listItem:function(e,t,i){const n=e.all(t),o=i?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const i=e.children;let n=-1;for(;!t&&++n0&&i.children.unshift({type:"text",value:" "}),i.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a0){const n={type:"element",tagName:"tbody",properties:{},children:e.wrap(i,!0)},s=xV(t.children[1]),r=CV(t.children[t.children.length-1]);s&&r&&(n.position={start:s,end:r}),o.push(n)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(t,s),e.applyData(t,s)},tableCell:function(e,t){const i={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)},tableRow:function(e,t,i){const n=i?i.children:void 0,o=0===(n?n.indexOf(t):1)?"th":"td",s=i&&"table"===i.type?i.align:void 0,r=s?s.length:t.children.length;let a=-1;const l=[];for(;++a0&&i.push({type:"text",value:"\n"}),i}function DV(e){let t=0,i=e.charCodeAt(t);for(;9===i||32===i;)t++,i=e.charCodeAt(t);return e.slice(t)}function zV(e,t){const i=function(e,t){const i=t||LV,n=new Map,o=new Map,s=new Map,r={...VV,...i.handlers},a={all:function(e){const t=[];if("children"in e){const i=e.children;let n=-1;for(;++n0&&d.push({type:"text",value:" "});let e="string"==typeof i?i:i(l,u);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(u>1?"-"+u:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof n?n:n(l,u),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const m=s[s.length-1];if(m&&"element"===m.type&&"p"===m.tagName){const e=m.children[m.children.length-1];e&&"text"===e.type?e.value+=" ":m.children.push({type:"text",value:" "}),m.children.push(...d)}else s.push(...d);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(s,!0)};e.patch(o,g),a.push(g)}if(0!==a.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...vV(r),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:"\n"}]}}(i),s=Array.isArray(n)?{type:"root",children:n}:n||{type:"root",children:[]};return o&&s.children.push({type:"text",value:"\n"},o),s}function HV(e,t){return e&&"run"in e?async function(i,n){const o=zV(i,{file:n,...t});await e.run(o,n)}:function(i,n){return zV(i,{file:n,...e||t})}}function UV(){return{type:"break"}}function $V(){return function(e){!function(e){RE(e,[/\r?\n|\r/g,UV])}(e)}}class qV{constructor(e,t,i){this.normal=t,this.property=e,i&&(this.space=i)}}function jV(e,t){const i={},n={};for(const t of e)Object.assign(i,t.property),Object.assign(n,t.normal);return new qV(i,n,t)}function WV(e){return e.toLowerCase()}qV.prototype.normal={},qV.prototype.property={},qV.prototype.space=void 0;class GV{constructor(e,t){this.attribute=t,this.property=e}}GV.prototype.attribute="",GV.prototype.booleanish=!1,GV.prototype.boolean=!1,GV.prototype.commaOrSpaceSeparated=!1,GV.prototype.commaSeparated=!1,GV.prototype.defined=!1,GV.prototype.mustUseProperty=!1,GV.prototype.number=!1,GV.prototype.overloadedBoolean=!1,GV.prototype.property="",GV.prototype.spaceSeparated=!1,GV.prototype.space=void 0;let KV=0;const JV=iO(),YV=iO(),QV=iO(),XV=iO(),ZV=iO(),eO=iO(),tO=iO();function iO(){return 2**++KV}const nO=Object.keys(t);class oO extends GV{constructor(e,i,n,o){let s=-1;if(super(e,i),sO(this,"space",o),"number"==typeof n)for(;++s"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function lO(e,t){return t in e?e[t]:t}function cO(e,t){return lO(e,t.toLowerCase())}const uO=rO({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:eO,acceptCharset:ZV,accessKey:ZV,action:null,allow:null,allowFullScreen:JV,allowPaymentRequest:JV,allowUserMedia:JV,alt:null,as:null,async:JV,autoCapitalize:null,autoComplete:ZV,autoFocus:JV,autoPlay:JV,blocking:ZV,capture:null,charSet:null,checked:JV,cite:null,className:ZV,cols:XV,colSpan:null,content:null,contentEditable:YV,controls:JV,controlsList:ZV,coords:XV|eO,crossOrigin:null,data:null,dateTime:null,decoding:null,default:JV,defer:JV,dir:null,dirName:null,disabled:JV,download:QV,draggable:YV,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:JV,formTarget:null,headers:ZV,height:XV,hidden:QV,high:XV,href:null,hrefLang:null,htmlFor:ZV,httpEquiv:ZV,id:null,imageSizes:null,imageSrcSet:null,inert:JV,inputMode:null,integrity:null,is:null,isMap:JV,itemId:null,itemProp:ZV,itemRef:ZV,itemScope:JV,itemType:ZV,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:JV,low:XV,manifest:null,max:null,maxLength:XV,media:null,method:null,min:null,minLength:XV,multiple:JV,muted:JV,name:null,nonce:null,noModule:JV,noValidate:JV,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:JV,optimum:XV,pattern:null,ping:ZV,placeholder:null,playsInline:JV,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:JV,referrerPolicy:null,rel:ZV,required:JV,reversed:JV,rows:XV,rowSpan:XV,sandbox:ZV,scope:null,scoped:JV,seamless:JV,selected:JV,shadowRootClonable:JV,shadowRootDelegatesFocus:JV,shadowRootMode:null,shape:null,size:XV,sizes:null,slot:null,span:XV,spellCheck:YV,src:null,srcDoc:null,srcLang:null,srcSet:null,start:XV,step:null,style:null,tabIndex:XV,target:null,title:null,translate:null,type:null,typeMustMatch:JV,useMap:null,value:YV,width:XV,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ZV,axis:null,background:null,bgColor:null,border:XV,borderColor:null,bottomMargin:XV,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:JV,declare:JV,event:null,face:null,frame:null,frameBorder:null,hSpace:XV,leftMargin:XV,link:null,longDesc:null,lowSrc:null,marginHeight:XV,marginWidth:XV,noResize:JV,noHref:JV,noShade:JV,noWrap:JV,object:null,profile:null,prompt:null,rev:null,rightMargin:XV,rules:null,scheme:null,scrolling:YV,standby:null,summary:null,text:null,topMargin:XV,valueType:null,version:null,vAlign:null,vLink:null,vSpace:XV,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:JV,disableRemotePlayback:JV,prefix:null,property:null,results:XV,security:null,unselectable:null},space:"html",transform:cO}),dO=rO({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:tO,accentHeight:XV,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:XV,amplitude:XV,arabicForm:null,ascent:XV,attributeName:null,attributeType:null,azimuth:XV,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:XV,by:null,calcMode:null,capHeight:XV,className:ZV,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:XV,diffuseConstant:XV,direction:null,display:null,dur:null,divisor:XV,dominantBaseline:null,download:JV,dx:null,dy:null,edgeMode:null,editable:null,elevation:XV,enableBackground:null,end:null,event:null,exponent:XV,externalResourcesRequired:null,fill:null,fillOpacity:XV,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:eO,g2:eO,glyphName:eO,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:XV,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:XV,horizOriginX:XV,horizOriginY:XV,id:null,ideographic:XV,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:XV,k:XV,k1:XV,k2:XV,k3:XV,k4:XV,kernelMatrix:tO,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:XV,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:XV,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:XV,overlineThickness:XV,paintOrder:null,panose1:null,path:null,pathLength:XV,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ZV,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:XV,pointsAtY:XV,pointsAtZ:XV,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:tO,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:tO,rev:tO,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:tO,requiredFeatures:tO,requiredFonts:tO,requiredFormats:tO,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:XV,specularExponent:XV,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:XV,strikethroughThickness:XV,string:null,stroke:null,strokeDashArray:tO,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:XV,strokeOpacity:XV,strokeWidth:null,style:null,surfaceScale:XV,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:tO,tabIndex:XV,tableValues:null,target:null,targetX:XV,targetY:XV,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:tO,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:XV,underlineThickness:XV,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:XV,values:null,vAlphabetic:XV,vMathematical:XV,vectorEffect:null,vHanging:XV,vIdeographic:XV,version:null,vertAdvY:XV,vertOriginX:XV,vertOriginY:XV,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:XV,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:lO}),hO=rO({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),mO=rO({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:cO}),gO=rO({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}),fO=jV([aO,uO,hO,mO,gO],"html"),pO=jV([aO,dO,hO,mO,gO],"svg"),bO=/[A-Z]/g,wO=/-[a-z]/g,vO=/^data[-\w.:]+$/i;function yO(e,t){const i=WV(t);let n=t,o=GV;if(i in e.normal)return e.property[e.normal[i]];if(i.length>4&&"data"===i.slice(0,4)&&vO.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(wO,kO);n="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!wO.test(e)){let i=e.replace(bO,_O);"-"!==i.charAt(0)&&(i="-"+i),t="data"+i}}o=oO}return new o(n,t)}function _O(e){return"-"+e.toLowerCase()}function kO(e){return e.charAt(1).toUpperCase()}const CO="http://www.w3.org/1999/xhtml",xO="http://www.w3.org/2000/svg",AO={}.hasOwnProperty;function TO(e,t){const i=function(e,t){switch(e.type){case"root":return function(e,t){const i=e.children||[];let n,o=0===i.length,s=-1;for(;++s";const t=document.createElement("template");return t.content.append(e),t.innerHTML}const IO=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],VO={}.hasOwnProperty;function OO(e,t){const i=t||{};function n(t,...i){let o=n.invalid;const s=n.handlers;if(t&&VO.call(t,e)){const i=String(t[e]);o=VO.call(s,i)?s[i]:n.unknown}if(o)return o.call(this,t,...i)}return n.handlers=i.handlers||{},n.invalid=i.invalid,n.unknown=i.unknown,n}const RO=/["&'<>`]/g,LO=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,BO=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,MO=/[|\\{}()[\]^$+*?.]/g,NO=new WeakMap;const FO=/[\dA-Fa-f]/,DO=/\d/,zO=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],HO={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},UO=["cent","copy","divide","gt","lt","not","para","times"],$O={}.hasOwnProperty,qO={};let jO;for(jO in HO)$O.call(HO,jO)&&(qO[HO[jO]]=jO);const WO=/[^\dA-Za-z]/;function GO(e,t,i){let n,o=function(e,t,i){const n="&#x"+e.toString(16).toUpperCase();return i&&t&&!FO.test(String.fromCharCode(t))?n:n+";"}(e,t,i.omitOptionalSemicolons);if((i.useNamedReferences||i.useShortestReferences)&&(n=function(e,t,i,n){const o=String.fromCharCode(e);if($O.call(qO,o)){const e=qO[o],s="&"+e;return i&&zO.includes(e)&&!UO.includes(e)&&(!n||t&&61!==t&&WO.test(String.fromCharCode(t)))?s:s+";"}return""}(e,t,i.omitOptionalSemicolons,i.attribute)),(i.useShortestReferences||!n)&&i.useShortestReferences){const n=function(e,t,i){const n="&#"+String(e);return i&&t&&!DO.test(String.fromCharCode(t))?n:n+";"}(e,t,i.omitOptionalSemicolons);n.length|^->||--!>|"],QO=["<",">"];function XO(e){const t=[],i=String(e||"");let n=i.indexOf(","),o=0,s=!1;for(;!s;){-1===n&&(n=i.length,s=!0);const e=i.slice(o,n).trim();!e&&s||t.push(e),o=n+1,n=i.indexOf(",",o)}return t}function ZO(e,t){const i=t||{};return(""===e[e.length-1]?[...e,""]:e).join((i.padRight?" ":"")+","+(!1===i.padLeft?"":" ")).trim()}function eR(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function tR(e){return e.join(" ").trim()}const iR=/[ \t\n\f\r]/g;function nR(e){return"object"==typeof e?"text"===e.type&&oR(e.value):oR(e)}function oR(e){return""===e.replace(iR,"")}const sR=lR(1),rR=lR(-1),aR=[];function lR(e){return function(t,i,n){const o=t?t.children:aR;let s=(i||0)+e,r=o[s];if(!n)for(;r&&nR(r);)s+=e,r=o[s];return r}}const cR={}.hasOwnProperty;function uR(e){return function(t,i,n){return cR.call(e,t.tagName)&&e[t.tagName](t,i,n)}}const dR=uR({body:function(e,t,i){const n=sR(i,t);return!n||"comment"!==n.type},caption:hR,colgroup:hR,dd:function(e,t,i){const n=sR(i,t);return!n||"element"===n.type&&("dt"===n.tagName||"dd"===n.tagName)},dt:function(e,t,i){const n=sR(i,t);return Boolean(n&&"element"===n.type&&("dt"===n.tagName||"dd"===n.tagName))},head:hR,html:function(e,t,i){const n=sR(i,t);return!n||"comment"!==n.type},li:function(e,t,i){const n=sR(i,t);return!n||"element"===n.type&&"li"===n.tagName},optgroup:function(e,t,i){const n=sR(i,t);return!n||"element"===n.type&&"optgroup"===n.tagName},option:function(e,t,i){const n=sR(i,t);return!n||"element"===n.type&&("option"===n.tagName||"optgroup"===n.tagName)},p:function(e,t,i){const n=sR(i,t);return n?"element"===n.type&&("address"===n.tagName||"article"===n.tagName||"aside"===n.tagName||"blockquote"===n.tagName||"details"===n.tagName||"div"===n.tagName||"dl"===n.tagName||"fieldset"===n.tagName||"figcaption"===n.tagName||"figure"===n.tagName||"footer"===n.tagName||"form"===n.tagName||"h1"===n.tagName||"h2"===n.tagName||"h3"===n.tagName||"h4"===n.tagName||"h5"===n.tagName||"h6"===n.tagName||"header"===n.tagName||"hgroup"===n.tagName||"hr"===n.tagName||"main"===n.tagName||"menu"===n.tagName||"nav"===n.tagName||"ol"===n.tagName||"p"===n.tagName||"pre"===n.tagName||"section"===n.tagName||"table"===n.tagName||"ul"===n.tagName):!i||!("element"===i.type&&("a"===i.tagName||"audio"===i.tagName||"del"===i.tagName||"ins"===i.tagName||"map"===i.tagName||"noscript"===i.tagName||"video"===i.tagName))},rp:mR,rt:mR,tbody:function(e,t,i){const n=sR(i,t);return!n||"element"===n.type&&("tbody"===n.tagName||"tfoot"===n.tagName)},td:gR,tfoot:function(e,t,i){return!sR(i,t)},th:gR,thead:function(e,t,i){const n=sR(i,t);return Boolean(n&&"element"===n.type&&("tbody"===n.tagName||"tfoot"===n.tagName))},tr:function(e,t,i){const n=sR(i,t);return!n||"element"===n.type&&"tr"===n.tagName}});function hR(e,t,i){const n=sR(i,t,!0);return!n||"comment"!==n.type&&!("text"===n.type&&nR(n.value.charAt(0)))}function mR(e,t,i){const n=sR(i,t);return!n||"element"===n.type&&("rp"===n.tagName||"rt"===n.tagName)}function gR(e,t,i){const n=sR(i,t);return!n||"element"===n.type&&("td"===n.tagName||"th"===n.tagName)}const fR=uR({body:function(e){const t=sR(e,-1,!0);return!(t&&("comment"===t.type||"text"===t.type&&nR(t.value.charAt(0))||"element"===t.type&&("meta"===t.tagName||"link"===t.tagName||"script"===t.tagName||"style"===t.tagName||"template"===t.tagName)))},colgroup:function(e,t,i){const n=rR(i,t),o=sR(e,-1,!0);return!(i&&n&&"element"===n.type&&"colgroup"===n.tagName&&dR(n,i.children.indexOf(n),i))&&Boolean(o&&"element"===o.type&&"col"===o.tagName)},head:function(e){const t=new Set;for(const i of e.children)if("element"===i.type&&("base"===i.tagName||"title"===i.tagName)){if(t.has(i.tagName))return!1;t.add(i.tagName)}const i=e.children[0];return!i||"element"===i.type},html:function(e){const t=sR(e,-1);return!t||"comment"!==t.type},tbody:function(e,t,i){const n=rR(i,t),o=sR(e,-1);return(!i||!n||"element"!==n.type||"thead"!==n.tagName&&"tbody"!==n.tagName||!dR(n,i.children.indexOf(n),i))&&Boolean(o&&"element"===o.type&&"tr"===o.tagName)}}),pR={name:[["\t\n\f\r &/=>".split(""),"\t\n\f\r \"&'/=>`".split("")],["\0\t\n\f\r \"&'/<=>".split(""),"\0\t\n\f\r \"&'/<=>`".split("")]],unquoted:[["\t\n\f\r &>".split(""),"\0\t\n\f\r \"&'<=>`".split("")],["\0\t\n\f\r \"&'<=>`".split(""),"\0\t\n\f\r \"&'<=>`".split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function bR(e,t,i){const n=yO(e.schema,t),o=e.settings.allowParseErrors&&"html"===e.schema.space?0:1,s=e.settings.allowDangerousCharacters?0:1;let r,a=e.quote;if(!n.overloadedBoolean||i!==n.attribute&&""!==i?!n.boolean&&!n.overloadedBoolean||"string"==typeof i&&i!==n.attribute&&""!==i||(i=Boolean(i)):i=!0,null==i||!1===i||"number"==typeof i&&Number.isNaN(i))return"";const l=KO(n.attribute,Object.assign({},e.settings.characterReferences,{subset:pR.name[o][s]}));return!0===i?l:(i=Array.isArray(i)?(n.commaSeparated?ZO:tR)(i,{padLeft:!e.settings.tightCommaSeparatedLists}):String(i),e.settings.collapseEmptyAttributes&&!i?l:(e.settings.preferUnquoted&&(r=KO(i,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:pR.unquoted[o][s]}))),r!==i&&(e.settings.quoteSmart&&hE(i,a)>hE(i,e.alternative)&&(a=e.alternative),r=a+KO(i,Object.assign({},e.settings.characterReferences,{subset:("'"===a?pR.single:pR.double)[o][s],attribute:!0}))+a),l+(r?"="+r:r)))}const wR=["<","&"];function vR(e,t,i,n){return!i||"element"!==i.type||"script"!==i.tagName&&"style"!==i.tagName?KO(e.value,Object.assign({},n.settings.characterReferences,{subset:wR})):e.value}const yR=OO("type",{invalid:function(e){throw new Error("Expected node, not `"+e+"`")},unknown:function(e){throw new Error("Cannot compile unknown node `"+e.type+"`")},handlers:{comment:function(e,t,i,n){return n.settings.bogusComments?"":"\x3c!--"+e.value.replace(JO,(function(e){return KO(e,Object.assign({},n.settings.characterReferences,{subset:QO}))}))+"--\x3e"},doctype:function(e,t,i,n){return""},element:function(e,t,i,n){const o=n.schema,s="svg"!==o.space&&n.settings.omitOptionalTags;let r="svg"===o.space?n.settings.closeEmptyElements:n.settings.voids.includes(e.tagName.toLowerCase());const a=[];let l;"html"===o.space&&"svg"===e.tagName&&(n.schema=pO);const c=function(e,t){const i=[];let n,o=-1;if(t)for(n in t)if(null!==t[n]&&void 0!==t[n]){const o=bR(e,n,t[n]);o&&i.push(o)}for(;++o")),a.push(u),r||s&&dR(e,t,i)||a.push(""),a.join("")},raw:function(e,t,i,n){return n.settings.allowDangerousHtml?e.value:vR(e,0,i,n)},root:function(e,t,i,n){return n.all(e)},text:vR}}),_R={},kR={},CR=[];function xR(e,t){const i=t||_R,n=i.quote||'"',o='"'===n?"'":'"';if('"'!==n&&"'"!==n)throw new Error("Invalid quote `"+n+"`, expected `'` or `\"`");return{one:AR,all:TR,settings:{omitOptionalTags:i.omitOptionalTags||!1,allowParseErrors:i.allowParseErrors||!1,allowDangerousCharacters:i.allowDangerousCharacters||!1,quoteSmart:i.quoteSmart||!1,preferUnquoted:i.preferUnquoted||!1,tightAttributes:i.tightAttributes||!1,upperDoctype:i.upperDoctype||!1,tightDoctype:i.tightDoctype||!1,bogusComments:i.bogusComments||!1,tightCommaSeparatedLists:i.tightCommaSeparatedLists||!1,tightSelfClosing:i.tightSelfClosing||!1,collapseEmptyAttributes:i.collapseEmptyAttributes||!1,allowDangerousHtml:i.allowDangerousHtml||!1,voids:i.voids||IO,characterReferences:i.characterReferences||kR,closeSelfClosing:i.closeSelfClosing||!1,closeEmptyElements:i.closeEmptyElements||!1},schema:"svg"===i.space?pO:fO,quote:n,alternative:o}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function AR(e,t,i){return yR(e,t,i,this)}function TR(e){const t=[],i=e&&e.children||CR;let n=-1;for(;++n","")}}function DR(){return e=>{xS(e,"element",(e=>{"ul"!==e.tagName&&"ol"!==e.tagName&&"li"!==e.tagName||(e.children=e.children.filter((e=>"text"!==e.type||!!e.value.trim())),delete e.properties.className)}))}}function zR(){return e=>{xS(e,["root","element"],(e=>{if(!function(e){return("root"===e.type||"element"===e.type)&&e.children}(e))return;if(!e.children.some((e=>"raw"===e.type)))return;const t=document.createElement("template");t.innerHTML=xR({type:"root",children:e.children},{allowDangerousHtml:!0}),e.children=Array.from(t.content.childNodes).map((e=>LR(e)))}))}}function HR(e){const t={...this.data("settings"),...e};this.parser=function(e){return LR((!1===t.fragment?UR:$R)(e))}}function UR(e){return(new DOMParser).parseFromString(e,"text/html")}function $R(e){const t=document.createElement("template");return t.innerHTML=e,t.content}const qR=function(e,t,i,n,o){const s=jR(t);if(null!=i&&("number"!=typeof i||i<0||i===Number.POSITIVE_INFINITY))throw new Error("Expected positive finite `index`");if(!(null==n||n.type&&n.children))throw new Error("Expected valid `parent`");if(null==i!=(null==n))throw new Error("Expected both `index` and `parent`");return!!KR(e)&&s.call(o,e,i,n)},jR=function(e){if(null==e)return GR;if("string"==typeof e)return function(e){return WR((function(t){return t.tagName===e}))}(e);if("object"==typeof e)return function(e){const t=[];let i=-1;for(;++ic&&(c=e):e&&(void 0!==c&&c>-1&&l.push("\n".repeat(c)||" "),c=-1,l.push(e))}return l.join("")}function kL(e,t,i){return"element"===e.type?function(e,t,i){const n=AL(e,i),o=e.children||[];let s,r,a=-1,l=[];if(vL(e))return l;for(fL(e)||wL(e)&&hL(t,e,wL)?r="\n":bL(e)?(s=2,r=2):yL(e)&&(s=1,r=1);++a0;){const e=t.codePointAt(i-1);if(void 0===e||10!==e&&13!==e)break;i--}return t.slice(0,i)}function EL(e,t){const i=t.children;let n,o,s=-1;if("pre"===t.tagName)for(;++s1)for(;++tt&&"break"===e[i-1].type;)i--;return 0===t&&i===e.length?e:e.slice(t,i)}function LL(e,t){const i={type:"heading",depth:Number(t.tagName.charAt(1))||1,children:RL(e.all(t))};return e.patch(t,i),i}function BL(e,t){const i=t.properties||{},n={type:"image",url:e.resolve(String(i.src||"")||null),title:i.title?String(i.title):null,alt:i.alt?String(i.alt):""};return e.patch(t,n),n}function ML(e,t){const i={type:"inlineCode",value:_L(t)};return e.patch(t,i),i}function NL(e,t){const i=[],n=[],o=t||e.properties||{},s=FL(e),r=Math.min(Number.parseInt(String(o.size),10),0)||(o.multiple?4:1);let a=-1;for(;++a0?i:s,c=Math.min(l.length,r);for(a=-1;++a0&&(o.push(...t(s)),s=[]),o.push(i(e)))}return s.length>0&&(o.push(...t(s)),s=[]),o}function ZL(e){const t=e.data&&e.data.hName;return t?$L({type:"element",tagName:t,properties:{},children:[]}):DS(e)}function eB(e){return vV({...e,children:[]})}function tB(e,t){const i=t.properties||{},n="video"===t.tagName?String(i.poster||""):"";let o=String(i.src||""),s=-1,r=!1,a=e.all(t);if(xS({type:"root",children:a},(function(e){if("link"===e.type)return r=!0,IE})),r||JL(a))return a;for(;!o&&++s0){const n={type:"paragraph",children:i};return e.patch(t,n),n}}const nB=['"'];function oB(e,t){const i={type:"strong",children:e.all(t)};return e.patch(t,i),i}function sB(e,t){const i={type:"tableCell",children:e.all(t)};if(e.patch(t,i),t.properties){const e=t.properties.rowSpan,n=t.properties.colSpan;if(e||n){const t=i.data||(i.data={});e&&(t.hastUtilToMdastTemporaryRowSpan=e),n&&(t.hastUtilToMdastTemporaryColSpan=n)}}return i}function rB(){return{type:"tableCell",children:[]}}function aB(){return{type:"tableCell",children:[]}}function lB(){return{type:"tableRow",children:[]}}const cB={comment:function(e,t){const i={type:"html",value:"\x3c!--"+t.value+"--\x3e"};return e.patch(t,i),i},doctype:mB,root:function(e,t){let i=e.all(t);(e.options.document||JL(i))&&(i=YL(i));const n={type:"root",children:i};return e.patch(t,n),n},text:function(e,t){const i={type:"text",value:t.value};return e.patch(t,i),i}},uB={applet:mB,area:mB,basefont:mB,bgsound:mB,caption:mB,col:mB,colgroup:mB,command:mB,content:mB,datalist:mB,dialog:mB,element:mB,embed:mB,frame:mB,frameset:mB,isindex:mB,keygen:mB,link:mB,math:mB,menu:mB,menuitem:mB,meta:mB,nextid:mB,noembed:mB,noframes:mB,optgroup:mB,option:mB,param:mB,script:mB,shadow:mB,source:mB,spacer:mB,style:mB,svg:mB,template:mB,title:mB,track:mB,abbr:dB,acronym:dB,bdi:dB,bdo:dB,big:dB,blink:dB,button:dB,canvas:dB,cite:dB,data:dB,details:dB,dfn:dB,font:dB,ins:dB,label:dB,map:dB,marquee:dB,meter:dB,nobr:dB,noscript:dB,object:dB,output:dB,progress:dB,rb:dB,rbc:dB,rp:dB,rt:dB,rtc:dB,ruby:dB,slot:dB,small:dB,span:dB,sup:dB,sub:dB,tbody:dB,tfoot:dB,thead:dB,time:dB,address:hB,article:hB,aside:hB,body:hB,center:hB,div:hB,fieldset:hB,figcaption:hB,figure:hB,form:hB,footer:hB,header:hB,hgroup:hB,html:hB,legend:hB,main:hB,multicol:hB,nav:hB,picture:hB,section:hB,a:function(e,t){const i=t.properties||{},n=e.all(t),o={type:"link",url:e.resolve(String(i.href||"")||null),title:i.title?String(i.title):null,children:n};return e.patch(t,o),o},audio:tB,b:oB,base:function(e,t){e.baseFound||(e.frozenBaseUrl=String(t.properties&&t.properties.href||"")||void 0,e.baseFound=!0)},blockquote:function(e,t){const i={type:"blockquote",children:e.toFlow(e.all(t))};return e.patch(t,i),i},br:function(e,t){const i={type:"break"};return e.patch(t,i),i},code:ML,dir:GL,dl:function(e,t){const i=[],n=[];let o=-1;for(;++o0&&r.push({type:"listItem",spread:t.length>1,checked:null,children:t})}if(r.length>0){const i={type:"list",ordered:!1,start:null,spread:PL(r),children:r};return e.patch(t,i),i}},dt:qL,dd:qL,del:SL,em:OL,h1:LL,h2:LL,h3:LL,h4:LL,h5:LL,h6:LL,hr:function(e,t){const i={type:"thematicBreak"};return e.patch(t,i),i},i:OL,iframe:function(e,t){const i=t.properties||{},n=String(i.src||""),o=String(i.title||"");if(n&&o){const i={type:"link",title:null,url:e.resolve(n),children:[{type:"text",value:o}]};return e.patch(t,i),i}},img:BL,image:BL,input:function(e,t){const i=t.properties||{},n=String(i.value||i.placeholder||"");if(i.disabled||"hidden"===i.type||"file"===i.type)return;if("checkbox"===i.type||"radio"===i.type){const n={type:"text",value:i.checked?e.options.checked||"[x]":e.options.unchecked||"[ ]"};return e.patch(t,n),n}if("image"===i.type){const o=i.alt||n;if(o){const n={type:"image",url:e.resolve(String(i.src||"")||null),title:String(i.title||"")||null,alt:String(o)};return e.patch(t,n),n}return}let o=[];if(n)o=[[n,void 0]];else if("button"!==i.type&&"file"!==i.type&&"password"!==i.type&&"reset"!==i.type&&"submit"!==i.type&&i.list){const t=String(i.list),n=e.elementById.get(t);n&&"datalist"===n.tagName&&(o=NL(n,i))}if(0===o.length)return;if("password"===i.type&&(o[0]=["•".repeat(o[0][0].length),void 0]),"email"===i.type||"url"===i.type){const t=[];let n=-1;for(;++n1?o.charAt(1):o;return s&&"text"===s.type?s.value=a+s.value:n.unshift({type:"text",value:a}),r&&"text"===r.type?r.value+=l:n.push({type:"text",value:l}),n},s:SL,samp:ML,select:function(e,t){const i=NL(t);let n=-1;const o=[];for(;++n0){const i={type:"text",value:o.join(", ")};return e.patch(t,i),i}},strike:SL,strong:oB,summary:iB,table:function(e,t){if(e.inTable){const i={type:"text",value:_L(t)};return e.patch(t,i),i}e.inTable=!0;const{align:i,headless:n}=function(e){const t={align:[null],headless:!0};let i=0,n=0;return xS(e,(function(o){if("element"===o.type){if("table"===o.tagName&&e!==o)return VE;if("th"!==o.tagName&&"td"!==o.tagName||!o.properties)"thead"===o.tagName?t.headless=!1:"tr"===o.tagName&&(i++,n=0);else{if(!t.align[n]){const e=String(o.properties.align||"")||null;"center"!==e&&"left"!==e&&"right"!==e&&null!==e||(t.align[n]=e)}t.headless&&i<2&&"th"===o.tagName&&(t.headless=!1),n++}}})),t}(t),o=e.toSpecificContent(e.all(t),lB);n&&o.unshift({type:"tableRow",children:[]});let s=-1;for(;++s1||r>1){let e=s-1;for(;++er&&(r=e.length)}for(s=-1;++s0&&(t.children.unshift(...o),o=[]),n.push(t);else{const e=t;o.push(e)}}if(o.length>0){let e=n[n.length-1];e||(e=t(),n.push(e)),e.children.push(...o),o=[]}return n;function r(e){return e.type===i.type}}const _B={};function kB(e,t){const i=vV(e),n=t||_B,o=dL({newlines:!0===n.newlines}),s=function(e){return{all:fB,baseFound:!1,elementById:new Map,frozenBaseUrl:void 0,handlers:{...uB,...e.handlers},inTable:!1,nodeHandlers:{...cB,...e.nodeHandlers},one:pB,options:e,patch:bB,qNesting:0,resolve:wB,toFlow:vB,toSpecificContent:yB}}(n);let r;o(i),xS(i,(function(e){if(e&&"element"===e.type&&e.properties){const t=String(e.properties.id||"")||void 0;t&&!s.elementById.has(t)&&s.elementById.set(t,e)}}));const a=s.one(i,void 0);return r=a?Array.isArray(a)?{type:"root",children:a}:a:{type:"root",children:[]},xS(r,(function(e,t,i){if("text"===e.type&&void 0!==t&&i){const n=i.children[t-1];if(n&&n.type===e.type)return n.value+=e.value,i.children.splice(t,1),n.position&&e.position&&(n.position.end=e.position.end),t-1;if(e.value=e.value.replace(/[\t ]*(\r?\n|\r)[\t ]*/,"$1"),!i||"heading"!==i.type&&"paragraph"!==i.type&&"root"!==i.type||(t||(e.value=e.value.replace(/^[\t ]+/,"")),t===i.children.length-1&&(e.value=e.value.replace(/[\t ]+$/,""))),!e.value)return i.children.splice(t,1),t}})),r}const CB={document:!0};function xB(e,t){return e&&"run"in e?async function(i,n){const o=kB(i,{...CB,...t});await e.run(o,n)}:function(t){return kB(t,{...CB,...e})}}const AB={}.hasOwnProperty;function TB(e,t){let i,n=-1;if(t.extensions)for(;++n"},{character:">",inConstruct:"destinationLiteral"},{atBreak:!0,character:"["},{character:"[",inConstruct:"phrasing",notInConstruct:PB},{character:"[",inConstruct:["label","reference"]},{character:"\\",after:"[\\r\\n]",inConstruct:"phrasing"},{character:"]",inConstruct:["label","reference"]},{atBreak:!0,character:"_"},{character:"_",inConstruct:"phrasing",notInConstruct:PB},{atBreak:!0,character:"`"},{character:"`",inConstruct:["codeFencedLangGraveAccent","codeFencedMetaGraveAccent"]},{character:"`",inConstruct:"phrasing",notInConstruct:PB},{atBreak:!0,character:"~"}];function VB(e){return e.label||!e.identifier?e.label||"":iV(e.identifier)}function OB(e){if(!e._compiled){const t=(e.atBreak?"[\\r\\n][\\t ]*":"")+(e.before?"(?:"+e.before+")":"");e._compiled=new RegExp((t?"("+t+")":"")+(/[|\\{}()[\]^$+*?.-]/.test(e.character)?"\\":"")+e.character+(e.after?"(?:"+e.after+")":""),"g")}return e._compiled}function RB(e,t,i,n){let o=n.join.length;for(;o--;){const s=n.join[o](e,t,i,n);if(!0===s||1===s)break;if("number"==typeof s)return"\n".repeat(1+s);if(!1===s)return"\n\n\x3c!----\x3e\n\n"}return"\n\n"}const LB=/\r?\n|\r/g;function BB(e,t){const i=[];let n,o=0,s=0;for(;n=LB.exec(e);)r(e.slice(o,n.index)),i.push(n[0]),o=n.index+n[0].length,s++;return r(e.slice(o)),i.join("");function r(e){i.push(t(e,s,!e))}}function MB(e,t){return e-t}function NB(e,t){const i=/\\(?=[!-/:-@[-`{-~])/g,n=[],o=[],s=e+t;let r,a=-1,l=0;for(;r=i.exec(s);)n.push(r.index);for(;++a0&&("\r"===l||"\n"===l)&&"html"===u.type&&(s[s.length-1]=s[s.length-1].replace(/(\r?\n|\r)$/," "),l=" ",c=t.createTracker(i),c.move(s.join("")));let h=t.handle(u,e,t,{...c.current(),after:d,before:l});r&&r===h.slice(0,1)&&(h=yS(r.charCodeAt(0))+h.slice(1));const m=t.attentionEncodeSurroundingInfo;t.attentionEncodeSurroundingInfo=void 0,r=void 0,m&&(s.length>0&&m.before&&l===s[s.length-1].slice(-1)&&(s[s.length-1]=s[s.length-1].slice(0,-1)+yS(l.charCodeAt(0))),m.after&&(r=d)),c.move(h),s.push(h),l=h.slice(-1)}return n.pop(),s.join("")}(e,this,t)}function qB(e,t){return function(e,t,i){const n=t.indexStack,o=e.children||[],s=t.createTracker(i),r=[];let a=-1;for(n.push(-1);++a=c||e+1(e[t]=(e,t)=>{const i=xR(OR(t.tagName,t.properties),{allowDangerousHtml:!0,closeSelfClosing:!0}),n=i.indexOf(">"),o=i.slice(0,n+1),s=i.slice(n+1);return[{type:"html",value:o},...e.all(t),{type:"html",value:s}]},e)),{})}_buildProcessor(){this._processor=sE().use(HR).use(KB).use(xB,{handlers:this._getRawTagsHandlers()}).use(HP,{singleTilde:!0}).use($V).use(WB,{resourceLink:!0,emphasis:"_",rule:"-",handlers:{break:()=>"\n"},unsafe:[{character:"<"}]})}}function KB(){return function(e){xS(e,"element",((e,t,i)=>{null!==t&&"label"===e.tagName&&"element"===i.type&&"li"===i.tagName&&i.children.splice(t,1,...e.children)}))}}class JB{_htmlDP;_markdown2html;_html2markdown;constructor(e){this._htmlDP=new ja(e),this._markdown2html=new FR,this._html2markdown=new GB}keepHtml(e){this._html2markdown.keep(e)}toView(e){const t=this._markdown2html.parse(e);return this._htmlDP.toView(t)}toData(e){const t=this._htmlDP.toData(e);return this._html2markdown.parse(t)}registerRawContentMatcher(e){this._htmlDP.registerRawContentMatcher(e)}useFillerType(){}}class YB extends cd{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=function(e,t,i){const n=function(e,t){const i=Yh(e,t).start.parent;return i.isEmpty&&!i.is("element","$root")?i.parent:i}(e,i);return t.checkChild(n,"pageBreak")}(i,t,e)}execute(){const e=this.editor.model;e.change((t=>{const i=t.createElement("pageBreak");e.insertObject(i,null,null,{setSelection:"after"})}))}}class QB extends ad{static get pluginName(){return"PageBreakEditing"}static get licenseFeatureCode(){return"PB"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;t.register("pageBreak",{inheritAllFrom:"$blockObject"}),n.for("dataDowncast").elementToStructure({model:"pageBreak",view:(e,{writer:t})=>t.createContainerElement("div",{class:"page-break",style:"page-break-after: always"},t.createContainerElement("span",{style:"display: none"}))}),n.for("editingDowncast").elementToStructure({model:"pageBreak",view:(e,{writer:t})=>{const n=i("Page break"),o=t.createContainerElement("div"),s=t.createRawElement("span",{class:"page-break__label"},(function(e){e.innerText=i("Page break")}));return t.addClass("page-break",o),t.insert(t.createPositionAt(o,0),s),function(e,t,i){return t.setCustomProperty("pageBreak",!0,e),jh(e,t,{label:i})}(o,t,n)}}),n.for("upcast").elementToElement({view:e=>{const t="always"==e.getStyle("page-break-before"),i="always"==e.getStyle("page-break-after");if(!t&&!i)return null;if(1==e.childCount){const t=e.getChild(0);if(!t.is("element","span")||"none"!=t.getStyle("display"))return null}else if(e.childCount>1)return null;return{name:!0,styles:[...t?["page-break-before"]:[],...i?["page-break-after"]:[]],...e.hasClass("page-break")&&{classes:["page-break"]}}},model:"pageBreak",converterPriority:"high"}),e.commands.add("pageBreak",new YB(e))}}class XB extends ad{static get pluginName(){return"PageBreakUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("pageBreak",(()=>{const e=this._createButton(Bn);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add("menuBar:pageBreak",(()=>this._createButton(Yu)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("pageBreak"),o=new e(t.locale),s=i.t;return o.set({label:s("Page break"),icon:''}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{t.execute("pageBreak"),t.editing.view.focus()})),o}}class ZB extends Bn{styleDefinition;previewView;constructor(e,t){super(e),this.styleDefinition=t,this.previewView=this._createPreview(),this.set({label:t.name,class:"ck-style-grid__button",withText:!0}),this.extendTemplate({attributes:{role:"option"}}),this.children.add(this.previewView,0)}_createPreview(){const e=new Hi(this.locale);return e.setTemplate({tag:"div",attributes:{class:["ck","ck-reset_all-excluded","ck-style-grid__button__preview","ck-content"],"aria-hidden":"true"},children:[this.styleDefinition.previewTemplate]}),e}}class eM extends Hi{focusTracker;keystrokes;children;constructor(e,t){super(e),this.focusTracker=new ei,this.keystrokes=new oi,this.set("activeStyles",[]),this.set("enabledStyles",[]),this.children=this.createCollection(),this.children.delegate("execute").to(this);for(const i of t){const t=new ZB(e,i);this.children.add(t)}this.on("change:activeStyles",(()=>{for(const e of this.children)e.isOn=this.activeStyles.includes(e.styleDefinition.name)})),this.on("change:enabledStyles",(()=>{for(const e of this.children)e.isEnabled=this.enabledStyles.includes(e.styleDefinition.name)})),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-grid"],role:"listbox"},children:this.children})}render(){super.render();for(const e of this.children)this.focusTracker.add(e.element);Sb({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.children,numberOfColumns:3,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection}),this.keystrokes.listenTo(this.element)}focus(){this.children.first.focus()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}class tM extends Hi{gridView;labelView;constructor(e,t,i){super(e),this.labelView=new du(e),this.labelView.text=t,this.gridView=new eM(e,i),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-panel__style-group"],role:"group","aria-labelledby":this.labelView.id},children:[this.labelView,this.gridView]})}}class iM extends Hi{focusTracker;keystrokes;children;blockStylesGroupView;inlineStylesGroupView;_focusables;_focusCycler;constructor(e,t){super(e);const i=e.t;this.focusTracker=new ei,this.keystrokes=new oi,this.children=this.createCollection(),this.blockStylesGroupView=new tM(e,i("Block styles"),t.block),this.inlineStylesGroupView=new tM(e,i("Text styles"),t.inline),this.set("activeStyles",[]),this.set("enabledStyles",[]),this._focusables=new wi,this._focusCycler=new Nn({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:["shift + tab"],focusNext:["tab"]}}),t.block.length&&this.children.add(this.blockStylesGroupView),t.inline.length&&this.children.add(this.inlineStylesGroupView),this.blockStylesGroupView.gridView.delegate("execute").to(this),this.inlineStylesGroupView.gridView.delegate("execute").to(this),this.blockStylesGroupView.gridView.bind("activeStyles","enabledStyles").to(this,"activeStyles","enabledStyles"),this.inlineStylesGroupView.gridView.bind("activeStyles","enabledStyles").to(this,"activeStyles","enabledStyles"),this.setTemplate({tag:"div",attributes:{class:["ck","ck-style-panel"]},children:this.children})}render(){super.render(),this._focusables.add(this.blockStylesGroupView.gridView),this._focusables.add(this.inlineStylesGroupView.gridView),this.focusTracker.add(this.blockStylesGroupView.gridView.element),this.focusTracker.add(this.inlineStylesGroupView.gridView.element),this.keystrokes.listenTo(this.element)}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}const nM=["caption","colgroup","dd","dt","figcaption","legend","li","optgroup","option","rp","rt","summary","tbody","td","tfoot","th","thead","tr"];class oM extends ad{_htmlSupport;static get pluginName(){return"StyleUtils"}static get isOfficialPlugin(){return!0}constructor(e){super(e),this.decorate("isStyleEnabledForBlock"),this.decorate("isStyleActiveForBlock"),this.decorate("getAffectedBlocks"),this.decorate("isStyleEnabledForInlineSelection"),this.decorate("isStyleActiveForInlineSelection"),this.decorate("getAffectedInlineSelectable"),this.decorate("getStylePreview"),this.decorate("configureGHSDataFilter")}init(){this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport")}normalizeConfig(e,t=[]){const i={block:[],inline:[]};for(const n of t){const t=[],o=[];for(const i of e.getDefinitionsForView(n.element)){const e="appliesToBlock"in i&&i.appliesToBlock;if(i.isBlock||e){if("string"==typeof e)t.push(e);else if(i.isBlock){const e=i;t.push(i.model),e.paragraphLikeModel&&t.push(e.paragraphLikeModel)}}else o.push(i.model)}const s=this.getStylePreview(n,[{text:"AaBbCcDdEeFfGgHhIiJj"}]);t.length?i.block.push({...n,previewTemplate:s,modelElements:t,isBlock:!0}):i.inline.push({...n,previewTemplate:s,ghsAttributes:o})}return i}isStyleEnabledForBlock(e,t){const i=this.editor.model,n=this._htmlSupport.getGhsAttributeNameForElement(e.element);return!!i.schema.checkAttribute(t,n)&&e.modelElements.includes(t.name)}isStyleActiveForBlock(e,t){const i=this._htmlSupport.getGhsAttributeNameForElement(e.element),n=t.getAttribute(i);return this.hasAllClasses(n,e.classes)}getAffectedBlocks(e,t){return e.modelElements.includes(t.name)?[t]:null}isStyleEnabledForInlineSelection(e,t){const i=this.editor.model;for(const n of e.ghsAttributes)if(i.schema.checkAttributeInSelection(t,n))return!0;return!1}isStyleActiveForInlineSelection(e,t){for(const i of e.ghsAttributes){const n=this._getValueFromFirstAllowedNode(t,i);if(this.hasAllClasses(n,e.classes))return!0}return!1}getAffectedInlineSelectable(e,t){return t}getStylePreview(e,t){const{element:i,classes:n}=e;return{tag:(o=i,nM.includes(o)?"div":i),attributes:{class:n},children:t};var o}hasAllClasses(e,t){return z(e)&&(i=e,Boolean(i.classes)&&Array.isArray(i.classes))&&t.every((t=>e.classes.includes(t)));var i}configureGHSDataFilter({block:e,inline:t}){const i=this.editor.plugins.get("DataFilter");i.loadAllowedConfig(e.map(sM)),i.loadAllowedConfig(t.map(sM))}_getValueFromFirstAllowedNode(e,t){const i=this.editor.model.schema;if(e.isCollapsed)return e.getAttribute(t);for(const n of e.getRanges())for(const e of n.getItems())if(i.checkAttribute(e,t))return e.getAttribute(t);return null}}function sM({element:e,classes:t}){return{name:e,classes:t}}class rM extends ad{static get pluginName(){return"StyleUI"}static get isOfficialPlugin(){return!0}static get requires(){return[oM]}init(){const e=this.editor,t=e.plugins.get("DataSchema"),i=e.plugins.get("StyleUtils"),n=e.config.get("style.definitions"),o=i.normalizeConfig(t,n);e.ui.componentFactory.add("style",(t=>{const i=t.t,n=Pu(t),s=e.commands.get("style");return n.once("change:isOpen",(()=>{const e=new iM(t,o);n.panelView.children.add(e),e.delegate("execute").to(n),e.bind("activeStyles").to(s,"value"),e.bind("enabledStyles").to(s,"enabledStyles")})),n.bind("isEnabled").to(s),n.buttonView.withText=!0,n.buttonView.bind("label").to(s,"value",(e=>e.length>1?i("Multiple styles"):1===e.length?e[0]:i("Styles"))),n.bind("class").to(s,"value",(e=>{const t=["ck-style-dropdown"];return e.length>1&&t.push("ck-style-dropdown_multiple-active"),t.join(" ")})),n.on("execute",(t=>{e.execute("style",{styleName:t.source.styleDefinition.name}),e.editing.view.focus()})),n}))}}class aM extends cd{_styleDefinitions;_styleUtils;constructor(e,t){super(e),this.set("value",[]),this.set("enabledStyles",[]),this._styleDefinitions=t,this._styleUtils=this.editor.plugins.get(oM)}refresh(){const e=this.editor.model,t=e.document.selection,i=new Set,n=new Set;for(const e of this._styleDefinitions.inline)this._styleUtils.isStyleEnabledForInlineSelection(e,t)&&n.add(e.name),this._styleUtils.isStyleActiveForInlineSelection(e,t)&&i.add(e.name);const o=Zt(t.getSelectedBlocks())||t.getFirstPosition().parent;if(o){const t=o.getAncestors({includeSelf:!0,parentFirst:!0});for(const o of t){if(o.is("rootElement"))break;for(const e of this._styleDefinitions.block)this._styleUtils.isStyleEnabledForBlock(e,o)&&(n.add(e.name),this._styleUtils.isStyleActiveForBlock(e,o)&&i.add(e.name));if(e.schema.isObject(o))break}}this.enabledStyles=Array.from(n).sort(),this.isEnabled=this.enabledStyles.length>0,this.value=this.isEnabled?Array.from(i).sort():[]}execute({styleName:e,forceValue:t}){if(!this.enabledStyles.includes(e))return void A("style-command-executed-with-incorrect-style-name");const i=this.editor.model,n=i.document.selection,o=this.editor.plugins.get("GeneralHtmlSupport"),s=[...this._styleDefinitions.inline,...this._styleDefinitions.block],r=s.filter((({name:e})=>this.value.includes(e))),a=s.find((({name:t})=>t==e)),l=void 0===t?!this.value.includes(a.name):t;i.change((()=>{let e;e=function(e){return"isBlock"in e}(a)?this._findAffectedBlocks(function(e){const t=Array.from(e.getSelectedBlocks());return t.length?t:[e.getFirstPosition().parent]}(n),a):[this._styleUtils.getAffectedInlineSelectable(a,n)];for(const t of e)l?o.addModelHtmlClass(a.element,a.classes,t):o.removeModelHtmlClass(a.element,lM(r,a),t)}))}_findAffectedBlocks(e,t){const i=new Set;for(const n of e){const e=n.getAncestors({includeSelf:!0,parentFirst:!0});for(const n of e){if(n.is("rootElement"))break;const e=this._styleUtils.getAffectedBlocks(t,n);if(e){for(const t of e)i.add(t);break}}}return i}}function lM(e,t){return e.reduce(((e,i)=>i.name===t.name?e:e.filter((e=>!i.classes.includes(e)))),t.classes)}class cM extends ad{_listUtils;_styleUtils;_htmlSupport;static get pluginName(){return"ListStyleSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[oM,"GeneralHtmlSupport"]}init(){const e=this.editor;e.plugins.has("ListEditing")&&(this._styleUtils=e.plugins.get(oM),this._listUtils=this.editor.plugins.get("ListUtils"),this._htmlSupport=this.editor.plugins.get("GeneralHtmlSupport"),this.listenTo(this._styleUtils,"isStyleEnabledForBlock",((e,[t,i])=>{this._isStyleEnabledForBlock(t,i)&&(e.return=!0,e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"isStyleActiveForBlock",((e,[t,i])=>{this._isStyleActiveForBlock(t,i)&&(e.return=!0,e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedBlocks",((e,[t,i])=>{const n=this._getAffectedBlocks(t,i);n&&(e.return=n,e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"getStylePreview",((e,[t,i])=>{const n=this._getStylePreview(t,i);n&&(e.return=n,e.stop())}),{priority:"high"}))}_isStyleEnabledForBlock(e,t){const i=this.editor.model;if(!["ol","ul","li"].includes(e.element))return!1;if(!this._listUtils.isListItemBlock(t))return!1;const n=this._htmlSupport.getGhsAttributeNameForElement(e.element);if("ol"==e.element||"ul"==e.element){if(!i.schema.checkAttribute(t,n))return!1;const o=this._listUtils.isNumberedListType(t.getAttribute("listType"))?"ol":"ul";return e.element==o}return i.schema.checkAttribute(t,n)}_isStyleActiveForBlock(e,t){const i=this._htmlSupport.getGhsAttributeNameForElement(e.element),n=t.getAttribute(i);return this._styleUtils.hasAllClasses(n,e.classes)}_getAffectedBlocks(e,t){return this._isStyleEnabledForBlock(e,t)?"li"==e.element?this._listUtils.expandListBlocksToCompleteItems(t,{withNested:!1}):this._listUtils.expandListBlocksToCompleteList(t):null}_getStylePreview(e,t){const{element:i,classes:n}=e;return"ol"==i||"ul"==i?{tag:i,attributes:{class:n},children:[{tag:"li",children:t}]}:"li"==i?{tag:"ol",children:[{tag:i,attributes:{class:n},children:t}]}:null}}class uM extends ad{_tableUtils;_styleUtils;static get pluginName(){return"TableStyleSupport"}static get isOfficialPlugin(){return!0}static get requires(){return[oM]}init(){const e=this.editor;e.plugins.has("TableEditing")&&(this._styleUtils=e.plugins.get(oM),this._tableUtils=this.editor.plugins.get("TableUtils"),this.listenTo(this._styleUtils,"isStyleEnabledForBlock",((e,[t,i])=>{this._isApplicable(t,i)&&(e.return=this._isStyleEnabledForBlock(t,i),e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedBlocks",((e,[t,i])=>{this._isApplicable(t,i)&&(e.return=this._getAffectedBlocks(t,i),e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"configureGHSDataFilter",((e,[{block:t}])=>{this.editor.plugins.get("DataFilter").loadAllowedConfig(t.filter((e=>"figcaption"==e.element)).map((e=>({name:"caption",classes:e.classes}))))})))}_isApplicable(e,t){return["td","th"].includes(e.element)?"tableCell"==t.name:!!["thead","tbody"].includes(e.element)&&"table"==t.name}_isStyleEnabledForBlock(e,t){if(["td","th"].includes(e.element)){const i=this._tableUtils.getCellLocation(t),n=t.parent.parent,o=n.getAttribute("headingRows")||0,s=n.getAttribute("headingColumns")||0,r=i.row0:i{"a"==t.element&&(e.return=this._isStyleEnabled(t,i),e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"isStyleActiveForInlineSelection",((e,[t,i])=>{"a"==t.element&&(e.return=this._isStyleActive(t,i),e.stop())}),{priority:"high"}),this.listenTo(this._styleUtils,"getAffectedInlineSelectable",((e,[t,i])=>{if("a"!=t.element)return;const n=this._getAffectedSelectable(t,i);n&&(e.return=n,e.stop())}),{priority:"high"}))}_isStyleEnabled(e,t){const i=this.editor.model;if(t.isCollapsed)return t.hasAttribute("linkHref");for(const e of t.getRanges())for(const t of e.getItems())if((t.is("$textProxy")||i.schema.isInline(t))&&t.hasAttribute("linkHref"))return!0;return!1}_isStyleActive(e,t){const i=this.editor.model,n=this._htmlSupport.getGhsAttributeNameForElement(e.element);if(t.isCollapsed){if(t.hasAttribute("linkHref")){const i=t.getAttribute(n);if(this._styleUtils.hasAllClasses(i,e.classes))return!0}return!1}for(const o of t.getRanges())for(const t of o.getItems())if((t.is("$textProxy")||i.schema.isInline(t))&&t.hasAttribute("linkHref")){const i=t.getAttribute(n);return this._styleUtils.hasAllClasses(i,e.classes)}return!1}_getAffectedSelectable(e,t){const i=this.editor.model;if(t.isCollapsed){const e=t.getAttribute("linkHref");return Eh(t.getFirstPosition(),"linkHref",e,i)}const n=[];for(const e of t.getRanges()){const t=i.createRange(hM(e.start,"linkHref",!0,i),hM(e.end,"linkHref",!1,i));for(const e of t.getItems())(e.is("$textProxy")||i.schema.isInline(e))&&e.hasAttribute("linkHref")&&n.push(this.editor.model.createRangeOn(e))}return function(e){for(let t=1;t{const i=t.createElement("horizontalLine");e.insertObject(i,null,null,{setSelection:"after"})}))}}class fM extends ad{static get pluginName(){return"HorizontalLineEditing"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),n.for("dataDowncast").elementToElement({model:"horizontalLine",view:(e,{writer:t})=>t.createEmptyElement("hr")}),n.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(e,{writer:t})=>{const n=i("Horizontal line"),o=t.createContainerElement("div",null,t.createEmptyElement("hr"));return t.addClass("ck-horizontal-line",o),t.setCustomProperty("hr",!0,o),function(e,t,i){return t.setCustomProperty("horizontalLine",!0,e),jh(e,t,{label:i})}(o,t,n)}}),n.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new gM(e))}}class pM extends ad{static get pluginName(){return"HorizontalLineUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("horizontalLine",(()=>{const e=this._createButton(Bn);return e.set({tooltip:!0}),e})),e.ui.componentFactory.add("menuBar:horizontalLine",(()=>this._createButton(Yu)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("horizontalLine"),o=new e(t.locale),s=i.t;return o.set({label:s("Horizontal line"),icon:''}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{t.execute("horizontalLine"),t.editing.view.focus()})),o}}class bM extends ad{static get requires(){return["ImageEditing","ImageUtils",Np]}static get pluginName(){return"LinkImageEditing"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.model.schema;e.plugins.has("ImageBlockEditing")&&t.extend("imageBlock",{allowAttributes:["linkHref"]}),e.conversion.for("upcast").add(function(e){const t=e.plugins.has("ImageInlineEditing"),i=e.plugins.get("ImageUtils");return e=>{e.on("element:a",((e,n,o)=>{const s=n.viewItem,r=i.findViewImgElement(s);if(!r)return;const a=r.findAncestor((e=>i.isBlockImageView(e)));if(t&&!a)return;const l={attributes:["href"]};if(!o.consumable.test(s,l))return;const c=s.getAttribute("href"),u=n.modelCursor.parent;u.is("element","imageBlock")&&(o.writer.setAttribute("linkHref",c,u),o.consumable.consume(s,l))}),{priority:"high"})}}(e)),e.conversion.for("downcast").add(function(e){const t=e.plugins.get("ImageUtils");return e=>{e.on("attribute:linkHref:imageBlock",((e,i,n)=>{if(!n.consumable.consume(i.item,e.name))return;const o=n.mapper.toViewElement(i.item),s=n.writer,r=Array.from(o.getChildren()).find((e=>e.is("element","a"))),a=t.findViewImgElement(o),l=a.parent.is("element","picture")?a.parent:a;if(r)i.attributeNewValue?s.setAttribute("href",i.attributeNewValue,r):(s.move(s.createRangeOn(l),s.createPositionAt(o,0)),s.remove(r));else{const e=s.createContainerElement("a",{href:i.attributeNewValue});s.insert(s.createPositionAt(o,0),e),s.move(s.createRangeOn(l),s.createPositionAt(e,0))}}),{priority:"high"})}}(e)),this._enableAutomaticDecorators(),this._enableManualDecorators()}_enableAutomaticDecorators(){const e=this.editor,t=e.commands.get("link").automaticDecorators;t.length&&e.conversion.for("downcast").add(t.getDispatcherForLinkedImage())}_enableManualDecorators(){const e=this.editor,t=e.commands.get("link");for(const i of t.manualDecorators)e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:i.id}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:i.id}),e.conversion.for("downcast").add(wM(i)),e.conversion.for("upcast").add(vM(e,i))}}function wM(e){return t=>{t.on(`attribute:${e.id}:imageBlock`,((t,i,n)=>{const o=n.mapper.toViewElement(i.item),s=Array.from(o.getChildren()).find((e=>e.is("element","a")));if(s){if(i.attributeOldValue){for(const t in e.attributes)n.writer.removeAttribute(t,s);e.classes&&n.writer.removeClass(e.classes,s);for(const t in e.styles)n.writer.removeStyle(t,s)}if(i.attributeNewValue){for(const[t,i]of si(e.attributes))n.writer.setAttribute(t,i,s);e.classes&&n.writer.addClass(e.classes,s);for(const t in e.styles)n.writer.setStyle(t,e.styles[t],s)}}}))}}function vM(e,t){const i=e.plugins.has("ImageInlineEditing"),n=e.plugins.get("ImageUtils");return e=>{e.on("element:a",((e,o,s)=>{const r=o.viewItem,a=n.findViewImgElement(r);if(!a)return;const l=a.findAncestor((e=>n.isBlockImageView(e)));if(i&&!l)return;const c=new co(t._createPattern()).match(r);if(!c)return;if(!s.consumable.test(r,c.match))return;const u=o.modelCursor.parent;u?.is("element","imageBlock")&&(s.writer.setAttribute(t.id,!0,u),s.consumable.consume(r,c.match))}),{priority:"high"})}}class yM extends ad{static get requires(){return[Np,Wp,"ImageBlockEditing"]}static get pluginName(){return"LinkImageUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",((t,i)=>{this._isSelectedLinkedImage(e.model.document.selection)&&(i.preventDefault(),t.stop())}),{priority:"high"}),this._createToolbarLinkImageButton()}_createToolbarLinkImageButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("linkImage",(i=>{const n=new Bn(i),o=e.plugins.get("LinkUI"),s=e.commands.get("link");return n.set({isEnabled:!0,label:t("Link image"),icon:Dp,keystroke:xp,tooltip:!0,isToggleable:!0}),n.bind("isEnabled").to(s,"isEnabled"),n.bind("isOn").to(s,"value",(e=>!!e)),this.listenTo(n,"execute",(()=>{this._isSelectedLinkedImage(e.model.document.selection)?o._addToolbarView():o._showUI(!0)})),n}))}_isSelectedLinkedImage(e){const t=e.getSelectedElement();return this.editor.plugins.get("ImageUtils").isImage(t)&&t.hasAttribute("linkHref")}}class _M extends cd{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection,n=kM(i);this.isEnabled=function(e,t,i){const n=function(e,t){const i=Yh(e,t).start.parent;return i.isEmpty&&!i.is("rootElement")?i.parent:i}(e,i);return t.checkChild(n,"rawHtml")}(i,t,e),this.value=n?n.getAttribute("value")||"":null}execute(e){const t=this.editor.model,i=t.document.selection;t.change((n=>{let o;null!==this.value?o=kM(i):(o=n.createElement("rawHtml"),t.insertObject(o,null,null,{setSelection:"on"})),n.setAttribute("value",e,o)}))}}function kM(e){const t=e.getSelectedElement();return t&&t.is("element","rawHtml")?t:null}class CM extends ad{_widgetButtonViewReferences=new Set;static get pluginName(){return"HtmlEmbedEditing"}static get licenseFeatureCode(){return"HE"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}constructor(e){super(e),e.config.define("htmlEmbed",{showPreviews:!1,sanitizeHtml:e=>(A("html-embed-provide-sanitize-function"),{html:e,hasChanged:!1})})}init(){const e=this.editor;e.model.schema.register("rawHtml",{inheritAllFrom:"$blockObject",allowAttributes:["value"]}),e.commands.add("htmlEmbed",new _M(e)),this._setupConversion()}_setupConversion(){const e=this.editor,t=e.t,i=e.editing.view,n=this._widgetButtonViewReferences,o=e.config.get("htmlEmbed");function s({editor:e,domElement:i,state:o,props:s}){i.textContent="";const a=i.ownerDocument;let l;if(o.isEditable){const e={isDisabled:!1,placeholder:s.textareaPlaceholder};l=r({domDocument:a,state:o,props:e}),i.append(l)}else if(o.showPreviews){const n={sanitizeHtml:s.sanitizeHtml};i.append(function({editor:e,domDocument:i,state:n,props:o}){const s=o.sanitizeHtml(n.getRawHtmlValue()),r=oe(i,"div",{class:"ck ck-reset_all raw-html-embed__preview-placeholder"},n.getRawHtmlValue().length>0?t("No preview available"):t("Empty snippet content")),a=oe(i,"div",{class:"raw-html-embed__preview-content",dir:e.locale.contentLanguageDirection}),l=i.createRange().createContextualFragment(s.html);a.appendChild(l);return oe(i,"div",{class:"raw-html-embed__preview"},[r,a])}({domDocument:a,state:o,props:n,editor:e}))}else{const e={isDisabled:!0,placeholder:s.textareaPlaceholder};i.append(r({domDocument:a,state:o,props:e}))}const c={onEditClick:s.onEditClick,onSaveClick:()=>{s.onSaveClick(l.value)},onCancelClick:s.onCancelClick};i.prepend(function({editor:e,domDocument:t,state:i,props:o}){const s=oe(t,"div",{class:"raw-html-embed__buttons-wrapper"});if(i.isEditable){const t=xM(e,"save",o.onSaveClick),i=xM(e,"cancel",o.onCancelClick);s.append(t.element,i.element),n.add(t).add(i)}else{const t=xM(e,"edit",o.onEditClick);s.append(t.element),n.add(t)}return s}({editor:e,domDocument:a,state:o,props:c}))}function r({domDocument:e,state:t,props:i}){const n=oe(e,"textarea",{placeholder:i.placeholder,class:"ck ck-reset ck-input ck-input-text raw-html-embed__source"});return n.disabled=i.isDisabled,n.value=t.getRawHtmlValue(),n}this.editor.editing.view.on("render",(()=>{for(const e of n){if(e.element&&e.element.isConnected)return;e.destroy(),n.delete(e)}}),{priority:"lowest"}),e.data.registerRawContentMatcher({name:"div",classes:"raw-html-embed"}),e.conversion.for("upcast").elementToElement({view:{name:"div",classes:"raw-html-embed"},model:(e,{writer:t})=>t.createElement("rawHtml",{value:e.getCustomProperty("$rawContent")})}),e.conversion.for("dataDowncast").elementToElement({model:"rawHtml",view:(e,{writer:t})=>t.createRawElement("div",{class:"raw-html-embed"},(function(t){t.innerHTML=e.getAttribute("value")||""}))}),e.conversion.for("editingDowncast").elementToStructure({model:{name:"rawHtml",attributes:["value"]},view:(n,{writer:r})=>{let a,l,c;const u=r.createRawElement("div",{class:"raw-html-embed__content-wrapper"},(function(t){a=t,s({editor:e,domElement:t,state:l,props:c}),a.addEventListener("mousedown",(()=>{if(l.isEditable){const t=e.model;t.document.selection.getSelectedElement()!==n&&t.change((e=>e.setSelection(n,"on")))}}),!0)})),d={makeEditable(){l=Object.assign({},l,{isEditable:!0}),s({domElement:a,editor:e,state:l,props:c}),i.change((e=>{e.setAttribute("data-cke-ignore-events","true",u)})),a.querySelector("textarea").focus()},save(t){t!==l.getRawHtmlValue()?(e.execute("htmlEmbed",t),e.editing.view.focus()):this.cancel()},cancel(){l=Object.assign({},l,{isEditable:!1}),s({domElement:a,editor:e,state:l,props:c}),e.editing.view.focus(),i.change((e=>{e.removeAttribute("data-cke-ignore-events",u)}))}};l={showPreviews:o.showPreviews,isEditable:!1,getRawHtmlValue:()=>n.getAttribute("value")||""},c={sanitizeHtml:o.sanitizeHtml,textareaPlaceholder:t("Paste raw HTML here..."),onEditClick(){d.makeEditable()},onSaveClick(e){d.save(e)},onCancelClick(){d.cancel()}};const h=r.createContainerElement("div",{class:"raw-html-embed","data-html-embed-label":t("HTML snippet"),dir:e.locale.uiLanguageDirection},u);return r.setCustomProperty("rawHtmlApi",d,h),r.setCustomProperty("rawHtml",!0,h),jh(h,r,{label:t("HTML snippet"),hasSelectionHandle:!0})}})}}function xM(e,t,i){const{t:n}=e.locale,o=new Bn(e.locale),s=e.commands.get("htmlEmbed");return o.set({class:`raw-html-embed__${t}-button`,icon:Fp,tooltip:!0,tooltipPosition:"rtl"===e.locale.uiLanguageDirection?"e":"w"}),o.render(),"edit"===t?(o.set({icon:Fp,label:n("Edit source")}),o.bind("isEnabled").to(s)):"save"===t?(o.set({icon:Tu,label:n("Save changes")}),o.bind("isEnabled").to(s)):o.set({icon:On,label:n("Cancel")}),o.on("execute",i),o}class AM extends ad{static get pluginName(){return"HtmlEmbedUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.locale.t;e.ui.componentFactory.add("htmlEmbed",(()=>{const e=this._createButton(Bn);return e.set({tooltip:!0,label:t("Insert HTML")}),e})),e.ui.componentFactory.add("menuBar:htmlEmbed",(()=>{const e=this._createButton(Yu);return e.set({label:t("HTML snippet")}),e}))}_createButton(e){const t=this.editor,i=t.commands.get("htmlEmbed"),n=new e(t.locale);return n.set({icon:''}),n.bind("isEnabled").to(i,"isEnabled"),this.listenTo(n,"execute",(()=>{t.execute("htmlEmbed"),t.editing.view.focus(),t.editing.view.document.selection.getSelectedElement().getCustomProperty("rawHtmlApi").makeEditable()})),n}}class TM extends ja{toView(e){if(!/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(e.trim().slice(0,1e4)))return super.toView(e);let t="",i="";e=(e=e.trim().replace(/<\?xml\s[^?]*\?>/i,(e=>(i=e,"")))).trim().replace(/^]*?>/i,(e=>(t=e,"")));const n=this._toDom(e),o=this.domConverter.domToView(n,{skipComments:this.skipComments}),s=new _c(o.document);s.setCustomProperty("$fullPageDocument",n.ownerDocument.documentElement.outerHTML,o);const r=Array.from(n.ownerDocument.querySelectorAll("head style"));return s.setCustomProperty("$fullPageHeadStyles",r,o),t&&s.setCustomProperty("$fullPageDocType",t,o),i&&s.setCustomProperty("$fullPageXmlDeclaration",i,o),o}toData(e){let t=super.toData(e);const i=e.getCustomProperty("$fullPageDocument"),n=e.getCustomProperty("$fullPageDocType"),o=e.getCustomProperty("$fullPageXmlDeclaration");return i&&(t=i.replace(/<\/body\s*>/,t+"$&"),n&&(t=n+"\n"+t),o&&(t=o+"\n"+t)),t}}function EM(e){return e.config.get("htmlSupport.fullPage.allowRenderStylesFromHead")}class SM extends Hi{tiles;focusTracker;keystrokes;constructor(e){super(e),this.tiles=this.createCollection(),this.setTemplate({tag:"div",children:[{tag:"div",attributes:{class:["ck","ck-character-grid__tiles"]},children:this.tiles}],attributes:{class:["ck","ck-character-grid"]}}),this.focusTracker=new ei,this.keystrokes=new oi,Sb({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.tiles,numberOfColumns:()=>n.window.getComputedStyle(this.element.firstChild).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}createTile(e,t){const i=new Bn(this.locale);return i.set({label:e,withText:!0,class:"ck-character-grid__tile"}),i.extendTemplate({attributes:{title:t},on:{mouseover:i.bindTemplate.to("mouseover"),focus:i.bindTemplate.to("focus")}}),i.on("mouseover",(()=>{this.fire("tileHover",{name:t,character:e})})),i.on("focus",(()=>{this.fire("tileFocus",{name:t,character:e})})),i.on("execute",(()=>{this.fire("execute",{name:t,character:e})})),i}render(){super.render();for(const e of this.tiles)this.focusTracker.add(e.element);this.tiles.on("change",((e,{added:t,removed:i})=>{if(t.length>0)for(const e of t)this.focusTracker.add(e.element);if(i.length>0)for(const e of i)this.focusTracker.remove(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.keystrokes.destroy()}focus(){this.tiles.first.focus()}}class PM extends Hi{constructor(e){super(e);const t=this.bindTemplate;this.set("character",null),this.set("name",null),this.bind("code").to(this,"character",IM),this.setTemplate({tag:"div",children:[{tag:"span",attributes:{class:["ck-character-info__name"]},children:[{text:t.to("name",(e=>e||"​"))}]},{tag:"span",attributes:{class:["ck-character-info__code"]},children:[{text:t.to("code")}]}],attributes:{class:["ck","ck-character-info"]}})}}function IM(e){return null===e?"":"U+"+("0000"+e.codePointAt(0).toString(16)).slice(-4)}class VM extends Hi{items;focusTracker;keystrokes;_focusCycler;categoriesView;gridView;infoView;constructor(e,t,i,n){super(e),this.categoriesView=t,this.gridView=i,this.infoView=n,this.items=this.createCollection(),this.focusTracker=new ei,this.keystrokes=new oi,this._focusCycler=new Nn({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",children:[this.categoriesView,this.gridView,this.infoView],attributes:{tabindex:"-1"}}),this.items.add(this.categoriesView),this.items.add(this.gridView)}render(){super.render(),this.focusTracker.add(this.categoriesView.element),this.focusTracker.add(this.gridView.element),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}}class OM extends Hi{_groupNames;_dropdownView;constructor(e,t){super(e),this.set("currentGroupName",Array.from(t.entries())[0][0]),this._groupNames=t,this._dropdownView=new yf(e,Ef),this.setTemplate({tag:"div",attributes:{class:["ck","ck-character-categories"]},children:[this._dropdownView]})}render(){super.render(),this._setupDropdown()}focus(){this._dropdownView.focus()}_setupDropdown(){const e=new Xt;for(const[t,i]of this._groupNames){const n={type:"button",model:new sf({name:t,label:i,role:"menuitemradio",withText:!0})};n.model.bind("isOn").to(this,"currentGroupName",(e=>e===t)),e.add(n)}const t=(0,this.locale.t)("Category");this._dropdownView.set({label:t,isEmpty:!1}),this._dropdownView.fieldView.panelPosition="rtl"===this.locale.uiLanguageDirection?"se":"sw",this._dropdownView.fieldView.buttonView.set({withText:!0,tooltip:t,ariaLabel:t,ariaLabelledBy:void 0,isOn:!1}),this._dropdownView.fieldView.buttonView.bind("label").to(this,"currentGroupName",(e=>this._groupNames.get(e))),this._dropdownView.fieldView.on("execute",(({source:e})=>{this.currentGroupName=e.name})),Ou(this._dropdownView.fieldView,e,{ariaLabel:t,role:"menu"})}}const RM="All";class LM extends ad{static get pluginName(){return"SpecialCharactersArrows"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Arrows",[{title:t("leftwards simple arrow"),character:"←"},{title:t("rightwards simple arrow"),character:"→"},{title:t("upwards simple arrow"),character:"↑"},{title:t("downwards simple arrow"),character:"↓"},{title:t("leftwards double arrow"),character:"⇐"},{title:t("rightwards double arrow"),character:"⇒"},{title:t("upwards double arrow"),character:"⇑"},{title:t("downwards double arrow"),character:"⇓"},{title:t("leftwards dashed arrow"),character:"⇠"},{title:t("rightwards dashed arrow"),character:"⇢"},{title:t("upwards dashed arrow"),character:"⇡"},{title:t("downwards dashed arrow"),character:"⇣"},{title:t("leftwards arrow to bar"),character:"⇤"},{title:t("rightwards arrow to bar"),character:"⇥"},{title:t("upwards arrow to bar"),character:"⤒"},{title:t("downwards arrow to bar"),character:"⤓"},{title:t("up down arrow with base"),character:"↨"},{title:t("back with leftwards arrow above"),character:"🔙"},{title:t("end with leftwards arrow above"),character:"🔚"},{title:t("on with exclamation mark with left right arrow above"),character:"🔛"},{title:t("soon with rightwards arrow above"),character:"🔜"},{title:t("top with upwards arrow above"),character:"🔝"}],{label:t("Arrows")})}}class BM extends ad{static get pluginName(){return"SpecialCharactersText"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Text",[{character:"‹",title:t("Single left-pointing angle quotation mark")},{character:"›",title:t("Single right-pointing angle quotation mark")},{character:"«",title:t("Left-pointing double angle quotation mark")},{character:"»",title:t("Right-pointing double angle quotation mark")},{character:"‘",title:t("Left single quotation mark")},{character:"’",title:t("Right single quotation mark")},{character:"“",title:t("Left double quotation mark")},{character:"”",title:t("Right double quotation mark")},{character:"‚",title:t("Single low-9 quotation mark")},{character:"„",title:t("Double low-9 quotation mark")},{character:"¡",title:t("Inverted exclamation mark")},{character:"¿",title:t("Inverted question mark")},{character:"‥",title:t("Two dot leader")},{character:"…",title:t("Horizontal ellipsis")},{character:"‡",title:t("Double dagger")},{character:"‰",title:t("Per mille sign")},{character:"‱",title:t("Per ten thousand sign")},{character:"‼",title:t("Double exclamation mark")},{character:"⁈",title:t("Question exclamation mark")},{character:"⁉",title:t("Exclamation question mark")},{character:"⁇",title:t("Double question mark")},{character:"©",title:t("Copyright sign")},{character:"®",title:t("Registered sign")},{character:"™",title:t("Trade mark sign")},{character:"§",title:t("Section sign")},{character:"¶",title:t("Paragraph sign")},{character:"⁋",title:t("Reversed paragraph sign")}],{label:t("Text")})}}class MM extends ad{static get pluginName(){return"SpecialCharactersMathematical"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Mathematical",[{character:"<",title:t("Less-than sign")},{character:">",title:t("Greater-than sign")},{character:"≤",title:t("Less-than or equal to")},{character:"≥",title:t("Greater-than or equal to")},{character:"–",title:t("En dash")},{character:"—",title:t("Em dash")},{character:"¯",title:t("Macron")},{character:"‾",title:t("Overline")},{character:"°",title:t("Degree sign")},{character:"−",title:t("Minus sign")},{character:"±",title:t("Plus-minus sign")},{character:"÷",title:t("Division sign")},{character:"⁄",title:t("Fraction slash")},{character:"×",title:t("Multiplication sign")},{character:"ƒ",title:t("Latin small letter f with hook")},{character:"∫",title:t("Integral")},{character:"∑",title:t("N-ary summation")},{character:"∞",title:t("Infinity")},{character:"√",title:t("Square root")},{character:"∼",title:t("Tilde operator")},{character:"≅",title:t("Approximately equal to")},{character:"≈",title:t("Almost equal to")},{character:"≠",title:t("Not equal to")},{character:"≡",title:t("Identical to")},{character:"∈",title:t("Element of")},{character:"∉",title:t("Not an element of")},{character:"∋",title:t("Contains as member")},{character:"∏",title:t("N-ary product")},{character:"∧",title:t("Logical and")},{character:"∨",title:t("Logical or")},{character:"¬",title:t("Not sign")},{character:"∩",title:t("Intersection")},{character:"∪",title:t("Union")},{character:"∂",title:t("Partial differential")},{character:"∀",title:t("For all")},{character:"∃",title:t("There exists")},{character:"∅",title:t("Empty set")},{character:"∇",title:t("Nabla")},{character:"∗",title:t("Asterisk operator")},{character:"∝",title:t("Proportional to")},{character:"∠",title:t("Angle")},{character:"¼",title:t("Vulgar fraction one quarter")},{character:"½",title:t("Vulgar fraction one half")},{character:"¾",title:t("Vulgar fraction three quarters")}],{label:t("Mathematical")})}}class NM extends ad{static get pluginName(){return"SpecialCharactersLatin"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Latin",[{character:"Ā",title:t("Latin capital letter a with macron")},{character:"ā",title:t("Latin small letter a with macron")},{character:"Ă",title:t("Latin capital letter a with breve")},{character:"ă",title:t("Latin small letter a with breve")},{character:"Ą",title:t("Latin capital letter a with ogonek")},{character:"ą",title:t("Latin small letter a with ogonek")},{character:"Ć",title:t("Latin capital letter c with acute")},{character:"ć",title:t("Latin small letter c with acute")},{character:"Ĉ",title:t("Latin capital letter c with circumflex")},{character:"ĉ",title:t("Latin small letter c with circumflex")},{character:"Ċ",title:t("Latin capital letter c with dot above")},{character:"ċ",title:t("Latin small letter c with dot above")},{character:"Č",title:t("Latin capital letter c with caron")},{character:"č",title:t("Latin small letter c with caron")},{character:"Ď",title:t("Latin capital letter d with caron")},{character:"ď",title:t("Latin small letter d with caron")},{character:"Đ",title:t("Latin capital letter d with stroke")},{character:"đ",title:t("Latin small letter d with stroke")},{character:"Ē",title:t("Latin capital letter e with macron")},{character:"ē",title:t("Latin small letter e with macron")},{character:"Ĕ",title:t("Latin capital letter e with breve")},{character:"ĕ",title:t("Latin small letter e with breve")},{character:"Ė",title:t("Latin capital letter e with dot above")},{character:"ė",title:t("Latin small letter e with dot above")},{character:"Ę",title:t("Latin capital letter e with ogonek")},{character:"ę",title:t("Latin small letter e with ogonek")},{character:"Ě",title:t("Latin capital letter e with caron")},{character:"ě",title:t("Latin small letter e with caron")},{character:"Ĝ",title:t("Latin capital letter g with circumflex")},{character:"ĝ",title:t("Latin small letter g with circumflex")},{character:"Ğ",title:t("Latin capital letter g with breve")},{character:"ğ",title:t("Latin small letter g with breve")},{character:"Ġ",title:t("Latin capital letter g with dot above")},{character:"ġ",title:t("Latin small letter g with dot above")},{character:"Ģ",title:t("Latin capital letter g with cedilla")},{character:"ģ",title:t("Latin small letter g with cedilla")},{character:"Ĥ",title:t("Latin capital letter h with circumflex")},{character:"ĥ",title:t("Latin small letter h with circumflex")},{character:"Ħ",title:t("Latin capital letter h with stroke")},{character:"ħ",title:t("Latin small letter h with stroke")},{character:"Ĩ",title:t("Latin capital letter i with tilde")},{character:"ĩ",title:t("Latin small letter i with tilde")},{character:"Ī",title:t("Latin capital letter i with macron")},{character:"ī",title:t("Latin small letter i with macron")},{character:"Ĭ",title:t("Latin capital letter i with breve")},{character:"ĭ",title:t("Latin small letter i with breve")},{character:"Į",title:t("Latin capital letter i with ogonek")},{character:"į",title:t("Latin small letter i with ogonek")},{character:"İ",title:t("Latin capital letter i with dot above")},{character:"ı",title:t("Latin small letter dotless i")},{character:"IJ",title:t("Latin capital ligature ij")},{character:"ij",title:t("Latin small ligature ij")},{character:"Ĵ",title:t("Latin capital letter j with circumflex")},{character:"ĵ",title:t("Latin small letter j with circumflex")},{character:"Ķ",title:t("Latin capital letter k with cedilla")},{character:"ķ",title:t("Latin small letter k with cedilla")},{character:"ĸ",title:t("Latin small letter kra")},{character:"Ĺ",title:t("Latin capital letter l with acute")},{character:"ĺ",title:t("Latin small letter l with acute")},{character:"Ļ",title:t("Latin capital letter l with cedilla")},{character:"ļ",title:t("Latin small letter l with cedilla")},{character:"Ľ",title:t("Latin capital letter l with caron")},{character:"ľ",title:t("Latin small letter l with caron")},{character:"Ŀ",title:t("Latin capital letter l with middle dot")},{character:"ŀ",title:t("Latin small letter l with middle dot")},{character:"Ł",title:t("Latin capital letter l with stroke")},{character:"ł",title:t("Latin small letter l with stroke")},{character:"Ń",title:t("Latin capital letter n with acute")},{character:"ń",title:t("Latin small letter n with acute")},{character:"Ņ",title:t("Latin capital letter n with cedilla")},{character:"ņ",title:t("Latin small letter n with cedilla")},{character:"Ň",title:t("Latin capital letter n with caron")},{character:"ň",title:t("Latin small letter n with caron")},{character:"ʼn",title:t("Latin small letter n preceded by apostrophe")},{character:"Ŋ",title:t("Latin capital letter eng")},{character:"ŋ",title:t("Latin small letter eng")},{character:"Ō",title:t("Latin capital letter o with macron")},{character:"ō",title:t("Latin small letter o with macron")},{character:"Ŏ",title:t("Latin capital letter o with breve")},{character:"ŏ",title:t("Latin small letter o with breve")},{character:"Ő",title:t("Latin capital letter o with double acute")},{character:"ő",title:t("Latin small letter o with double acute")},{character:"Œ",title:t("Latin capital ligature oe")},{character:"œ",title:t("Latin small ligature oe")},{character:"Ŕ",title:t("Latin capital letter r with acute")},{character:"ŕ",title:t("Latin small letter r with acute")},{character:"Ŗ",title:t("Latin capital letter r with cedilla")},{character:"ŗ",title:t("Latin small letter r with cedilla")},{character:"Ř",title:t("Latin capital letter r with caron")},{character:"ř",title:t("Latin small letter r with caron")},{character:"Ś",title:t("Latin capital letter s with acute")},{character:"ś",title:t("Latin small letter s with acute")},{character:"Ŝ",title:t("Latin capital letter s with circumflex")},{character:"ŝ",title:t("Latin small letter s with circumflex")},{character:"Ş",title:t("Latin capital letter s with cedilla")},{character:"ş",title:t("Latin small letter s with cedilla")},{character:"Š",title:t("Latin capital letter s with caron")},{character:"š",title:t("Latin small letter s with caron")},{character:"Ţ",title:t("Latin capital letter t with cedilla")},{character:"ţ",title:t("Latin small letter t with cedilla")},{character:"Ť",title:t("Latin capital letter t with caron")},{character:"ť",title:t("Latin small letter t with caron")},{character:"Ŧ",title:t("Latin capital letter t with stroke")},{character:"ŧ",title:t("Latin small letter t with stroke")},{character:"Ũ",title:t("Latin capital letter u with tilde")},{character:"ũ",title:t("Latin small letter u with tilde")},{character:"Ū",title:t("Latin capital letter u with macron")},{character:"ū",title:t("Latin small letter u with macron")},{character:"Ŭ",title:t("Latin capital letter u with breve")},{character:"ŭ",title:t("Latin small letter u with breve")},{character:"Ů",title:t("Latin capital letter u with ring above")},{character:"ů",title:t("Latin small letter u with ring above")},{character:"Ű",title:t("Latin capital letter u with double acute")},{character:"ű",title:t("Latin small letter u with double acute")},{character:"Ų",title:t("Latin capital letter u with ogonek")},{character:"ų",title:t("Latin small letter u with ogonek")},{character:"Ŵ",title:t("Latin capital letter w with circumflex")},{character:"ŵ",title:t("Latin small letter w with circumflex")},{character:"Ŷ",title:t("Latin capital letter y with circumflex")},{character:"ŷ",title:t("Latin small letter y with circumflex")},{character:"Ÿ",title:t("Latin capital letter y with diaeresis")},{character:"Ź",title:t("Latin capital letter z with acute")},{character:"ź",title:t("Latin small letter z with acute")},{character:"Ż",title:t("Latin capital letter z with dot above")},{character:"ż",title:t("Latin small letter z with dot above")},{character:"Ž",title:t("Latin capital letter z with caron")},{character:"ž",title:t("Latin small letter z with caron")},{character:"ſ",title:t("Latin small letter long s")}],{label:t("Latin")})}}class FM extends ad{static get pluginName(){return"SpecialCharactersCurrency"}static get isOfficialPlugin(){return!0}init(){const e=this.editor,t=e.t;e.plugins.get("SpecialCharacters").addItems("Currency",[{character:"$",title:t("Dollar sign")},{character:"€",title:t("Euro sign")},{character:"¥",title:t("Yen sign")},{character:"£",title:t("Pound sign")},{character:"¢",title:t("Cent sign")},{character:"₠",title:t("Euro-currency sign")},{character:"₡",title:t("Colon sign")},{character:"₢",title:t("Cruzeiro sign")},{character:"₣",title:t("French franc sign")},{character:"₤",title:t("Lira sign")},{character:"¤",title:t("Currency sign")},{character:"₿",title:t("Bitcoin sign")},{character:"₥",title:t("Mill sign")},{character:"₦",title:t("Naira sign")},{character:"₧",title:t("Peseta sign")},{character:"₨",title:t("Rupee sign")},{character:"₩",title:t("Won sign")},{character:"₪",title:t("New sheqel sign")},{character:"₫",title:t("Dong sign")},{character:"₭",title:t("Kip sign")},{character:"₮",title:t("Tugrik sign")},{character:"₯",title:t("Drachma sign")},{character:"₰",title:t("German penny sign")},{character:"₱",title:t("Peso sign")},{character:"₲",title:t("Guarani sign")},{character:"₳",title:t("Austral sign")},{character:"₴",title:t("Hryvnia sign")},{character:"₵",title:t("Cedi sign")},{character:"₶",title:t("Livre tournois sign")},{character:"₷",title:t("Spesmilo sign")},{character:"₸",title:t("Tenge sign")},{character:"₹",title:t("Indian rupee sign")},{character:"₺",title:t("Turkish lira sign")},{character:"₻",title:t("Nordic mark sign")},{character:"₼",title:t("Manat sign")},{character:"₽",title:t("Ruble sign")}],{label:t("Currency")})}}class DM extends cd{constructor(e){super(e),this.affectsData=!1,this.value=!1}execute(){const e="ck-show-blocks",t=this.editor.editing.view;t.change((i=>{for(const n of t.document.roots)n.hasClass(e)?(i.removeClass(e,n),this.value=!1):(i.addClass(e,n),this.value=!0)}))}}class zM extends ad{static get pluginName(){return"ShowBlocksEditing"}static get isOfficialPlugin(){return!0}init(){const{editor:e}=this;e.commands.add("showBlocks",new DM(e))}}class HM extends ad{static get pluginName(){return"ShowBlocksUI"}static get isOfficialPlugin(){return!0}init(){const e=this.editor;e.ui.componentFactory.add("showBlocks",(()=>{const e=this._createButton(Bn);return e.set({tooltip:!0,icon:''}),e})),e.ui.componentFactory.add("menuBar:showBlocks",(()=>this._createButton(Yu)))}_createButton(e){const t=this.editor,i=t.locale,n=t.commands.get("showBlocks"),o=new e(i),s=i.t;return o.set({label:s("Show blocks"),isToggleable:!0,role:"menuitemcheckbox"}),o.bind("isEnabled").to(n),o.bind("isOn").to(n,"value",n,"isEnabled",((e,t)=>e&&t)),this.listenTo(o,"execute",(()=>{t.execute("showBlocks"),t.editing.view.focus()})),o}}const UM='';class $M extends Hi{children;_findInputView;_replaceInputView;_findButtonView;_findPrevButtonView;_findNextButtonView;_advancedOptionsCollapsibleView;_matchCaseSwitchView;_wholeWordsOnlySwitchView;_replaceButtonView;_replaceAllButtonView;_inputsDivView;_actionButtonsDivView;_focusTracker;_keystrokes;_focusables;focusCycler;constructor(e){super(e);const t=e.t;this.children=this.createCollection(),this.set("matchCount",0),this.set("highlightOffset",0),this.set("isDirty",!1),this.set("_areCommandsEnabled",{}),this.set("_resultsCounterText",""),this.set("_matchCase",!1),this.set("_wholeWordsOnly",!1),this.bind("_searchResultsFound").to(this,"matchCount",this,"isDirty",((e,t)=>e>0&&!t)),this._findInputView=this._createInputField(t("Find in text…")),this._findPrevButtonView=this._createButton({label:t("Previous result"),class:"ck-button-prev",icon:cm,keystroke:"Shift+F3",tooltip:!0}),this._findNextButtonView=this._createButton({label:t("Next result"),class:"ck-button-next",icon:cm,keystroke:"F3",tooltip:!0}),this._replaceInputView=this._createInputField(t("Replace with…"),"ck-labeled-field-replace"),this._inputsDivView=this._createInputsDiv(),this._matchCaseSwitchView=this._createMatchCaseSwitch(),this._wholeWordsOnlySwitchView=this._createWholeWordsOnlySwitch(),this._advancedOptionsCollapsibleView=this._createAdvancedOptionsCollapsible(),this._replaceAllButtonView=this._createButton({label:t("Replace all"),class:"ck-button-replaceall",withText:!0}),this._replaceButtonView=this._createButton({label:t("Replace"),class:"ck-button-replace",withText:!0}),this._findButtonView=this._createButton({label:t("Find"),class:"ck-button-find ck-button-action",withText:!0}),this._actionButtonsDivView=this._createActionButtonsDiv(),this._focusTracker=new ei,this._keystrokes=new oi,this._focusables=new wi,this.focusCycler=new Nn({focusables:this._focusables,focusTracker:this._focusTracker,keystrokeHandler:this._keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.children.addMany([this._inputsDivView,this._advancedOptionsCollapsibleView,this._actionButtonsDivView]),this.setTemplate({tag:"form",attributes:{class:["ck","ck-find-and-replace-form"],tabindex:"-1"},children:this.children})}render(){super.render(),vf({view:this}),this._initFocusCycling(),this._initKeystrokeHandling()}destroy(){super.destroy(),this._focusTracker.destroy(),this._keystrokes.destroy()}focus(e){-1===e?this.focusCycler.focusLast():this.focusCycler.focusFirst()}reset(){this._findInputView.errorText=null,this.isDirty=!0}get _textToFind(){return this._findInputView.fieldView.element.value}get _textToReplace(){return this._replaceInputView.fieldView.element.value}_createInputsDiv(){const e=this.locale,t=e.t,i=new Hi(e);return this._findInputView.fieldView.on("input",(()=>{this.isDirty=!0})),this._findPrevButtonView.delegate("execute").to(this,"findPrevious"),this._findNextButtonView.delegate("execute").to(this,"findNext"),this._findPrevButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",(({findPrevious:e})=>e)),this._findNextButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",(({findNext:e})=>e)),this._injectFindResultsCounter(),this._replaceInputView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replace:e},t)=>e&&t)),this._replaceInputView.bind("infoText").to(this._replaceInputView,"isEnabled",this._replaceInputView,"isFocused",((e,i)=>e||!i?"":t("Tip: Find some text first in order to replace it."))),i.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__inputs"]},children:[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView]}),i}_onFindButtonExecute(){if(this._textToFind)this.isDirty=!1,this.fire("findNext",{searchText:this._textToFind,matchCase:this._matchCase,wholeWords:this._wholeWordsOnly});else{const e=this.t;this._findInputView.errorText=e("Text to find must not be empty.")}}_injectFindResultsCounter(){const e=this.locale,t=e.t,i=this.bindTemplate,n=new Hi(this.locale);this.bind("_resultsCounterText").to(this,"highlightOffset",this,"matchCount",((e,i)=>t("%0 of %1",[e,i]))),n.setTemplate({tag:"span",attributes:{class:["ck","ck-results-counter",i.if("isDirty","ck-hidden")]},children:[{text:i.to("_resultsCounterText")}]});const o=()=>{const t=this._findInputView.fieldView.element;if(!t||!ht(t))return;const i=new Ze(n.element).width,o="ltr"===e.uiLanguageDirection?"paddingRight":"paddingLeft";t.style[o]=i?`calc( 2 * var(--ck-spacing-standard) + ${i}px )`:""};this.on("change:_resultsCounterText",o,{priority:"low"}),this.on("change:isDirty",o,{priority:"low"}),this._findInputView.template.children[0].children.push(n)}_createAdvancedOptionsCollapsible(){const e=this.locale.t,t=new Uf(this.locale,[this._matchCaseSwitchView,this._wholeWordsOnlySwitchView]);return t.set({label:e("Advanced options"),isCollapsed:!0}),t}_createActionButtonsDiv(){const e=new Hi(this.locale);return this._replaceButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replace:e},t)=>e&&t)),this._replaceAllButtonView.bind("isEnabled").to(this,"_areCommandsEnabled",this,"_searchResultsFound",(({replaceAll:e},t)=>e&&t)),this._replaceButtonView.on("execute",(()=>{this.fire("replace",{searchText:this._textToFind,replaceText:this._textToReplace})})),this._replaceAllButtonView.on("execute",(()=>{this.fire("replaceAll",{searchText:this._textToFind,replaceText:this._textToReplace}),this.focus()})),this._findButtonView.on("execute",this._onFindButtonExecute.bind(this)),e.setTemplate({tag:"div",attributes:{class:["ck","ck-find-and-replace-form__actions"]},children:[this._replaceAllButtonView,this._replaceButtonView,this._findButtonView]}),e}_createMatchCaseSwitch(){const e=this.locale.t,t=new Au(this.locale);return t.set({label:e("Match case"),withText:!0}),t.bind("isOn").to(this,"_matchCase"),t.on("execute",(()=>{this._matchCase=!this._matchCase,this.isDirty=!0})),t}_createWholeWordsOnlySwitch(){const e=this.locale.t,t=new Au(this.locale);return t.set({label:e("Whole words only"),withText:!0}),t.bind("isOn").to(this,"_wholeWordsOnly"),t.on("execute",(()=>{this._wholeWordsOnly=!this._wholeWordsOnly,this.isDirty=!0})),t}_initFocusCycling(){[this._findInputView,this._findPrevButtonView,this._findNextButtonView,this._replaceInputView,this._advancedOptionsCollapsibleView.buttonView,this._matchCaseSwitchView,this._wholeWordsOnlySwitchView,this._replaceAllButtonView,this._replaceButtonView,this._findButtonView].forEach((e=>{this._focusables.add(e),this._focusTracker.add(e.element)}))}_initKeystrokeHandling(){const e=e=>e.stopPropagation(),t=e=>{e.stopPropagation(),e.preventDefault()};this._keystrokes.listenTo(this.element),this._keystrokes.set("f3",(e=>{t(e),this._findNextButtonView.fire("execute")})),this._keystrokes.set("shift+f3",(e=>{t(e),this._findPrevButtonView.fire("execute")})),this._keystrokes.set("enter",(e=>{const i=e.target;i===this._findInputView.fieldView.element?(this._areCommandsEnabled.findNext?this._findNextButtonView.fire("execute"):this._findButtonView.fire("execute"),t(e)):i!==this._replaceInputView.fieldView.element||this.isDirty||(this._replaceButtonView.fire("execute"),t(e))})),this._keystrokes.set("shift+enter",(e=>{e.target===this._findInputView.fieldView.element&&(this._areCommandsEnabled.findPrevious?this._findPrevButtonView.fire("execute"):this._findButtonView.fire("execute"),t(e))})),this._keystrokes.set("arrowright",e),this._keystrokes.set("arrowleft",e),this._keystrokes.set("arrowup",e),this._keystrokes.set("arrowdown",e)}_createButton(e){const t=new Bn(this.locale);return t.set(e),t}_createInputField(e,t){const i=new yf(this.locale,Af);return i.label=e,i.class=t,i}}class qM extends ad{static get requires(){return[eg]}static get pluginName(){return"FindAndReplaceUI"}static get isOfficialPlugin(){return!0}formView;constructor(e){super(e),e.config.define("findAndReplace.uiType","dialog"),this.formView=null}init(){const e=this.editor,t="dropdown"===e.config.get("findAndReplace.uiType"),i=e.commands.get("find"),n=this.editor.t;e.ui.componentFactory.add("findAndReplace",(()=>{let n;return t?(n=this._createDropdown(),n.bind("isEnabled").to(i)):n=this._createDialogButtonForToolbar(),e.keystrokes.set("Ctrl+F",((t,o)=>{if(i.isEnabled){if(n instanceof wu){const e=n.buttonView;e.isOn||e.fire("execute")}else n.isOn?e.plugins.get("Dialog").view.focus():n.fire("execute");o()}})),n})),t||e.ui.componentFactory.add("menuBar:findAndReplace",(()=>this._createDialogButtonForMenuBar())),e.accessibility.addKeystrokeInfos({keystrokes:[{label:n("Find in the document"),keystroke:"CTRL+F"}]})}_createDropdown(){const e=this.editor,t=e.locale.t,i=Pu(e.locale);return i.once("change:isOpen",(()=>{this.formView=this._createFormView(),this.formView.children.add(new Rn(e.locale,{label:t("Find and replace")}),0),i.panelView.children.add(this.formView)})),i.on("change:isOpen",((e,t,i)=>{i?this._setupFormView():this.fire("searchReseted")}),{priority:"low"}),i.buttonView.set({icon:UM,label:t("Find and replace"),keystroke:"CTRL+F",tooltip:!0}),i}_createDialogButtonForToolbar(){const e=this.editor,t=this._createButton(Bn),i=e.plugins.get("Dialog");return t.set({tooltip:!0}),t.bind("isOn").to(i,"id",(e=>"findAndReplace"===e)),t.on("execute",(()=>{t.isOn?i.hide():this._showDialog()})),t}_createDialogButtonForMenuBar(){const e=this._createButton(Yu),t=this.editor.plugins.get("Dialog"),i=this.editor.plugins.get("Dialog");return e.set({role:"menuitemcheckbox",isToggleable:!0}),e.bind("isOn").to(i,"id",(e=>"findAndReplace"===e)),e.on("execute",(()=>{"findAndReplace"!==t.id?this._showDialog():t.hide()})),e}_createButton(e){const t=this.editor,i=t.commands.get("find"),n=new e(t.locale),o=t.locale.t;return n.bind("isEnabled").to(i),n.set({icon:UM,label:o("Find and replace"),keystroke:"CTRL+F"}),n}_showDialog(){const e=this.editor,t=e.plugins.get("Dialog"),i=e.locale.t;this.formView||(this.formView=this._createFormView()),t.show({id:"findAndReplace",title:i("Find and replace"),content:this.formView,position:jn,onShow:()=>{this._setupFormView()},onHide:()=>{this.fire("searchReseted")}})}_createFormView(){const e=this.editor,t=new(bf($M))(e.locale),i=e.commands,n=this.editor.plugins.get("FindAndReplaceEditing").state;t.bind("highlightOffset").to(n,"highlightedOffset"),t.listenTo(n.results,"change",(()=>{t.matchCount=n.results.length}));const o=i.get("findNext"),s=i.get("findPrevious"),r=i.get("replace"),a=i.get("replaceAll");return t.bind("_areCommandsEnabled").to(o,"isEnabled",s,"isEnabled",r,"isEnabled",a,"isEnabled",((e,t,i,n)=>({findNext:e,findPrevious:t,replace:i,replaceAll:n}))),t.delegate("findNext","findPrevious","replace","replaceAll").to(this),t.on("change:isDirty",((e,t,i)=>{i&&this.fire("searchReseted")})),t}_setupFormView(){this.formView.disableCssTransitions(),this.formView.reset(),this.formView._findInputView.fieldView.select(),this.formView.enableCssTransitions()}}class jM extends cd{_state;constructor(e,t){super(e),this.isEnabled=!0,this.affectsData=!1,this._state=t}execute(e,{matchCase:t,wholeWords:i}={}){const{editor:n}=this,{model:o}=n,s=n.plugins.get("FindAndReplaceUtils");let r,a="";r="string"==typeof e?(...n)=>({results:s.findByTextCallback(e,{matchCase:t,wholeWords:i})(...n),searchText:e}):e;const l=r;r=(...e)=>{const t=l(...e);return t&&"searchText"in t&&(a=t.searchText),t};const c=o.document.getRootNames().reduce(((e,t)=>s.updateFindResultFromRange(o.createRangeIn(o.document.getRoot(t)),o,r,e)),null);return this._state.clear(o),this._state.results.addMany(c),this._state.highlightedResult=c.get(0),this._state.searchText=a,r&&(this._state.lastSearchCallback=r),this._state.matchCase=!!t,this._state.matchWholeWords=!!i,{results:c,findCallback:r}}}class WM extends(G()){constructor(e){super(),this.set("results",new Xt),this.set("highlightedResult",null),this.set("highlightedOffset",0),this.set("searchText",""),this.set("replaceText",""),this.set("lastSearchCallback",null),this.set("matchCase",!1),this.set("matchWholeWords",!1),this.results.on("change",((t,{removed:i,index:n})=>{if(Array.from(i).length){let t=!1;if(e.change((n=>{for(const o of i)this.highlightedResult===o&&(t=!0),e.markers.has(o.marker.name)&&n.removeMarker(o.marker)})),t){const e=n>=this.results.length?0:n;this.highlightedResult=this.results.get(e)}}})),this.on("change:highlightedResult",(()=>{this.refreshHighlightOffset(e)}))}clear(e){this.searchText="",e.change((t=>{if(this.highlightedResult){const i=this.highlightedResult.marker.name.split(":")[1],n=e.markers.get(`findResultHighlighted:${i}`);n&&t.removeMarker(n)}[...this.results].forEach((({marker:e})=>{t.removeMarker(e)}))})),this.results.clear()}refreshHighlightOffset(e){const{highlightedResult:t,results:i}=this;this.highlightedOffset=t?GM(e,[...i]).indexOf(t)+1:0}}function GM(e,t){const i={before:-1,same:0,after:1,different:1};return e.document.getRootNames().flatMap((e=>t.filter((t=>t.marker.getStart().root.rootName===e)).sort(((e,t)=>i[e.marker.getStart().compareWith(t.marker.getStart())]))))}class KM extends cd{_state;constructor(e,t){super(e),this.isEnabled=!0,this._state=t,this._isEnabledBasedOnSelection=!1}_replace(e,t){const{model:i}=this.editor,n=t.marker.getRange();i.canEditAt(n)&&i.change((o=>{if("$graveyard"===n.root.rootName)return void this._state.results.remove(t);let s={};for(const e of n.getItems())if(e.is("$text")||e.is("$textProxy")){s=e.getAttributes();break}i.insertContent(o.createText(e,s),n),this._state.results.has(t)&&this._state.results.remove(t)}))}}class JM extends KM{execute(e,t){const i=Math.max(this._state.highlightedOffset-1,0);if(this._replace(e,t),this._state.results.length){const e=GM(this.editor.model,[...this._state.results]);this._state.highlightedResult=e[i%e.length]}}}class YM extends KM{execute(e,t){const{editor:i}=this,{model:n}=i,o=i.plugins.get("FindAndReplaceUtils"),s=t instanceof Xt?t:n.document.getRootNames().reduce(((e,i)=>o.updateFindResultFromRange(n.createRangeIn(n.document.getRoot(i)),n,o.findByTextCallback(t,this._state),e)),null);s.length&&n.change((()=>{[...s].forEach((t=>{this._replace(e,t)}))}))}}class QM extends cd{_state;constructor(e,t){super(e),this.affectsData=!1,this._state=t,this.isEnabled=!1,this.listenTo(this._state.results,"change",(()=>{this.isEnabled=this._state.results.length>1}))}refresh(){this.isEnabled=this._state.results.length>1}execute(){const e=this._state.results,t=e.getIndex(this._state.highlightedResult),i=t+1>=e.length?0:t+1;this._state.highlightedResult=this._state.results.get(i)}}class XM extends QM{execute(){const e=this._state.results.getIndex(this._state.highlightedResult),t=e-1<0?this._state.results.length-1:e-1;this._state.highlightedResult=this._state.results.get(t)}}class ZM extends ad{static get pluginName(){return"FindAndReplaceUtils"}static get isOfficialPlugin(){return!0}updateFindResultFromRange(e,t,i,n){const o=n||new Xt;return t.change((n=>{[...e].forEach((({type:e,item:s})=>{if("elementStart"===e&&t.schema.checkChild(s,"$text")){let e=i({item:s,text:this.rangeToText(t.createRangeIn(s))});if(!e)return;"results"in e&&(e=e.results),e.forEach((e=>{const t=`findResult:${_()}`,i=n.addMarker(t,{usingOperation:!1,affectsData:!1,range:n.createRange(n.createPositionAt(s,e.start),n.createPositionAt(s,e.end))}),r=function(e,t){const i=e.find((({marker:e})=>t.getStart().isBefore(e.getStart())));return i?e.getIndex(i):e.length}(o,i);(e=>o.find((t=>{const{marker:i}=t,n=i.getRange(),o=e.getRange();return n.isEqual(o)})))(i)||o.add({id:t,label:e.label,marker:i},r)}))}}))})),o}rangeToText(e){return Array.from(e.getItems({shallow:!0})).reduce(((e,t)=>t.is("$text")||t.is("$textProxy")?e+t.data:`${e}\n`),"")}findByTextCallback(e,t){let i="gu";t.matchCase||(i+="i");let n=`(${o=e,function(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}(Ah(o))})`;var o;if(t.wholeWords){const t="[^a-zA-ZÀ-ɏḀ-ỿ]";new RegExp("^"+t).test(e)||(n=`(^|${t}|_)${n}`),new RegExp(t+"$").test(e)||(n=`${n}(?=_|${t}|$)`)}const s=new RegExp(n,i);return function({text:e}){return[...e.matchAll(s)].map(eN)}}}function eN(e){const t=e.length-1;let i=e.index;return 3===e.length&&(i+=e[1].length),{label:e[t],start:i,end:i+e[t].length}}class tN extends ad{static get requires(){return[ZM]}static get pluginName(){return"FindAndReplaceEditing"}static get licenseFeatureCode(){return"FAR"}static get isPremiumPlugin(){return!0}static get isOfficialPlugin(){return!0}state;init(){this.state=new WM(this.editor.model),this.set("_isSearchActive",!1),this._defineConverters(),this._defineCommands(),this.listenTo(this.state,"change:highlightedResult",((e,t,i,n)=>{const{model:o}=this.editor;o.change((e=>{if(n){const t=n.marker.name.split(":")[1],i=o.markers.get(`findResultHighlighted:${t}`);i&&e.removeMarker(i)}if(i){const t=i.marker.name.split(":")[1];e.addMarker(`findResultHighlighted:${t}`,{usingOperation:!1,affectsData:!1,range:i.marker.getRange()})}}))}));const e=Wi(((e,t,i)=>{if(i){const e=this.editor.editing.view.domConverter,t=this.editor.editing.mapper.toViewRange(i.marker.getRange());yt({target:e.viewRangeToDom(t),viewportOffset:40})}}).bind(this),32);this.listenTo(this.state,"change:highlightedResult",e,{priority:"low"}),this.listenTo(this.editor,"destroy",e.cancel),this.on("change:_isSearchActive",((e,t,i)=>{i?this.listenTo(this.editor.model.document,"change:data",this._onDocumentChange):this.stopListening(this.editor.model.document,"change:data",this._onDocumentChange)}))}find(e,t){return this._isSearchActive=!0,this.editor.execute("find",e,t),this.state.results}stop(){this.state.clear(this.editor.model),this._isSearchActive=!1}_defineCommands(){this.editor.commands.add("find",new jM(this.editor,this.state)),this.editor.commands.add("findNext",new QM(this.editor,this.state)),this.editor.commands.add("findPrevious",new XM(this.editor,this.state)),this.editor.commands.add("replace",new JM(this.editor,this.state)),this.editor.commands.add("replaceAll",new YM(this.editor,this.state))}_defineConverters(){const{editor:e}=this;e.conversion.for("editingDowncast").markerToHighlight({model:"findResult",view:({markerName:e})=>{const[,t]=e.split(":");return{name:"span",classes:["ck-find-result"],attributes:{"data-find-result":t}}}}),e.conversion.for("editingDowncast").markerToHighlight({model:"findResultHighlighted",view:({markerName:e})=>{const[,t]=e.split(":");return{name:"span",classes:["ck-find-result_selected"],attributes:{"data-find-result":t}}}})}_onDocumentChange=()=>{const e=new Set,t=new Set,i=this.editor.model,{results:n}=this.state,o=i.document.differ.getChanges(),s=i.document.differ.getChangedMarkers();o.forEach((n=>{n.position&&("$text"===n.name||n.position.nodeAfter&&i.schema.isInline(n.position.nodeAfter)?(e.add(n.position.parent),[...i.markers.getMarkersAtPosition(n.position)].forEach((e=>{t.add(e.name)}))):"insert"===n.type&&n.position.nodeAfter&&e.add(n.position.nodeAfter))})),s.forEach((({name:e,data:{newRange:i}})=>{i&&"$graveyard"===i.start.root.rootName&&t.add(e)})),e.forEach((e=>{[...i.markers.getMarkersIntersectingRange(i.createRangeIn(e))].forEach((e=>t.add(e.name)))})),t.forEach((e=>{n.has(e)&&(n.get(e)===this.state.highlightedResult&&(this.state.highlightedResult=null),n.remove(e))}));const r=[],a=this.editor.plugins.get("FindAndReplaceUtils");e.forEach((e=>{const t=a.updateFindResultFromRange(i.createRangeOn(e),i,this.state.lastSearchCallback,n);r.push(...t)})),s.forEach((e=>{if(e.data.newRange){const t=a.updateFindResultFromRange(e.data.newRange,i,this.state.lastSearchCallback,n);r.push(...t)}})),!this.state.highlightedResult&&r.length?this.state.highlightedResult=r[0]:this.state.refreshHighlightOffset(i)}}class iN extends Nd{}iN.builtinPlugins=[class extends ad{static get requires(){return[ng,Mm,Bh,Um,Dh,fh,Xm]}static get pluginName(){return"Essentials"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[sg]}static get pluginName(){return"CKFinderUploadAdapter"}static get isOfficialPlugin(){return!0}init(){const e=this.editor.config.get("ckfinder.uploadUrl");e&&(this.editor.plugins.get(sg).createUploadAdapter=t=>new cg(t,e,this.editor.t))}},class extends ad{static get requires(){return[Px,Rx]}static get pluginName(){return"CodeBlock"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[gh]}static get pluginName(){return"Autoformat"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=this.editor.t;this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats(),e.accessibility.addKeystrokeInfos({keystrokes:[{label:t("Revert autoformatting action"),keystroke:"Backspace"}]})}_addListAutoformats(){const e=this.editor.commands;e.get("bulletedList")&&ug(this.editor,this,/^[*-]\s$/,"bulletedList"),e.get("numberedList")&&ug(this.editor,this,/^1[.|)]\s$/,"numberedList"),e.get("todoList")&&ug(this.editor,this,/^\[\s?\]\s$/,"todoList"),e.get("checkTodoList")&&ug(this.editor,this,/^\[\s?x\s?\]\s$/,(()=>{this.editor.execute("todoList"),this.editor.execute("checkTodoList")}))}_addBasicStylesAutoformats(){const e=this.editor.commands;if(e.get("bold")){const e=mg(this.editor,"bold");dg(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,e),dg(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,e)}if(e.get("italic")){const e=mg(this.editor,"italic");dg(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,e),dg(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,e)}if(e.get("code")){const e=mg(this.editor,"code");dg(this.editor,this,/(`)([^`]+)(`)$/g,e)}if(e.get("strikethrough")){const e=mg(this.editor,"strikethrough");dg(this.editor,this,/(~~)([^~]+)(~~)$/g,e)}}_addHeadingAutoformats(){const e=this.editor.commands.get("heading");e&&e.modelElements.filter((e=>e.match(/^heading[1-6]$/))).forEach((t=>{const i=t[7],n=new RegExp(`^(#{${i}})\\s$`);ug(this.editor,this,n,(()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute("heading",{value:t})}))}))}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&ug(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const e=this.editor,t=e.model.document.selection;e.commands.get("codeBlock")&&ug(e,this,/^```$/,(()=>{if(t.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})}))}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&ug(this.editor,this,/^---$/,"horizontalLine")}},class extends ad{static get requires(){return[pg,vg]}static get pluginName(){return"Bold"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[_g,Cg]}static get pluginName(){return"Italic"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[Ag,Eg]}static get pluginName(){return"Underline"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[Pg,Vg]}static get pluginName(){return"Strikethrough"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[Rg,Bg]}static get pluginName(){return"Code"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[Ng,Dg]}static get pluginName(){return"Subscript"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[Hg,$g]}static get pluginName(){return"Superscript"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[Kg,Jg]}static get pluginName(){return"BlockQuote"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[of,rf]}static get pluginName(){return"Heading"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[jf,Gf]}static get pluginName(){return"Image"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[Yf,Xf]}static get pluginName(){return"ImageCaption"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[mp,fp]}static get pluginName(){return"ImageStyle"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[fm,gf]}static get pluginName(){return"ImageToolbar"}static get isOfficialPlugin(){return!0}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(fm),n=e.plugins.get("ImageUtils");var o;i.register("image",{ariaLabel:t("Image toolbar"),items:(o=e.config.get("image.toolbar")||[],o.map((e=>z(e)?e.name:e))),getRelatedElement:e=>n.getClosestSelectedImageWidget(e)})}},class extends ad{static get requires(){return[qv,Qv,iy,Wv]}static get pluginName(){return"ImageResize"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[Np,Wp,Jp]}static get pluginName(){return"Link"}static get isOfficialPlugin(){return!0}},class extends ad{static get requires(){return[Mv,Uv]}static get pluginName(){return"List"}static get isOfficialPlugin(){return!0}},Zg,class extends ad{static get requires(){return[cy,gy]}static get pluginName(){return"Alignment"}static get isOfficialPlugin(){return!0}},class extends ad{adapter;_debouncedSave;_lastDocumentVersion;_savePromise;_domEmitter;_config;_pendingActions;_makeImmediateSave;_action=null;static get pluginName(){return"Autosave"}static get isOfficialPlugin(){return!0}static get requires(){return[Md]}constructor(e){super(e);const t=e.config.get("autosave")||{},i=t.waitingTime||1e3;this.set("state","synchronized"),this._debouncedSave=Wi(this._save.bind(this),i),this._lastDocumentVersion=e.model.document.version,this._savePromise=null,this._domEmitter=new($e()),this._config=t,this._pendingActions=e.plugins.get(Md),this._makeImmediateSave=!1}init(){const e=this.editor,t=e.model.document;this.listenTo(e,"ready",(()=>{this.listenTo(t,"change:data",((e,t)=>{this._saveCallbacks.length&&t.isLocal&&("synchronized"===this.state&&(this.state="waiting",this._setPendingAction()),"waiting"===this.state&&this._debouncedSave())}))})),this.listenTo(e,"destroy",(()=>this._flush()),{priority:"highest"}),this._domEmitter.listenTo(window,"beforeunload",((e,t)=>{this._pendingActions.hasAny&&(t.returnValue=this._pendingActions.first.message)}))}destroy(){this._domEmitter.stopListening(),super.destroy()}save(){return this._debouncedSave.cancel(),this._save()}_flush(){this._debouncedSave.flush()}_save(){return this._savePromise?(this._makeImmediateSave=this.editor.model.document.version>this._lastDocumentVersion,this._savePromise):(this._setPendingAction(),this.state="saving",this._lastDocumentVersion=this.editor.model.document.version,this._savePromise=Promise.resolve().then((()=>Promise.all(this._saveCallbacks.map((e=>e(this.editor)))))).finally((()=>{this._savePromise=null})).then((()=>{if(this._makeImmediateSave)return this._makeImmediateSave=!1,this._save();this.editor.model.document.version>this._lastDocumentVersion?(this.state="waiting",this._debouncedSave()):(this.state="synchronized",this._pendingActions.remove(this._action),this._action=null)})).catch((e=>{throw this.state="error",this.state="saving",this._debouncedSave(),e})),this._savePromise)}_setPendingAction(){const e=this.editor.t;this._action||(this._action=this._pendingActions.add(e("Saving changes")))}get _saveCallbacks(){const e=[];return this.adapter&&this.adapter.save&&e.push(this.adapter.save),this._config.save&&e.push(this._config.save),e}},class extends ad{static get requires(){return[Gw,iv,uv,gv]}static get pluginName(){return"Font"}static get isOfficialPlugin(){return!0}},class extends ad{static get pluginName(){return"PasteFromOffice"}static get licenseFeatureCode(){return"PFO"}static get isOfficialPlugin(){return!0}static get isPremiumPlugin(){return!0}static get requires(){return[Qd]}init(){const e=this.editor,t=e.plugins.get("ClipboardPipeline"),i=e.editing.view.document,n=[],o=this.editor.plugins.has("MultiLevelListEditing"),s=this.editor.plugins.has("TablePropertiesEditing"),r=!!this.editor.config.get("experimentalFlags.useExtendedTableBlockAlignment");n.push(new Oy(i,o,s,r)),n.push(new Fy(i)),n.push(new zy(i)),t.on("inputTransformation",((t,o)=>{if(o._isTransformedWithPasteFromOffice)return;if(e.model.document.selection.getFirstPosition().parent.is("element","codeBlock"))return;const s=o.dataTransfer.getData("text/html"),r=n.find((e=>e.isActive(s)));r&&(o._parsedData||(o._parsedData=function(e,t){const i=new DOMParser,n=function(e){return Hy(Hy(e)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/()[\r\n]+(<\/span>)/g,"$1 $2").replace(/ <\//g," <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(e){const t="",i=e.indexOf(t);if(i<0)return e;const n=e.indexOf("",i+7);return e.substring(0,i+7)+(n>=0?e.substring(n):"")}(e=(e=e.replace(/

abc

\n //\n if (isAttribute && child._canMergeAttributesFrom(wrapElement)) {\n child._mergeAttributesFrom(wrapElement);\n wrapPositions.push(new ViewPosition(parent, i));\n }\n //\n // Wrap the child if it is not an attribute element or if it is an attribute element that should be inside\n // `wrapElement` (due to priority).\n //\n //

abc

-->

abc

\n //

abc

-->

abc

\n else if (isText || !isAttribute || shouldABeOutsideB(wrapElement, child)) {\n // Clone attribute.\n const newAttribute = wrapElement._clone();\n // Wrap current node with new attribute.\n child._remove();\n newAttribute._appendChild(child);\n parent._insertChild(i, newAttribute);\n this._addToClonedElementsGroup(newAttribute);\n wrapPositions.push(new ViewPosition(parent, i));\n }\n //\n // If other nested attribute is found and it wasn't wrapped (see above), continue wrapping inside it.\n //\n //

abc

-->

abc

\n //\n else /* if ( isAttribute ) */ {\n this._wrapChildren(child, 0, child.childCount, wrapElement);\n }\n i++;\n }\n // Merge at each wrap.\n let offsetChange = 0;\n for (const position of wrapPositions) {\n position.offset -= offsetChange;\n // Do not merge with elements outside selected children.\n if (position.offset == startOffset) {\n continue;\n }\n const newPosition = this.mergeAttributes(position);\n // If nodes were merged - other merge offsets will change.\n if (!newPosition.isEqual(position)) {\n offsetChange++;\n endOffset--;\n }\n }\n return ViewRange._createFromParentsAndOffsets(parent, startOffset, parent, endOffset);\n }\n /**\n * Unwraps children from provided `unwrapElement`. Only children contained in `parent` element between\n * `startOffset` and `endOffset` will be unwrapped.\n */\n _unwrapChildren(parent, startOffset, endOffset, unwrapElement) {\n let i = startOffset;\n const unwrapPositions = [];\n // Iterate over each element between provided offsets inside parent.\n // We don't use tree walker or range iterator because we will be removing and merging potentially multiple nodes,\n // so it could get messy. It is safer to it manually in this case.\n while (i < endOffset) {\n const child = parent.getChild(i);\n // Skip all text nodes. There should be no container element's here either.\n if (!child.is('attributeElement')) {\n i++;\n continue;\n }\n //\n // (In all examples, assume that `unwrapElement` is `` element.)\n //\n // If the child is similar to the given attribute element, unwrap it - it will be completely removed.\n //\n //

abcxyz

-->

abcxyz

\n //\n if (child.isSimilar(unwrapElement)) {\n const unwrapped = child.getChildren();\n const count = child.childCount;\n // Replace wrapper element with its children\n child._remove();\n parent._insertChild(i, unwrapped);\n this._removeFromClonedElementsGroup(child);\n // Save start and end position of moved items.\n unwrapPositions.push(new ViewPosition(parent, i), new ViewPosition(parent, i + count));\n // Skip elements that were unwrapped. Assuming there won't be another element to unwrap in child elements.\n i += count;\n endOffset += count - 1;\n continue;\n }\n //\n // If the child is not similar but is an attribute element, try partial unwrapping - remove the same attributes/styles/classes.\n // Partial unwrapping will happen only if the elements have the same name.\n //\n //

abcxyz

-->

abcxyz

\n //

abcxyz

-->

abcxyz

\n //\n if (child._canSubtractAttributesOf(unwrapElement)) {\n child._subtractAttributesOf(unwrapElement);\n unwrapPositions.push(new ViewPosition(parent, i), new ViewPosition(parent, i + 1));\n i++;\n continue;\n }\n //\n // If other nested attribute is found, look through it's children for elements to unwrap.\n //\n //

abc

-->

abc

\n //\n this._unwrapChildren(child, 0, child.childCount, unwrapElement);\n i++;\n }\n // Merge at each unwrap.\n let offsetChange = 0;\n for (const position of unwrapPositions) {\n position.offset -= offsetChange;\n // Do not merge with elements outside selected children.\n if (position.offset == startOffset || position.offset == endOffset) {\n continue;\n }\n const newPosition = this.mergeAttributes(position);\n // If nodes were merged - other merge offsets will change.\n if (!newPosition.isEqual(position)) {\n offsetChange++;\n endOffset--;\n }\n }\n return ViewRange._createFromParentsAndOffsets(parent, startOffset, parent, endOffset);\n }\n /**\n * Helper function for `view.writer.wrap`. Wraps range with provided attribute element.\n * This method will also merge newly added attribute element with its siblings whenever possible.\n *\n * Throws {@link module:utils/ckeditorerror~CKEditorError} `view-writer-wrap-invalid-attribute` when passed attribute element is not\n * an instance of {@link module:engine/view/attributeelement~ViewAttributeElement ViewAttributeElement}.\n *\n * @returns New range after wrapping, spanning over wrapping attribute element.\n */\n _wrapRange(range, attribute) {\n // Break attributes at range start and end.\n const { start: breakStart, end: breakEnd } = this._breakAttributesRange(range, true);\n const parentContainer = breakStart.parent;\n // Wrap all children with attribute.\n const newRange = this._wrapChildren(parentContainer, breakStart.offset, breakEnd.offset, attribute);\n // Merge attributes at the both ends and return a new range.\n const start = this.mergeAttributes(newRange.start);\n // If start position was merged - move end position back.\n if (!start.isEqual(newRange.start)) {\n newRange.end.offset--;\n }\n const end = this.mergeAttributes(newRange.end);\n return new ViewRange(start, end);\n }\n /**\n * Helper function for {@link #wrap}. Wraps position with provided attribute element.\n * This method will also merge newly added attribute element with its siblings whenever possible.\n *\n * Throws {@link module:utils/ckeditorerror~CKEditorError} `view-writer-wrap-invalid-attribute` when passed attribute element is not\n * an instance of {@link module:engine/view/attributeelement~ViewAttributeElement ViewAttributeElement}.\n *\n * @returns New position after wrapping.\n */\n _wrapPosition(position, attribute) {\n // Return same position when trying to wrap with attribute similar to position parent.\n if (attribute.isSimilar(position.parent)) {\n return movePositionToTextNode(position.clone());\n }\n // When position is inside text node - break it and place new position between two text nodes.\n if (position.parent.is('$text')) {\n position = breakTextNode(position);\n }\n // Create fake element that will represent position, and will not be merged with other attributes.\n const fakeElement = this.createAttributeElement('_wrapPosition-fake-element');\n fakeElement._priority = Number.POSITIVE_INFINITY;\n fakeElement.isSimilar = () => false;\n // Insert fake element in position location.\n position.parent._insertChild(position.offset, fakeElement);\n // Range around inserted fake attribute element.\n const wrapRange = new ViewRange(position, position.getShiftedBy(1));\n // Wrap fake element with attribute (it will also merge if possible).\n this.wrap(wrapRange, attribute);\n // Remove fake element and place new position there.\n const newPosition = new ViewPosition(fakeElement.parent, fakeElement.index);\n fakeElement._remove();\n // If position is placed between text nodes - merge them and return position inside.\n const nodeBefore = newPosition.nodeBefore;\n const nodeAfter = newPosition.nodeAfter;\n if (nodeBefore && nodeBefore.is('view:$text') && nodeAfter && nodeAfter.is('view:$text')) {\n return mergeTextNodes(nodeBefore, nodeAfter);\n }\n // If position is next to text node - move position inside.\n return movePositionToTextNode(newPosition);\n }\n /**\n * Helper function used by other `ViewDowncastWriter` methods. Breaks attribute elements at the boundaries of given range.\n *\n * @param range Range which `start` and `end` positions will be used to break attributes.\n * @param forceSplitText If set to `true`, will break text nodes even if they are directly in container element.\n * This behavior will result in incorrect view state, but is needed by other view writing methods which then fixes view state.\n * @returns New range with located at break positions.\n */\n _breakAttributesRange(range, forceSplitText = false) {\n const rangeStart = range.start;\n const rangeEnd = range.end;\n validateRangeContainer(range, this.document);\n // Break at the collapsed position. Return new collapsed range.\n if (range.isCollapsed) {\n const position = this._breakAttributes(range.start, forceSplitText);\n return new ViewRange(position, position);\n }\n const breakEnd = this._breakAttributes(rangeEnd, forceSplitText);\n const count = breakEnd.parent.childCount;\n const breakStart = this._breakAttributes(rangeStart, forceSplitText);\n // Calculate new break end offset.\n breakEnd.offset += breakEnd.parent.childCount - count;\n return new ViewRange(breakStart, breakEnd);\n }\n /**\n * Helper function used by other `ViewDowncastWriter` methods. Breaks attribute elements at given position.\n *\n * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-cannot-break-empty-element` when break position\n * is placed inside {@link module:engine/view/emptyelement~ViewEmptyElement ViewEmptyElement}.\n *\n * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-cannot-break-ui-element` when break position\n * is placed inside {@link module:engine/view/uielement~ViewUIElement UIElement}.\n *\n * @param position Position where to break attributes.\n * @param forceSplitText If set to `true`, will break text nodes even if they are directly in container element.\n * This behavior will result in incorrect view state, but is needed by other view writing methods which then fixes view state.\n * @returns New position after breaking the attributes.\n */\n _breakAttributes(position, forceSplitText = false) {\n const positionOffset = position.offset;\n const positionParent = position.parent;\n // If position is placed inside ViewEmptyElement - throw an exception as we cannot break inside.\n if (position.parent.is('emptyElement')) {\n /**\n * Cannot break an `EmptyElement` instance.\n *\n * This error is thrown if\n * {@link module:engine/view/downcastwriter~ViewDowncastWriter#breakAttributes `ViewDowncastWriter#breakAttributes()`}\n * was executed in an incorrect position.\n *\n * @error view-writer-cannot-break-empty-element\n */\n throw new CKEditorError('view-writer-cannot-break-empty-element', this.document);\n }\n // If position is placed inside UIElement - throw an exception as we cannot break inside.\n if (position.parent.is('uiElement')) {\n /**\n * Cannot break a `UIElement` instance.\n *\n * This error is thrown if\n * {@link module:engine/view/downcastwriter~ViewDowncastWriter#breakAttributes `ViewDowncastWriter#breakAttributes()`}\n * was executed in an incorrect position.\n *\n * @error view-writer-cannot-break-ui-element\n */\n throw new CKEditorError('view-writer-cannot-break-ui-element', this.document);\n }\n // If position is placed inside RawElement - throw an exception as we cannot break inside.\n if (position.parent.is('rawElement')) {\n /**\n * Cannot break a `RawElement` instance.\n *\n * This error is thrown if\n * {@link module:engine/view/downcastwriter~ViewDowncastWriter#breakAttributes `ViewDowncastWriter#breakAttributes()`}\n * was executed in an incorrect position.\n *\n * @error view-writer-cannot-break-raw-element\n */\n throw new CKEditorError('view-writer-cannot-break-raw-element', this.document);\n }\n // There are no attributes to break and text nodes breaking is not forced.\n if (!forceSplitText && positionParent.is('$text') && isContainerOrFragment(positionParent.parent)) {\n return position.clone();\n }\n // Position's parent is container, so no attributes to break.\n if (isContainerOrFragment(positionParent)) {\n return position.clone();\n }\n // Break text and start again in new position.\n if (positionParent.is('$text')) {\n return this._breakAttributes(breakTextNode(position), forceSplitText);\n }\n const length = positionParent.childCount;\n //

foobar{}

\n //

foobar[]

\n //

foobar[]

\n if (positionOffset == length) {\n const newPosition = new ViewPosition(positionParent.parent, positionParent.index + 1);\n return this._breakAttributes(newPosition, forceSplitText);\n }\n else {\n //

foo{}bar

\n //

foo[]bar

\n //

foo{}bar

\n if (positionOffset === 0) {\n const newPosition = new ViewPosition(positionParent.parent, positionParent.index);\n return this._breakAttributes(newPosition, forceSplitText);\n }\n //

foob{}ar

\n //

foob[]ar

\n //

foob[]ar

\n //

foob[]ar

\n else {\n const offsetAfter = positionParent.index + 1;\n // Break element.\n const clonedNode = positionParent._clone();\n // Insert cloned node to position's parent node.\n positionParent.parent._insertChild(offsetAfter, clonedNode);\n this._addToClonedElementsGroup(clonedNode);\n // Get nodes to move.\n const count = positionParent.childCount - positionOffset;\n const nodesToMove = positionParent._removeChildren(positionOffset, count);\n // Move nodes to cloned node.\n clonedNode._appendChild(nodesToMove);\n // Create new position to work on.\n const newPosition = new ViewPosition(positionParent.parent, offsetAfter);\n return this._breakAttributes(newPosition, forceSplitText);\n }\n }\n }\n /**\n * Stores the information that an {@link module:engine/view/attributeelement~ViewAttributeElement attribute element} was\n * added to the tree. Saves the reference to the group in the given element and updates the group, so other elements\n * from the group now keep a reference to the given attribute element.\n *\n * The clones group can be obtained using {@link module:engine/view/attributeelement~ViewAttributeElement#getElementsWithSameId}.\n *\n * Does nothing if added element has no {@link module:engine/view/attributeelement~ViewAttributeElement#id id}.\n *\n * @param element Attribute element to save.\n */\n _addToClonedElementsGroup(element) {\n // Add only if the element is in document tree.\n if (!element.root.is('rootElement')) {\n return;\n }\n // Traverse the element's children recursively to find other attribute elements that also might got inserted.\n // The loop is at the beginning so we can make fast returns later in the code.\n if (element.is('element')) {\n for (const child of element.getChildren()) {\n this._addToClonedElementsGroup(child);\n }\n }\n const id = element.id;\n if (!id) {\n return;\n }\n let group = this._cloneGroups.get(id);\n if (!group) {\n group = new Set();\n this._cloneGroups.set(id, group);\n }\n group.add(element);\n element._clonesGroup = group;\n }\n /**\n * Removes all the information about the given {@link module:engine/view/attributeelement~ViewAttributeElement attribute element}\n * from its clones group.\n *\n * Keep in mind, that the element will still keep a reference to the group (but the group will not keep a reference to it).\n * This allows to reference the whole group even if the element was already removed from the tree.\n *\n * Does nothing if the element has no {@link module:engine/view/attributeelement~ViewAttributeElement#id id}.\n *\n * @param element Attribute element to remove.\n */\n _removeFromClonedElementsGroup(element) {\n // Traverse the element's children recursively to find other attribute elements that also got removed.\n // The loop is at the beginning so we can make fast returns later in the code.\n if (element.is('element')) {\n for (const child of element.getChildren()) {\n this._removeFromClonedElementsGroup(child);\n }\n }\n const id = element.id;\n if (!id) {\n return;\n }\n const group = this._cloneGroups.get(id);\n if (!group) {\n return;\n }\n group.delete(element);\n // Not removing group from element on purpose!\n // If other parts of code have reference to this element, they will be able to get references to other elements from the group.\n }\n}\n// Helper function for `view.writer.wrap`. Checks if given element has any children that are not ui elements.\nfunction _hasNonUiChildren(parent) {\n return Array.from(parent.getChildren()).some(child => !child.is('uiElement'));\n}\n/**\n * The `attribute` passed to {@link module:engine/view/downcastwriter~ViewDowncastWriter#wrap `ViewDowncastWriter#wrap()`}\n * must be an instance of {@link module:engine/view/attributeelement~ViewAttributeElement `AttributeElement`}.\n *\n * @error view-writer-wrap-invalid-attribute\n */\n/**\n * Returns first parent container of specified {@link module:engine/view/position~ViewPosition Position}.\n * Position's parent node is checked as first, then next parents are checked.\n * Note that {@link module:engine/view/documentfragment~ViewDocumentFragment DocumentFragment} is treated like a container.\n *\n * @param position Position used as a start point to locate parent container.\n * @returns Parent container element or `undefined` if container is not found.\n */\nfunction getParentContainer(position) {\n let parent = position.parent;\n while (!isContainerOrFragment(parent)) {\n if (!parent) {\n return undefined;\n }\n parent = parent.parent;\n }\n return parent;\n}\n/**\n * Checks if first {@link module:engine/view/attributeelement~ViewAttributeElement ViewAttributeElement} provided to the function\n * can be wrapped outside second element. It is done by comparing elements'\n * {@link module:engine/view/attributeelement~ViewAttributeElement#priority priorities}, if both have same priority\n * {@link module:engine/view/element~ViewElement#getIdentity identities} are compared.\n */\nfunction shouldABeOutsideB(a, b) {\n if (a.priority < b.priority) {\n return true;\n }\n else if (a.priority > b.priority) {\n return false;\n }\n // When priorities are equal and names are different - use identities.\n return a.getIdentity() < b.getIdentity();\n}\n/**\n * Returns new position that is moved to near text node. Returns same position if there is no text node before of after\n * specified position.\n *\n * ```html\n *

foo[]

->

foo{}

\n *

[]foo

->

{}foo

\n * ```\n *\n * @returns Position located inside text node or same position if there is no text nodes\n * before or after position location.\n */\nfunction movePositionToTextNode(position) {\n const nodeBefore = position.nodeBefore;\n if (nodeBefore && nodeBefore.is('$text')) {\n return new ViewPosition(nodeBefore, nodeBefore.data.length);\n }\n const nodeAfter = position.nodeAfter;\n if (nodeAfter && nodeAfter.is('$text')) {\n return new ViewPosition(nodeAfter, 0);\n }\n return position;\n}\n/**\n * Breaks text node into two text nodes when possible.\n *\n * ```html\n *

foo{}bar

->

foo[]bar

\n *

{}foobar

->

[]foobar

\n *

foobar{}

->

foobar[]

\n * ```\n *\n * @param position Position that need to be placed inside text node.\n * @returns New position after breaking text node.\n */\nfunction breakTextNode(position) {\n if (position.offset == position.parent.data.length) {\n return new ViewPosition(position.parent.parent, position.parent.index + 1);\n }\n if (position.offset === 0) {\n return new ViewPosition(position.parent.parent, position.parent.index);\n }\n // Get part of the text that need to be moved.\n const textToMove = position.parent.data.slice(position.offset);\n // Leave rest of the text in position's parent.\n position.parent._data = position.parent.data.slice(0, position.offset);\n // Insert new text node after position's parent text node.\n position.parent.parent._insertChild(position.parent.index + 1, new ViewText(position.root.document, textToMove));\n // Return new position between two newly created text nodes.\n return new ViewPosition(position.parent.parent, position.parent.index + 1);\n}\n/**\n * Merges two text nodes into first node. Removes second node and returns merge position.\n *\n * @param t1 First text node to merge. Data from second text node will be moved at the end of this text node.\n * @param t2 Second text node to merge. This node will be removed after merging.\n * @returns Position after merging text nodes.\n */\nfunction mergeTextNodes(t1, t2) {\n // Merge text data into first text node and remove second one.\n const nodeBeforeLength = t1.data.length;\n t1._data += t2.data;\n t2._remove();\n return new ViewPosition(t1, nodeBeforeLength);\n}\nconst validNodesToInsert = [ViewText, ViewAttributeElement, ViewContainerElement, ViewEmptyElement, ViewRawElement, ViewUIElement];\n/**\n * Checks if provided nodes are valid to insert.\n *\n * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-insert-invalid-node` when nodes to insert\n * contains instances that are not supported ones (see error description for valid ones.\n */\nfunction validateNodesToInsert(nodes, errorContext) {\n for (const node of nodes) {\n if (!validNodesToInsert.some(validNode => node instanceof validNode)) {\n /**\n * One of the nodes to be inserted is of an invalid type.\n *\n * Nodes to be inserted with {@link module:engine/view/downcastwriter~ViewDowncastWriter#insert `ViewDowncastWriter#insert()`}\n * should be of the following types:\n *\n * * {@link module:engine/view/attributeelement~ViewAttributeElement ViewAttributeElement},\n * * {@link module:engine/view/containerelement~ViewContainerElement ViewContainerElement},\n * * {@link module:engine/view/emptyelement~ViewEmptyElement ViewEmptyElement},\n * * {@link module:engine/view/uielement~ViewUIElement UIElement},\n * * {@link module:engine/view/rawelement~ViewRawElement RawElement},\n * * {@link module:engine/view/text~ViewText Text}.\n *\n * @error view-writer-insert-invalid-node-type\n */\n throw new CKEditorError('view-writer-insert-invalid-node-type', errorContext);\n }\n if (!node.is('$text')) {\n validateNodesToInsert(node.getChildren(), errorContext);\n }\n }\n}\n/**\n * Checks if node is ViewContainerElement or DocumentFragment, because in most cases they should be treated the same way.\n *\n * @returns Returns `true` if node is instance of ViewContainerElement or DocumentFragment.\n */\nfunction isContainerOrFragment(node) {\n return node && (node.is('containerElement') || node.is('documentFragment'));\n}\n/**\n * Checks if {@link module:engine/view/range~ViewRange#start range start} and {@link module:engine/view/range~ViewRange#end range end}\n * are placed inside same {@link module:engine/view/containerelement~ViewContainerElement container element}.\n * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-writer-invalid-range-container` when validation fails.\n */\nfunction validateRangeContainer(range, errorContext) {\n const startContainer = getParentContainer(range.start);\n const endContainer = getParentContainer(range.end);\n if (!startContainer || !endContainer || startContainer !== endContainer) {\n /**\n * The container of the given range is invalid.\n *\n * This may happen if {@link module:engine/view/range~ViewRange#start range start} and\n * {@link module:engine/view/range~ViewRange#end range end} positions are not placed inside the same container element or\n * a parent container for these positions cannot be found.\n *\n * Methods like {@link module:engine/view/downcastwriter~ViewDowncastWriter#wrap `ViewDowncastWriter#remove()`},\n * {@link module:engine/view/downcastwriter~ViewDowncastWriter#wrap `ViewDowncastWriter#clean()`},\n * {@link module:engine/view/downcastwriter~ViewDowncastWriter#wrap `ViewDowncastWriter#wrap()`},\n * {@link module:engine/view/downcastwriter~ViewDowncastWriter#wrap `ViewDowncastWriter#unwrap()`} need to be called\n * on a range that has its start and end positions located in the same container element. Both positions can be\n * nested within other elements (e.g. an attribute element) but the closest container ancestor must be the same.\n *\n * @error view-writer-invalid-range-container\n */\n throw new CKEditorError('view-writer-invalid-range-container', errorContext);\n }\n}\n/**\n * Checks if the provided argument is a plain object that can be used as options for container element.\n */\nfunction isContainerOptions(childrenOrOptions) {\n return isPlainObject(childrenOrOptions);\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { keyCodes, isText } from '@ckeditor/ckeditor5-utils';\n/**\n * Set of utilities related to handling block and inline fillers.\n *\n * Browsers do not allow to put caret in elements which does not have height. Because of it, we need to fill all\n * empty elements which should be selectable with elements or characters called \"fillers\". Unfortunately there is no one\n * universal filler, this is why two types are uses:\n *\n * * Block filler is an element which fill block elements, like `

`. CKEditor uses `
` as a block filler during the editing,\n * as browsers do natively. So instead of an empty `

` there will be `


`. The advantage of block filler is that\n * it is transparent for the selection, so when the caret is before the `
` and user presses right arrow he will be\n * moved to the next paragraph, not after the `
`. The disadvantage is that it breaks a block, so it cannot be used\n * in the middle of a line of text. The {@link module:engine/view/filler~BR_FILLER `
` filler} can be replaced with any other\n * character in the data output, for instance {@link module:engine/view/filler~NBSP_FILLER non-breaking space} or\n * {@link module:engine/view/filler~MARKED_NBSP_FILLER marked non-breaking space}.\n *\n * * Inline filler is a filler which does not break a line of text, so it can be used inside the text, for instance in the empty\n * `` surrendered by text: `foobar`, if we want to put the caret there. CKEditor uses a sequence of the zero-width\n * spaces as an {@link module:engine/view/filler~INLINE_FILLER inline filler} having the predetermined\n * {@link module:engine/view/filler~INLINE_FILLER_LENGTH length}. A sequence is used, instead of a single character to\n * avoid treating random zero-width spaces as the inline filler. Disadvantage of the inline filler is that it is not\n * transparent for the selection. The arrow key moves the caret between zero-width spaces characters, so the additional\n * code is needed to handle the caret.\n *\n * Both inline and block fillers are handled by the {@link module:engine/view/renderer~ViewRenderer renderer} and are not present in the\n * view.\n *\n * @module engine/view/filler\n */\n/**\n * Non-breaking space filler creator. This function creates the ` ` text node.\n * It defines how the filler is created.\n *\n * @see module:engine/view/filler~MARKED_NBSP_FILLER\n * @see module:engine/view/filler~BR_FILLER\n * @internal\n */\nexport const NBSP_FILLER = (domDocument) => domDocument.createTextNode('\\u00A0');\n/**\n * Marked non-breaking space filler creator. This function creates the ` ` element.\n * It defines how the filler is created.\n *\n * @see module:engine/view/filler~NBSP_FILLER\n * @see module:engine/view/filler~BR_FILLER\n * @internal\n */\nexport const MARKED_NBSP_FILLER = (domDocument) => {\n const span = domDocument.createElement('span');\n span.dataset.ckeFiller = 'true';\n span.innerText = '\\u00A0';\n return span;\n};\n/**\n * `
` filler creator. This function creates the `
` element.\n * It defines how the filler is created.\n *\n * @see module:engine/view/filler~NBSP_FILLER\n * @see module:engine/view/filler~MARKED_NBSP_FILLER\n * @internal\n */\nexport const BR_FILLER = (domDocument) => {\n const fillerBr = domDocument.createElement('br');\n fillerBr.dataset.ckeFiller = 'true';\n return fillerBr;\n};\n/**\n * Length of the {@link module:engine/view/filler~INLINE_FILLER INLINE_FILLER}.\n *\n * @internal\n */\nexport const INLINE_FILLER_LENGTH = 7;\n/**\n * Inline filler which is a sequence of the word joiners.\n *\n * @internal\n */\nexport const INLINE_FILLER = '\\u2060'.repeat(INLINE_FILLER_LENGTH);\n/**\n * Checks if the node is a text node which starts with the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n *\n * ```ts\n * startsWithFiller( document.createTextNode( INLINE_FILLER ) ); // true\n * startsWithFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ); // true\n * startsWithFiller( document.createTextNode( 'foo' ) ); // false\n * startsWithFiller( document.createElement( 'p' ) ); // false\n * ```\n *\n * @param domNode DOM node.\n * @returns True if the text node starts with the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n * @internal\n */\nexport function startsWithFiller(domNode) {\n if (typeof domNode == 'string') {\n return domNode.substr(0, INLINE_FILLER_LENGTH) === INLINE_FILLER;\n }\n return isText(domNode) && (domNode.data.substr(0, INLINE_FILLER_LENGTH) === INLINE_FILLER);\n}\n/**\n * Checks if the text node contains only the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n *\n * ```ts\n * isInlineFiller( document.createTextNode( INLINE_FILLER ) ); // true\n * isInlineFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ); // false\n * ```\n *\n * @param domText DOM text node.\n * @returns True if the text node contains only the {@link module:engine/view/filler~INLINE_FILLER inline filler}.\n * @internal\n */\nexport function isInlineFiller(domText) {\n return domText.data.length == INLINE_FILLER_LENGTH && startsWithFiller(domText);\n}\n/**\n * Get string data from the text node, removing an {@link module:engine/view/filler~INLINE_FILLER inline filler} from it,\n * if text node contains it.\n *\n * ```ts\n * getDataWithoutFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ) == 'foo' // true\n * getDataWithoutFiller( document.createTextNode( 'foo' ) ) == 'foo' // true\n * ```\n *\n * @param domText DOM text node, possible with inline filler.\n * @returns Data without filler.\n * @internal\n */\nexport function getDataWithoutFiller(domText) {\n const data = typeof domText == 'string' ? domText : domText.data;\n if (startsWithFiller(domText)) {\n return data.slice(INLINE_FILLER_LENGTH);\n }\n return data;\n}\n/**\n * Assign key observer which move cursor from the end of the inline filler to the beginning of it when\n * the left arrow is pressed, so the filler does not break navigation.\n *\n * @param view View controller instance we should inject quirks handling on.\n * @internal\n */\nexport function injectQuirksHandling(view) {\n view.document.on('arrowKey', jumpOverInlineFiller, { priority: 'low' });\n}\n/**\n * Move cursor from the end of the inline filler to the beginning of it when, so the filler does not break navigation.\n */\nfunction jumpOverInlineFiller(evt, data) {\n if (data.keyCode == keyCodes.arrowleft) {\n const domSelection = data.domTarget.ownerDocument.defaultView.getSelection();\n if (domSelection.rangeCount == 1 && domSelection.getRangeAt(0).collapsed) {\n const domParent = domSelection.getRangeAt(0).startContainer;\n const domOffset = domSelection.getRangeAt(0).startOffset;\n if (startsWithFiller(domParent) && domOffset <= INLINE_FILLER_LENGTH) {\n domSelection.collapse(domParent, 0);\n }\n }\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module engine/view/renderer\n */\nimport { ViewText } from './text.js';\nimport { ViewPosition } from './position.js';\nimport { INLINE_FILLER, INLINE_FILLER_LENGTH, startsWithFiller, isInlineFiller } from './filler.js';\nimport { CKEditorError, ObservableMixin, diff, env, fastDiff, insertAt, isComment, isNode, isText, remove, indexOf } from '@ckeditor/ckeditor5-utils';\n// @if CK_DEBUG_TYPING // const { _buildLogMessage } = require( '../dev-utils/utils.js' );\nimport '../../theme/renderer.css';\n/**\n * Renderer is responsible for updating the DOM structure and the DOM selection based on\n * the {@link module:engine/view/renderer~ViewRenderer#markToSync information about updated view nodes}.\n * In other words, it renders the view to the DOM.\n *\n * Its main responsibility is to make only the necessary, minimal changes to the DOM. However, unlike in many\n * virtual DOM implementations, the primary reason for doing minimal changes is not the performance but ensuring\n * that native editing features such as text composition, autocompletion, spell checking, selection's x-index are\n * affected as little as possible.\n *\n * Renderer uses {@link module:engine/view/domconverter~ViewDomConverter} to transform view nodes and positions\n * to and from the DOM.\n */\nexport class ViewRenderer extends /* #__PURE__ */ ObservableMixin() {\n /**\n * Set of DOM Documents instances.\n */\n domDocuments = new Set();\n /**\n * Converter instance.\n */\n domConverter;\n /**\n * Set of nodes which attributes changed and may need to be rendered.\n */\n markedAttributes = new Set();\n /**\n * Set of elements which child lists changed and may need to be rendered.\n */\n markedChildren = new Set();\n /**\n * Set of text nodes which text data changed and may need to be rendered.\n */\n markedTexts = new Set();\n /**\n * View selection. Renderer updates DOM selection based on the view selection.\n */\n selection;\n /**\n * The text node in which the inline filler was rendered.\n */\n _inlineFiller = null;\n /**\n * DOM element containing fake selection.\n */\n _fakeSelectionContainer = null;\n /**\n * Creates a renderer instance.\n *\n * @param domConverter Converter instance.\n * @param selection View selection.\n */\n constructor(domConverter, selection) {\n super();\n this.domConverter = domConverter;\n this.selection = selection;\n this.set('isFocused', false);\n this.set('isSelecting', false);\n this.set('isComposing', false);\n // Rendering the selection and inline filler manipulation should be postponed in (non-Android) Blink until the user finishes\n // creating the selection in DOM to avoid accidental selection collapsing\n // (https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723).\n // When the user stops selecting, all pending changes should be rendered ASAP, though.\n if (env.isBlink && !env.isAndroid) {\n this.on('change:isSelecting', () => {\n if (!this.isSelecting) {\n this.render();\n }\n });\n }\n }\n /**\n * Marks a view node to be updated in the DOM by {@link #render `render()`}.\n *\n * Note that only view nodes whose parents have corresponding DOM elements need to be marked to be synchronized.\n *\n * @see #markedAttributes\n * @see #markedChildren\n * @see #markedTexts\n *\n * @param type Type of the change.\n * @param node ViewNode to be marked.\n */\n markToSync(type, node) {\n if (type === 'text') {\n if (this.domConverter.mapViewToDom(node.parent)) {\n this.markedTexts.add(node);\n }\n }\n else {\n // If the node has no DOM element it is not rendered yet,\n // its children/attributes do not need to be marked to be sync.\n if (!this.domConverter.mapViewToDom(node)) {\n return;\n }\n if (type === 'attributes') {\n this.markedAttributes.add(node);\n }\n else if (type === 'children') {\n this.markedChildren.add(node);\n }\n else {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const unreachable = type;\n /**\n * Unknown type passed to Renderer.markToSync.\n *\n * @error view-renderer-unknown-type\n */\n throw new CKEditorError('view-renderer-unknown-type', this);\n }\n }\n }\n /**\n * Renders all buffered changes ({@link #markedAttributes}, {@link #markedChildren} and {@link #markedTexts}) and\n * the current view selection (if needed) to the DOM by applying a minimal set of changes to it.\n *\n * Renderer tries not to break the text composition (e.g. IME) and x-index of the selection,\n * so it does as little as it is needed to update the DOM.\n *\n * Renderer also handles {@link module:engine/view/filler fillers}. Especially, it checks if the inline filler is needed\n * at the selection position and adds or removes it. To prevent breaking text composition inline filler will not be\n * removed as long as the selection is in the text node which needed it at first.\n */\n render() {\n // Ignore rendering while in the composition mode. Composition events are not cancellable and browser will modify the DOM tree.\n // All marked elements, attributes, etc. will wait until next render after the composition ends.\n // On Android composition events are immediately applied to the model, so we don't need to skip rendering,\n // and we should not do it because the difference between view and DOM could lead to position mapping problems.\n if (this.isComposing && !env.isAndroid) {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'%cRendering aborted while isComposing.',\n // @if CK_DEBUG_TYPING // \t\t'font-style: italic'\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n return;\n }\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.group( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'%cRendering',\n // @if CK_DEBUG_TYPING // \t\t'font-weight: bold'\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n let inlineFillerPosition = null;\n const isInlineFillerRenderingPossible = env.isBlink && !env.isAndroid ? !this.isSelecting : true;\n // Refresh mappings.\n for (const element of this.markedChildren) {\n this._updateChildrenMappings(element);\n }\n // Don't manipulate inline fillers while the selection is being made in (non-Android) Blink to prevent accidental\n // DOM selection collapsing\n // (https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723).\n if (isInlineFillerRenderingPossible) {\n // There was inline filler rendered in the DOM but it's not\n // at the selection position any more, so we can remove it\n // (cause even if it's needed, it must be placed in another location).\n if (this._inlineFiller && !this._isSelectionInInlineFiller()) {\n this._removeInlineFiller();\n }\n // If we've got the filler, let's try to guess its position in the view.\n if (this._inlineFiller) {\n inlineFillerPosition = this._getInlineFillerPosition();\n }\n // Otherwise, if it's needed, create it at the selection position.\n else if (this._needsInlineFillerAtSelection()) {\n inlineFillerPosition = this.selection.getFirstPosition();\n // Do not use `markToSync` so it will be added even if the parent is already added.\n this.markedChildren.add(inlineFillerPosition.parent);\n }\n }\n // Make sure the inline filler has any parent, so it can be mapped to view position by ViewDomConverter.\n else if (this._inlineFiller && this._inlineFiller.parentNode) {\n // While the user is making selection, preserve the inline filler at its original position.\n inlineFillerPosition = this.domConverter.domPositionToView(this._inlineFiller);\n // While down-casting the document selection attributes, all existing empty\n // attribute elements (for selection position) are removed from the view and DOM,\n // so make sure that we were able to map filler position.\n // https://github.com/ckeditor/ckeditor5/issues/12026\n if (inlineFillerPosition && inlineFillerPosition.parent.is('$text')) {\n // The inline filler position is expected to be before the text node.\n inlineFillerPosition = ViewPosition._createBefore(inlineFillerPosition.parent);\n }\n }\n for (const element of this.markedAttributes) {\n this._updateAttrs(element);\n }\n for (const element of this.markedChildren) {\n this._updateChildren(element, { inlineFillerPosition });\n }\n for (const node of this.markedTexts) {\n if (!this.markedChildren.has(node.parent) && this.domConverter.mapViewToDom(node.parent)) {\n this._updateText(node, { inlineFillerPosition });\n }\n }\n // * Check whether the inline filler is required and where it really is in the DOM.\n // At this point in most cases it will be in the DOM, but there are exceptions.\n // For example, if the inline filler was deep in the created DOM structure, it will not be created.\n // Similarly, if it was removed at the beginning of this function and then neither text nor children were updated,\n // it will not be present. Fix those and similar scenarios.\n // * Don't manipulate inline fillers while the selection is being made in (non-Android) Blink to prevent accidental\n // DOM selection collapsing\n // (https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723).\n if (isInlineFillerRenderingPossible) {\n if (inlineFillerPosition) {\n const fillerDomPosition = this.domConverter.viewPositionToDom(inlineFillerPosition);\n const domDocument = fillerDomPosition.parent.ownerDocument;\n if (!startsWithFiller(fillerDomPosition.parent)) {\n // Filler has not been created at filler position. Create it now.\n this._inlineFiller = addInlineFiller(domDocument, fillerDomPosition.parent, fillerDomPosition.offset);\n }\n else {\n // Filler has been found, save it.\n this._inlineFiller = fillerDomPosition.parent;\n }\n }\n else {\n // There is no filler needed.\n this._inlineFiller = null;\n }\n }\n // First focus the new editing host, then update the selection.\n // Otherwise, FF may throw an error (https://github.com/ckeditor/ckeditor5/issues/721).\n this._updateFocus();\n this._updateSelection();\n this.domConverter._clearTemporaryCustomProperties();\n this.markedTexts.clear();\n this.markedAttributes.clear();\n this.markedChildren.clear();\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.groupEnd();\n // @if CK_DEBUG_TYPING // }\n }\n /**\n * Updates mappings of view element's children.\n *\n * Children that were replaced in the view structure by similar elements (same tag name) are treated as 'replaced'.\n * This means that their mappings can be updated so the new view elements are mapped to the existing DOM elements.\n * Thanks to that these elements do not need to be re-rendered completely.\n *\n * @param viewElement The view element whose children mappings will be updated.\n */\n _updateChildrenMappings(viewElement) {\n const domElement = this.domConverter.mapViewToDom(viewElement);\n if (!domElement) {\n // If there is no `domElement` it means that it was already removed from DOM and there is no need to process it.\n return;\n }\n // Removing nodes from the DOM as we iterate can cause `actualDomChildren`\n // (which is a live-updating `NodeList`) to get out of sync with the\n // indices that we compute as we iterate over `actions`.\n // This would produce incorrect element mappings.\n //\n // Converting live list to an array to make the list static.\n const actualDomChildren = Array.from(domElement.childNodes);\n const expectedDomChildren = Array.from(this.domConverter.viewChildrenToDom(viewElement, { withChildren: false }));\n const diff = this._diffNodeLists(actualDomChildren, expectedDomChildren);\n const actions = this._findUpdateActions(diff, actualDomChildren, expectedDomChildren, areSimilarElements);\n if (actions.indexOf('update') !== -1) {\n const counter = { equal: 0, insert: 0, delete: 0 };\n for (const action of actions) {\n if (action === 'update') {\n const insertIndex = counter.equal + counter.insert;\n const deleteIndex = counter.equal + counter.delete;\n const viewChild = viewElement.getChild(insertIndex);\n // UIElement and RawElement are special cases. Their children are not stored in a view (#799)\n // so we cannot use them with replacing flow (since they use view children during rendering\n // which will always result in rendering empty elements).\n if (viewChild && !viewChild.is('uiElement') && !viewChild.is('rawElement')) {\n this._updateElementMappings(viewChild, actualDomChildren[deleteIndex]);\n }\n remove(expectedDomChildren[insertIndex]);\n counter.equal++;\n }\n else {\n counter[action]++;\n }\n }\n }\n }\n /**\n * Updates mappings of a given view element.\n *\n * @param viewElement The view element whose mappings will be updated.\n * @param domElement The DOM element representing the given view element.\n */\n _updateElementMappings(viewElement, domElement) {\n // Remap 'DomConverter' bindings.\n this.domConverter.unbindDomElement(domElement);\n this.domConverter.bindElements(domElement, viewElement);\n // View element may have children which needs to be updated, but are not marked, mark them to update.\n this.markedChildren.add(viewElement);\n // Because we replace new view element mapping with the existing one, the corresponding DOM element\n // will not be rerendered. The new view element may have different attributes than the previous one.\n // Since its corresponding DOM element will not be rerendered, new attributes will not be added\n // to the DOM, so we need to mark it here to make sure its attributes gets updated. See #1427 for more\n // detailed case study.\n // Also there are cases where replaced element is removed from the view structure and then has\n // its attributes changed or removed. In such cases the element will not be present in `markedAttributes`\n // and also may be the same (`element.isSimilar()`) as the reused element not having its attributes updated.\n // To prevent such situations we always mark reused element to have its attributes rerenderd (#1560).\n this.markedAttributes.add(viewElement);\n }\n /**\n * Gets the position of the inline filler based on the current selection.\n * Here, we assume that we know that the filler is needed and\n * {@link #_isSelectionInInlineFiller is at the selection position}, and, since it is needed,\n * it is somewhere at the selection position.\n *\n * Note: The filler position cannot be restored based on the filler's DOM text node, because\n * when this method is called (before rendering), the bindings will often be broken. View-to-DOM\n * bindings are only dependable after rendering.\n */\n _getInlineFillerPosition() {\n const firstPos = this.selection.getFirstPosition();\n if (firstPos.parent.is('$text')) {\n return ViewPosition._createBefore(firstPos.parent);\n }\n else {\n return firstPos;\n }\n }\n /**\n * Returns `true` if the selection has not left the inline filler's text node.\n * If it is `true`, it means that the filler had been added for a reason and the selection did not\n * leave the filler's text node. For example, the user can be in the middle of a composition so it should not be touched.\n *\n * @returns `true` if the inline filler and selection are in the same place.\n */\n _isSelectionInInlineFiller() {\n if (this.selection.rangeCount != 1 || !this.selection.isCollapsed) {\n return false;\n }\n // Note, we can't check if selection's position equals position of the\n // this._inlineFiller node, because of #663. We may not be able to calculate\n // the filler's position in the view at this stage.\n // Instead, we check it the other way – whether selection is anchored in\n // that text node or next to it.\n // Possible options are:\n // \"FILLER{}\"\n // \"FILLERadded-text{}\"\n const selectionPosition = this.selection.getFirstPosition();\n const position = this.domConverter.viewPositionToDom(selectionPosition);\n if (position && isText(position.parent) && startsWithFiller(position.parent)) {\n return true;\n }\n return false;\n }\n /**\n * Removes the inline filler.\n */\n _removeInlineFiller() {\n const domFillerNode = this._inlineFiller;\n // Something weird happened and the stored node doesn't contain the filler's text.\n if (!startsWithFiller(domFillerNode)) {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.log( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'Inline filler node: ' +\n // @if CK_DEBUG_TYPING // \t\t`%c${ _escapeTextNodeData( domFillerNode.data ) }%c (${ domFillerNode.data.length })`,\n // @if CK_DEBUG_TYPING // \t\t'color: blue',\n // @if CK_DEBUG_TYPING // \t\t''\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n /**\n * The inline filler node was lost. Most likely, something overwrote the filler text node\n * in the DOM.\n *\n * @error view-renderer-filler-was-lost\n */\n throw new CKEditorError('view-renderer-filler-was-lost', this);\n }\n if (isInlineFiller(domFillerNode)) {\n domFillerNode.remove();\n }\n else {\n domFillerNode.data = domFillerNode.data.substr(INLINE_FILLER_LENGTH);\n }\n this._inlineFiller = null;\n }\n /**\n * Checks if the inline {@link module:engine/view/filler filler} should be added.\n *\n * @returns `true` if the inline filler should be added.\n */\n _needsInlineFillerAtSelection() {\n if (this.selection.rangeCount != 1 || !this.selection.isCollapsed) {\n return false;\n }\n const selectionPosition = this.selection.getFirstPosition();\n const selectionParent = selectionPosition.parent;\n const selectionOffset = selectionPosition.offset;\n // If there is no DOM root we do not care about fillers.\n if (!this.domConverter.mapViewToDom(selectionParent.root)) {\n return false;\n }\n if (!(selectionParent.is('element'))) {\n return false;\n }\n // Prevent adding inline filler inside elements with contenteditable=false.\n // https://github.com/ckeditor/ckeditor5-engine/issues/1170\n if (!isEditable(selectionParent)) {\n return false;\n }\n const nodeBefore = selectionPosition.nodeBefore;\n const nodeAfter = selectionPosition.nodeAfter;\n if (nodeBefore instanceof ViewText || nodeAfter instanceof ViewText) {\n return false;\n }\n // We have block filler, we do not need inline one.\n if (selectionOffset === selectionParent.getFillerOffset() && (!nodeBefore || !nodeBefore.is('element', 'br'))) {\n return false;\n }\n // Do not use inline filler while typing outside inline elements on Android.\n // The deleteContentBackward would remove part of the inline filler instead of removing last letter in a link.\n if (env.isAndroid && (nodeBefore || nodeAfter)) {\n return false;\n }\n return true;\n }\n /**\n * Checks if text needs to be updated and possibly updates it.\n *\n * @param viewText View text to update.\n * @param options.inlineFillerPosition The position where the inline filler should be rendered.\n */\n _updateText(viewText, options) {\n const domText = this.domConverter.findCorrespondingDomText(viewText);\n const newDomText = this.domConverter.viewToDom(viewText);\n let expectedText = newDomText.data;\n const filler = options.inlineFillerPosition;\n if (filler && filler.parent == viewText.parent && filler.offset == viewText.index) {\n expectedText = INLINE_FILLER + expectedText;\n }\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.group( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'%cUpdate text',\n // @if CK_DEBUG_TYPING // \t\t'font-weight: normal'\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n this._updateTextNode(domText, expectedText);\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.groupEnd();\n // @if CK_DEBUG_TYPING // }\n }\n /**\n * Checks if attribute list needs to be updated and possibly updates it.\n *\n * @param viewElement The view element to update.\n */\n _updateAttrs(viewElement) {\n const domElement = this.domConverter.mapViewToDom(viewElement);\n if (!domElement) {\n // If there is no `domElement` it means that 'viewElement' is outdated as its mapping was updated\n // in 'this._updateChildrenMappings()'. There is no need to process it as new view element which\n // replaced old 'viewElement' mapping was also added to 'this.markedAttributes'\n // in 'this._updateChildrenMappings()' so it will be processed separately.\n return;\n }\n // Remove attributes from DOM elements if they do not exist in the view.\n //\n // Note: It is important to first remove DOM attributes and then set new ones, because some view attributes may be renamed\n // as they are set on DOM (due to unsafe attributes handling). If we set the view attribute first, and then remove\n // non-existing DOM attributes, then we would remove the attribute that we just set.\n //\n // Note: The domElement.attributes is a live collection, so we need to convert it to an array to avoid issues.\n for (const domAttr of Array.from(domElement.attributes)) {\n const key = domAttr.name;\n // All other attributes not present in the DOM should be removed.\n if (!viewElement.hasAttribute(key)) {\n this.domConverter.removeDomElementAttribute(domElement, key);\n }\n }\n // Add or overwrite attributes.\n for (const key of viewElement.getAttributeKeys()) {\n this.domConverter.setDomElementAttribute(domElement, key, viewElement.getAttribute(key), viewElement);\n }\n }\n /**\n * Checks if elements child list needs to be updated and possibly updates it.\n *\n * Note that on Android, to reduce the risk of composition breaks, it tries to update data of an existing\n * child text nodes instead of replacing them completely.\n *\n * @param viewElement View element to update.\n * @param options.inlineFillerPosition The position where the inline filler should be rendered.\n */\n _updateChildren(viewElement, options) {\n const domElement = this.domConverter.mapViewToDom(viewElement);\n if (!domElement) {\n // If there is no `domElement` it means that it was already removed from DOM.\n // There is no need to process it. It will be processed when re-inserted.\n return;\n }\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.group( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'%cUpdate children',\n // @if CK_DEBUG_TYPING // \t\t'font-weight: normal'\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n // IME on Android inserts a new text node while typing after a link\n // instead of updating an existing text node that follows the link.\n // We must normalize those text nodes so the diff won't get confused.\n // https://github.com/ckeditor/ckeditor5/issues/12574.\n if (env.isAndroid) {\n let previousDomNode = null;\n for (const domNode of Array.from(domElement.childNodes)) {\n if (previousDomNode && isText(previousDomNode) && isText(domNode)) {\n domElement.normalize();\n break;\n }\n previousDomNode = domNode;\n }\n }\n const inlineFillerPosition = options.inlineFillerPosition;\n const actualDomChildren = domElement.childNodes;\n const expectedDomChildren = Array.from(this.domConverter.viewChildrenToDom(viewElement, { bind: true }));\n // Inline filler element has to be created as it is present in the DOM, but not in the view. It is required\n // during diffing so text nodes could be compared correctly and also during rendering to maintain\n // proper order and indexes while updating the DOM.\n if (inlineFillerPosition && inlineFillerPosition.parent === viewElement) {\n addInlineFiller(domElement.ownerDocument, expectedDomChildren, inlineFillerPosition.offset);\n }\n const diff = this._diffNodeLists(actualDomChildren, expectedDomChildren);\n // We need to make sure that we update the existing text node and not replace it with another one.\n // The composition and different \"language\" browser extensions are fragile to text node being completely replaced.\n const actions = this._findUpdateActions(diff, actualDomChildren, expectedDomChildren, areTextNodes);\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping && actions.every( a => a == 'equal' ) ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'%cNothing to update.',\n // @if CK_DEBUG_TYPING // \t\t'font-style: italic'\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n let i = 0;\n const nodesToUnbind = new Set();\n // Handle deletions first.\n // This is to prevent a situation where an element that already exists in `actualDomChildren` is inserted at a different\n // index in `actualDomChildren`. Since `actualDomChildren` is a `NodeList`, this works like move, not like an insert,\n // and it disrupts the whole algorithm. See https://github.com/ckeditor/ckeditor5/issues/6367.\n //\n // It doesn't matter in what order we remove or add nodes, as long as we remove and add correct nodes at correct indexes.\n for (const action of actions) {\n if (action === 'delete') {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING //\tconst node = actualDomChildren[ i ];\n // @if CK_DEBUG_TYPING // \tif ( isText( node ) ) {\n // @if CK_DEBUG_TYPING // \t\tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t\t'%cRemove text node' +\n // @if CK_DEBUG_TYPING // \t\t\t`${ this.isComposing ? ' while composing (may break composition)' : '' }: ` +\n // @if CK_DEBUG_TYPING // \t\t\t`%c${ _escapeTextNodeData( node.data ) }%c (${ node.data.length })`,\n // @if CK_DEBUG_TYPING // \t\t\tthis.isComposing ? 'color: red; font-weight: bold' : '',\n // @if CK_DEBUG_TYPING // \t\t\t'color: blue', ''\n // @if CK_DEBUG_TYPING // \t\t) );\n // @if CK_DEBUG_TYPING // \t} else {\n // @if CK_DEBUG_TYPING // \t\tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t\t'%cRemove element' +\n // @if CK_DEBUG_TYPING // \t\t\t`${ this.isComposing ? ' while composing (may break composition)' : '' }: `,\n // @if CK_DEBUG_TYPING // \t\t\tthis.isComposing ? 'color: red; font-weight: bold' : '',\n // @if CK_DEBUG_TYPING // \t\t\tnode\n // @if CK_DEBUG_TYPING // \t\t) );\n // @if CK_DEBUG_TYPING // \t}\n // @if CK_DEBUG_TYPING // }\n nodesToUnbind.add(actualDomChildren[i]);\n remove(actualDomChildren[i]);\n }\n else if (action === 'equal' || action === 'update') {\n i++;\n }\n }\n i = 0;\n for (const action of actions) {\n if (action === 'insert') {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING //\tconst node = expectedDomChildren[ i ];\n // @if CK_DEBUG_TYPING //\tif ( isText( node ) ) {\n // @if CK_DEBUG_TYPING //\t\tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING //\t\t\t'%cInsert text node' +\n // @if CK_DEBUG_TYPING //\t\t\t`${ this.isComposing ? ' while composing (may break composition)' : '' }: ` +\n // @if CK_DEBUG_TYPING //\t\t\t`%c${ _escapeTextNodeData( node.data ) }%c (${ node.data.length })`,\n // @if CK_DEBUG_TYPING //\t\t\tthis.isComposing ? 'color: red; font-weight: bold' : '',\n // @if CK_DEBUG_TYPING //\t\t\t'color: blue',\n // @if CK_DEBUG_TYPING //\t\t\t''\n // @if CK_DEBUG_TYPING //\t\t) );\n // @if CK_DEBUG_TYPING //\t} else {\n // @if CK_DEBUG_TYPING //\t\tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING //\t\t\t'%cInsert element:',\n // @if CK_DEBUG_TYPING //\t\t\t'font-weight: normal',\n // @if CK_DEBUG_TYPING //\t\t\tnode\n // @if CK_DEBUG_TYPING //\t\t) );\n // @if CK_DEBUG_TYPING //\t}\n // @if CK_DEBUG_TYPING // }\n insertAt(domElement, i, expectedDomChildren[i]);\n i++;\n }\n // Update the existing text node data.\n else if (action === 'update') {\n this._updateTextNode(actualDomChildren[i], expectedDomChildren[i].data);\n i++;\n }\n else if (action === 'equal') {\n // Force updating text nodes inside elements which did not change and do not need to be re-rendered (#1125).\n // Do it here (not in the loop above) because only after insertions the `i` index is correct.\n this._markDescendantTextToSync(this.domConverter.domToView(expectedDomChildren[i]));\n i++;\n }\n }\n // Unbind removed nodes. When node does not have a parent it means that it was removed from DOM tree during\n // comparison with the expected DOM. We don't need to check child nodes, because if child node was reinserted,\n // it was moved to DOM tree out of the removed node.\n for (const node of nodesToUnbind) {\n if (!node.parentNode) {\n this.domConverter.unbindDomElement(node);\n }\n }\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.groupEnd();\n // @if CK_DEBUG_TYPING // }\n }\n /**\n * Shorthand for diffing two arrays or node lists of DOM nodes.\n *\n * @param actualDomChildren Actual DOM children\n * @param expectedDomChildren Expected DOM children.\n * @returns The list of actions based on the {@link module:utils/diff~diff} function.\n */\n _diffNodeLists(actualDomChildren, expectedDomChildren) {\n actualDomChildren = filterOutFakeSelectionContainer(actualDomChildren, this._fakeSelectionContainer);\n return diff(actualDomChildren, expectedDomChildren, sameNodes.bind(null, this.domConverter));\n }\n /**\n * Finds DOM nodes that were replaced with the similar nodes (same tag name) in the view. All nodes are compared\n * within one `insert`/`delete` action group, for example:\n *\n * ```\n * Actual DOM:\t\t

FooBarBazBax

\n * Expected DOM:\t

Bar123Baz456

\n * Input actions:\t[ insert, insert, delete, delete, equal, insert, delete ]\n * Output actions:\t[ insert, replace, delete, equal, replace ]\n * ```\n *\n * @param actions Actions array which is a result of the {@link module:utils/diff~diff} function.\n * @param actualDom Actual DOM children\n * @param expectedDom Expected DOM children.\n * @param comparator A comparator function that should return `true` if the given node should be reused\n * (either by the update of a text node data or an element children list for similar elements).\n * @returns Actions array modified with the `update` actions.\n */\n _findUpdateActions(actions, actualDom, expectedDom, comparator) {\n // If there is no both 'insert' and 'delete' actions, no need to check for replaced elements.\n if (actions.indexOf('insert') === -1 || actions.indexOf('delete') === -1) {\n return actions;\n }\n let newActions = [];\n let actualSlice = [];\n let expectedSlice = [];\n const counter = { equal: 0, insert: 0, delete: 0 };\n for (const action of actions) {\n if (action === 'insert') {\n expectedSlice.push(expectedDom[counter.equal + counter.insert]);\n }\n else if (action === 'delete') {\n actualSlice.push(actualDom[counter.equal + counter.delete]);\n }\n else { // equal\n newActions = newActions.concat(diff(actualSlice, expectedSlice, comparator)\n .map(action => action === 'equal' ? 'update' : action));\n newActions.push('equal');\n // Reset stored elements on 'equal'.\n actualSlice = [];\n expectedSlice = [];\n }\n counter[action]++;\n }\n return newActions.concat(diff(actualSlice, expectedSlice, comparator)\n .map(action => action === 'equal' ? 'update' : action));\n }\n /**\n * Checks if text needs to be updated and possibly updates it by removing and inserting only parts\n * of the data from the existing text node to reduce impact on the IME composition.\n *\n * @param domText DOM text node to update.\n * @param expectedText The expected data of a text node.\n */\n _updateTextNode(domText, expectedText) {\n const actualText = domText.data;\n if (actualText == expectedText) {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'%cText node does not need update:%c ' +\n // @if CK_DEBUG_TYPING // \t\t`${ _escapeTextNodeData( actualText ) }%c (${ actualText.length })`,\n // @if CK_DEBUG_TYPING // \t\t'font-style: italic',\n // @if CK_DEBUG_TYPING // \t\t'color: blue',\n // @if CK_DEBUG_TYPING // \t\t''\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n return;\n }\n // Our approach to interleaving space character with NBSP might differ with the one implemented by the browser.\n // Avoid modifying the text node in the DOM if only NBSPs and spaces are interchanged.\n // We should avoid DOM modifications while composing to avoid breakage of composition.\n // See: https://github.com/ckeditor/ckeditor5/issues/13994.\n if (env.isAndroid && this.isComposing && actualText.replace(/\\u00A0/g, ' ') == expectedText.replace(/\\u00A0/g, ' ')) {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'%cText node ignore NBSP changes while composing: ' +\n // @if CK_DEBUG_TYPING // \t\t`%c${ _escapeTextNodeData( actualText ) }%c (${ actualText.length }) -> ` +\n // @if CK_DEBUG_TYPING // \t\t`%c${ _escapeTextNodeData( expectedText ) }%c (${ expectedText.length })`,\n // @if CK_DEBUG_TYPING // \t\t'font-style: italic',\n // @if CK_DEBUG_TYPING // \t\t'color: blue',\n // @if CK_DEBUG_TYPING // \t\t'',\n // @if CK_DEBUG_TYPING // \t\t'color: blue',\n // @if CK_DEBUG_TYPING // \t\t''\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n return;\n }\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'%cUpdate text node' +\n // @if CK_DEBUG_TYPING // \t\t`${ this.isComposing ? ' while composing (may break composition)' : '' }: ` +\n // @if CK_DEBUG_TYPING // \t\t`%c${ _escapeTextNodeData( actualText ) }%c (${ actualText.length }) -> ` +\n // @if CK_DEBUG_TYPING // \t\t`%c${ _escapeTextNodeData( expectedText ) }%c (${ expectedText.length })`,\n // @if CK_DEBUG_TYPING // \t\tthis.isComposing ? 'color: red; font-weight: bold' : '',\n // @if CK_DEBUG_TYPING // \t\t'color: blue',\n // @if CK_DEBUG_TYPING // \t\t'',\n // @if CK_DEBUG_TYPING // \t\t'color: blue',\n // @if CK_DEBUG_TYPING // \t\t''\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n this._updateTextNodeInternal(domText, expectedText);\n }\n /**\n * Part of the `_updateTextNode` method extracted for easier testing.\n */\n _updateTextNodeInternal(domText, expectedText) {\n const actions = fastDiff(domText.data, expectedText);\n for (const action of actions) {\n if (action.type === 'insert') {\n domText.insertData(action.index, action.values.join(''));\n }\n else { // 'delete'\n domText.deleteData(action.index, action.howMany);\n }\n }\n }\n /**\n * Marks text nodes to be synchronized.\n *\n * If a text node is passed, it will be marked. If an element is passed, all descendant text nodes inside it will be marked.\n *\n * @param viewNode View node to sync.\n */\n _markDescendantTextToSync(viewNode) {\n if (!viewNode) {\n return;\n }\n if (viewNode.is('$text')) {\n this.markedTexts.add(viewNode);\n }\n else if (viewNode.is('element')) {\n for (const child of viewNode.getChildren()) {\n this._markDescendantTextToSync(child);\n }\n }\n }\n /**\n * Checks if the selection needs to be updated and possibly updates it.\n */\n _updateSelection() {\n // Block updating DOM selection in (non-Android) Blink while the user is selecting to prevent accidental selection collapsing.\n // Note: Structural changes in DOM must trigger selection rendering, though. Nodes the selection was anchored\n // to, may disappear in DOM which would break the selection (e.g. in real-time collaboration scenarios).\n // https://github.com/ckeditor/ckeditor5/issues/10562, https://github.com/ckeditor/ckeditor5/issues/10723\n if (env.isBlink && !env.isAndroid && this.isSelecting && !this.markedChildren.size) {\n return;\n }\n // If there is no selection - remove DOM and fake selections.\n if (this.selection.rangeCount === 0) {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'Update DOM selection: remove all ranges'\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n this._removeDomSelection();\n this._removeFakeSelection();\n return;\n }\n const domEditable = this.domConverter.mapViewToDom(this.selection.editableElement);\n // Do not update DOM selection if there is no focus, or there is no DOM element corresponding to selection's editable element.\n if (!this.isFocused || !domEditable) {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'Skip updating DOM selection:',\n // @if CK_DEBUG_TYPING // \t\t`isFocused: ${ this.isFocused }, hasDomEditable: ${ !!domEditable }`\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n // But if there was a fake selection, and it is not fake anymore - remove it as it can map to no longer existing widget.\n // See https://github.com/ckeditor/ckeditor5/issues/18123.\n if (!this.selection.isFake && this._fakeSelectionContainer && this._fakeSelectionContainer.isConnected) {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'Remove fake selection (not focused editable)'\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n this._removeFakeSelection();\n }\n return;\n }\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'Update DOM selection'\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n // Render fake selection - create the fake selection container (if needed) and move DOM selection to it.\n if (this.selection.isFake) {\n this._updateFakeSelection(domEditable);\n }\n // There was a fake selection so remove it and update the DOM selection.\n // This is especially important on Android because otherwise IME will try to compose over the fake selection container.\n else if (this._fakeSelectionContainer && this._fakeSelectionContainer.isConnected) {\n this._removeFakeSelection();\n this._updateDomSelection(domEditable);\n }\n // Update the DOM selection in case of a plain selection change (no fake selection is involved).\n // On non-Android the whole rendering is disabled in composition mode (including DOM selection update),\n // but updating DOM selection should be also disabled on Android if in the middle of the composition\n // (to not interrupt it).\n else if (!(this.isComposing && env.isAndroid)) {\n this._updateDomSelection(domEditable);\n }\n }\n /**\n * Updates the fake selection.\n *\n * @param domEditable A valid DOM editable where the fake selection container should be added.\n */\n _updateFakeSelection(domEditable) {\n const domDocument = domEditable.ownerDocument;\n if (!this._fakeSelectionContainer) {\n this._fakeSelectionContainer = createFakeSelectionContainer(domDocument);\n }\n const container = this._fakeSelectionContainer;\n // Bind fake selection container with the current selection *position*.\n this.domConverter.bindFakeSelection(container, this.selection);\n if (!this._fakeSelectionNeedsUpdate(domEditable)) {\n return;\n }\n if (!container.parentElement || container.parentElement != domEditable) {\n domEditable.appendChild(container);\n }\n container.textContent = this.selection.fakeSelectionLabel || '\\u00A0';\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'Set DOM fake selection'\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n const domSelection = domDocument.getSelection();\n const domRange = domDocument.createRange();\n domSelection.removeAllRanges();\n domRange.selectNodeContents(container);\n domSelection.addRange(domRange);\n }\n /**\n * Updates the DOM selection.\n *\n * @param domEditable A valid DOM editable where the DOM selection should be rendered.\n */\n _updateDomSelection(domEditable) {\n const domSelection = domEditable.ownerDocument.defaultView.getSelection();\n // Let's check whether DOM selection needs updating at all.\n if (!this._domSelectionNeedsUpdate(domSelection)) {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'%cDOM selection is already correct',\n // @if CK_DEBUG_TYPING // \t\t'font-style: italic;'\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n return;\n }\n // Multi-range selection is not available in most browsers, and, at least in Chrome, trying to\n // set such selection, that is not continuous, throws an error. Because of that, we will just use anchor\n // and focus of view selection.\n // Since we are not supporting multi-range selection, we also do not need to check if proper editable is\n // selected. If there is any editable selected, it is okay (editable is taken from selection anchor).\n const anchor = this.domConverter.viewPositionToDom(this.selection.anchor);\n const focus = this.domConverter.viewPositionToDom(this.selection.focus);\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'Update DOM selection:',\n // @if CK_DEBUG_TYPING // \t\tanchor,\n // @if CK_DEBUG_TYPING // \t\tfocus\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n domSelection.setBaseAndExtent(anchor.parent, anchor.offset, focus.parent, focus.offset);\n // Firefox–specific hack (https://github.com/ckeditor/ckeditor5-engine/issues/1439).\n if (env.isGecko) {\n fixGeckoSelectionAfterBr(focus, domSelection);\n }\n }\n /**\n * Checks whether a given DOM selection needs to be updated.\n *\n * @param domSelection The DOM selection to check.\n */\n _domSelectionNeedsUpdate(domSelection) {\n if (!this.domConverter.isDomSelectionCorrect(domSelection)) {\n // Current DOM selection is in incorrect position. We need to update it.\n return true;\n }\n const oldViewSelection = domSelection && this.domConverter.domSelectionToView(domSelection);\n if (oldViewSelection && this.selection.isEqual(oldViewSelection)) {\n return false;\n }\n // If selection is not collapsed, it does not need to be updated if it is similar.\n if (!this.selection.isCollapsed && this.selection.isSimilar(oldViewSelection)) {\n // Selection did not changed and is correct, do not update.\n return false;\n }\n // Selections are not similar.\n return true;\n }\n /**\n * Checks whether the fake selection needs to be updated.\n *\n * @param domEditable A valid DOM editable where a new fake selection container should be added.\n */\n _fakeSelectionNeedsUpdate(domEditable) {\n const container = this._fakeSelectionContainer;\n const domSelection = domEditable.ownerDocument.getSelection();\n // Fake selection needs to be updated if there's no fake selection container, or the container currently sits\n // in a different root.\n if (!container || container.parentElement !== domEditable) {\n return true;\n }\n // Make sure that the selection actually is within the fake selection.\n if (domSelection.anchorNode !== container && !container.contains(domSelection.anchorNode)) {\n return true;\n }\n return container.textContent !== this.selection.fakeSelectionLabel;\n }\n /**\n * Removes the DOM selection.\n */\n _removeDomSelection() {\n for (const doc of this.domDocuments) {\n const domSelection = doc.getSelection();\n if (domSelection.rangeCount) {\n const activeDomElement = doc.activeElement;\n const viewElement = this.domConverter.mapDomToView(activeDomElement);\n if (activeDomElement && viewElement) {\n domSelection.removeAllRanges();\n }\n }\n }\n }\n /**\n * Removes the fake selection.\n */\n _removeFakeSelection() {\n const container = this._fakeSelectionContainer;\n if (container) {\n container.remove();\n }\n }\n /**\n * Checks if focus needs to be updated and possibly updates it.\n */\n _updateFocus() {\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.group( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t`update focus: ${ this.isFocused ? 'focused' : 'not focused' }`\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n if (this.isFocused) {\n const editable = this.selection.editableElement;\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.info( ..._buildLogMessage( this, 'Renderer',\n // @if CK_DEBUG_TYPING // \t\t'focus editable:',\n // @if CK_DEBUG_TYPING // \t\t{ editable }\n // @if CK_DEBUG_TYPING // \t) );\n // @if CK_DEBUG_TYPING // }\n if (editable) {\n this.domConverter.focus(editable);\n }\n }\n // @if CK_DEBUG_TYPING // if ( ( window as any ).logCKETyping ) {\n // @if CK_DEBUG_TYPING // \tconsole.groupEnd();\n // @if CK_DEBUG_TYPING // }\n }\n}\n/**\n * Checks if provided element is editable.\n */\nfunction isEditable(element) {\n if (element.getAttribute('contenteditable') == 'false') {\n return false;\n }\n const parent = element.findAncestor(element => element.hasAttribute('contenteditable'));\n return !parent || parent.getAttribute('contenteditable') == 'true';\n}\n/**\n * Adds inline filler at a given position.\n *\n * The position can be given as an array of DOM nodes and an offset in that array,\n * or a DOM parent element and an offset in that element.\n *\n * @returns The DOM text node that contains an inline filler.\n */\nfunction addInlineFiller(domDocument, domParentOrArray, offset) {\n const childNodes = domParentOrArray instanceof Array ? domParentOrArray : domParentOrArray.childNodes;\n const nodeAfterFiller = childNodes[offset];\n if (isText(nodeAfterFiller)) {\n nodeAfterFiller.data = INLINE_FILLER + nodeAfterFiller.data;\n return nodeAfterFiller;\n }\n else {\n const fillerNode = domDocument.createTextNode(INLINE_FILLER);\n if (Array.isArray(domParentOrArray)) {\n childNodes.splice(offset, 0, fillerNode);\n }\n else {\n insertAt(domParentOrArray, offset, fillerNode);\n }\n return fillerNode;\n }\n}\n/**\n * Whether two DOM nodes should be considered as similar.\n * Nodes are considered similar if they have the same tag name.\n */\nfunction areSimilarElements(node1, node2) {\n return isNode(node1) && isNode(node2) &&\n !isText(node1) && !isText(node2) &&\n !isComment(node1) && !isComment(node2) &&\n node1.tagName.toLowerCase() === node2.tagName.toLowerCase();\n}\n/**\n * Whether two DOM nodes are text nodes.\n */\nfunction areTextNodes(node1, node2) {\n return isNode(node1) && isNode(node2) &&\n isText(node1) && isText(node2);\n}\n/**\n * Whether two dom nodes should be considered as the same.\n * Two nodes which are considered the same are:\n *\n * * Text nodes with the same text.\n * * Element nodes represented by the same object.\n * * Two block filler elements.\n *\n * @param blockFillerMode Block filler mode, see {@link module:engine/view/domconverter~ViewDomConverter#blockFillerMode}.\n */\nfunction sameNodes(domConverter, actualDomChild, expectedDomChild) {\n // Elements.\n if (actualDomChild === expectedDomChild) {\n return true;\n }\n // Texts.\n else if (isText(actualDomChild) && isText(expectedDomChild)) {\n return actualDomChild.data === expectedDomChild.data;\n }\n // Block fillers.\n else if (domConverter.isBlockFiller(actualDomChild) &&\n domConverter.isBlockFiller(expectedDomChild)) {\n return true;\n }\n // Not matching types.\n return false;\n}\n/**\n * The following is a Firefox–specific hack (https://github.com/ckeditor/ckeditor5-engine/issues/1439).\n * When the native DOM selection is at the end of the block and preceded by
e.g.\n *\n * ```html\n *

foo
[]

\n * ```\n *\n * which happens a lot when using the soft line break, the browser fails to (visually) move the\n * caret to the new line. A quick fix is as simple as force–refreshing the selection with the same range.\n */\nfunction fixGeckoSelectionAfterBr(focus, domSelection) {\n let parent = focus.parent;\n let offset = focus.offset;\n if (isText(parent) && isInlineFiller(parent)) {\n offset = indexOf(parent) + 1;\n parent = parent.parentNode;\n }\n // This fix works only when the focus point is at the very end of an element.\n // There is no point in running it in cases unrelated to the browser bug.\n if (parent.nodeType != Node.ELEMENT_NODE || offset != parent.childNodes.length - 1) {\n return;\n }\n const childAtOffset = parent.childNodes[offset];\n // To stay on the safe side, the fix being as specific as possible, it targets only the\n // selection which is at the very end of the element and preceded by
.\n if (childAtOffset && childAtOffset.tagName == 'BR') {\n domSelection.addRange(domSelection.getRangeAt(0));\n }\n}\nfunction filterOutFakeSelectionContainer(domChildList, fakeSelectionContainer) {\n const childList = Array.from(domChildList);\n if (childList.length == 0 || !fakeSelectionContainer) {\n return childList;\n }\n const last = childList[childList.length - 1];\n if (last == fakeSelectionContainer) {\n childList.pop();\n }\n return childList;\n}\n/**\n * Creates a fake selection container for a given document.\n */\nfunction createFakeSelectionContainer(domDocument) {\n const container = domDocument.createElement('div');\n container.className = 'ck-fake-selection-container';\n Object.assign(container.style, {\n position: 'fixed',\n top: 0,\n left: '-9999px',\n // See https://github.com/ckeditor/ckeditor5/issues/752.\n width: '42px'\n });\n // Fill it with a text node so we can update it later.\n container.textContent = '\\u00A0';\n return container;\n}\n// @if CK_DEBUG_TYPING // function _escapeTextNodeData( text ) {\n// @if CK_DEBUG_TYPING // \tconst escapedText = text\n// @if CK_DEBUG_TYPING // \t\t.replace( /&/g, '&' )\n// @if CK_DEBUG_TYPING // \t\t.replace( /\\u00A0/g, ' ' )\n// @if CK_DEBUG_TYPING // \t\t.replace( /\\u2060/g, '⁠' );\n// @if CK_DEBUG_TYPING //\n// @if CK_DEBUG_TYPING // \treturn `\"${ escapedText }\"`;\n// @if CK_DEBUG_TYPING // }\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module engine/view/domconverter\n */\nimport { ViewText } from './text.js';\nimport { ViewElement } from './element.js';\nimport { ViewUIElement } from './uielement.js';\nimport { ViewPosition } from './position.js';\nimport { ViewRange } from './range.js';\nimport { ViewSelection } from './selection.js';\nimport { ViewDocumentFragment } from './documentfragment.js';\nimport { ViewTreeWalker } from './treewalker.js';\nimport { Matcher } from './matcher.js';\nimport { BR_FILLER, INLINE_FILLER_LENGTH, NBSP_FILLER, MARKED_NBSP_FILLER, getDataWithoutFiller, isInlineFiller, startsWithFiller } from './filler.js';\nimport { global, logWarning, indexOf, getAncestors, isText, isComment, isValidAttributeName, first, env } from '@ckeditor/ckeditor5-utils';\nconst BR_FILLER_REF = BR_FILLER(global.document); // eslint-disable-line new-cap\nconst NBSP_FILLER_REF = NBSP_FILLER(global.document); // eslint-disable-line new-cap\nconst MARKED_NBSP_FILLER_REF = MARKED_NBSP_FILLER(global.document); // eslint-disable-line new-cap\nconst UNSAFE_ATTRIBUTE_NAME_PREFIX = 'data-ck-unsafe-attribute-';\nconst UNSAFE_ELEMENT_REPLACEMENT_ATTRIBUTE = 'data-ck-unsafe-element';\n/**\n * `ViewDomConverter` is a set of tools to do transformations between DOM nodes and view nodes. It also handles\n * {@link module:engine/view/domconverter~ViewDomConverter#bindElements bindings} between these nodes.\n *\n * An instance of the DOM converter is available under\n * {@link module:engine/view/view~EditingView#domConverter `editor.editing.view.domConverter`}.\n *\n * The DOM converter does not check which nodes should be rendered (use {@link module:engine/view/renderer~ViewRenderer}), does not keep the\n * state of a tree nor keeps the synchronization between the tree view and\n * the DOM tree (use {@link module:engine/view/document~ViewDocument}).\n *\n * The DOM converter keeps DOM elements to view element bindings, so when the converter gets destroyed, the bindings are lost.\n * Two converters will keep separate binding maps, so one tree view can be bound with two DOM trees.\n */\nexport class ViewDomConverter {\n document;\n /**\n * Whether to leave the View-to-DOM conversion result unchanged or improve editing experience by filtering out interactive data.\n */\n renderingMode;\n /**\n * The mode of a block filler used by the DOM converter.\n */\n blockFillerMode;\n /**\n * Elements which are considered pre-formatted elements.\n */\n preElements;\n /**\n * Elements which are considered block elements (and hence should be filled with a\n * {@link #isBlockFiller block filler}).\n *\n * Whether an element is considered a block element also affects handling of trailing whitespaces.\n *\n * You can extend this array if you introduce support for block elements which are not yet recognized here.\n */\n blockElements;\n /**\n * A list of elements that exist inline (in text) but their inner structure cannot be edited because\n * of the way they are rendered by the browser. They are mostly HTML form elements but there are other\n * elements such as `` or `' +\n '');\n }\n },\n {\n name: 'spotify',\n url: [\n /^open\\.spotify\\.com\\/(artist\\/\\w+)/,\n /^open\\.spotify\\.com\\/(album\\/\\w+)/,\n /^open\\.spotify\\.com\\/(track\\/\\w+)/\n ],\n html: match => {\n const id = match[1];\n return ('
' +\n `' +\n '
');\n }\n },\n {\n name: 'youtube',\n url: [\n /^(?:m\\.)?youtube\\.com\\/watch\\?v=([\\w-]+)(?:&t=(\\d+))?/,\n /^(?:m\\.)?youtube\\.com\\/shorts\\/([\\w-]+)(?:\\?t=(\\d+))?/,\n /^(?:m\\.)?youtube\\.com\\/v\\/([\\w-]+)(?:\\?t=(\\d+))?/,\n /^youtube\\.com\\/embed\\/([\\w-]+)(?:\\?start=(\\d+))?/,\n /^youtu\\.be\\/([\\w-]+)(?:\\?t=(\\d+))?/\n ],\n html: match => {\n const id = match[1];\n const time = match[2];\n return ('
' +\n `' +\n '
');\n }\n },\n {\n name: 'vimeo',\n url: [\n /^vimeo\\.com\\/(\\d+)/,\n /^vimeo\\.com\\/[^/]+\\/[^/]+\\/video\\/(\\d+)/,\n /^vimeo\\.com\\/album\\/[^/]+\\/video\\/(\\d+)/,\n /^vimeo\\.com\\/channels\\/[^/]+\\/(\\d+)/,\n /^vimeo\\.com\\/groups\\/[^/]+\\/videos\\/(\\d+)/,\n /^vimeo\\.com\\/ondemand\\/[^/]+\\/(\\d+)/,\n /^player\\.vimeo\\.com\\/video\\/(\\d+)/\n ],\n html: match => {\n const id = match[1];\n return ('
' +\n `' +\n '
');\n }\n },\n {\n name: 'instagram',\n url: [\n /^instagram\\.com\\/p\\/(\\w+)/,\n /^instagram\\.com\\/reel\\/(\\w+)/\n ]\n },\n {\n name: 'twitter',\n url: [\n /^twitter\\.com/,\n /^x\\.com/\n ]\n },\n {\n name: 'googleMaps',\n url: [\n /^google\\.com\\/maps/,\n /^goo\\.gl\\/maps/,\n /^maps\\.google\\.com/,\n /^maps\\.app\\.goo\\.gl/\n ]\n },\n {\n name: 'flickr',\n url: /^flickr\\.com/\n },\n {\n name: 'facebook',\n url: /^facebook\\.com/\n }\n ]\n });\n this.registry = new MediaRegistry(editor.locale, editor.config.get('mediaEmbed'));\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const schema = editor.model.schema;\n const t = editor.t;\n const conversion = editor.conversion;\n const renderMediaPreview = editor.config.get('mediaEmbed.previewsInData');\n const elementName = editor.config.get('mediaEmbed.elementName');\n const registry = this.registry;\n editor.commands.add('mediaEmbed', new MediaEmbedCommand(editor));\n // Configure the schema.\n schema.register('media', {\n inheritAllFrom: '$blockObject',\n allowAttributes: ['url']\n });\n // Model -> Data\n conversion.for('dataDowncast').elementToStructure({\n model: 'media',\n view: (modelElement, { writer }) => {\n const url = modelElement.getAttribute('url');\n return createMediaFigureElement(writer, registry, url, {\n elementName,\n renderMediaPreview: !!url && renderMediaPreview\n });\n }\n });\n // Model -> Data (url -> data-oembed-url)\n conversion.for('dataDowncast').add(modelToViewUrlAttributeConverter(registry, {\n elementName,\n renderMediaPreview\n }));\n // Model -> View (element)\n conversion.for('editingDowncast').elementToStructure({\n model: 'media',\n view: (modelElement, { writer }) => {\n const url = modelElement.getAttribute('url');\n const figure = createMediaFigureElement(writer, registry, url, {\n elementName,\n renderForEditingView: true\n });\n return toMediaWidget(figure, writer, t('media widget'));\n }\n });\n // Model -> View (url -> data-oembed-url)\n conversion.for('editingDowncast').add(modelToViewUrlAttributeConverter(registry, {\n elementName,\n renderForEditingView: true\n }));\n // View -> Model (data-oembed-url -> url)\n conversion.for('upcast')\n // Upcast semantic media.\n .elementToElement({\n view: element => ['oembed', elementName].includes(element.name) && element.getAttribute('url') ?\n { name: true } :\n null,\n model: (viewMedia, { writer }) => {\n const url = viewMedia.getAttribute('url');\n if (registry.hasMedia(url)) {\n return writer.createElement('media', { url });\n }\n return null;\n }\n })\n // Upcast non-semantic media.\n .elementToElement({\n view: {\n name: 'div',\n attributes: {\n 'data-oembed-url': true\n }\n },\n model: (viewMedia, { writer }) => {\n const url = viewMedia.getAttribute('data-oembed-url');\n if (registry.hasMedia(url)) {\n return writer.createElement('media', { url });\n }\n return null;\n }\n })\n // Consume `
` elements, that were left after upcast.\n .add(dispatcher => {\n const converter = (evt, data, conversionApi) => {\n if (!conversionApi.consumable.consume(data.viewItem, { name: true, classes: 'media' })) {\n return;\n }\n const { modelRange, modelCursor } = conversionApi.convertChildren(data.viewItem, data.modelCursor);\n data.modelRange = modelRange;\n data.modelCursor = modelCursor;\n const modelElement = first(modelRange.getItems());\n if (!modelElement) {\n // Revert consumed figure so other features can convert it.\n conversionApi.consumable.revert(data.viewItem, { name: true, classes: 'media' });\n }\n };\n dispatcher.on('element:figure', converter);\n });\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module media-embed/automediaembed\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { ModelLiveRange, ModelLivePosition } from 'ckeditor5/src/engine.js';\nimport { Clipboard } from 'ckeditor5/src/clipboard.js';\nimport { Delete } from 'ckeditor5/src/typing.js';\nimport { Undo } from 'ckeditor5/src/undo.js';\nimport { global } from 'ckeditor5/src/utils.js';\nimport { MediaEmbedEditing } from './mediaembedediting.js';\nimport { insertMedia } from './utils.js';\nconst URL_REGEXP = /^(?:http(s)?:\\/\\/)?[\\w-]+\\.[\\w-.~:/?#[\\]@!$&'()*+,;=%]+$/;\n/**\n * The auto-media embed plugin. It recognizes media links in the pasted content and embeds\n * them shortly after they are injected into the document.\n */\nexport class AutoMediaEmbed extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [Clipboard, Delete, Undo];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'AutoMediaEmbed';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * The paste–to–embed `setTimeout` ID. Stored as a property to allow\n * cleaning of the timeout.\n */\n _timeoutId;\n /**\n * The position where the `` element will be inserted after the timeout,\n * determined each time the new content is pasted into the document.\n */\n _positionToInsert;\n /**\n * @inheritDoc\n */\n constructor(editor) {\n super(editor);\n this._timeoutId = null;\n this._positionToInsert = null;\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const modelDocument = editor.model.document;\n // We need to listen on `Clipboard#inputTransformation` because we need to save positions of selection.\n // After pasting, the content between those positions will be checked for a URL that could be transformed\n // into media.\n const clipboardPipeline = editor.plugins.get('ClipboardPipeline');\n this.listenTo(clipboardPipeline, 'inputTransformation', () => {\n const firstRange = modelDocument.selection.getFirstRange();\n const leftLivePosition = ModelLivePosition.fromPosition(firstRange.start);\n leftLivePosition.stickiness = 'toPrevious';\n const rightLivePosition = ModelLivePosition.fromPosition(firstRange.end);\n rightLivePosition.stickiness = 'toNext';\n modelDocument.once('change:data', () => {\n this._embedMediaBetweenPositions(leftLivePosition, rightLivePosition);\n leftLivePosition.detach();\n rightLivePosition.detach();\n }, { priority: 'high' });\n });\n const undoCommand = editor.commands.get('undo');\n undoCommand.on('execute', () => {\n if (this._timeoutId) {\n global.window.clearTimeout(this._timeoutId);\n this._positionToInsert.detach();\n this._timeoutId = null;\n this._positionToInsert = null;\n }\n }, { priority: 'high' });\n }\n /**\n * Analyzes the part of the document between provided positions in search for a URL representing media.\n * When the URL is found, it is automatically converted into media.\n *\n * @param leftPosition Left position of the selection.\n * @param rightPosition Right position of the selection.\n */\n _embedMediaBetweenPositions(leftPosition, rightPosition) {\n const editor = this.editor;\n const mediaRegistry = editor.plugins.get(MediaEmbedEditing).registry;\n // TODO: Use marker instead of ModelLiveRange & LivePositions.\n const urlRange = new ModelLiveRange(leftPosition, rightPosition);\n const walker = urlRange.getWalker({ ignoreElementEnd: true });\n let url = '';\n for (const node of walker) {\n if (node.item.is('$textProxy')) {\n url += node.item.data;\n }\n }\n url = url.trim();\n // If the URL does not match to universal URL regexp, let's skip that.\n if (!url.match(URL_REGEXP)) {\n urlRange.detach();\n return;\n }\n // If the URL represents a media, let's use it.\n if (!mediaRegistry.hasMedia(url)) {\n urlRange.detach();\n return;\n }\n const mediaEmbedCommand = editor.commands.get('mediaEmbed');\n // Do not anything if media element cannot be inserted at the current position (#47).\n if (!mediaEmbedCommand.isEnabled) {\n urlRange.detach();\n return;\n }\n // Position won't be available in the `setTimeout` function so let's clone it.\n this._positionToInsert = ModelLivePosition.fromPosition(leftPosition);\n // This action mustn't be executed if undo was called between pasting and auto-embedding.\n this._timeoutId = global.window.setTimeout(() => {\n editor.model.change(writer => {\n this._timeoutId = null;\n writer.remove(urlRange);\n urlRange.detach();\n let insertionPosition = null;\n // Check if position where the media element should be inserted is still valid.\n // Otherwise leave it as undefined to use document.selection - default behavior of model.insertContent().\n if (this._positionToInsert.root.rootName !== '$graveyard') {\n insertionPosition = this._positionToInsert;\n }\n insertMedia(editor.model, url, insertionPosition, false);\n this._positionToInsert.detach();\n this._positionToInsert = null;\n });\n editor.plugins.get(Delete).requestUndoOnBackspace();\n }, 100);\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module media-embed/ui/mediaformview\n */\nimport { LabeledFieldView, View, createLabeledInputText, submitHandler } from 'ckeditor5/src/ui.js';\nimport { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';\n// See: #8833.\n// eslint-disable-next-line ckeditor5-rules/ckeditor-imports\nimport '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';\nimport '../../theme/mediaform.css';\n/**\n * The media form view controller class.\n *\n * See {@link module:media-embed/ui/mediaformview~MediaFormView}.\n */\nexport class MediaFormView extends View {\n /**\n * Tracks information about the DOM focus in the form.\n */\n focusTracker;\n /**\n * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.\n */\n keystrokes;\n /**\n * The URL input view.\n */\n urlInputView;\n /**\n * An array of form validators used by {@link #isValid}.\n */\n _validators;\n /**\n * The default info text for the {@link #urlInputView}.\n */\n _urlInputViewInfoDefault;\n /**\n * The info text with an additional tip for the {@link #urlInputView},\n * displayed when the input has some value.\n */\n _urlInputViewInfoTip;\n /**\n * @param validators Form validators used by {@link #isValid}.\n * @param locale The localization services instance.\n */\n constructor(validators, locale) {\n super(locale);\n this.focusTracker = new FocusTracker();\n this.keystrokes = new KeystrokeHandler();\n this.set('mediaURLInputValue', '');\n this.urlInputView = this._createUrlInput();\n this._validators = validators;\n this.setTemplate({\n tag: 'form',\n attributes: {\n class: [\n 'ck',\n 'ck-media-form',\n 'ck-responsive-form'\n ],\n tabindex: '-1'\n },\n children: [\n this.urlInputView\n ]\n });\n }\n /**\n * @inheritDoc\n */\n render() {\n super.render();\n submitHandler({\n view: this\n });\n // Register the view in the focus tracker.\n this.focusTracker.add(this.urlInputView.element);\n // Start listening for the keystrokes coming from #element.\n this.keystrokes.listenTo(this.element);\n }\n /**\n * @inheritDoc\n */\n destroy() {\n super.destroy();\n this.focusTracker.destroy();\n this.keystrokes.destroy();\n }\n /**\n * Focuses the {@link #urlInputView}.\n */\n focus() {\n this.urlInputView.focus();\n }\n /**\n * The native DOM `value` of the {@link #urlInputView} element.\n *\n * **Note**: Do not confuse it with the {@link module:ui/inputtext/inputtextview~InputTextView#value}\n * which works one way only and may not represent the actual state of the component in the DOM.\n */\n get url() {\n return this.urlInputView.fieldView.element.value.trim();\n }\n set url(url) {\n this.urlInputView.fieldView.value = url.trim();\n }\n /**\n * Validates the form and returns `false` when some fields are invalid.\n */\n isValid() {\n this.resetFormStatus();\n for (const validator of this._validators) {\n const errorText = validator(this);\n // One error per field is enough.\n if (errorText) {\n // Apply updated error.\n this.urlInputView.errorText = errorText;\n return false;\n }\n }\n return true;\n }\n /**\n * Cleans up the supplementary error and information text of the {@link #urlInputView}\n * bringing them back to the state when the form has been displayed for the first time.\n *\n * See {@link #isValid}.\n */\n resetFormStatus() {\n this.urlInputView.errorText = null;\n this.urlInputView.infoText = this._urlInputViewInfoDefault;\n }\n /**\n * Creates a labeled input view.\n *\n * @returns Labeled input view instance.\n */\n _createUrlInput() {\n const t = this.locale.t;\n const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);\n const inputField = labeledInput.fieldView;\n this._urlInputViewInfoDefault = t('Paste the media URL in the input.');\n this._urlInputViewInfoTip = t('Tip: Paste the URL into the content to embed faster.');\n labeledInput.label = t('Media URL');\n labeledInput.infoText = this._urlInputViewInfoDefault;\n inputField.inputMode = 'url';\n inputField.on('input', () => {\n // Display the tip text only when there is some value. Otherwise fall back to the default info text.\n labeledInput.infoText = inputField.element.value ? this._urlInputViewInfoTip : this._urlInputViewInfoDefault;\n this.mediaURLInputValue = inputField.element.value.trim();\n });\n return labeledInput;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module media-embed/mediaembedui\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { IconMedia } from 'ckeditor5/src/icons.js';\nimport { ButtonView, CssTransitionDisablerMixin, MenuBarMenuListItemButtonView, Dialog } from 'ckeditor5/src/ui.js';\nimport { MediaFormView } from './ui/mediaformview.js';\nimport { MediaEmbedEditing } from './mediaembedediting.js';\n/**\n * The media embed UI plugin.\n */\nexport class MediaEmbedUI extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [MediaEmbedEditing, Dialog];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'MediaEmbedUI';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n _formView;\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n editor.ui.componentFactory.add('mediaEmbed', () => {\n const t = this.editor.locale.t;\n const button = this._createDialogButton(ButtonView);\n button.tooltip = true;\n button.label = t('Insert media');\n return button;\n });\n editor.ui.componentFactory.add('menuBar:mediaEmbed', () => {\n const t = this.editor.locale.t;\n const button = this._createDialogButton(MenuBarMenuListItemButtonView);\n button.label = t('Media');\n return button;\n });\n }\n /**\n * Creates a button for menu bar that will show media embed dialog.\n */\n _createDialogButton(ButtonClass) {\n const editor = this.editor;\n const buttonView = new ButtonClass(editor.locale);\n const command = editor.commands.get('mediaEmbed');\n const dialogPlugin = this.editor.plugins.get('Dialog');\n buttonView.icon = IconMedia;\n buttonView.bind('isEnabled').to(command, 'isEnabled');\n buttonView.on('execute', () => {\n if (dialogPlugin.id === 'mediaEmbed') {\n dialogPlugin.hide();\n }\n else {\n this._showDialog();\n }\n });\n return buttonView;\n }\n _showDialog() {\n const editor = this.editor;\n const dialog = editor.plugins.get('Dialog');\n const command = editor.commands.get('mediaEmbed');\n const t = editor.locale.t;\n const isMediaSelected = command.value !== undefined;\n if (!this._formView) {\n const registry = editor.plugins.get(MediaEmbedEditing).registry;\n this._formView = new (CssTransitionDisablerMixin(MediaFormView))(getFormValidators(editor.t, registry), editor.locale);\n this._formView.on('submit', () => this._handleSubmitForm());\n }\n dialog.show({\n id: 'mediaEmbed',\n title: t('Media embed'),\n content: this._formView,\n isModal: true,\n onShow: () => {\n this._formView.url = command.value || '';\n this._formView.resetFormStatus();\n this._formView.urlInputView.fieldView.select();\n },\n actionButtons: [\n {\n label: t('Cancel'),\n withText: true,\n onExecute: () => dialog.hide()\n },\n {\n label: isMediaSelected ? t('Save') : t('Insert'),\n class: 'ck-button-action',\n withText: true,\n onExecute: () => this._handleSubmitForm()\n }\n ]\n });\n }\n _handleSubmitForm() {\n const editor = this.editor;\n const dialog = editor.plugins.get('Dialog');\n if (this._formView.isValid()) {\n editor.execute('mediaEmbed', this._formView.url);\n dialog.hide();\n editor.editing.view.focus();\n }\n }\n}\nfunction getFormValidators(t, registry) {\n return [\n form => {\n if (!form.url.length) {\n return t('The URL must not be empty.');\n }\n },\n form => {\n if (!registry.hasMedia(form.url)) {\n return t('This media URL is not supported.');\n }\n }\n ];\n}\n","export default \"\";","export default \"\";","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module remove-format/removeformatui\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { IconRemoveFormat } from 'ckeditor5/src/icons.js';\nimport { ButtonView, MenuBarMenuListItemButtonView } from 'ckeditor5/src/ui.js';\nconst REMOVE_FORMAT = 'removeFormat';\n/**\n * The remove format UI plugin. It registers the `'removeFormat'` button which can be\n * used in the toolbar.\n */\nexport class RemoveFormatUI extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'RemoveFormatUI';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n editor.ui.componentFactory.add(REMOVE_FORMAT, () => {\n const view = this._createButton(ButtonView);\n view.set({\n tooltip: true\n });\n return view;\n });\n editor.ui.componentFactory.add(`menuBar:${REMOVE_FORMAT}`, () => this._createButton(MenuBarMenuListItemButtonView));\n }\n /**\n * Creates a button for remove format command to use either in toolbar or in menu bar.\n */\n _createButton(ButtonClass) {\n const editor = this.editor;\n const locale = editor.locale;\n const command = editor.commands.get(REMOVE_FORMAT);\n const view = new ButtonClass(editor.locale);\n const t = locale.t;\n view.set({\n label: t('Remove Format'),\n icon: IconRemoveFormat\n });\n view.bind('isEnabled').to(command, 'isEnabled');\n // Execute the command.\n this.listenTo(view, 'execute', () => {\n editor.execute(REMOVE_FORMAT);\n editor.editing.view.focus();\n });\n return view;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { first } from 'ckeditor5/src/utils.js';\n/**\n * The remove format command.\n *\n * It is used by the {@link module:remove-format/removeformat~RemoveFormat remove format feature}\n * to clear the formatting in the selection.\n *\n * ```ts\n * editor.execute( 'removeFormat' );\n * ```\n */\nexport class RemoveFormatCommand extends Command {\n /**\n * List of all registered custom attribute handlers.\n */\n _customAttributesHandlers = [];\n /**\n * @inheritDoc\n */\n refresh() {\n const model = this.editor.model;\n this.isEnabled = !!first(this._getFormattingItems(model.document.selection));\n }\n /**\n * @inheritDoc\n */\n execute() {\n const model = this.editor.model;\n model.change(writer => {\n for (const item of this._getFormattingItems(model.document.selection)) {\n if (item.is('selection')) {\n for (const attributeName of this._getFormattingAttributes(item)) {\n writer.removeSelectionAttribute(attributeName);\n }\n }\n else {\n // Workaround for items with multiple removable attributes. See\n // https://github.com/ckeditor/ckeditor5-remove-format/pull/1#pullrequestreview-220515609\n const itemRange = writer.createRangeOn(item);\n for (const attributeName of this._getFormattingAttributes(item)) {\n this._removeFormatting(attributeName, item, itemRange, writer);\n }\n }\n }\n });\n }\n /**\n * Registers a custom attribute handler that will be used to determine if an attribute is formatting and how to remove it.\n *\n * @internal\n */\n registerCustomAttribute(isFormatting, removeFormatting) {\n this._customAttributesHandlers.push({\n isFormatting,\n removeFormatting\n });\n }\n /**\n * Helper method that removes a formatting attribute from an item either using custom callbacks or writer remove attribute.\n */\n _removeFormatting(attributeName, item, itemRange, writer) {\n let customHandled = false;\n for (const { isFormatting, removeFormatting } of this._customAttributesHandlers) {\n if (isFormatting(attributeName, item)) {\n removeFormatting(attributeName, itemRange, writer);\n customHandled = true;\n }\n }\n if (!customHandled) {\n writer.removeAttribute(attributeName, itemRange);\n }\n }\n /**\n * Returns an iterable of items in a selection (including the selection itself) that have formatting model\n * attributes to be removed by the feature.\n */\n *_getFormattingItems(selection) {\n const model = this.editor.model;\n const schema = model.schema;\n const itemHasRemovableFormatting = (item) => {\n return !!first(this._getFormattingAttributes(item));\n };\n // Check formatting on selected items.\n for (const curRange of selection.getRanges()) {\n for (const item of curRange.getItems()) {\n // Ignore last block if range ends at the beginning of it.\n if (schema.isBlock(item) && curRange.end.isTouching(model.createPositionAt(item, 0))) {\n continue;\n }\n if (itemHasRemovableFormatting(item)) {\n yield item;\n }\n }\n }\n // Check formatting from selected blocks (to include partly selected blocks).\n for (const block of selection.getSelectedBlocks()) {\n if (itemHasRemovableFormatting(block)) {\n yield block;\n }\n }\n // Finally the selection might be formatted as well, so make sure to check it.\n if (itemHasRemovableFormatting(selection)) {\n yield selection;\n }\n }\n /**\n * Returns an iterable of formatting attributes of a given model item.\n *\n * **Note:** Formatting items have the `isFormatting` property set to `true`.\n *\n * @returns The names of formatting attributes found in a given item.\n */\n *_getFormattingAttributes(item) {\n const schema = this.editor.model.schema;\n for (const [attributeName] of item.getAttributes()) {\n for (const { isFormatting } of this._customAttributesHandlers) {\n if (isFormatting(attributeName, item)) {\n yield attributeName;\n }\n }\n const attributeProperties = schema.getAttributeProperties(attributeName);\n if (attributeProperties && attributeProperties.isFormatting) {\n yield attributeName;\n }\n }\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module remove-format/removeformatediting\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { RemoveFormatCommand } from './removeformatcommand.js';\n/**\n * The remove format editing plugin.\n *\n * It registers the {@link module:remove-format/removeformatcommand~RemoveFormatCommand removeFormat} command.\n */\nexport class RemoveFormatEditing extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'RemoveFormatEditing';\n }\n /**\n * @inheritDoc\n * @internal\n */\n static get licenseFeatureCode() {\n return 'RF';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get isPremiumPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n editor.commands.add('removeFormat', new RemoveFormatCommand(editor));\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { first } from 'ckeditor5/src/utils.js';\nconst ALIGN_VALUES_REG_EXP = /^(left|center|right)$/;\nconst FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;\n/**\n * Conversion helper for upcasting attributes using normalized styles.\n *\n * @param options.modelAttribute The attribute to set.\n * @param options.styleName The style name to convert.\n * @param options.attributeName The HTML attribute name to convert.\n * @param options.attributeType The HTML attribute type for value normalization.\n * @param options.viewElement The view element name that should be converted.\n * @param options.defaultValue The default value for the specified `modelAttribute`.\n * @param options.shouldUpcast The function which returns `true` if style should be upcasted from this element.\n * @internal\n */\nexport function upcastStyleToAttribute(conversion, options) {\n const { modelAttribute, styleName, attributeName, attributeType, viewElement, defaultValue, shouldUpcast = () => true, reduceBoxSides = false } = options;\n conversion.for('upcast').attributeToAttribute({\n view: {\n name: viewElement,\n styles: {\n [styleName]: /[\\s\\S]+/\n }\n },\n model: {\n key: modelAttribute,\n value: (viewElement, conversionApi, data) => {\n // Ignore table elements inside figures and figures without the table class.\n if (!shouldUpcast(viewElement)) {\n return;\n }\n const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);\n const normalized = viewElement.getNormalizedStyle(styleName);\n const value = reduceBoxSides ? reduceBoxSidesValue(normalized) : normalized;\n if (localDefaultValue !== value) {\n return value;\n }\n // Consume the style even if not applied to the element so it won't be processed by other converters.\n conversionApi.consumable.consume(viewElement, { styles: styleName });\n }\n }\n });\n if (attributeName) {\n conversion.for('upcast').attributeToAttribute({\n view: {\n name: viewElement,\n attributes: {\n [attributeName]: /.+/\n }\n },\n model: {\n key: modelAttribute,\n value: (viewElement, conversionApi, data) => {\n // Convert attributes of table and table cell elements, ignore figure.\n // Do not convert attribute if related style is set as it has a higher priority.\n // Do not convert attribute if the element is a table inside a figure with the related style set.\n if (viewElement.name == 'figure' ||\n viewElement.hasStyle(styleName) ||\n viewElement.name == 'table' && viewElement.parent.name == 'figure' && viewElement.parent.hasStyle(styleName)) {\n return;\n }\n const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);\n let value = viewElement.getAttribute(attributeName);\n if (value && attributeType == 'length') {\n const parsedValue = parseFloat(value);\n if (isNaN(parsedValue)) {\n value = localDefaultValue;\n }\n else {\n value = parsedValue + (value.includes('%') ? '%' : 'px');\n }\n }\n if (localDefaultValue !== value) {\n return value;\n }\n // Consume the attribute even if not applied to the element so it won't be processed by other converters.\n conversionApi.consumable.consume(viewElement, { attributes: attributeName });\n }\n }\n });\n }\n}\n/**\n * Conversion helper for upcasting border styles for view elements.\n *\n * @param editor The editor instance.\n * @param defaultBorder The default border values.\n * @param defaultBorder.color The default `borderColor` value.\n * @param defaultBorder.style The default `borderStyle` value.\n * @param defaultBorder.width The default `borderWidth` value.\n * @internal\n */\nexport function upcastBorderStyles(editor, viewElementName, modelAttributes, defaultBorder) {\n const { conversion } = editor;\n conversion.for('upcast').add(dispatcher => dispatcher.on('element:' + viewElementName, (evt, data, conversionApi) => {\n // If the element was not converted by element-to-element converter,\n // we should not try to convert the style. See #8393.\n if (!data.modelRange) {\n return;\n }\n // Check the most detailed properties. These will be always set directly or\n // when using the \"group\" properties like: `border-(top|right|bottom|left)` or `border`.\n const stylesToConsume = [\n 'border-top-width',\n 'border-top-color',\n 'border-top-style',\n 'border-bottom-width',\n 'border-bottom-color',\n 'border-bottom-style',\n 'border-right-width',\n 'border-right-color',\n 'border-right-style',\n 'border-left-width',\n 'border-left-color',\n 'border-left-style'\n ].filter(styleName => data.viewItem.hasStyle(styleName));\n if (!stylesToConsume.length) {\n return;\n }\n const matcherPattern = {\n styles: stylesToConsume\n };\n // Try to consume appropriate values from consumable values list.\n if (!conversionApi.consumable.test(data.viewItem, matcherPattern)) {\n return;\n }\n const modelElement = [...data.modelRange.getItems({ shallow: true })].pop();\n const tableElement = modelElement.findAncestor('table', { includeSelf: true });\n let localDefaultBorder = defaultBorder;\n if (tableElement && tableElement.getAttribute('tableType') == 'layout') {\n localDefaultBorder = {\n style: 'none',\n color: '',\n width: ''\n };\n }\n conversionApi.consumable.consume(data.viewItem, matcherPattern);\n const normalizedBorder = {\n style: data.viewItem.getNormalizedStyle('border-style'),\n color: data.viewItem.getNormalizedStyle('border-color'),\n width: data.viewItem.getNormalizedStyle('border-width')\n };\n const reducedBorder = {\n style: reduceBoxSidesValue(normalizedBorder.style),\n color: reduceBoxSidesValue(normalizedBorder.color),\n width: reduceBoxSidesValue(normalizedBorder.width)\n };\n if (reducedBorder.style !== localDefaultBorder.style) {\n conversionApi.writer.setAttribute(modelAttributes.style, reducedBorder.style, modelElement);\n }\n if (reducedBorder.color !== localDefaultBorder.color) {\n conversionApi.writer.setAttribute(modelAttributes.color, reducedBorder.color, modelElement);\n }\n if (reducedBorder.width !== localDefaultBorder.width) {\n conversionApi.writer.setAttribute(modelAttributes.width, reducedBorder.width, modelElement);\n }\n }));\n if (editor.config.get('experimentalFlags.upcastTableBorderZeroAttributes')) {\n // If parent table has `border=\"0\"` attribute then set border style to `none`\n // all table cells of that table and table itself.\n conversion.for('upcast').add(dispatcher => {\n dispatcher.on(`element:${viewElementName}`, (evt, data, conversionApi) => {\n const { modelRange, viewItem } = data;\n const viewTable = (viewItem.is('element', 'table') ?\n viewItem :\n viewItem.findAncestor('table'));\n // If something already consumed the border attribute on the nearest table element, skip the conversion.\n if (!conversionApi.consumable.test(viewTable, { attributes: 'border' })) {\n return;\n }\n // Ignore tables with border different than \"0\".\n if (viewTable.getAttribute('border') !== '0') {\n return;\n }\n const modelElement = modelRange?.start?.nodeAfter;\n // If model element has any non-default border attribute, skip the conversion.\n if (!modelElement ||\n Object.values(modelAttributes).some(attributeName => modelElement.hasAttribute(attributeName))) {\n return;\n }\n conversionApi.writer.setAttribute(modelAttributes.style, 'none', modelElement);\n if (viewItem.is('element', 'table')) {\n conversionApi.consumable.consume(viewItem, { attributes: 'border' });\n }\n });\n });\n }\n}\n/**\n * Conversion helper for downcasting an attribute to a style.\n *\n * @internal\n */\nexport function downcastAttributeToStyle(conversion, options) {\n const { modelElement, modelAttribute, styleName } = options;\n conversion.for('downcast').attributeToAttribute({\n model: {\n name: modelElement,\n key: modelAttribute\n },\n view: modelAttributeValue => ({\n key: 'style',\n value: {\n [styleName]: modelAttributeValue\n }\n })\n });\n}\n/**\n * Conversion helper for downcasting attributes from the model table to a view table (not to `
`).\n *\n * @internal\n */\nexport function downcastTableAttribute(conversion, options) {\n const { modelAttribute, styleName } = options;\n conversion.for('downcast').add(dispatcher => dispatcher.on(`attribute:${modelAttribute}:table`, (evt, data, conversionApi) => {\n const { item, attributeNewValue } = data;\n const { mapper, writer } = conversionApi;\n if (!conversionApi.consumable.consume(data.item, evt.name)) {\n return;\n }\n const table = [...mapper.toViewElement(item).getChildren()].find(child => child.is('element', 'table'));\n if (attributeNewValue) {\n writer.setStyle(styleName, attributeNewValue, table);\n }\n else {\n writer.removeStyle(styleName, table);\n }\n }));\n}\n/**\n * Returns the default value for table or table cell property adjusted for layout tables.\n *\n * @internal\n */\nexport function getDefaultValueAdjusted(defaultValue, layoutTableDefault, data) {\n const modelElement = data.modelRange && first(data.modelRange.getItems({ shallow: true }));\n const tableElement = modelElement && modelElement.is('element') && modelElement.findAncestor('table', { includeSelf: true });\n if (tableElement && tableElement.getAttribute('tableType') === 'layout') {\n return layoutTableDefault;\n }\n return defaultValue;\n}\n/**\n * Reduces the full top, right, bottom, left object to a single string if all sides are equal.\n * Returns original style otherwise.\n */\nfunction reduceBoxSidesValue(style) {\n if (!style) {\n return;\n }\n const sides = ['top', 'right', 'bottom', 'left'];\n const allSidesDefined = sides.every(side => style[side]);\n if (!allSidesDefined) {\n return style;\n }\n const topSideStyle = style.top;\n const allSidesEqual = sides.every(side => style[side] === topSideStyle);\n if (!allSidesEqual) {\n return style;\n }\n return topSideStyle;\n}\n/**\n * Default table alignment options.\n */\nexport const DEFAULT_TABLE_ALIGNMENT_OPTIONS = {\n left: { className: 'table-style-align-left' },\n center: { className: 'table-style-align-center' },\n right: { className: 'table-style-align-right' },\n blockLeft: { className: 'table-style-block-align-left' },\n blockRight: { className: 'table-style-block-align-right' }\n};\n/**\n * Configuration for upcasting table alignment from view to model.\n */\nexport const upcastTableAlignmentConfig = [\n // Support for the `float:*;` CSS definition for the table alignment.\n {\n view: {\n name: /^(table|figure)$/,\n styles: {\n float: FLOAT_VALUES_REG_EXP\n }\n },\n getAlign: (viewElement) => {\n let align = viewElement.getStyle('float');\n if (align === 'none') {\n align = 'center';\n }\n return align;\n },\n getConsumables(viewElement) {\n const float = viewElement.getStyle('float');\n const styles = ['float'];\n if (float === 'left' && viewElement.hasStyle('margin-right')) {\n styles.push('margin-right');\n }\n else if (float === 'right' && viewElement.hasStyle('margin-left')) {\n styles.push('margin-left');\n }\n return { styles };\n }\n },\n // Support for the `margin-left:auto; margin-right:auto;` CSS definition for the table alignment.\n {\n view: {\n name: /^(table|figure)$/,\n styles: {\n 'margin-left': 'auto',\n 'margin-right': 'auto'\n }\n },\n getAlign: () => 'center',\n getConsumables: () => {\n return { styles: ['margin-left', 'margin-right'] };\n }\n },\n // Support for the left alignment using CSS classes.\n {\n view: {\n name: /^(table|figure)$/,\n key: 'class',\n value: 'table-style-align-left'\n },\n getAlign: () => 'left',\n getConsumables() {\n return { classes: DEFAULT_TABLE_ALIGNMENT_OPTIONS.left.className };\n }\n },\n // Support for the right alignment using CSS classes.\n {\n view: {\n name: /^(table|figure)$/,\n key: 'class',\n value: DEFAULT_TABLE_ALIGNMENT_OPTIONS.right.className\n },\n getAlign: () => 'right',\n getConsumables() {\n return { classes: DEFAULT_TABLE_ALIGNMENT_OPTIONS.right.className };\n }\n },\n // Support for the center alignment using CSS classes.\n {\n view: {\n name: /^(table|figure)$/,\n key: 'class',\n value: DEFAULT_TABLE_ALIGNMENT_OPTIONS.center.className\n },\n getAlign: () => 'center',\n getConsumables() {\n return { classes: DEFAULT_TABLE_ALIGNMENT_OPTIONS.center.className };\n }\n },\n // Support for the block alignment left using CSS classes.\n {\n view: {\n name: /^(table|figure)$/,\n key: 'class',\n value: DEFAULT_TABLE_ALIGNMENT_OPTIONS.blockLeft.className\n },\n getAlign: () => 'blockLeft',\n getConsumables() {\n return { classes: DEFAULT_TABLE_ALIGNMENT_OPTIONS.blockLeft.className };\n }\n },\n // Support for the block alignment right using CSS classes.\n {\n view: {\n name: /^(table|figure)$/,\n key: 'class',\n value: DEFAULT_TABLE_ALIGNMENT_OPTIONS.blockRight.className\n },\n getAlign: () => 'blockRight',\n getConsumables() {\n return { classes: DEFAULT_TABLE_ALIGNMENT_OPTIONS.blockRight.className };\n }\n },\n // Support for the block alignment left using margin CSS styles.\n {\n view: {\n name: /^(table|figure)$/,\n styles: {\n 'margin-left': '0',\n 'margin-right': 'auto'\n }\n },\n getAlign: () => 'blockLeft',\n getConsumables() {\n return { styles: ['margin-left', 'margin-right'] };\n }\n },\n // Support for the block alignment right using margin CSS styles.\n {\n view: {\n name: /^(table|figure)$/,\n styles: {\n 'margin-left': 'auto',\n 'margin-right': '0'\n }\n },\n getAlign: () => 'blockRight',\n getConsumables() {\n return { styles: ['margin-left', 'margin-right'] };\n }\n },\n // Support for the `align` attribute as the backward compatibility while pasting from other sources.\n {\n view: {\n name: 'table',\n attributes: {\n align: ALIGN_VALUES_REG_EXP\n }\n },\n getAlign: (viewElement) => viewElement.getAttribute('align'),\n getConsumables() {\n return { attributes: 'align' };\n }\n }\n];\nexport const downcastTableAlignmentConfig = {\n center: {\n align: 'center',\n style: 'margin-left: auto; margin-right: auto;',\n className: 'table-style-align-center'\n },\n left: {\n align: 'left',\n style: 'float: left;',\n className: 'table-style-align-left'\n },\n right: {\n align: 'right',\n style: 'float: right;',\n className: 'table-style-align-right'\n },\n blockLeft: {\n align: undefined,\n style: 'margin-left: 0; margin-right: auto;',\n className: DEFAULT_TABLE_ALIGNMENT_OPTIONS.blockLeft.className\n },\n blockRight: {\n align: undefined,\n style: 'margin-left: auto; margin-right: 0;',\n className: DEFAULT_TABLE_ALIGNMENT_OPTIONS.blockRight.className\n }\n};\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * The table iterator class. It allows to iterate over table cells. For each cell the iterator yields\n * {@link module:table/tablewalker~TableSlot} with proper table cell attributes.\n */\nexport class TableWalker {\n /**\n * The walker's table element.\n *\n * @internal\n */\n _table;\n /**\n * A row index from which this iterator will start.\n */\n _startRow;\n /**\n * A row index at which this iterator will end.\n */\n _endRow;\n /**\n * If set, the table walker will only output cells from a given column and following ones or cells that overlap them.\n */\n _startColumn;\n /**\n * If set, the table walker will only output cells up to a given column.\n */\n _endColumn;\n /**\n * Enables output of spanned cells that are normally not yielded.\n */\n _includeAllSlots;\n /**\n * Row indexes to skip from the iteration.\n */\n _skipRows;\n /**\n * The current row index.\n *\n * @internal\n */\n _row;\n /**\n * The index of the current row element in the table.\n *\n * @internal\n */\n _rowIndex;\n /**\n * The current column index.\n *\n * @internal\n */\n _column;\n /**\n * The cell index in a parent row. For spanned cells when {@link #_includeAllSlots} is set to `true`,\n * this represents the index of the next table cell.\n *\n * @internal\n */\n _cellIndex;\n /**\n * Holds a map of spanned cells in a table.\n */\n _spannedCells;\n /**\n * Index of the next column where a cell is anchored.\n */\n _nextCellAtColumn;\n /**\n * Indicates whether the iterator jumped to (or close to) the start row, ignoring rows that don't need to be traversed.\n */\n _jumpedToStartRow = false;\n /**\n * Creates an instance of the table walker.\n *\n * The table walker iterates internally by traversing the table from row index = 0 and column index = 0.\n * It walks row by row and column by column in order to output values defined in the constructor.\n * By default it will output only the locations that are occupied by a cell. To include also spanned rows and columns,\n * pass the `includeAllSlots` option to the constructor.\n *\n * The most important values of the iterator are column and row indexes of a cell.\n *\n * See {@link module:table/tablewalker~TableSlot} what values are returned by the table walker.\n *\n * To iterate over a given row:\n *\n * ```ts\n * const tableWalker = new TableWalker( table, { startRow: 1, endRow: 2 } );\n *\n * for ( const tableSlot of tableWalker ) {\n * console.log( 'A cell at row', tableSlot.row, 'and column', tableSlot.column );\n * }\n * ```\n *\n * For instance the code above for the following table:\n *\n * +----+----+----+----+----+----+\n * | 00 | 02 | 03 | 04 | 05 |\n * | +----+----+----+----+\n * | | 12 | 14 | 15 |\n * | +----+----+----+ +\n * | | 22 | |\n * |----+----+----+----+----+ +\n * | 30 | 31 | 32 | 33 | 34 | |\n * +----+----+----+----+----+----+\n *\n * will log in the console:\n *\n * 'A cell at row 1 and column 2'\n * 'A cell at row 1 and column 4'\n * 'A cell at row 1 and column 5'\n * 'A cell at row 2 and column 2'\n *\n * To also iterate over spanned cells:\n *\n * ```ts\n * const tableWalker = new TableWalker( table, { row: 1, includeAllSlots: true } );\n *\n * for ( const tableSlot of tableWalker ) {\n * console.log( 'Slot at', tableSlot.row, 'x', tableSlot.column, ':', tableSlot.isAnchor ? 'is anchored' : 'is spanned' );\n * }\n * ```\n *\n * will log in the console for the table from the previous example:\n *\n * 'Cell at 1 x 0 : is spanned'\n * 'Cell at 1 x 1 : is spanned'\n * 'Cell at 1 x 2 : is anchored'\n * 'Cell at 1 x 3 : is spanned'\n * 'Cell at 1 x 4 : is anchored'\n * 'Cell at 1 x 5 : is anchored'\n *\n * **Note**: Option `row` is a shortcut that sets both `startRow` and `endRow` to the same row.\n * (Use either `row` or `startRow` and `endRow` but never together). Similarly the `column` option sets both `startColumn`\n * and `endColumn` to the same column (Use either `column` or `startColumn` and `endColumn` but never together).\n *\n * @param table A table over which the walker iterates.\n * @param options An object with configuration.\n * @param options.row A row index for which this iterator will output cells. Can't be used together with `startRow` and `endRow`.\n * @param options.startRow A row index from which this iterator should start. Can't be used together with `row`. Default value is 0.\n * @param options.endRow A row index at which this iterator should end. Can't be used together with `row`.\n * @param options.column A column index for which this iterator will output cells.\n * Can't be used together with `startColumn` and `endColumn`.\n * @param options.startColumn A column index from which this iterator should start.\n * Can't be used together with `column`. Default value is 0.\n * @param options.endColumn A column index at which this iterator should end. Can't be used together with `column`.\n * @param options.includeAllSlots Also return values for spanned cells. Default value is \"false\".\n */\n constructor(table, options = {}) {\n this._table = table;\n this._startRow = options.row !== undefined ? options.row : options.startRow || 0;\n this._endRow = options.row !== undefined ? options.row : options.endRow;\n this._startColumn = options.column !== undefined ? options.column : options.startColumn || 0;\n this._endColumn = options.column !== undefined ? options.column : options.endColumn;\n this._includeAllSlots = !!options.includeAllSlots;\n this._skipRows = new Set();\n this._row = 0;\n this._rowIndex = 0;\n this._column = 0;\n this._cellIndex = 0;\n this._spannedCells = new Map();\n this._nextCellAtColumn = -1;\n }\n /**\n * Iterable interface.\n */\n [Symbol.iterator]() {\n return this;\n }\n /**\n * Gets the next table walker's value.\n *\n * @returns The next table walker's value.\n */\n next() {\n if (this._canJumpToStartRow()) {\n this._jumpToNonSpannedRowClosestToStartRow();\n }\n const row = this._table.getChild(this._rowIndex);\n // Iterator is done when there's no row (table ended) or the row is after `endRow` limit.\n if (!row || this._isOverEndRow()) {\n return { done: true, value: undefined };\n }\n // We step over current element when it is not a tableRow instance.\n if (!row.is('element', 'tableRow')) {\n this._rowIndex++;\n return this.next();\n }\n if (this._isOverEndColumn()) {\n return this._advanceToNextRow();\n }\n let outValue = null;\n const spanData = this._getSpanned();\n if (spanData) {\n if (this._includeAllSlots && !this._shouldSkipSlot()) {\n outValue = this._formatOutValue(spanData.cell, spanData.row, spanData.column);\n }\n }\n else {\n const cell = row.getChild(this._cellIndex);\n if (!cell) {\n // If there are no more cells left in row advance to the next row.\n return this._advanceToNextRow();\n }\n const colspan = parseInt(cell.getAttribute('colspan') || '1');\n const rowspan = parseInt(cell.getAttribute('rowspan') || '1');\n // Record this cell spans if it's not 1x1 cell.\n if (colspan > 1 || rowspan > 1) {\n this._recordSpans(cell, rowspan, colspan);\n }\n if (!this._shouldSkipSlot()) {\n outValue = this._formatOutValue(cell);\n }\n this._nextCellAtColumn = this._column + colspan;\n }\n // Advance to the next column before returning value.\n this._column++;\n if (this._column == this._nextCellAtColumn) {\n this._cellIndex++;\n }\n // The current value will be returned only if current row and column are not skipped.\n return outValue || this.next();\n }\n /**\n * Marks a row to skip in the next iteration. It will also skip cells from the current row if there are any cells from the current row\n * to output.\n *\n * @param row The row index to skip.\n */\n skipRow(row) {\n this._skipRows.add(row);\n }\n /**\n * Advances internal cursor to the next row.\n */\n _advanceToNextRow() {\n this._row++;\n this._rowIndex++;\n this._column = 0;\n this._cellIndex = 0;\n this._nextCellAtColumn = -1;\n return this.next();\n }\n /**\n * Checks if the current row is over {@link #_endRow}.\n */\n _isOverEndRow() {\n // If #_endRow is defined skip all rows after it.\n return this._endRow !== undefined && this._row > this._endRow;\n }\n /**\n * Checks if the current cell is over {@link #_endColumn}\n */\n _isOverEndColumn() {\n // If #_endColumn is defined skip all cells after it.\n return this._endColumn !== undefined && this._column > this._endColumn;\n }\n /**\n * A common method for formatting the iterator's output value.\n *\n * @param cell The table cell to output.\n * @param anchorRow The row index of a cell anchor slot.\n * @param anchorColumn The column index of a cell anchor slot.\n */\n _formatOutValue(cell, anchorRow = this._row, anchorColumn = this._column) {\n return {\n done: false,\n value: new TableSlot(this, cell, anchorRow, anchorColumn)\n };\n }\n /**\n * Checks if the current slot should be skipped.\n */\n _shouldSkipSlot() {\n const rowIsMarkedAsSkipped = this._skipRows.has(this._row);\n const rowIsBeforeStartRow = this._row < this._startRow;\n const columnIsBeforeStartColumn = this._column < this._startColumn;\n const columnIsAfterEndColumn = this._endColumn !== undefined && this._column > this._endColumn;\n return rowIsMarkedAsSkipped || rowIsBeforeStartRow || columnIsBeforeStartColumn || columnIsAfterEndColumn;\n }\n /**\n * Returns the cell element that is spanned over the current cell location.\n */\n _getSpanned() {\n const rowMap = this._spannedCells.get(this._row);\n // No spans for given row.\n if (!rowMap) {\n return null;\n }\n // If spans for given rows has entry for column it means that this location if spanned by other cell.\n return rowMap.get(this._column) || null;\n }\n /**\n * Updates spanned cells map relative to the current cell location and its span dimensions.\n *\n * @param cell A cell that is spanned.\n * @param rowspan Cell height.\n * @param colspan Cell width.\n */\n _recordSpans(cell, rowspan, colspan) {\n const data = {\n cell,\n row: this._row,\n column: this._column\n };\n for (let rowToUpdate = this._row; rowToUpdate < this._row + rowspan; rowToUpdate++) {\n for (let columnToUpdate = this._column; columnToUpdate < this._column + colspan; columnToUpdate++) {\n if (rowToUpdate != this._row || columnToUpdate != this._column) {\n this._markSpannedCell(rowToUpdate, columnToUpdate, data);\n }\n }\n }\n }\n /**\n * Marks the cell location as spanned by another cell.\n *\n * @param row The row index of the cell location.\n * @param column The column index of the cell location.\n * @param data A spanned cell details (cell element, anchor row and column).\n */\n _markSpannedCell(row, column, data) {\n if (!this._spannedCells.has(row)) {\n this._spannedCells.set(row, new Map());\n }\n const rowSpans = this._spannedCells.get(row);\n rowSpans.set(column, data);\n }\n /**\n * Checks if part of the table can be skipped.\n */\n _canJumpToStartRow() {\n return !!this._startRow &&\n this._startRow > 0 &&\n !this._jumpedToStartRow;\n }\n /**\n * Sets the current row to `this._startRow` or the first row before it that has the number of cells\n * equal to the number of columns in the table.\n *\n * Example:\n * \t+----+----+----+\n * | 00 | 01 | 02 |\n * |----+----+----+\n * | 10 | 12 |\n * | +----+\n * | | 22 |\n * | +----+\n * | | 32 | <--- Start row\n * +----+----+----+\n * | 40 | 41 | 42 |\n * +----+----+----+\n *\n * If the 4th row is a `this._startRow`, this method will:\n * 1.) Count the number of columns this table has based on the first row (3 columns in this case).\n * 2.) Check if the 4th row contains 3 cells. It doesn't, so go to the row before it.\n * 3.) Check if the 3rd row contains 3 cells. It doesn't, so go to the row before it.\n * 4.) Check if the 2nd row contains 3 cells. It does, so set the current row to that row.\n *\n * Setting the current row this way is necessary to let the `next()` method loop over the cells\n * spanning multiple rows or columns and update the `this._spannedCells` property.\n */\n _jumpToNonSpannedRowClosestToStartRow() {\n const firstRowLength = this._getRowLength(0);\n for (let i = this._startRow; !this._jumpedToStartRow; i--) {\n if (firstRowLength === this._getRowLength(i)) {\n this._row = i;\n this._rowIndex = i;\n this._jumpedToStartRow = true;\n }\n }\n }\n /**\n * Returns a number of columns in a row taking `colspan` into consideration.\n */\n _getRowLength(rowIndex) {\n const row = this._table.getChild(rowIndex);\n return [...row.getChildren()].reduce((cols, row) => {\n return cols + parseInt(row.getAttribute('colspan') || '1');\n }, 0);\n }\n}\n/**\n * An object returned by {@link module:table/tablewalker~TableWalker} when traversing table cells.\n */\nclass TableSlot {\n /**\n * The current table cell.\n */\n cell;\n /**\n * The row index of a table slot.\n */\n row;\n /**\n * The column index of a table slot.\n */\n column;\n /**\n * The row index of a cell anchor slot.\n */\n cellAnchorRow;\n /**\n * The column index of a cell anchor slot.\n */\n cellAnchorColumn;\n /**\n * The index of the current cell in the parent row.\n */\n _cellIndex;\n /**\n * The index of the current row element in the table.\n */\n _rowIndex;\n /**\n * The table element.\n */\n _table;\n /**\n * Creates an instance of the table walker value.\n *\n * @param tableWalker The table walker instance.\n * @param cell The current table cell.\n * @param anchorRow The row index of a cell anchor slot.\n * @param anchorColumn The column index of a cell anchor slot.\n */\n constructor(tableWalker, cell, anchorRow, anchorColumn) {\n this.cell = cell;\n this.row = tableWalker._row;\n this.column = tableWalker._column;\n this.cellAnchorRow = anchorRow;\n this.cellAnchorColumn = anchorColumn;\n this._cellIndex = tableWalker._cellIndex;\n this._rowIndex = tableWalker._rowIndex;\n this._table = tableWalker._table;\n }\n // @if CK_DEBUG // public get isSpanned(): unknown { return throwMissingGetterError( 'isSpanned' ); }\n // @if CK_DEBUG // public get colspan(): unknown { return throwMissingGetterError( 'colspan' ); }\n // @if CK_DEBUG // public get rowspan(): unknown { return throwMissingGetterError( 'rowspan' ); }\n // @if CK_DEBUG // public get cellIndex(): unknown { return throwMissingGetterError( 'cellIndex' ); }\n /**\n * Whether the cell is anchored in the current slot.\n */\n get isAnchor() {\n return this.row === this.cellAnchorRow && this.column === this.cellAnchorColumn;\n }\n /**\n * The width of a cell defined by a `colspan` attribute. If the model attribute is not present, it is set to `1`.\n */\n get cellWidth() {\n return parseInt(this.cell.getAttribute('colspan') || '1');\n }\n /**\n * The height of a cell defined by a `rowspan` attribute. If the model attribute is not present, it is set to `1`.\n */\n get cellHeight() {\n return parseInt(this.cell.getAttribute('rowspan') || '1');\n }\n /**\n * The index of the current row element in the table.\n */\n get rowIndex() {\n return this._rowIndex;\n }\n /**\n * Returns the {@link module:engine/model/position~ModelPosition} before the table slot.\n */\n getPositionBefore() {\n const model = this._table.root.document.model;\n return model.createPositionAt(this._table.getChild(this.row), this._cellIndex);\n }\n}\nexport { TableSlot };\n/**\n * This `TableSlot`'s getter (property) was removed in CKEditor 5 v20.0.0.\n *\n * Check out the new `TableWalker`'s API in the documentation.\n *\n * @error tableslot-getter-removed\n * @param getterName\n */\n// @if CK_DEBUG // function throwMissingGetterError( getterName: string ): void {\n// @if CK_DEBUG //\t\tthrow new CKEditorError( 'tableslot-getter-removed', null, {\n// @if CK_DEBUG //\t\t\tgetterName\n// @if CK_DEBUG //\t\t} );\n// @if CK_DEBUG // }\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { downcastAttributeToStyle, upcastStyleToAttribute } from '../converters/tableproperties.js';\nimport { TableWalker } from '../tablewalker.js';\n/**\n * A common method to update the numeric value. If a value is the default one, it will be unset.\n *\n * @internal\n * @param key An attribute key.\n * @param value The new attribute value.\n * @param item A model item on which the attribute will be set.\n * @param defaultValue The default attribute value. If a value is lower or equal, it will be unset.\n */\nexport function updateNumericAttribute(key, value, item, writer, defaultValue = 1) {\n if (value !== undefined && value !== null && defaultValue !== undefined && defaultValue !== null && value > defaultValue) {\n writer.setAttribute(key, value, item);\n }\n else {\n writer.removeAttribute(key, item);\n }\n}\n/**\n * A common method to create an empty table cell. It creates a proper model structure as a table cell must have at least one block inside.\n *\n * @internal\n * @param writer The model writer.\n * @param insertPosition The position at which the table cell should be inserted.\n * @param attributes The element attributes.\n * @returns Created table cell.\n */\nexport function createEmptyTableCell(writer, insertPosition, attributes = {}) {\n const tableCell = writer.createElement('tableCell', attributes);\n writer.insertElement('paragraph', tableCell);\n writer.insert(tableCell, insertPosition);\n return tableCell;\n}\n/**\n * Checks if a table cell belongs to the heading column section.\n *\n * @internal\n */\nexport function isHeadingColumnCell(tableUtils, tableCell) {\n const table = tableCell.parent.parent;\n const headingColumns = parseInt(table.getAttribute('headingColumns') || '0');\n const { column } = tableUtils.getCellLocation(tableCell);\n return !!headingColumns && column < headingColumns;\n}\n/**\n * Enables conversion for an attribute for simple view-model mappings.\n *\n * @internal\n * @param options.defaultValue The default value for the specified `modelAttribute`.\n */\nexport function enableProperty(schema, conversion, options) {\n const { modelAttribute } = options;\n schema.extend('tableCell', {\n allowAttributes: [modelAttribute]\n });\n schema.setAttributeProperties(modelAttribute, { isFormatting: true });\n upcastStyleToAttribute(conversion, { viewElement: /^(td|th)$/, ...options });\n downcastAttributeToStyle(conversion, { modelElement: 'tableCell', ...options });\n}\n/**\n * Depending on the position of the selection we either return the table under cursor or look for the table higher in the hierarchy.\n *\n * @internal\n */\nexport function getSelectionAffectedTable(selection) {\n const selectedElement = selection.getSelectedElement();\n // Is the command triggered from the `tableToolbar`?\n if (selectedElement && selectedElement.is('element', 'table')) {\n return selectedElement;\n }\n return selection.getFirstPosition().findAncestor('table');\n}\n/**\n * Groups table cells by their parent table.\n *\n * @internal\n */\nexport function groupCellsByTable(tableCells) {\n const tableMap = new Map();\n for (const tableCell of tableCells) {\n const table = tableCell.findAncestor('table');\n if (!tableMap.has(table)) {\n tableMap.set(table, []);\n }\n tableMap.get(table).push(tableCell);\n }\n return tableMap;\n}\n/**\n * Checks if all cells in a given row or column are header cells.\n *\n * @internal\n */\nexport function isEntireCellsLineHeader({ table, row, column }) {\n const tableWalker = new TableWalker(table, { row, column });\n for (const { cell } of tableWalker) {\n const cellType = cell.getAttribute('tableCellType');\n if (cellType !== 'header') {\n return false;\n }\n }\n return true;\n}\n/**\n * Checks whether the `tableCellType` attribute is enabled in the editor schema and the experimental flag is set.\n *\n * @internal\n */\nexport function isTableCellTypeEnabled(editor) {\n const { model, config } = editor;\n return (model.schema.checkAttribute('tableCell', 'tableCellType') &&\n config.get('experimentalFlags.tableCellTypeSupport') === true);\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TableWalker } from '../tablewalker.js';\nimport { createEmptyTableCell, updateNumericAttribute } from './common.js';\n/**\n * Returns a cropped table according to given dimensions.\n\n * To return a cropped table that starts at first row and first column and end in third row and column:\n *\n * ```ts\n * const croppedTable = cropTableToDimensions( table, {\n * startRow: 1,\n * endRow: 3,\n * startColumn: 1,\n * endColumn: 3\n * }, writer );\n * ```\n *\n * Calling the code above for the table below:\n *\n * 0 1 2 3 4 0 1 2\n * ┌───┬───┬───┬───┬───┐\n * 0 │ a │ b │ c │ d │ e │\n * ├───┴───┤ ├───┴───┤ ┌───┬───┬───┐\n * 1 │ f │ │ g │ │ │ │ g │ 0\n * ├───┬───┴───┼───┬───┤ will return: ├───┴───┼───┤\n * 2 │ h │ i │ j │ k │ │ i │ j │ 1\n * ├───┤ ├───┤ │ │ ├───┤\n * 3 │ l │ │ m │ │ │ │ m │ 2\n * ├───┼───┬───┤ ├───┤ └───────┴───┘\n * 4 │ n │ o │ p │ │ q │\n * └───┴───┴───┴───┴───┘\n *\n * @internal\n */\nexport function cropTableToDimensions(sourceTable, cropDimensions, writer) {\n const { startRow, startColumn, endRow, endColumn } = cropDimensions;\n // Initialize the cropped table element.\n const croppedTable = writer.createElement('table');\n // Copy table type attribute if present.\n const sourceTableType = sourceTable.getAttribute('tableType');\n if (sourceTableType) {\n writer.setAttribute('tableType', sourceTableType, croppedTable);\n }\n // Create empty table with empty rows equal to crop height.\n const cropHeight = endRow - startRow + 1;\n for (let i = 0; i < cropHeight; i++) {\n writer.insertElement('tableRow', croppedTable, 'end');\n }\n const tableMap = [...new TableWalker(sourceTable, { startRow, endRow, startColumn, endColumn, includeAllSlots: true })];\n // Iterate over source table slots (including empty - spanned - ones).\n for (const { row: sourceRow, column: sourceColumn, cell: tableCell, isAnchor, cellAnchorRow, cellAnchorColumn } of tableMap) {\n // Row index in cropped table.\n const rowInCroppedTable = sourceRow - startRow;\n const row = croppedTable.getChild(rowInCroppedTable);\n // For empty slots: fill the gap with empty table cell.\n if (!isAnchor) {\n // But fill the gap only if the spanning cell is anchored outside cropped area.\n // In the table from method jsdoc those cells are: \"c\" & \"f\".\n if (cellAnchorRow < startRow || cellAnchorColumn < startColumn) {\n createEmptyTableCell(writer, writer.createPositionAt(row, 'end'));\n }\n }\n // Otherwise clone the cell with all children and trim if it exceeds cropped area.\n else {\n const tableCellCopy = writer.cloneElement(tableCell);\n writer.append(tableCellCopy, row);\n // Trim table if it exceeds cropped area.\n // In the table from method jsdoc those cells are: \"g\" & \"m\".\n trimTableCellIfNeeded(tableCellCopy, sourceRow, sourceColumn, endRow, endColumn, writer);\n }\n }\n // Adjust heading rows & columns in cropped table if crop selection includes headings parts.\n addHeadingsToCroppedTable(croppedTable, sourceTable, startRow, startColumn, writer);\n return croppedTable;\n}\n/**\n * Returns slot info of cells that starts above and overlaps a given row.\n *\n * In a table below, passing `overlapRow = 3`\n *\n * ┌───┬───┬───┬───┬───┐\n * 0 │ a │ b │ c │ d │ e │\n * │ ├───┼───┼───┼───┤\n * 1 │ │ f │ g │ h │ i │\n * ├───┤ ├───┼───┤ │\n * 2 │ j │ │ k │ l │ │\n * │ │ │ ├───┼───┤\n * 3 │ │ │ │ m │ n │ <- overlap row to check\n * ├───┼───┤ │ ├───│\n * 4 │ o │ p │ │ │ q │\n * └───┴───┴───┴───┴───┘\n *\n * will return slot info for cells: \"j\", \"f\", \"k\".\n *\n * @internal\n * @param table The table to check.\n * @param overlapRow The index of the row to check.\n * @param startRow row to start analysis. Use it when it is known that the cells above that row will not overlap. Default value is 0.\n */\nexport function getVerticallyOverlappingCells(table, overlapRow, startRow = 0) {\n const cells = [];\n const tableWalker = new TableWalker(table, { startRow, endRow: overlapRow - 1 });\n for (const slotInfo of tableWalker) {\n const { row, cellHeight } = slotInfo;\n const cellEndRow = row + cellHeight - 1;\n if (row < overlapRow && overlapRow <= cellEndRow) {\n cells.push(slotInfo);\n }\n }\n return cells;\n}\n/**\n * Splits the table cell horizontally.\n *\n * @internal\n * @returns Created table cell, if any were created.\n */\nexport function splitHorizontally(tableCell, splitRow, writer) {\n const tableRow = tableCell.parent;\n const table = tableRow.parent;\n const rowIndex = tableRow.index;\n const rowspan = parseInt(tableCell.getAttribute('rowspan'));\n const newRowspan = splitRow - rowIndex;\n const newCellAttributes = {};\n const newCellRowSpan = rowspan - newRowspan;\n if (newCellRowSpan > 1) {\n newCellAttributes.rowspan = newCellRowSpan;\n }\n const colspan = parseInt(tableCell.getAttribute('colspan') || '1');\n if (colspan > 1) {\n newCellAttributes.colspan = colspan;\n }\n const startRow = rowIndex;\n const endRow = startRow + newRowspan;\n const tableMap = [...new TableWalker(table, { startRow, endRow, includeAllSlots: true })];\n let newCell = null;\n let columnIndex;\n for (const tableSlot of tableMap) {\n const { row, column, cell } = tableSlot;\n if (cell === tableCell && columnIndex === undefined) {\n columnIndex = column;\n }\n if (columnIndex !== undefined && columnIndex === column && row === endRow) {\n newCell = createEmptyTableCell(writer, tableSlot.getPositionBefore(), newCellAttributes);\n }\n }\n // Update the rowspan attribute after updating table.\n updateNumericAttribute('rowspan', newRowspan, tableCell, writer);\n return newCell;\n}\n/**\n * Returns slot info of cells that starts before and overlaps a given column.\n *\n * In a table below, passing `overlapColumn = 3`\n *\n * 0 1 2 3 4\n * ┌───────┬───────┬───┐\n * │ a │ b │ c │\n * │───┬───┴───────┼───┤\n * │ d │ e │ f │\n * ├───┼───┬───────┴───┤\n * │ g │ h │ i │\n * ├───┼───┼───┬───────┤\n * │ j │ k │ l │ m │\n * ├───┼───┴───┼───┬───┤\n * │ n │ o │ p │ q │\n * └───┴───────┴───┴───┘\n * ^\n * Overlap column to check\n *\n * will return slot info for cells: \"b\", \"e\", \"i\".\n *\n * @internal\n * @param table The table to check.\n * @param overlapColumn The index of the column to check.\n */\nexport function getHorizontallyOverlappingCells(table, overlapColumn) {\n const cellsToSplit = [];\n const tableWalker = new TableWalker(table);\n for (const slotInfo of tableWalker) {\n const { column, cellWidth } = slotInfo;\n const cellEndColumn = column + cellWidth - 1;\n if (column < overlapColumn && overlapColumn <= cellEndColumn) {\n cellsToSplit.push(slotInfo);\n }\n }\n return cellsToSplit;\n}\n/**\n * Splits the table cell vertically.\n *\n * @internal\n * @param columnIndex The table cell column index.\n * @param splitColumn The index of column to split cell on.\n * @returns Created table cell.\n */\nexport function splitVertically(tableCell, columnIndex, splitColumn, writer) {\n const colspan = parseInt(tableCell.getAttribute('colspan'));\n const newColspan = splitColumn - columnIndex;\n const newCellAttributes = {};\n const newCellColSpan = colspan - newColspan;\n if (newCellColSpan > 1) {\n newCellAttributes.colspan = newCellColSpan;\n }\n const rowspan = parseInt(tableCell.getAttribute('rowspan') || '1');\n if (rowspan > 1) {\n newCellAttributes.rowspan = rowspan;\n }\n const newCell = createEmptyTableCell(writer, writer.createPositionAfter(tableCell), newCellAttributes);\n // Update the colspan attribute after updating table.\n updateNumericAttribute('colspan', newColspan, tableCell, writer);\n return newCell;\n}\n/**\n * Adjusts table cell dimensions to not exceed limit row and column.\n *\n * If table cell width (or height) covers a column (or row) that is after a limit column (or row)\n * this method will trim \"colspan\" (or \"rowspan\") attribute so the table cell will fit in a defined limits.\n *\n * @internal\n */\nexport function trimTableCellIfNeeded(tableCell, cellRow, cellColumn, limitRow, limitColumn, writer) {\n const colspan = parseInt(tableCell.getAttribute('colspan') || '1');\n const rowspan = parseInt(tableCell.getAttribute('rowspan') || '1');\n const endColumn = cellColumn + colspan - 1;\n if (endColumn > limitColumn) {\n const trimmedSpan = limitColumn - cellColumn + 1;\n updateNumericAttribute('colspan', trimmedSpan, tableCell, writer, 1);\n }\n const endRow = cellRow + rowspan - 1;\n if (endRow > limitRow) {\n const trimmedSpan = limitRow - cellRow + 1;\n updateNumericAttribute('rowspan', trimmedSpan, tableCell, writer, 1);\n }\n}\n/**\n * Sets proper heading attributes to a cropped table.\n */\nfunction addHeadingsToCroppedTable(croppedTable, sourceTable, startRow, startColumn, writer) {\n const headingRows = parseInt(sourceTable.getAttribute('headingRows') || '0');\n if (headingRows > 0) {\n const headingRowsInCrop = headingRows - startRow;\n updateNumericAttribute('headingRows', headingRowsInCrop, croppedTable, writer, 0);\n }\n const headingColumns = parseInt(sourceTable.getAttribute('headingColumns') || '0');\n if (headingColumns > 0) {\n const headingColumnsInCrop = headingColumns - startColumn;\n updateNumericAttribute('headingColumns', headingColumnsInCrop, croppedTable, writer, 0);\n }\n}\n/**\n * Removes columns that have no cells anchored.\n *\n * In table below:\n *\n * +----+----+----+----+----+----+----+\n * | 00 | 01 | 03 | 04 | 06 |\n * +----+----+----+----+ +----+\n * | 10 | 11 | 13 | | 16 |\n * +----+----+----+----+----+----+----+\n * | 20 | 21 | 23 | 24 | 26 |\n * +----+----+----+----+----+----+----+\n * ^--- empty ---^\n *\n * Will remove columns 2 and 5.\n *\n * **Note:** This is a low-level helper method for clearing invalid model state when doing table modifications.\n * To remove a column from a table use {@link module:table/tableutils~TableUtils#removeColumns `TableUtils.removeColumns()`}.\n *\n * @internal\n * @returns True if removed some columns.\n */\nexport function removeEmptyColumns(table, tableUtils) {\n const width = tableUtils.getColumns(table);\n const columnsMap = new Array(width).fill(0);\n for (const { column } of new TableWalker(table)) {\n columnsMap[column]++;\n }\n const emptyColumns = columnsMap.reduce((result, cellsCount, column) => {\n return cellsCount ? result : [...result, column];\n }, []);\n if (emptyColumns.length > 0) {\n // Remove only last empty column because it will recurrently trigger removing empty rows.\n const emptyColumn = emptyColumns[emptyColumns.length - 1];\n // @if CK_DEBUG_TABLE // console.log( `Removing empty column: ${ emptyColumn }.` );\n tableUtils.removeColumns(table, { at: emptyColumn });\n return true;\n }\n return false;\n}\n/**\n * Removes rows that have no cells anchored.\n *\n * In table below:\n *\n * +----+----+----+\n * | 00 | 01 | 02 |\n * +----+----+----+\n * | 10 | 11 | 12 |\n * + + + +\n * | | | | <-- empty\n * +----+----+----+\n * | 30 | 31 | 32 |\n * +----+----+----+\n * | 40 | 42 |\n * + + +\n * | | | <-- empty\n * +----+----+----+\n * | 60 | 61 | 62 |\n * +----+----+----+\n *\n * Will remove rows 2 and 5.\n *\n * **Note:** This is a low-level helper method for clearing invalid model state when doing table modifications.\n * To remove a row from a table use {@link module:table/tableutils~TableUtils#removeRows `TableUtils.removeRows()`}.\n *\n * @internal\n * @returns True if removed some rows.\n */\nexport function removeEmptyRows(table, tableUtils) {\n const emptyRows = [];\n const tableRowCount = tableUtils.getRows(table);\n for (let rowIndex = 0; rowIndex < tableRowCount; rowIndex++) {\n const tableRow = table.getChild(rowIndex);\n if (tableRow.isEmpty) {\n emptyRows.push(rowIndex);\n }\n }\n if (emptyRows.length > 0) {\n // Remove only last empty row because it will recurrently trigger removing empty columns.\n const emptyRow = emptyRows[emptyRows.length - 1];\n // @if CK_DEBUG_TABLE // console.log( `Removing empty row: ${ emptyRow }.` );\n tableUtils.removeRows(table, { at: emptyRow });\n return true;\n }\n return false;\n}\n/**\n * Removes rows and columns that have no cells anchored.\n *\n * In table below:\n *\n * +----+----+----+----+\n * | 00 | 02 |\n * +----+----+ +\n * | 10 | |\n * +----+----+----+----+\n * | 20 | 22 | 23 |\n * + + + +\n * | | | | <-- empty row\n * +----+----+----+----+\n * ^--- empty column\n *\n * Will remove row 3 and column 1.\n *\n * **Note:** This is a low-level helper method for clearing invalid model state when doing table modifications.\n * To remove a rows from a table use {@link module:table/tableutils~TableUtils#removeRows `TableUtils.removeRows()`} and\n * {@link module:table/tableutils~TableUtils#removeColumns `TableUtils.removeColumns()`} to remove a column.\n *\n * @internal\n */\nexport function removeEmptyRowsColumns(table, tableUtils) {\n const removedColumns = removeEmptyColumns(table, tableUtils);\n // If there was some columns removed then cleaning empty rows was already triggered.\n if (!removedColumns) {\n removeEmptyRows(table, tableUtils);\n }\n}\n/**\n * Returns adjusted last row index if selection covers part of a row with empty slots (spanned by other cells).\n * The `dimensions.lastRow` is equal to last row index but selection might be bigger.\n *\n * This happens *only* on rectangular selection so we analyze a case like this:\n *\n * +---+---+---+---+\n * 0 | a | b | c | d |\n * + + +---+---+\n * 1 | | e | f | g |\n * + +---+ +---+\n * 2 | | h | | i | <- last row, each cell has rowspan = 2,\n * + + + + + so we need to return 3, not 2\n * 3 | | | | |\n * +---+---+---+---+\n *\n * @internal\n * @returns Adjusted last row index.\n */\nexport function adjustLastRowIndex(table, dimensions) {\n const lastRowMap = Array.from(new TableWalker(table, {\n startColumn: dimensions.firstColumn,\n endColumn: dimensions.lastColumn,\n row: dimensions.lastRow\n }));\n const everyCellHasSingleRowspan = lastRowMap.every(({ cellHeight }) => cellHeight === 1);\n // It is a \"flat\" row, so the last row index is OK.\n if (everyCellHasSingleRowspan) {\n return dimensions.lastRow;\n }\n // Otherwise get any cell's rowspan and adjust the last row index.\n const rowspanAdjustment = lastRowMap[0].cellHeight - 1;\n return dimensions.lastRow + rowspanAdjustment;\n}\n/**\n * Returns adjusted last column index if selection covers part of a column with empty slots (spanned by other cells).\n * The `dimensions.lastColumn` is equal to last column index but selection might be bigger.\n *\n * This happens *only* on rectangular selection so we analyze a case like this:\n *\n * 0 1 2 3\n * +---+---+---+---+\n * | a |\n * +---+---+---+---+\n * | b | c | d |\n * +---+---+---+---+\n * | e | f |\n * +---+---+---+---+\n * | g | h |\n * +---+---+---+---+\n * ^\n * last column, each cell has colspan = 2, so we need to return 3, not 2\n *\n * @internal\n * @returns Adjusted last column index.\n */\nexport function adjustLastColumnIndex(table, dimensions) {\n const lastColumnMap = Array.from(new TableWalker(table, {\n startRow: dimensions.firstRow,\n endRow: dimensions.lastRow,\n column: dimensions.lastColumn\n }));\n const everyCellHasSingleColspan = lastColumnMap.every(({ cellWidth }) => cellWidth === 1);\n // It is a \"flat\" column, so the last column index is OK.\n if (everyCellHasSingleColspan) {\n return dimensions.lastColumn;\n }\n // Otherwise get any cell's colspan and adjust the last column index.\n const colspanAdjustment = lastColumnMap[0].cellWidth - 1;\n return dimensions.lastColumn + colspanAdjustment;\n}\n/**\n * Get view `` element from the wrapper.\n */\nexport function getViewTableFromWrapper(wrapperView) {\n for (const wrapperChild of wrapperView.getChildren()) {\n if (wrapperChild.is('element', 'table')) {\n return wrapperChild;\n }\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { createEmptyTableCell } from '../utils/common.js';\nimport { getViewTableFromWrapper } from '../utils/structure.js';\nimport { first } from 'ckeditor5/src/utils.js';\n/**\n * Returns a function that converts the table view representation:\n *\n * ```xml\n *
...
\n * ```\n *\n * to the model representation:\n *\n * ```xml\n *
\n * ```\n *\n * @internal\n */\nexport function upcastTableFigure() {\n return (dispatcher) => {\n dispatcher.on('element:figure', (evt, data, conversionApi) => {\n // Do not convert if this is not a \"table figure\".\n if (!conversionApi.consumable.test(data.viewItem, { name: true, classes: 'table' })) {\n return;\n }\n // Find a table element inside the figure element.\n const viewTable = getViewTableFromWrapper(data.viewItem);\n // Do not convert if table element is absent or was already converted.\n if (!viewTable || !conversionApi.consumable.test(viewTable, { name: true })) {\n return;\n }\n // Consume the figure to prevent other converters from processing it again.\n conversionApi.consumable.consume(data.viewItem, { name: true, classes: 'table' });\n // Convert view table to model table.\n const conversionResult = conversionApi.convertItem(viewTable, data.modelCursor);\n // Get table element from conversion result.\n const modelTable = first(conversionResult.modelRange.getItems());\n // When table wasn't successfully converted then finish conversion.\n if (!modelTable || !modelTable.is('element', 'table')) {\n // Revert consumed figure so other features can convert it.\n conversionApi.consumable.revert(data.viewItem, { name: true, classes: 'table' });\n // If anyway some table content was converted, we have to pass the model range and cursor.\n if (conversionResult.modelRange && !conversionResult.modelRange.isCollapsed) {\n data.modelRange = conversionResult.modelRange;\n data.modelCursor = conversionResult.modelCursor;\n }\n return;\n }\n conversionApi.convertChildren(data.viewItem, conversionApi.writer.createPositionAt(modelTable, 'end'));\n conversionApi.updateConversionResult(modelTable, data);\n });\n };\n}\n/**\n * View table element to model table element conversion helper.\n *\n * This conversion helper converts the table element as well as table rows.\n *\n * @returns Conversion helper.\n * @internal\n */\nexport function upcastTable() {\n return (dispatcher) => {\n dispatcher.on('element:table', (evt, data, conversionApi) => {\n const viewTable = data.viewItem;\n // When element was already consumed then skip it.\n if (!conversionApi.consumable.test(viewTable, { name: true })) {\n return;\n }\n const { rows, headingRows, headingColumns } = scanTable(viewTable);\n // Only set attributes if values is greater then 0.\n const attributes = {};\n if (headingColumns) {\n attributes.headingColumns = headingColumns;\n }\n if (headingRows) {\n attributes.headingRows = headingRows;\n }\n const table = conversionApi.writer.createElement('table', attributes);\n if (!conversionApi.safeInsert(table, data.modelCursor)) {\n return;\n }\n conversionApi.consumable.consume(viewTable, { name: true });\n // Upcast table rows in proper order (heading rows first).\n rows.forEach(row => conversionApi.convertItem(row, conversionApi.writer.createPositionAt(table, 'end')));\n // Convert everything else.\n conversionApi.convertChildren(viewTable, conversionApi.writer.createPositionAt(table, 'end'));\n // Create one row and one table cell for empty table.\n if (table.isEmpty) {\n const row = conversionApi.writer.createElement('tableRow');\n conversionApi.writer.insert(row, conversionApi.writer.createPositionAt(table, 'end'));\n createEmptyTableCell(conversionApi.writer, conversionApi.writer.createPositionAt(row, 'end'));\n }\n conversionApi.updateConversionResult(table, data);\n });\n };\n}\n/**\n * A conversion helper that skips empty elements from upcasting at the beginning of the table.\n *\n * An empty row is considered a table model error but when handling clipboard data there could be rows that contain only row-spanned cells\n * and empty TR-s are used to maintain the table structure (also {@link module:table/tablewalker~TableWalker} assumes that there are only\n * rows that have related `tableRow` elements).\n *\n * *Note:* Only the first empty rows are removed because they have no meaning and it solves the issue\n * of an improper table with all empty rows.\n *\n * @internal\n * @returns Conversion helper.\n */\nexport function skipEmptyTableRow() {\n return (dispatcher) => {\n dispatcher.on('element:tr', (evt, data) => {\n if (data.viewItem.isEmpty && data.modelCursor.index == 0) {\n evt.stop();\n }\n }, { priority: 'high' });\n };\n}\n/**\n * A converter that ensures an empty paragraph is inserted in a table cell if no other content was converted.\n *\n * @internal\n * @returns Conversion helper.\n */\nexport function ensureParagraphInTableCell(elementName) {\n return (dispatcher) => {\n dispatcher.on(`element:${elementName}`, (evt, data, { writer }) => {\n // The default converter will create a model range on converted table cell.\n if (!data.modelRange) {\n return;\n }\n const tableCell = data.modelRange.start.nodeAfter;\n const modelCursor = writer.createPositionAt(tableCell, 0);\n // Ensure a paragraph in the model for empty table cells for converted table cells.\n if (data.viewItem.isEmpty) {\n writer.insertElement('paragraph', modelCursor);\n return;\n }\n const childNodes = Array.from(tableCell.getChildren());\n // In case there are only markers inside the table cell then move them to the paragraph.\n if (childNodes.every(node => node.is('element', '$marker'))) {\n const paragraph = writer.createElement('paragraph');\n writer.insert(paragraph, writer.createPositionAt(tableCell, 0));\n for (const node of childNodes) {\n writer.move(writer.createRangeOn(node), writer.createPositionAt(paragraph, 'end'));\n }\n }\n }, { priority: 'low' });\n };\n}\n/**\n * Scans table rows and extracts required metadata from the table:\n *\n * headingRows - The number of rows that go as table headers.\n * headingColumns - The maximum number of row headings.\n * rows - Sorted `` elements as they should go into the model - ie. if `` is inserted after `` in the view.\n *\n * @param viewTable The view table element.\n * @returns The table metadata.\n */\nfunction scanTable(viewTable) {\n let headingColumns = undefined;\n let shouldAccumulateHeadingRows = true;\n // The `` and `` sections in the DOM do not have to be in order `` -> `` and there might be more than one\n // of them.\n // As the model does not have these sections, rows from different sections must be sorted.\n // For example, below is a valid HTML table:\n //\n // \n // \n // \n // \n //
2
1
3
\n //\n // But browsers will render rows in order as: 1 as the heading and 2 and 3 as the body.\n const headRows = [];\n const bodyRows = [];\n // Currently the editor does not support more then one section.\n // Only the first from the view will be used as a heading row and the others will be converted to body rows.\n let firstTheadElement;\n for (const tableChild of Array.from(viewTable.getChildren())) {\n // Only ``, `` & `` from allowed table children can have ``s.\n // The else is for future purposes (mainly ``).\n if (tableChild.name !== 'tbody' && tableChild.name !== 'thead' && tableChild.name !== 'tfoot') {\n continue;\n }\n // Save the first `` in the table as table header - all other ones will be converted to table body rows.\n if (tableChild.name === 'thead' && !firstTheadElement) {\n shouldAccumulateHeadingRows = true;\n firstTheadElement = tableChild;\n }\n // There might be some extra empty text nodes between the ``s.\n // Make sure further code operates on `tr`s only. (#145)\n const trs = Array.from(tableChild.getChildren()).filter((el) => el.is('element', 'tr'));\n // Keep tracking of the previous row columns count to improve detection of heading rows.\n let maxPrevColumns = null;\n for (const tr of trs) {\n const trColumns = Array\n .from(tr.getChildren())\n .filter(el => el.is('element', 'td') || el.is('element', 'th'));\n // This is a child of a first element.\n if ((firstTheadElement && tableChild === firstTheadElement) ||\n (tableChild.name === 'tbody' &&\n trColumns.length > 0 &&\n // These conditions handles the case when the first column is a element and it's the only column in the row.\n // This case is problematic because it's not clear if this row should be a heading row or not, as it may be result\n // of the cell span from the previous row.\n // Issue: https://github.com/ckeditor/ckeditor5/issues/17556\n (maxPrevColumns === null || trColumns.length === maxPrevColumns) &&\n trColumns.every(e => e.is('element', 'th')) &&\n // If there is at least one \"normal\" table row between heading rows, then stop accumulating heading rows.\n shouldAccumulateHeadingRows)) {\n headRows.push(tr);\n shouldAccumulateHeadingRows = true;\n }\n else {\n bodyRows.push(tr);\n shouldAccumulateHeadingRows = false;\n }\n // We use the maximum number of columns to avoid false positives when detecting\n // multiple rows with single column within `rowspan`. Without it the last row of `rowspan=3`\n // would be detected as a heading row because it has only one column (identical to the previous row).\n maxPrevColumns = Math.max(maxPrevColumns || 0, trColumns.length);\n }\n }\n // Generate the cell matrix so we can calculate the heading columns.\n const bodyMatrix = generateCellMatrix(bodyRows);\n for (const rowSlots of bodyMatrix) {\n // Look for the first non-`` entry (either a `` or a missing cell).\n let index = 0;\n while (index < rowSlots.length) {\n if (rowSlots[index]?.name !== 'th') {\n break;\n }\n index += 1;\n }\n // Update headingColumns.\n if (headingColumns === undefined || index < headingColumns) {\n headingColumns = index;\n }\n }\n return {\n headingRows: headRows.length,\n headingColumns: headingColumns || 0,\n rows: [...headRows, ...bodyRows]\n };\n}\n/**\n * Takes an array of `` elements and generates a \"matrix\" (square\n * two-dimensional array) describing which ``s and ``s fill which\n * \"slots\", factoring in `rowspan`s and `colspan`s. For example, given\n *\n * ```xml\n * \n * \n * \n * \n *
11 12-22 13
21 23
31-32 33
\n * ```\n *\n * The result would be (with cell elements' text content in place of the element\n * objects for readability):\n *\n * ```js\n * [\n * [ '11', '12-22', '13' ],\n * [ '21', '12-22', '23' ],\n * [ '31-32', '31-32', '33' ],\n * ]\n * ```\n *\n * This allows for a computation of heading columns that factors in the case\n * where a cell from a previous rows with a `rowspan` attribute effectively adds\n * an additional header cell to a subsequent row.\n *\n * There are also cases where cells are \"missing\" from a row. A simple one is\n * the case where a row simply has fewer cells than another row in the same\n * table. But another is one where a row has a cell with a `rowspan` that\n * effectively adds a cell to a subsequent row \"off the end\" of the row. In this\n * case, there will be a `null` value instead of an element object in that\n * position. For example,\n *\n * ```xml\n * \n * \n * \n * \n *
11 12 13-23
21
31
\n * ```\n *\n * would result in\n *\n * ```js\n * [\n * [ '11', '12', '13-23' ],\n * [ '21', null, '13-23' ],\n * [ '31', null, null ]\n * ]\n * ```\n *\n * @param trs the array of `` elements\n * @returns the cell matrix\n */\nfunction generateCellMatrix(trs) {\n // As we iterate, we keep track of cells with rowspans >1 so later rows can\n // factor them in. This trackes any such cells from previous rows.\n let prevRowspans = new Map();\n // This is the maximum number of columns we've encountered.\n let maxColumns = 0;\n const slots = trs.map(tr => {\n // This will be the slots that are in this row, including cells from\n // previous rows with a big enough \"rowspan\" to affect this row.\n const curSlots = [];\n // Get the cell elements\n const children = Array.from(tr.getChildren())\n .filter(child => child.name === 'th' || child.name === 'td');\n // This will be any cells in this row that have a rowspan >1, so we can\n // combine it with `prevRowspans` when we're done processing this row.\n const curRowspans = new Map();\n // We need to process all the cells in this row, but also previous rows'\n // cells with rowspans might add additional slots to the end of this row, so\n // we need to iterate until we've both consumed all the children _and_\n // filled out slots to the max number of columns we've encountered so far.\n while (children.length || curSlots.length < maxColumns) {\n const rowSpan = prevRowspans.get(curSlots.length);\n if (rowSpan && rowSpan.remaining > 0) {\n // We have a cell at this index in a previous row whose rowspan extends\n // it into this row, so we insert a copy of it here.\n curSlots.push(rowSpan.cell);\n }\n else {\n // See if we have more cells in the row.\n const cell = children.shift();\n if (cell) {\n // We do, so process it\n const colspan = parseInt(cell.getAttribute('colspan') || '1');\n const rowspan = parseInt(cell.getAttribute('rowspan') || '1');\n // Process this cell as many times as needed according to its colspan.\n for (let i = 0; i < colspan; i++) {\n // if we have a >1 rowspan, create a record in the rowSpans map for\n // this column index keeping track of it.\n if (rowspan > 1) {\n curRowspans.set(curSlots.length, { cell, remaining: rowspan - 1 });\n }\n curSlots.push(cell);\n }\n }\n else {\n // No remaining children in this row, so no cell in this slot.\n curSlots.push(null);\n continue;\n }\n }\n }\n // Now update the row spans. In weird edge cases where colspan and rowspan\n // conflict, we can end up with a cell in a column in this row that\n // \"truncates\" a row-spanning cell from a previous column, so make sure in\n // those cases, the value in `curRowspans` always \"wins\". We do this by\n // copying (and decrementing) values from `prevRowspans` into `curRowspans`\n // as long as there is no conflict, and then re-assigning `prevRowspans`.\n for (const [index, entry] of prevRowspans.entries()) {\n entry.remaining -= 1;\n if (entry.remaining > 0 && !curRowspans.has(index)) {\n curRowspans.set(index, entry);\n }\n }\n prevRowspans = curRowspans;\n // Finally, update `maxColumns`.\n maxColumns = Math.max(maxColumns, curSlots.length);\n return curSlots;\n });\n // Now expand any rows that have fewer than `maxColumns` with nulls so we have\n // a proper matrix.\n for (const rowSlots of slots) {\n while (rowSlots.length < maxColumns) {\n rowSlots.push(null);\n }\n }\n return slots;\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { isObject } from 'es-toolkit/compat';\n/**\n * Returns a string if all four values of box sides are equal.\n *\n * If a string is passed, it is treated as a single value (pass-through).\n *\n * ```ts\n * // Returns 'foo':\n * getSingleValue( { top: 'foo', right: 'foo', bottom: 'foo', left: 'foo' } );\n * getSingleValue( 'foo' );\n *\n * // Returns undefined:\n * getSingleValue( { top: 'foo', right: 'foo', bottom: 'bar', left: 'foo' } );\n * getSingleValue( { top: 'foo', right: 'foo' } );\n * ```\n *\n * @internal\n */\nexport function getSingleValue(objectOrString) {\n if (!objectOrString || !isObject(objectOrString)) {\n return objectOrString;\n }\n const { top, right, bottom, left } = objectOrString;\n if (top == right && right == bottom && bottom == left) {\n return top;\n }\n}\n/**\n * Adds a unit to a value if the value is a number or a string representing a number.\n *\n * **Note**: It does nothing to non-numeric values.\n *\n * ```ts\n * getSingleValue( 25, 'px' ); // '25px'\n * getSingleValue( 25, 'em' ); // '25em'\n * getSingleValue( '25em', 'px' ); // '25em'\n * getSingleValue( 'foo', 'px' ); // 'foo'\n * ```\n *\n * @internal\n * @param defaultUnit A default unit added to a numeric value.\n */\nexport function addDefaultUnitToNumericValue(value, defaultUnit) {\n const numericValue = parseFloat(value);\n if (Number.isNaN(numericValue)) {\n return value;\n }\n if (String(numericValue) !== String(value)) {\n return value;\n }\n return `${numericValue}${defaultUnit}`;\n}\n/**\n * Returns the normalized configuration.\n *\n * @internal\n * @param config The configuration to normalize.\n * @param options Options used to determine which properties should be added.\n */\nexport function getNormalizedDefaultProperties(config, options = {}) {\n const normalizedConfig = {\n borderStyle: 'none',\n borderWidth: '',\n borderColor: '',\n backgroundColor: '',\n width: '',\n height: '',\n ...config\n };\n if (options.includeAlignmentProperty && !normalizedConfig.alignment) {\n normalizedConfig.alignment = 'center';\n }\n if (options.includePaddingProperty && !normalizedConfig.padding) {\n normalizedConfig.padding = '';\n }\n if (options.includeVerticalAlignmentProperty && !normalizedConfig.verticalAlignment) {\n normalizedConfig.verticalAlignment = 'middle';\n }\n if (options.includeHorizontalAlignmentProperty && !normalizedConfig.horizontalAlignment) {\n normalizedConfig.horizontalAlignment = options.isRightToLeftContent ? 'right' : 'left';\n }\n return normalizedConfig;\n}\n/**\n * Returns the normalized default table properties.\n *\n * @internal\n * @param config The configuration to normalize.\n * @param options Options used to determine which properties should be added.\n */\nexport function getNormalizedDefaultTableProperties(config, options) {\n return getNormalizedDefaultProperties({\n // It adds support for border none in the table element, keep it in sync with the content styles\n // See more: https://github.com/ckeditor/ckeditor5/issues/6841#issuecomment-1959195608\n borderStyle: 'double',\n borderColor: 'hsl(0, 0%, 70%)',\n borderWidth: '1px',\n ...config\n }, options);\n}\n/**\n * Returns the normalized default cell properties.\n *\n * @internal\n * @param config The configuration to normalize.\n * @param options Options used to determine which properties should be added.\n */\nexport function getNormalizedDefaultCellProperties(config, options) {\n return getNormalizedDefaultProperties({\n // It adds support for border none in the table element, keep it in sync with the content styles\n // See more: https://github.com/ckeditor/ckeditor5/issues/6841#issuecomment-1959195608\n borderStyle: 'solid',\n borderColor: 'hsl(0, 0%, 75%)',\n borderWidth: '1px',\n ...config\n }, options);\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { toWidget, toWidgetEditable } from 'ckeditor5/src/widget.js';\nimport { downcastTableAlignmentConfig } from './tableproperties.js';\nimport { getNormalizedDefaultTableProperties } from '../utils/table-properties.js';\nimport { TableWalker } from '../tablewalker.js';\n/**\n * Model table element to view table element conversion helper.\n *\n * @internal\n */\nexport function downcastTable(tableUtils, options) {\n return (table, { writer }) => {\n const headingRows = table.getAttribute('headingRows') || 0;\n const tableElement = writer.createContainerElement('table', null, []);\n const figureElement = writer.createContainerElement('figure', { class: 'table' }, tableElement);\n // Table head slot.\n if (headingRows > 0) {\n writer.insert(writer.createPositionAt(tableElement, 'end'), writer.createContainerElement('thead', null, writer.createSlot(element => element.is('element', 'tableRow') && element.index < headingRows)));\n }\n // Table body slot.\n if (headingRows < tableUtils.getRows(table)) {\n writer.insert(writer.createPositionAt(tableElement, 'end'), writer.createContainerElement('tbody', null, writer.createSlot(element => element.is('element', 'tableRow') && element.index >= headingRows)));\n }\n // Dynamic slots.\n for (const { positionOffset, filter } of options.additionalSlots) {\n writer.insert(writer.createPositionAt(tableElement, positionOffset), writer.createSlot(filter));\n }\n // Create a slot with items that don't fit into the table.\n writer.insert(writer.createPositionAt(tableElement, 'after'), writer.createSlot(element => {\n if (element.is('element', 'tableRow')) {\n return false;\n }\n return !options.additionalSlots.some(({ filter }) => filter(element));\n }));\n return options.asWidget ? toTableWidget(figureElement, writer) : figureElement;\n };\n}\n/**\n * Model table row element to view `` element conversion helper.\n *\n * @internal\n * @returns Element creator.\n */\nexport function downcastRow() {\n return (tableRow, { writer }) => {\n return tableRow.isEmpty ?\n writer.createEmptyElement('tr') :\n writer.createContainerElement('tr');\n };\n}\n/**\n * Model table cell element to view `` or `` element conversion helper.\n *\n * This conversion helper will create proper `` elements for table cells that are in the heading section (heading row or column)\n * and `` otherwise.\n *\n * @internal\n * @param options.asWidget If set to `true`, the downcast conversion will produce a widget.\n * @param options.cellTypeEnabled If returns `true`, the downcast conversion will use the `tableCellType` attribute to determine cell type.\n * @returns Element creator.\n */\nexport function downcastCell(options) {\n return (tableCell, { writer }) => {\n // If the table cell type feature is enabled, then we can simply check the cell type attribute.\n if (options.cellTypeEnabled?.()) {\n const cellElementName = (tableCell.getAttribute('tableCellType') === 'header' ?\n 'th' :\n 'td');\n return createCellElement(writer, cellElementName);\n }\n // If the table cell type feature is not enabled, we should iterate through the table structure\n // to determine whether the cell is in the heading section.\n const tableRow = tableCell.parent;\n const table = tableRow.parent;\n const rowIndex = table.getChildIndex(tableRow);\n const tableWalker = new TableWalker(table, { row: rowIndex });\n const headingRows = table.getAttribute('headingRows') || 0;\n const headingColumns = table.getAttribute('headingColumns') || 0;\n let result = null;\n // We need to iterate over a table in order to get proper row & column values from a walker.\n for (const tableSlot of tableWalker) {\n if (tableSlot.cell == tableCell) {\n const isHeading = tableSlot.row < headingRows || tableSlot.column < headingColumns;\n result = createCellElement(writer, isHeading ? 'th' : 'td');\n break;\n }\n }\n return result;\n };\n function createCellElement(writer, name) {\n return (options.asWidget ?\n toWidgetEditable(writer.createEditableElement(name), writer, { withAriaRole: false }) :\n writer.createContainerElement(name));\n }\n}\n/**\n * Overrides paragraph inside table cell conversion.\n *\n * This converter:\n * * should be used to override default paragraph conversion.\n * * It will only convert `` placed directly inside ``.\n * * For a single paragraph without attributes it returns `` to simulate data table.\n * * For all other cases it returns `

` element.\n *\n * @internal\n * @param options.asWidget If set to `true`, the downcast conversion will produce a widget.\n * @returns Element creator.\n */\nexport function convertParagraphInTableCell(options = {}) {\n return (modelElement, { writer }) => {\n if (!modelElement.parent.is('element', 'tableCell')) {\n return null;\n }\n if (!isSingleParagraphWithoutAttributes(modelElement)) {\n return null;\n }\n if (options.asWidget) {\n return writer.createContainerElement('span', { class: 'ck-table-bogus-paragraph' });\n }\n else {\n // Using `

` in case there are some markers on it and transparentRendering will render it anyway.\n const viewElement = writer.createContainerElement('p');\n writer.setCustomProperty('dataPipeline:transparentRendering', true, viewElement);\n return viewElement;\n }\n };\n}\n/**\n * Checks if given model `` is an only child of a parent (``) and if it has any attribute set.\n *\n * The paragraph should be converted in the editing view to:\n *\n * * If returned `true` - to a ``\n * * If returned `false` - to a `

`\n *\n * @internal\n */\nexport function isSingleParagraphWithoutAttributes(modelElement) {\n const tableCell = modelElement.parent;\n const isSingleParagraph = tableCell.childCount == 1;\n return isSingleParagraph && !hasAnyAttribute(modelElement);\n}\n/**\n * Converts a given {@link module:engine/view/element~ViewElement} to a table widget:\n * * Adds a {@link module:engine/view/element~ViewElement#_setCustomProperty custom property}\n * allowing to recognize the table widget element.\n * * Calls the {@link module:widget/utils~toWidget} function with the proper element's label creator.\n *\n * @param writer An instance of the view writer.\n * @param label The element's label. It will be concatenated with the table `alt` attribute if one is present.\n */\nfunction toTableWidget(viewElement, writer) {\n writer.setCustomProperty('table', true, viewElement);\n return toWidget(viewElement, writer, { hasSelectionHandle: true });\n}\n/**\n * Checks if an element has any attributes set.\n */\nfunction hasAnyAttribute(element) {\n for (const attributeKey of element.getAttributeKeys()) {\n // Ignore selection attributes stored on block elements.\n if (attributeKey.startsWith('selection:') || attributeKey == 'htmlEmptyBlock') {\n continue;\n }\n return true;\n }\n return false;\n}\n/**\n * Downcasts a plain table (also used in the clipboard pipeline).\n */\nexport function convertPlainTable(editor) {\n return (table, conversionApi) => {\n const hasPlainTableOutput = editor.plugins.has('PlainTableOutput');\n const isClipboardPipeline = conversionApi.options.isClipboardPipeline;\n const useExtendedAlignment = editor.config.get('experimentalFlags.useExtendedTableBlockAlignment');\n if (!hasPlainTableOutput && !(useExtendedAlignment && isClipboardPipeline)) {\n return null;\n }\n return downcastPlainTable(table, conversionApi, editor);\n };\n}\n/**\n * Downcasts a plain table caption (also used in the clipboard pipeline).\n */\nexport function convertPlainTableCaption(editor) {\n return (modelElement, { writer, options }) => {\n const hasPlainTableOutput = editor.plugins.has('PlainTableOutput');\n const isClipboardPipeline = options.isClipboardPipeline;\n const useExtendedAlignment = editor.config.get('experimentalFlags.useExtendedTableBlockAlignment');\n if (!hasPlainTableOutput && !(useExtendedAlignment && isClipboardPipeline)) {\n return null;\n }\n if (modelElement.parent.name === 'table') {\n return writer.createContainerElement('caption');\n }\n return null;\n };\n}\n/**\n * Downcasts a plain table.\n *\n * @param table Table model element.\n * @param conversionApi The conversion API object.\n * @param editor The editor instance.\n * @returns Created element.\n */\nexport function downcastPlainTable(table, conversionApi, editor) {\n const writer = conversionApi.writer;\n const headingRows = table.getAttribute('headingRows') || 0;\n // Table head rows slot.\n const headRowsSlot = writer.createSlot((element) => element.is('element', 'tableRow') && element.index < headingRows);\n // Table body rows slot.\n const bodyRowsSlot = writer.createSlot((element) => element.is('element', 'tableRow') && element.index >= headingRows);\n // Table children slot.\n const childrenSlot = writer.createSlot((element) => !element.is('element', 'tableRow'));\n // Table element with all the heading rows.\n const theadElement = writer.createContainerElement('thead', null, headRowsSlot);\n // Table element with all the body rows.\n const tbodyElement = writer.createContainerElement('tbody', null, bodyRowsSlot);\n // Table contents element containing and when necessary.\n const tableContentElements = [];\n if (headingRows) {\n tableContentElements.push(theadElement);\n }\n if (headingRows < table.childCount) {\n tableContentElements.push(tbodyElement);\n }\n const tableAttributes = { class: 'table' };\n if (editor.plugins.has('TablePropertiesEditing') && conversionApi.options.isClipboardPipeline) {\n const defaultTableProperties = getNormalizedDefaultTableProperties(editor.config.get('table.tableProperties.defaultProperties'), {\n includeAlignmentProperty: true\n });\n const tableAlignment = table.getAttribute('tableAlignment');\n let localDefaultValue = defaultTableProperties.alignment;\n if (table.getAttribute('tableType') === 'layout') {\n localDefaultValue = '';\n }\n const tableAlignmentValue = tableAlignment || localDefaultValue;\n if (tableAlignmentValue) {\n tableAttributes.class += ' ' + downcastTableAlignmentConfig[tableAlignmentValue].className;\n tableAttributes.style = downcastTableAlignmentConfig[tableAlignmentValue].style;\n if (downcastTableAlignmentConfig[tableAlignmentValue].align !== undefined) {\n tableAttributes.align = downcastTableAlignmentConfig[tableAlignmentValue].align;\n }\n }\n }\n // Create table structure.\n //\n // \n // {children-slot-like-caption}\n // \n // {table-head-rows-slot}\n // \n // \n // {table-body-rows-slot}\n // \n //
\n return writer.createContainerElement('table', tableAttributes, [childrenSlot, ...tableContentElements]);\n}\n/**\n * Registers border and background attributes converters for plain tables or when the clipboard pipeline is used.\n */\nexport function downcastTableBorderAndBackgroundAttributes(editor) {\n const modelAttributes = {\n 'border-width': 'tableBorderWidth',\n 'border-color': 'tableBorderColor',\n 'border-style': 'tableBorderStyle',\n 'background-color': 'tableBackgroundColor'\n };\n for (const [styleName, modelAttribute] of Object.entries(modelAttributes)) {\n editor.conversion.for('dataDowncast').add(dispatcher => {\n return dispatcher.on(`attribute:${modelAttribute}:table`, (evt, data, conversionApi) => {\n const { item, attributeNewValue } = data;\n const { mapper, writer } = conversionApi;\n const hasPlainTableOutput = editor.plugins.has('PlainTableOutput');\n const isClipboardPipeline = conversionApi.options.isClipboardPipeline;\n const useExtendedAlignment = editor.config.get('experimentalFlags.useExtendedTableBlockAlignment');\n if (!hasPlainTableOutput && !(useExtendedAlignment && isClipboardPipeline)) {\n return;\n }\n if (!conversionApi.consumable.consume(item, evt.name)) {\n return;\n }\n const table = mapper.toViewElement(item);\n if (attributeNewValue) {\n writer.setStyle(styleName, attributeNewValue, table);\n }\n else {\n writer.removeStyle(styleName, table);\n }\n }, { priority: 'high' });\n });\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/commands/inserttablecommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\n/**\n * The insert table command.\n *\n * The command is registered by {@link module:table/tableediting~TableEditing} as the `'insertTable'` editor command.\n *\n * To insert a table at the current selection, execute the command and specify the dimensions:\n *\n * ```ts\n * editor.execute( 'insertTable', { rows: 20, columns: 5 } );\n * ```\n */\nexport class InsertTableCommand extends Command {\n /**\n * @inheritDoc\n */\n refresh() {\n const model = this.editor.model;\n const selection = model.document.selection;\n const schema = model.schema;\n this.isEnabled = isAllowedInParent(selection, schema);\n }\n /**\n * Executes the command.\n *\n * Inserts a table with the given number of rows and columns into the editor.\n *\n * @param options.rows The number of rows to create in the inserted table. Default value is 2.\n * @param options.columns The number of columns to create in the inserted table. Default value is 2.\n * @param options.headingRows The number of heading rows. If not provided it will default to\n * {@link module:table/tableconfig~TableConfig#defaultHeadings `config.table.defaultHeadings.rows`} table config.\n * @param options.headingColumns The number of heading columns. If not provided it will default to\n * {@link module:table/tableconfig~TableConfig#defaultHeadings `config.table.defaultHeadings.columns`} table config.\n * @fires execute\n */\n execute(options = {}) {\n const editor = this.editor;\n const model = editor.model;\n const tableUtils = editor.plugins.get('TableUtils');\n const defaultRows = editor.config.get('table.defaultHeadings.rows');\n const defaultColumns = editor.config.get('table.defaultHeadings.columns');\n if (options.headingRows === undefined && defaultRows) {\n options.headingRows = defaultRows;\n }\n if (options.headingColumns === undefined && defaultColumns) {\n options.headingColumns = defaultColumns;\n }\n model.change(writer => {\n const table = tableUtils.createTable(writer, options);\n model.insertObject(table, null, null, { findOptimalPosition: 'auto' });\n writer.setSelection(writer.createPositionAt(table.getNodeByPath([0, 0, 0]), 0));\n });\n }\n}\n/**\n * Checks if the table is allowed in the parent.\n */\nfunction isAllowedInParent(selection, schema) {\n const positionParent = selection.getFirstPosition().parent;\n const validParent = positionParent === positionParent.root ? positionParent : positionParent.parent;\n return schema.checkChild(validParent, 'table');\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/commands/insertrowcommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\n/**\n * The insert row command.\n *\n * The command is registered by {@link module:table/tableediting~TableEditing} as the `'insertTableRowBelow'` and\n * `'insertTableRowAbove'` editor commands.\n *\n * To insert a row below the selected cell, execute the following command:\n *\n * ```ts\n * editor.execute( 'insertTableRowBelow' );\n * ```\n *\n * To insert a row above the selected cell, execute the following command:\n *\n * ```ts\n * editor.execute( 'insertTableRowAbove' );\n * ```\n */\nexport class InsertRowCommand extends Command {\n /**\n * The order of insertion relative to the row in which the caret is located.\n */\n order;\n /**\n * Creates a new `InsertRowCommand` instance.\n *\n * @param editor The editor on which this command will be used.\n * @param options.order The order of insertion relative to the row in which the caret is located.\n * Possible values: `\"above\"` and `\"below\"`. Default value is \"below\"\n */\n constructor(editor, options = {}) {\n super(editor);\n this.order = options.order || 'below';\n }\n /**\n * @inheritDoc\n */\n refresh() {\n const selection = this.editor.model.document.selection;\n const tableUtils = this.editor.plugins.get('TableUtils');\n const isAnyCellSelected = !!tableUtils.getSelectionAffectedTableCells(selection).length;\n this.isEnabled = isAnyCellSelected;\n }\n /**\n * Executes the command.\n *\n * Depending on the command's {@link #order} value, it inserts a row `'below'` or `'above'` the row in which selection is set.\n *\n * @fires execute\n */\n execute() {\n const editor = this.editor;\n const selection = editor.model.document.selection;\n const tableUtils = editor.plugins.get('TableUtils');\n const insertAbove = this.order === 'above';\n const affectedTableCells = tableUtils.getSelectionAffectedTableCells(selection);\n const rowIndexes = tableUtils.getRowIndexes(affectedTableCells);\n const row = insertAbove ? rowIndexes.first : rowIndexes.last;\n const table = affectedTableCells[0].findAncestor('table');\n tableUtils.insertRows(table, { at: insertAbove ? row : row + 1, copyStructureFromAbove: !insertAbove });\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/commands/insertcolumncommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\n/**\n * The insert column command.\n *\n * The command is registered by {@link module:table/tableediting~TableEditing} as the `'insertTableColumnLeft'` and\n * `'insertTableColumnRight'` editor commands.\n *\n * To insert a column to the left of the selected cell, execute the following command:\n *\n * ```ts\n * editor.execute( 'insertTableColumnLeft' );\n * ```\n *\n * To insert a column to the right of the selected cell, execute the following command:\n *\n * ```ts\n * editor.execute( 'insertTableColumnRight' );\n * ```\n */\nexport class InsertColumnCommand extends Command {\n /**\n * The order of insertion relative to the column in which the caret is located.\n */\n order;\n /**\n * Creates a new `InsertColumnCommand` instance.\n *\n * @param editor An editor on which this command will be used.\n * @param options.order The order of insertion relative to the column in which the caret is located.\n * Possible values: `\"left\"` and `\"right\"`. Default value is \"right\".\n */\n constructor(editor, options = {}) {\n super(editor);\n this.order = options.order || 'right';\n }\n /**\n * @inheritDoc\n */\n refresh() {\n const selection = this.editor.model.document.selection;\n const tableUtils = this.editor.plugins.get('TableUtils');\n const isAnyCellSelected = !!tableUtils.getSelectionAffectedTableCells(selection).length;\n this.isEnabled = isAnyCellSelected;\n }\n /**\n * Executes the command.\n *\n * Depending on the command's {@link #order} value, it inserts a column to the `'left'` or `'right'` of the column\n * in which the selection is set.\n *\n * @fires execute\n */\n execute() {\n const editor = this.editor;\n const selection = editor.model.document.selection;\n const tableUtils = editor.plugins.get('TableUtils');\n const insertBefore = this.order === 'left';\n const affectedTableCells = tableUtils.getSelectionAffectedTableCells(selection);\n const columnIndexes = tableUtils.getColumnIndexes(affectedTableCells);\n const column = insertBefore ? columnIndexes.first : columnIndexes.last;\n const table = affectedTableCells[0].findAncestor('table');\n tableUtils.insertColumns(table, { columns: 1, at: insertBefore ? column : column + 1 });\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/commands/splitcellcommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\n/**\n * The split cell command.\n *\n * The command is registered by {@link module:table/tableediting~TableEditing} as the `'splitTableCellVertically'`\n * and `'splitTableCellHorizontally'` editor commands.\n *\n * You can split any cell vertically or horizontally by executing this command. For example, to split the selected table cell vertically:\n *\n * ```ts\n * editor.execute( 'splitTableCellVertically' );\n * ```\n */\nexport class SplitCellCommand extends Command {\n /**\n * The direction that indicates which cell will be split.\n */\n direction;\n /**\n * Creates a new `SplitCellCommand` instance.\n *\n * @param editor The editor on which this command will be used.\n * @param options.direction Indicates whether the command should split cells `'horizontally'` or `'vertically'`.\n */\n constructor(editor, options = {}) {\n super(editor);\n this.direction = options.direction || 'horizontally';\n }\n /**\n * @inheritDoc\n */\n refresh() {\n const tableUtils = this.editor.plugins.get('TableUtils');\n const selectedCells = tableUtils.getSelectionAffectedTableCells(this.editor.model.document.selection);\n this.isEnabled = selectedCells.length === 1;\n }\n /**\n * @inheritDoc\n */\n execute() {\n const tableUtils = this.editor.plugins.get('TableUtils');\n const tableCell = tableUtils.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];\n const isHorizontal = this.direction === 'horizontally';\n if (isHorizontal) {\n tableUtils.splitCellHorizontally(tableCell, 2);\n }\n else {\n tableUtils.splitCellVertically(tableCell, 2);\n }\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { TableWalker } from '../tablewalker.js';\nimport { isHeadingColumnCell } from '../utils/common.js';\nimport { removeEmptyRowsColumns } from '../utils/structure.js';\n/**\n * The merge cell command.\n *\n * The command is registered by {@link module:table/tableediting~TableEditing} as the `'mergeTableCellRight'`, `'mergeTableCellLeft'`,\n * `'mergeTableCellUp'` and `'mergeTableCellDown'` editor commands.\n *\n * To merge a table cell at the current selection with another cell, execute the command corresponding with the preferred direction.\n *\n * For example, to merge with a cell to the right:\n *\n * ```ts\n * editor.execute( 'mergeTableCellRight' );\n * ```\n *\n * **Note**: If a table cell has a different [`rowspan`](https://www.w3.org/TR/html50/tabular-data.html#attr-tdth-rowspan)\n * (for `'mergeTableCellRight'` and `'mergeTableCellLeft'`) or [`colspan`](https://www.w3.org/TR/html50/tabular-data.html#attr-tdth-colspan)\n * (for `'mergeTableCellUp'` and `'mergeTableCellDown'`), the command will be disabled.\n */\nexport class MergeCellCommand extends Command {\n /**\n * The direction that indicates which cell will be merged with the currently selected one.\n */\n direction;\n /**\n * Whether the merge is horizontal (left/right) or vertical (up/down).\n */\n isHorizontal;\n /**\n * Creates a new `MergeCellCommand` instance.\n *\n * @param editor The editor on which this command will be used.\n * @param options.direction Indicates which cell to merge with the currently selected one.\n * Possible values are: `'left'`, `'right'`, `'up'` and `'down'`.\n */\n constructor(editor, options) {\n super(editor);\n this.direction = options.direction;\n this.isHorizontal = this.direction == 'right' || this.direction == 'left';\n }\n /**\n * @inheritDoc\n */\n refresh() {\n const cellToMerge = this._getMergeableCell();\n this.value = cellToMerge;\n this.isEnabled = !!cellToMerge;\n }\n /**\n * Executes the command.\n *\n * Depending on the command's {@link #direction} value, it will merge the cell that is to the `'left'`, `'right'`, `'up'` or `'down'`.\n *\n * @fires execute\n */\n execute() {\n const model = this.editor.model;\n const doc = model.document;\n const tableUtils = this.editor.plugins.get('TableUtils');\n const tableCell = tableUtils.getTableCellsContainingSelection(doc.selection)[0];\n const cellToMerge = this.value;\n const direction = this.direction;\n model.change(writer => {\n const isMergeNext = direction == 'right' || direction == 'down';\n // The merge mechanism is always the same so sort cells to be merged.\n const cellToExpand = (isMergeNext ? tableCell : cellToMerge);\n const cellToRemove = (isMergeNext ? cellToMerge : tableCell);\n // Cache the parent of cell to remove for later check.\n const removedTableCellRow = cellToRemove.parent;\n mergeTableCells(cellToRemove, cellToExpand, writer);\n const spanAttribute = this.isHorizontal ? 'colspan' : 'rowspan';\n const cellSpan = parseInt(tableCell.getAttribute(spanAttribute) || '1');\n const cellToMergeSpan = parseInt(cellToMerge.getAttribute(spanAttribute) || '1');\n // Update table cell span attribute and merge set selection on merged contents.\n writer.setAttribute(spanAttribute, cellSpan + cellToMergeSpan, cellToExpand);\n writer.setSelection(writer.createRangeIn(cellToExpand));\n const tableUtils = this.editor.plugins.get('TableUtils');\n const table = removedTableCellRow.findAncestor('table');\n // Remove empty rows and columns after merging.\n removeEmptyRowsColumns(table, tableUtils);\n });\n }\n /**\n * Returns a cell that can be merged with the current cell depending on the command's direction.\n */\n _getMergeableCell() {\n const model = this.editor.model;\n const doc = model.document;\n const tableUtils = this.editor.plugins.get('TableUtils');\n const tableCell = tableUtils.getTableCellsContainingSelection(doc.selection)[0];\n if (!tableCell) {\n return;\n }\n // First get the cell on proper direction.\n const cellToMerge = this.isHorizontal ?\n getHorizontalCell(tableCell, this.direction, tableUtils) :\n getVerticalCell(tableCell, this.direction, tableUtils);\n if (!cellToMerge) {\n return;\n }\n // If found check if the span perpendicular to merge direction is equal on both cells.\n const spanAttribute = this.isHorizontal ? 'rowspan' : 'colspan';\n const span = parseInt(tableCell.getAttribute(spanAttribute) || '1');\n const cellToMergeSpan = parseInt(cellToMerge.getAttribute(spanAttribute) || '1');\n if (cellToMergeSpan === span) {\n return cellToMerge;\n }\n }\n}\n/**\n * Returns the cell that can be merged horizontally.\n */\nfunction getHorizontalCell(tableCell, direction, tableUtils) {\n const tableRow = tableCell.parent;\n const table = tableRow.parent;\n const horizontalCell = direction == 'right' ? tableCell.nextSibling : tableCell.previousSibling;\n const hasHeadingColumns = (table.getAttribute('headingColumns') || 0) > 0;\n if (!horizontalCell) {\n return;\n }\n // Sort cells:\n const cellOnLeft = (direction == 'right' ? tableCell : horizontalCell);\n const cellOnRight = (direction == 'right' ? horizontalCell : tableCell);\n // Get their column indexes:\n const { column: leftCellColumn } = tableUtils.getCellLocation(cellOnLeft);\n const { column: rightCellColumn } = tableUtils.getCellLocation(cellOnRight);\n const leftCellSpan = parseInt(cellOnLeft.getAttribute('colspan') || '1');\n const isCellOnLeftInHeadingColumn = isHeadingColumnCell(tableUtils, cellOnLeft);\n const isCellOnRightInHeadingColumn = isHeadingColumnCell(tableUtils, cellOnRight);\n // We cannot merge heading columns cells with regular cells.\n if (hasHeadingColumns && isCellOnLeftInHeadingColumn != isCellOnRightInHeadingColumn) {\n return;\n }\n // The cell on the right must have index that is distant to the cell on the left by the left cell's width (colspan).\n const cellsAreTouching = leftCellColumn + leftCellSpan === rightCellColumn;\n // If the right cell's column index is different it means that there are rowspanned cells between them.\n return cellsAreTouching ? horizontalCell : undefined;\n}\n/**\n * Returns the cell that can be merged vertically.\n */\nfunction getVerticalCell(tableCell, direction, tableUtils) {\n const tableRow = tableCell.parent;\n const table = tableRow.parent;\n const rowIndex = table.getChildIndex(tableRow);\n // Don't search for mergeable cell if direction points out of the table.\n if ((direction == 'down' && rowIndex === tableUtils.getRows(table) - 1) || (direction == 'up' && rowIndex === 0)) {\n return null;\n }\n const rowspan = parseInt(tableCell.getAttribute('rowspan') || '1');\n const headingRows = table.getAttribute('headingRows') || 0;\n const isMergeWithBodyCell = direction == 'down' && (rowIndex + rowspan) === headingRows;\n const isMergeWithHeadCell = direction == 'up' && rowIndex === headingRows;\n // Don't search for mergeable cell if direction points out of the current table section.\n if (headingRows && (isMergeWithBodyCell || isMergeWithHeadCell)) {\n return null;\n }\n const currentCellRowSpan = parseInt(tableCell.getAttribute('rowspan') || '1');\n const rowOfCellToMerge = direction == 'down' ? rowIndex + currentCellRowSpan : rowIndex;\n const tableMap = [...new TableWalker(table, { endRow: rowOfCellToMerge })];\n const currentCellData = tableMap.find(value => value.cell === tableCell);\n const mergeColumn = currentCellData.column;\n const cellToMergeData = tableMap.find(({ row, cellHeight, column }) => {\n if (column !== mergeColumn) {\n return false;\n }\n if (direction == 'down') {\n // If merging a cell below the mergeRow is already calculated.\n return row === rowOfCellToMerge;\n }\n else {\n // If merging a cell above calculate if it spans to mergeRow.\n return rowOfCellToMerge === row + cellHeight;\n }\n });\n return cellToMergeData && cellToMergeData.cell ? cellToMergeData.cell : null;\n}\n/**\n * Merges two table cells. It will ensure that after merging cells with an empty paragraph, the resulting table cell will only have one\n * paragraph. If one of the merged table cells is empty, the merged table cell will have the contents of the non-empty table cell.\n * If both are empty, the merged table cell will have only one empty paragraph.\n */\nfunction mergeTableCells(cellToRemove, cellToExpand, writer) {\n if (!isEmpty(cellToRemove)) {\n if (isEmpty(cellToExpand)) {\n writer.remove(writer.createRangeIn(cellToExpand));\n }\n writer.move(writer.createRangeIn(cellToRemove), writer.createPositionAt(cellToExpand, 'end'));\n }\n // Remove merged table cell.\n writer.remove(cellToRemove);\n}\n/**\n * Checks if the passed table cell contains an empty paragraph.\n */\nfunction isEmpty(tableCell) {\n const firstTableChild = tableCell.getChild(0);\n return tableCell.childCount == 1 && firstTableChild.is('element', 'paragraph') && firstTableChild.isEmpty;\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/commands/removerowcommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\n/**\n * The remove row command.\n *\n * The command is registered by {@link module:table/tableediting~TableEditing} as the `'removeTableRow'` editor command.\n *\n * To remove the row containing the selected cell, execute the command:\n *\n * ```ts\n * editor.execute( 'removeTableRow' );\n * ```\n */\nexport class RemoveRowCommand extends Command {\n /**\n * @inheritDoc\n */\n refresh() {\n const tableUtils = this.editor.plugins.get('TableUtils');\n const selectedCells = tableUtils.getSelectionAffectedTableCells(this.editor.model.document.selection);\n const firstCell = selectedCells[0];\n if (firstCell) {\n const table = firstCell.findAncestor('table');\n const tableRowCount = tableUtils.getRows(table);\n const lastRowIndex = tableRowCount - 1;\n const selectedRowIndexes = tableUtils.getRowIndexes(selectedCells);\n const areAllRowsSelected = selectedRowIndexes.first === 0 && selectedRowIndexes.last === lastRowIndex;\n // Disallow selecting whole table -> delete whole table should be used instead.\n this.isEnabled = !areAllRowsSelected;\n }\n else {\n this.isEnabled = false;\n }\n }\n /**\n * @inheritDoc\n */\n execute() {\n const model = this.editor.model;\n const tableUtils = this.editor.plugins.get('TableUtils');\n const referenceCells = tableUtils.getSelectionAffectedTableCells(model.document.selection);\n const removedRowIndexes = tableUtils.getRowIndexes(referenceCells);\n const firstCell = referenceCells[0];\n const table = firstCell.findAncestor('table');\n const columnIndexToFocus = tableUtils.getCellLocation(firstCell).column;\n model.change(writer => {\n const rowsToRemove = removedRowIndexes.last - removedRowIndexes.first + 1;\n tableUtils.removeRows(table, {\n at: removedRowIndexes.first,\n rows: rowsToRemove\n });\n const cellToFocus = getCellToFocus(table, removedRowIndexes.first, columnIndexToFocus, tableUtils.getRows(table));\n writer.setSelection(writer.createPositionAt(cellToFocus, 0));\n });\n }\n}\n/**\n * Returns a cell that should be focused before removing the row, belonging to the same column as the currently focused cell.\n * - If the row was not the last one, the cell to focus will be in the row that followed it (before removal).\n * - If the row was the last one, the cell to focus will be in the row that preceded it (before removal).\n */\nfunction getCellToFocus(table, removedRowIndex, columnToFocus, tableRowCount) {\n // Don't go beyond last row's index.\n const row = table.getChild(Math.min(removedRowIndex, tableRowCount - 1));\n // Default to first table cell.\n let cellToFocus = row.getChild(0);\n let column = 0;\n for (const tableCell of row.getChildren()) {\n if (column > columnToFocus) {\n return cellToFocus;\n }\n cellToFocus = tableCell;\n column += parseInt(tableCell.getAttribute('colspan') || '1');\n }\n return cellToFocus;\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/commands/removecolumncommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { TableWalker } from '../tablewalker.js';\n/**\n * The remove column command.\n *\n * The command is registered by {@link module:table/tableediting~TableEditing} as the `'removeTableColumn'` editor command.\n *\n * To remove the column containing the selected cell, execute the command:\n *\n * ```ts\n * editor.execute( 'removeTableColumn' );\n * ```\n */\nexport class RemoveColumnCommand extends Command {\n /**\n * @inheritDoc\n */\n refresh() {\n const tableUtils = this.editor.plugins.get('TableUtils');\n const selectedCells = tableUtils.getSelectionAffectedTableCells(this.editor.model.document.selection);\n const firstCell = selectedCells[0];\n if (firstCell) {\n const table = firstCell.findAncestor('table');\n const tableColumnCount = tableUtils.getColumns(table);\n const { first, last } = tableUtils.getColumnIndexes(selectedCells);\n this.isEnabled = last - first < (tableColumnCount - 1);\n }\n else {\n this.isEnabled = false;\n }\n }\n /**\n * @inheritDoc\n */\n execute() {\n const tableUtils = this.editor.plugins.get('TableUtils');\n const [firstCell, lastCell] = getBoundaryCells(this.editor.model.document.selection, tableUtils);\n const table = firstCell.parent.parent;\n // Cache the table before removing or updating colspans.\n const tableMap = [...new TableWalker(table)];\n // Store column indexes of removed columns.\n const removedColumnIndexes = {\n first: tableMap.find(value => value.cell === firstCell).column,\n last: tableMap.find(value => value.cell === lastCell).column\n };\n const cellToFocus = getCellToFocus(tableMap, firstCell, lastCell, removedColumnIndexes);\n this.editor.model.change(writer => {\n const columnsToRemove = removedColumnIndexes.last - removedColumnIndexes.first + 1;\n tableUtils.removeColumns(table, {\n at: removedColumnIndexes.first,\n columns: columnsToRemove\n });\n writer.setSelection(writer.createPositionAt(cellToFocus, 0));\n });\n }\n}\n/**\n * Returns a proper table cell to focus after removing a column.\n * - selection is on last table cell it will return previous cell.\n */\nfunction getCellToFocus(tableMap, firstCell, lastCell, removedColumnIndexes) {\n const colspan = parseInt(lastCell.getAttribute('colspan') || '1');\n // If the table cell is spanned over 2+ columns - it will be truncated so the selection should\n // stay in that cell.\n if (colspan > 1) {\n return lastCell;\n }\n // Normally, look for the cell in the same row that precedes the first cell to put selection there (\"column on the left\").\n // If the deleted column is the first column of the table, there will be no predecessor: use the cell\n // from the column that follows then (also in the same row).\n else if (firstCell.previousSibling || lastCell.nextSibling) {\n return lastCell.nextSibling || firstCell.previousSibling;\n }\n // It can happen that table cells have no siblings in a row, for instance, when there are row spans\n // in the table (in the previous row). Then just look for the closest cell that is in a column\n // that will not be removed to put the selection there.\n else {\n // Look for any cell in a column that precedes the first removed column.\n if (removedColumnIndexes.first) {\n return tableMap.reverse().find(({ column }) => {\n return column < removedColumnIndexes.first;\n }).cell;\n }\n // If the first removed column is the first column of the table, then\n // look for any cell that is in a column that follows the last removed column.\n else {\n return tableMap.reverse().find(({ column }) => {\n return column > removedColumnIndexes.last;\n }).cell;\n }\n }\n}\n/**\n * Returns helper object returning the first and the last cell contained in given selection, based on DOM order.\n */\nfunction getBoundaryCells(selection, tableUtils) {\n const referenceCells = tableUtils.getSelectionAffectedTableCells(selection);\n const firstCell = referenceCells[0];\n const lastCell = referenceCells.pop();\n const returnValue = [firstCell, lastCell];\n return firstCell.isBefore(lastCell) ? returnValue : returnValue.reverse();\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/commands/setheaderrowcommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { getVerticallyOverlappingCells, splitHorizontally } from '../utils/structure.js';\n/**\n * The header row command.\n *\n * The command is registered by {@link module:table/tableediting~TableEditing} as the `'setTableColumnHeader'` editor command.\n *\n * You can make the row containing the selected cell a [header](https://www.w3.org/TR/html50/tabular-data.html#the-th-element) by executing:\n *\n * ```ts\n * editor.execute( 'setTableRowHeader' );\n * ```\n *\n * **Note:** All preceding rows will also become headers. If the current row is already a header, executing this command\n * will make it a regular row back again (including the following rows).\n */\nexport class SetHeaderRowCommand extends Command {\n /**\n * @inheritDoc\n */\n refresh() {\n const tableUtils = this.editor.plugins.get('TableUtils');\n const model = this.editor.model;\n const selectedCells = tableUtils.getSelectionAffectedTableCells(model.document.selection);\n if (selectedCells.length === 0) {\n this.isEnabled = false;\n this.value = false;\n return;\n }\n const table = selectedCells[0].findAncestor('table');\n this.isEnabled = model.schema.checkAttribute(table, 'headingRows');\n this.value = selectedCells.every(cell => this._isInHeading(cell, cell.parent.parent));\n }\n /**\n * Executes the command.\n *\n * When the selection is in a non-header row, the command will set the `headingRows` table attribute to cover that row.\n *\n * When the selection is already in a header row, it will set `headingRows` so the heading section will end before that row.\n *\n * @fires execute\n * @param options.forceValue If set, the command will set (`true`) or unset (`false`) the header rows according to\n * the `forceValue` parameter instead of the current model state.\n */\n execute(options = {}) {\n if (options.forceValue === this.value) {\n return;\n }\n const tableUtils = this.editor.plugins.get('TableUtils');\n const model = this.editor.model;\n const selectedCells = tableUtils.getSelectionAffectedTableCells(model.document.selection);\n const table = selectedCells[0].findAncestor('table');\n const { first, last } = tableUtils.getRowIndexes(selectedCells);\n const headingRowsToSet = this.value ? first : last + 1;\n const currentHeadingRows = table.getAttribute('headingRows') || 0;\n model.change(writer => {\n if (headingRowsToSet) {\n // Changing heading rows requires to check if any of a heading cell is overlapping vertically the table head.\n // Any table cell that has a rowspan attribute > 1 will not exceed the table head so we need to fix it in rows below.\n const startRow = headingRowsToSet > currentHeadingRows ? currentHeadingRows : 0;\n const overlappingCells = getVerticallyOverlappingCells(table, headingRowsToSet, startRow);\n for (const { cell } of overlappingCells) {\n splitHorizontally(cell, headingRowsToSet, writer);\n }\n }\n tableUtils.setHeadingRowsCount(writer, table, headingRowsToSet);\n });\n }\n /**\n * Checks if a table cell is in the heading section.\n */\n _isInHeading(tableCell, table) {\n const headingRows = parseInt(table.getAttribute('headingRows') || '0');\n return !!headingRows && tableCell.parent.index < headingRows;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/commands/setheadercolumncommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { isHeadingColumnCell } from '../utils/common.js';\nimport { getHorizontallyOverlappingCells, splitVertically } from '../utils/structure.js';\n/**\n * The header column command.\n *\n * The command is registered by {@link module:table/tableediting~TableEditing} as the `'setTableColumnHeader'` editor command.\n *\n * You can make the column containing the selected cell a [header](https://www.w3.org/TR/html50/tabular-data.html#the-th-element)\n * by executing:\n *\n * ```ts\n * editor.execute( 'setTableColumnHeader' );\n * ```\n *\n * **Note:** All preceding columns will also become headers. If the current column is already a header, executing this command\n * will make it a regular column back again (including the following columns).\n */\nexport class SetHeaderColumnCommand extends Command {\n /**\n * @inheritDoc\n */\n refresh() {\n const tableUtils = this.editor.plugins.get('TableUtils');\n const model = this.editor.model;\n const selectedCells = tableUtils.getSelectionAffectedTableCells(model.document.selection);\n if (selectedCells.length === 0) {\n this.isEnabled = false;\n this.value = false;\n return;\n }\n const table = selectedCells[0].findAncestor('table');\n this.isEnabled = model.schema.checkAttribute(table, 'headingColumns');\n this.value = selectedCells.every(cell => isHeadingColumnCell(tableUtils, cell));\n }\n /**\n * Executes the command.\n *\n * When the selection is in a non-header column, the command will set the `headingColumns` table attribute to cover that column.\n *\n * When the selection is already in a header column, it will set `headingColumns` so the heading section will end before that column.\n *\n * @fires execute\n * @param options.forceValue If set, the command will set (`true`) or unset (`false`) the header columns according to\n * the `forceValue` parameter instead of the current model state.\n */\n execute(options = {}) {\n if (options.forceValue === this.value) {\n return;\n }\n const tableUtils = this.editor.plugins.get('TableUtils');\n const model = this.editor.model;\n const selectedCells = tableUtils.getSelectionAffectedTableCells(model.document.selection);\n const table = selectedCells[0].findAncestor('table');\n const { first, last } = tableUtils.getColumnIndexes(selectedCells);\n const headingColumnsToSet = this.value ? first : last + 1;\n model.change(writer => {\n if (headingColumnsToSet) {\n // Changing heading columns requires to check if any of a heading cell is overlapping horizontally the table head.\n // Any table cell that has a colspan attribute > 1 will not exceed the table head so we need to fix it in columns before.\n const overlappingCells = getHorizontallyOverlappingCells(table, headingColumnsToSet);\n for (const { cell, column } of overlappingCells) {\n splitVertically(cell, column, headingColumnsToSet, writer);\n }\n }\n tableUtils.setHeadingColumnsCount(writer, table, headingColumnsToSet);\n });\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { global } from 'ckeditor5/src/utils.js';\nimport { COLUMN_WIDTH_PRECISION, COLUMN_MIN_WIDTH_AS_PERCENTAGE, COLUMN_MIN_WIDTH_IN_PIXELS } from './constants.js';\n/**\n * Returns all the inserted or changed table model elements in a given change set. Only the tables\n * with 'columnsWidth' attribute are taken into account. The returned set may be empty.\n *\n * Most notably if an entire table is removed it will not be included in returned set.\n *\n * @internal\n * @param model The model to collect the affected elements from.\n * @returns A set of table model elements.\n */\nexport function getChangedResizedTables(model) {\n const affectedTables = new Set();\n for (const change of model.document.differ.getChanges()) {\n let referencePosition = null;\n // Checks if the particular change from the differ is:\n // - an insertion or removal of a table, a row or a cell,\n // - an attribute change on a table, a row or a cell.\n switch (change.type) {\n case 'insert':\n referencePosition = ['table', 'tableRow', 'tableCell'].includes(change.name) ?\n change.position :\n null;\n break;\n case 'remove':\n // If the whole table is removed, there's no need to update its column widths (#12201).\n referencePosition = ['tableRow', 'tableCell'].includes(change.name) ?\n change.position :\n null;\n break;\n case 'attribute':\n if (change.range.start.nodeAfter) {\n referencePosition = ['table', 'tableRow', 'tableCell'].includes(change.range.start.nodeAfter.name) ?\n change.range.start :\n null;\n }\n break;\n }\n if (!referencePosition) {\n continue;\n }\n const tableNode = (referencePosition.nodeAfter && referencePosition.nodeAfter.is('element', 'table')) ?\n referencePosition.nodeAfter : referencePosition.findAncestor('table');\n // We iterate over the whole table looking for the nested tables that are also affected.\n for (const node of model.createRangeOn(tableNode).getItems()) {\n if (!node.is('element', 'table')) {\n continue;\n }\n if (!getColumnGroupElement(node)) {\n continue;\n }\n affectedTables.add(node);\n }\n }\n return affectedTables;\n}\n/**\n * Calculates the percentage of the minimum column width given in pixels for a given table.\n *\n * @internal\n * @param modelTable A table model element.\n * @param editor The editor instance.\n * @returns The minimal column width in percentage.\n */\nexport function getColumnMinWidthAsPercentage(modelTable, editor) {\n return COLUMN_MIN_WIDTH_IN_PIXELS * 100 / getTableWidthInPixels(modelTable, editor);\n}\n/**\n * Calculates the table width in pixels.\n *\n * @internal\n * @param modelTable A table model element.\n * @param editor The editor instance.\n * @returns The width of the table in pixels.\n */\nexport function getTableWidthInPixels(modelTable, editor) {\n // It is possible for a table to not have a element - see #11878.\n const referenceElement = getChildrenViewElement(modelTable, 'tbody', editor) || getChildrenViewElement(modelTable, 'thead', editor);\n const domReferenceElement = editor.editing.view.domConverter.mapViewToDom(referenceElement);\n return getElementWidthInPixels(domReferenceElement);\n}\n/**\n * Returns the a view element with a given name that is nested directly in a `` element\n * related to a given `modelTable`.\n *\n * @param elementName Name of a view to be looked for, e.g. `'colgroup`', `'thead`'.\n * @returns Matched view or `undefined` otherwise.\n */\nfunction getChildrenViewElement(modelTable, elementName, editor) {\n const viewFigure = editor.editing.mapper.toViewElement(modelTable);\n const viewTable = [...viewFigure.getChildren()]\n .find((node) => node.is('element', 'table'));\n return [...viewTable.getChildren()]\n .find((node) => node.is('element', elementName));\n}\n/**\n * Returns the computed width (in pixels) of the DOM element without padding and borders.\n *\n * @internal\n * @param domElement A DOM element.\n * @returns The width of the DOM element in pixels.\n */\nexport function getElementWidthInPixels(domElement) {\n const styles = global.window.getComputedStyle(domElement);\n // In the 'border-box' box sizing algorithm, the element's width\n // already includes the padding and border width (#12335).\n if (styles.boxSizing === 'border-box') {\n return parseFloat(styles.width) -\n parseFloat(styles.paddingLeft) -\n parseFloat(styles.paddingRight) -\n parseFloat(styles.borderLeftWidth) -\n parseFloat(styles.borderRightWidth);\n }\n else {\n return parseFloat(styles.width);\n }\n}\n/**\n * Returns the column indexes on the left and right edges of a cell. They differ if the cell spans\n * across multiple columns.\n *\n * @internal\n * @param cell A table cell model element.\n * @param tableUtils The Table Utils plugin instance.\n * @returns An object containing the indexes of the left and right edges of the cell.\n */\nexport function getColumnEdgesIndexes(cell, tableUtils) {\n const cellColumnIndex = tableUtils.getCellLocation(cell).column;\n const cellWidth = cell.getAttribute('colspan') || 1;\n return {\n leftEdge: cellColumnIndex,\n rightEdge: cellColumnIndex + cellWidth - 1\n };\n}\n/**\n * Rounds the provided value to a fixed-point number with defined number of digits after the decimal point.\n *\n * @internal\n * @param value A number to be rounded.\n * @returns The rounded number.\n */\nexport function toPrecision(value) {\n const multiplier = Math.pow(10, COLUMN_WIDTH_PRECISION);\n const number = typeof value === 'number' ? value : parseFloat(value);\n return Math.round(number * multiplier) / multiplier;\n}\n/**\n * Clamps the number within the inclusive lower (min) and upper (max) bounds. Returned number is rounded using the\n * {@link ~toPrecision `toPrecision()`} function.\n *\n * @internal\n * @param number A number to be clamped.\n * @param min A lower bound.\n * @param max An upper bound.\n * @returns The clamped number.\n */\nexport function clamp(number, min, max) {\n if (number <= min) {\n return toPrecision(min);\n }\n if (number >= max) {\n return toPrecision(max);\n }\n return toPrecision(number);\n}\n/**\n * Creates an array with defined length and fills all elements with defined value.\n *\n * @internal\n * @param length The length of the array.\n * @param value The value to fill the array with.\n * @returns An array with defined length and filled with defined value.\n */\nexport function createFilledArray(length, value) {\n return Array(length).fill(value);\n}\n/**\n * Sums all array values that can be parsed to a float.\n *\n * @internal\n * @param array An array of numbers.\n * @returns The sum of all array values.\n */\nexport function sumArray(array) {\n return array\n .map(value => typeof value === 'number' ? value : parseFloat(value))\n .filter(value => !Number.isNaN(value))\n .reduce((result, item) => result + item, 0);\n}\n/**\n * Makes sure that the sum of the widths from all columns is 100%. If the sum of all the widths is not equal 100%, all the widths are\n * changed proportionally so that they all sum back to 100%. If there are columns without specified width, the amount remaining\n * after assigning the known widths will be distributed equally between them.\n *\n * @internal\n * @param columnWidths An array of column widths.\n * @returns An array of column widths guaranteed to sum up to 100%.\n */\nexport function normalizeColumnWidths(columnWidths) {\n const widths = columnWidths.map(width => {\n if (width === 'auto' || width === undefined) {\n return 'auto';\n }\n return parseFloat(width.replace('%', ''));\n });\n let normalizedWidths = calculateMissingColumnWidths(widths);\n const totalWidth = sumArray(normalizedWidths);\n if (totalWidth !== 100) {\n normalizedWidths = normalizedWidths\n // Adjust all the columns proportionally.\n .map(width => toPrecision(width * 100 / totalWidth))\n // Due to rounding of numbers it may happen that the sum of the widths of all columns will not be exactly 100%.\n // Therefore, the width of the last column is explicitly adjusted (narrowed or expanded), since all the columns\n // have been proportionally changed already.\n .map((columnWidth, columnIndex, width) => {\n const isLastColumn = columnIndex === width.length - 1;\n if (!isLastColumn) {\n return columnWidth;\n }\n const totalWidth = sumArray(width);\n return toPrecision(columnWidth + 100 - totalWidth);\n });\n }\n return normalizedWidths.map(width => width + '%');\n}\n/**\n * Initializes the column widths by parsing the attribute value and calculating the uninitialized column widths. The special value 'auto'\n * indicates that width for the column must be calculated. The width of such uninitialized column is calculated as follows:\n * - If there is enough free space in the table for all uninitialized columns to have at least the minimum allowed width for all of them,\n * then set this width equally for all uninitialized columns.\n * - Otherwise, just set the minimum allowed width for all uninitialized columns. The sum of all column widths will be greater than 100%,\n * but then it will be adjusted proportionally to 100% in {@link #normalizeColumnWidths `normalizeColumnWidths()`}.\n *\n * @param columnWidths An array of column widths.\n * @returns An array with 'auto' values replaced with calculated widths.\n */\nfunction calculateMissingColumnWidths(columnWidths) {\n const numberOfUninitializedColumns = columnWidths.filter(columnWidth => columnWidth === 'auto').length;\n if (numberOfUninitializedColumns === 0) {\n return columnWidths.map(columnWidth => toPrecision(columnWidth));\n }\n const totalWidthOfInitializedColumns = sumArray(columnWidths);\n const widthForUninitializedColumn = Math.max((100 - totalWidthOfInitializedColumns) / numberOfUninitializedColumns, COLUMN_MIN_WIDTH_AS_PERCENTAGE);\n return columnWidths\n .map(columnWidth => columnWidth === 'auto' ? widthForUninitializedColumn : columnWidth)\n .map(columnWidth => toPrecision(columnWidth));\n}\n/**\n * Calculates the total horizontal space taken by the cell. That includes:\n * * width,\n * * left and red padding,\n * * border width.\n *\n * @internal\n * @param domCell A DOM cell element.\n * @returns Width in pixels without `px` at the end.\n */\nexport function getDomCellOuterWidth(domCell) {\n const styles = global.window.getComputedStyle(domCell);\n // In the 'border-box' box sizing algorithm, the element's width\n // already includes the padding and border width (#12335).\n if (styles.boxSizing === 'border-box') {\n return parseInt(styles.width);\n }\n else {\n return parseFloat(styles.width) +\n parseFloat(styles.paddingLeft) +\n parseFloat(styles.paddingRight) +\n parseFloat(styles.borderWidth);\n }\n}\n/**\n * Updates column elements to match columns widths.\n *\n * @internal\n * @param columns\n * @param tableColumnGroup\n * @param normalizedWidths\n * @param writer\n */\nexport function updateColumnElements(columns, tableColumnGroup, normalizedWidths, writer) {\n for (let i = 0; i < Math.max(normalizedWidths.length, columns.length); i++) {\n const column = columns[i];\n const columnWidth = normalizedWidths[i];\n if (!columnWidth) {\n // Number of `` elements exceeds actual number of columns.\n writer.remove(column);\n }\n else if (!column) {\n // There is fewer `` elements than actual columns.\n writer.appendElement('tableColumn', { columnWidth }, tableColumnGroup);\n }\n else {\n // Update column width.\n writer.setAttribute('columnWidth', columnWidth, column);\n }\n }\n}\n/**\n * Returns a 'tableColumnGroup' element from the 'table'.\n *\n * @internal\n * @param element A 'table' or 'tableColumnGroup' element.\n * @returns A 'tableColumnGroup' element.\n */\nexport function getColumnGroupElement(element) {\n if (element.is('element', 'tableColumnGroup')) {\n return element;\n }\n const children = element.getChildren();\n return Array\n .from(children)\n .find(element => element.is('element', 'tableColumnGroup'));\n}\n/**\n * Returns an array of 'tableColumn' elements. It may be empty if there's no `tableColumnGroup` element.\n *\n * @internal\n * @param element A 'table' or 'tableColumnGroup' element.\n * @returns An array of 'tableColumn' elements.\n */\nexport function getTableColumnElements(element) {\n const columnGroupElement = getColumnGroupElement(element);\n if (!columnGroupElement) {\n return [];\n }\n return Array.from(columnGroupElement.getChildren());\n}\n/**\n * Returns an array of table column widths.\n *\n * @internal\n * @param element A 'table' or 'tableColumnGroup' element.\n * @returns An array of table column widths.\n */\nexport function getTableColumnsWidths(element) {\n return getTableColumnElements(element).map(column => column.getAttribute('columnWidth'));\n}\n/**\n * Translates the `colSpan` model attribute into additional column widths and returns the resulting array.\n *\n * @internal\n * @param element A 'table' or 'tableColumnGroup' element.\n * @param writer A writer instance.\n * @returns An array of table column widths.\n */\nexport function translateColSpanAttribute(element, writer) {\n const tableColumnElements = getTableColumnElements(element);\n return tableColumnElements.reduce((acc, element) => {\n const columnWidth = element.getAttribute('columnWidth');\n const colSpan = element.getAttribute('colSpan');\n if (!colSpan) {\n acc.push(columnWidth);\n return acc;\n }\n // Translate the `colSpan` model attribute on to the proper number of column widths\n // and remove it from the element.\n // See https://github.com/ckeditor/ckeditor5/issues/14521#issuecomment-1662102889 for more details.\n for (let i = 0; i < colSpan; i++) {\n acc.push(columnWidth);\n }\n writer.removeAttribute('colSpan', element);\n return acc;\n }, []);\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tableutils\n */\nimport { CKEditorError } from 'ckeditor5/src/utils.js';\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { TableWalker } from './tablewalker.js';\nimport { createEmptyTableCell, updateNumericAttribute, isEntireCellsLineHeader, isTableCellTypeEnabled } from './utils/common.js';\nimport { removeEmptyColumns, removeEmptyRows } from './utils/structure.js';\nimport { getTableColumnElements } from './tablecolumnresize/utils.js';\n/**\n * The table utilities plugin.\n */\nexport class TableUtils extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TableUtils';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n this.decorate('insertColumns');\n this.decorate('insertRows');\n }\n /**\n * Returns the table cell location as an object with table row and table column indexes.\n *\n * For instance, in the table below:\n *\n * 0 1 2 3\n * +---+---+---+---+\n * 0 | a | b | c |\n * + + +---+\n * 1 | | | d |\n * +---+---+ +---+\n * 2 | e | | f |\n * +---+---+---+---+\n *\n * the method will return:\n *\n * ```ts\n * const cellA = table.getNodeByPath( [ 0, 0 ] );\n * editor.plugins.get( 'TableUtils' ).getCellLocation( cellA );\n * // will return { row: 0, column: 0 }\n *\n * const cellD = table.getNodeByPath( [ 1, 0 ] );\n * editor.plugins.get( 'TableUtils' ).getCellLocation( cellD );\n * // will return { row: 1, column: 3 }\n * ```\n *\n * @returns Returns a `{row, column}` object.\n */\n getCellLocation(tableCell) {\n const tableRow = tableCell.parent;\n const table = tableRow.parent;\n const rowIndex = table.getChildIndex(tableRow);\n const tableWalker = new TableWalker(table, { row: rowIndex });\n for (const { cell, row, column } of tableWalker) {\n if (cell === tableCell) {\n return { row, column };\n }\n }\n // Should be unreachable code.\n /* istanbul ignore next -- @preserve */\n return undefined;\n }\n /**\n * Creates an empty table with a proper structure. The table needs to be inserted into the model,\n * for example, by using the {@link module:engine/model/model~Model#insertContent} function.\n *\n * ```ts\n * model.change( ( writer ) => {\n * // Create a table of 2 rows and 7 columns:\n * const table = tableUtils.createTable( writer, { rows: 2, columns: 7 } );\n *\n * // Insert a table to the model at the best position taking the current selection:\n * model.insertContent( table );\n * }\n * ```\n *\n * @param writer The model writer.\n * @param options.rows The number of rows to create. Default value is 2.\n * @param options.columns The number of columns to create. Default value is 2.\n * @param options.headingRows The number of heading rows. Default value is 0.\n * @param options.headingColumns The number of heading columns. Default value is 0.\n * @returns The created table element.\n */\n createTable(writer, options) {\n const table = writer.createElement('table');\n const rows = options.rows || 2;\n const columns = options.columns || 2;\n createEmptyRows(writer, table, 0, rows, columns);\n if (options.headingRows) {\n this.setHeadingRowsCount(writer, table, Math.min(options.headingRows, rows));\n }\n if (options.headingColumns) {\n this.setHeadingColumnsCount(writer, table, Math.min(options.headingColumns, columns));\n }\n return table;\n }\n /**\n * Inserts rows into a table.\n *\n * ```ts\n * editor.plugins.get( 'TableUtils' ).insertRows( table, { at: 1, rows: 2 } );\n * ```\n *\n * Assuming the table on the left, the above code will transform it to the table on the right:\n *\n * row index\n * 0 +---+---+---+ `at` = 1, +---+---+---+ 0\n * | a | b | c | `rows` = 2, | a | b | c |\n * 1 + +---+---+ <-- insert here + +---+---+ 1\n * | | d | e | | | | |\n * 2 + +---+---+ will give: + +---+---+ 2\n * | | f | g | | | | |\n * 3 +---+---+---+ + +---+---+ 3\n * | | d | e |\n * + +---+---+ 4\n * + + f | g |\n * +---+---+---+ 5\n *\n * @param table The table model element where the rows will be inserted.\n * @param options.at The row index at which the rows will be inserted. Default value is 0.\n * @param options.rows The number of rows to insert. Default value is 1.\n * @param options.copyStructureFromAbove The flag for copying row structure. Note that\n * the row structure will not be copied if this option is not provided.\n */\n insertRows(table, options = {}) {\n const model = this.editor.model;\n const insertAt = options.at || 0;\n const rowsToInsert = options.rows || 1;\n const isCopyStructure = options.copyStructureFromAbove !== undefined;\n const copyStructureFrom = options.copyStructureFromAbove ? insertAt - 1 : insertAt;\n const cellTypeEnabled = isTableCellTypeEnabled(this.editor);\n const rows = this.getRows(table);\n const columns = this.getColumns(table);\n if (insertAt > rows) {\n /**\n * The `options.at` points at a row position that does not exist.\n *\n * @error tableutils-insertrows-insert-out-of-range\n */\n throw new CKEditorError('tableutils-insertrows-insert-out-of-range', this, { options });\n }\n model.change(writer => {\n let headingRows = table.getAttribute('headingRows') || 0;\n const headingColumns = table.getAttribute('headingColumns') || 0;\n // Inserting rows inside heading section requires to update `headingRows` attribute as the heading section will grow.\n if (headingRows > insertAt) {\n headingRows += rowsToInsert;\n this.setHeadingRowsCount(writer, table, headingRows, {\n shallow: true\n });\n }\n // Inserting at the end or at the beginning of a table doesn't require to calculate anything special.\n if (!isCopyStructure && (insertAt === 0 || insertAt === rows)) {\n const rows = createEmptyRows(writer, table, insertAt, rowsToInsert, columns);\n if (cellTypeEnabled) {\n for (let rowOffset = 0; rowOffset < rows.length; rowOffset++) {\n const row = rows[rowOffset];\n for (let columnIndex = 0; columnIndex < columns; columnIndex++) {\n const cell = row[columnIndex];\n if (insertAt + rowOffset < headingRows || columnIndex < headingColumns) {\n writer.setAttribute('tableCellType', 'header', cell);\n }\n }\n }\n }\n return;\n }\n // Iterate over all the rows above the inserted rows in order to check for the row-spanned cells.\n const walkerEndRow = isCopyStructure ? Math.max(insertAt, copyStructureFrom) : insertAt;\n const tableIterator = new TableWalker(table, { endRow: walkerEndRow });\n // Store spans of the reference row to reproduce it's structure. This array is column number indexed.\n const rowColSpansMap = new Array(columns).fill(1);\n for (const { row, column, cellHeight, cellWidth, cell } of tableIterator) {\n const lastCellRow = row + cellHeight - 1;\n const isOverlappingInsertedRow = row < insertAt && insertAt <= lastCellRow;\n const isReferenceRow = row <= copyStructureFrom && copyStructureFrom <= lastCellRow;\n // If the cell is row-spanned and overlaps the inserted row, then reserve space for it in the row map.\n if (isOverlappingInsertedRow) {\n // This cell overlaps the inserted rows so we need to expand it further.\n writer.setAttribute('rowspan', cellHeight + rowsToInsert, cell);\n // Mark this cell with negative number to indicate how many cells should be skipped when adding the new cells.\n rowColSpansMap[column] = -cellWidth;\n }\n // Store the colspan from reference row.\n else if (isCopyStructure && isReferenceRow) {\n rowColSpansMap[column] = cellWidth;\n }\n }\n for (let rowIndex = 0; rowIndex < rowsToInsert; rowIndex++) {\n const tableRow = writer.createElement('tableRow');\n writer.insert(tableRow, table, insertAt);\n for (let cellIndex = 0; cellIndex < rowColSpansMap.length; cellIndex++) {\n const colspan = rowColSpansMap[cellIndex];\n const insertPosition = writer.createPositionAt(tableRow, 'end');\n // Insert the empty cell only if this slot is not row-spanned from any other cell.\n if (colspan > 0) {\n const insertedCells = createEmptyTableCell(writer, insertPosition, colspan > 1 ? { colspan } : undefined);\n // If we insert row in heading section, set proper cell type.\n if (cellTypeEnabled && (insertAt + rowIndex < headingRows || cellIndex < headingColumns)) {\n writer.setAttribute('tableCellType', 'header', insertedCells);\n }\n }\n // Skip the col-spanned slots, there won't be any cells.\n cellIndex += Math.abs(colspan) - 1;\n }\n }\n });\n }\n /**\n * Inserts columns into a table.\n *\n * ```ts\n * editor.plugins.get( 'TableUtils' ).insertColumns( table, { at: 1, columns: 2 } );\n * ```\n *\n * Assuming the table on the left, the above code will transform it to the table on the right:\n *\n * 0 1 2 3 0 1 2 3 4 5\n * +---+---+---+ +---+---+---+---+---+\n * | a | b | | a | b |\n * + +---+ + +---+\n * | | c | | | c |\n * +---+---+---+ will give: +---+---+---+---+---+\n * | d | e | f | | d | | | e | f |\n * +---+ +---+ +---+---+---+ +---+\n * | g | | h | | g | | | | h |\n * +---+---+---+ +---+---+---+---+---+\n * | i | | i |\n * +---+---+---+ +---+---+---+---+---+\n * ^---- insert here, `at` = 1, `columns` = 2\n *\n * @param table The table model element where the columns will be inserted.\n * @param options.at The column index at which the columns will be inserted. Default value is 0.\n * @param options.columns The number of columns to insert. Default value is 1.\n */\n insertColumns(table, options = {}) {\n const model = this.editor.model;\n const insertAt = options.at || 0;\n const columnsToInsert = options.columns || 1;\n const cellTypeEnabled = isTableCellTypeEnabled(this.editor);\n model.change(writer => {\n const headingRows = table.getAttribute('headingRows') || 0;\n let headingColumns = table.getAttribute('headingColumns');\n // Inserting columns inside heading section requires to update `headingColumns` attribute as the heading section will grow.\n if (insertAt < headingColumns) {\n headingColumns += columnsToInsert;\n this.setHeadingColumnsCount(writer, table, headingColumns, {\n shallow: true\n });\n }\n const tableColumns = this.getColumns(table);\n // Inserting at the end and at the beginning of a table doesn't require to calculate anything special.\n if (insertAt === 0 || tableColumns === insertAt) {\n let rowIndex = 0;\n for (const tableRow of table.getChildren()) {\n // Ignore non-row elements inside the table (e.g. caption).\n if (!tableRow.is('element', 'tableRow')) {\n continue;\n }\n const insertedCells = createCells(columnsToInsert, writer, writer.createPositionAt(tableRow, insertAt ? 'end' : 0));\n if (cellTypeEnabled) {\n // If we insert column in heading section, set proper cell type.\n for (let columnOffset = 0; columnOffset < insertedCells.length; columnOffset++) {\n if (insertAt + columnOffset < headingColumns || rowIndex < headingRows) {\n writer.setAttribute('tableCellType', 'header', insertedCells[columnOffset]);\n }\n }\n }\n rowIndex++;\n }\n return;\n }\n const tableWalker = new TableWalker(table, { column: insertAt, includeAllSlots: true });\n for (const tableSlot of tableWalker) {\n const { row, cell, cellAnchorColumn, cellAnchorRow, cellWidth, cellHeight } = tableSlot;\n // When iterating over column the table walker outputs either:\n // - cells at given column index (cell \"e\" from method docs),\n // - spanned columns (spanned cell from row between cells \"g\" and \"h\" - spanned by \"e\", only if `includeAllSlots: true`),\n // - or a cell from the same row which spans over this column (cell \"a\").\n if (cellAnchorColumn < insertAt) {\n // If cell is anchored in previous column, it is a cell that spans over an inserted column (cell \"a\" & \"i\").\n // For such cells expand them by a number of columns inserted.\n writer.setAttribute('colspan', cellWidth + columnsToInsert, cell);\n // This cell will overlap cells in rows below so skip them (because of `includeAllSlots` option) - (cell \"a\")\n const lastCellRow = cellAnchorRow + cellHeight - 1;\n for (let i = row; i <= lastCellRow; i++) {\n tableWalker.skipRow(i);\n }\n }\n else {\n // It's either cell at this column index or spanned cell by a row-spanned cell from row above.\n // In table above it's cell \"e\" and a spanned position from row below (empty cell between cells \"g\" and \"h\")\n const insertedCells = createCells(columnsToInsert, writer, tableSlot.getPositionBefore());\n // If we insert column in heading section, set proper cell type.\n if (cellTypeEnabled) {\n for (let columnOffset = 0; columnOffset < insertedCells.length; columnOffset++) {\n if (insertAt + columnOffset < headingColumns || row < headingRows) {\n writer.setAttribute('tableCellType', 'header', insertedCells[columnOffset]);\n }\n }\n }\n }\n }\n });\n }\n /**\n * Removes rows from the given `table`.\n *\n * This method re-calculates the table geometry including `rowspan` attribute of table cells overlapping removed rows\n * and table headings values.\n *\n * ```ts\n * editor.plugins.get( 'TableUtils' ).removeRows( table, { at: 1, rows: 2 } );\n * ```\n *\n * Executing the above code in the context of the table on the left will transform its structure as presented on the right:\n *\n * row index\n * ┌───┬───┬───┐ `at` = 1 ┌───┬───┬───┐\n * 0 │ a │ b │ c │ `rows` = 2 │ a │ b │ c │ 0\n * │ ├───┼───┤ │ ├───┼───┤\n * 1 │ │ d │ e │ <-- remove from here │ │ d │ g │ 1\n * │ │ ├───┤ will give: ├───┼───┼───┤\n * 2 │ │ │ f │ │ h │ i │ j │ 2\n * │ │ ├───┤ └───┴───┴───┘\n * 3 │ │ │ g │\n * ├───┼───┼───┤\n * 4 │ h │ i │ j │\n * └───┴───┴───┘\n *\n * @param options.at The row index at which the removing rows will start.\n * @param options.rows The number of rows to remove. Default value is 1.\n */\n removeRows(table, options) {\n const model = this.editor.model;\n const rowsToRemove = options.rows || 1;\n const rowCount = this.getRows(table);\n const first = options.at;\n const last = first + rowsToRemove - 1;\n if (last > rowCount - 1) {\n /**\n * The `options.at` param must point at existing row and `options.rows` must not exceed the rows in the table.\n *\n * @error tableutils-removerows-row-index-out-of-range\n */\n throw new CKEditorError('tableutils-removerows-row-index-out-of-range', this, { table, options });\n }\n model.change(writer => {\n const indexesObject = { first, last };\n // Removing rows from the table require that most calculations to be done prior to changing table structure.\n // Preparations must be done in the same enqueueChange callback to use the current table structure.\n // 1. Preparation - get row-spanned cells that have to be modified after removing rows.\n const { cellsToMove, cellsToTrim } = getCellsToMoveAndTrimOnRemoveRow(table, indexesObject);\n // 2. Execution\n // 2a. Move cells from removed rows that extends over a removed section - must be done before removing rows.\n // This will fill any gaps in a rows below that previously were empty because of row-spanned cells.\n if (cellsToMove.size) {\n const rowAfterRemovedSection = last + 1;\n moveCellsToRow(table, rowAfterRemovedSection, cellsToMove, writer);\n }\n // 2b. Remove all required rows.\n for (let i = last; i >= first; i--) {\n writer.remove(table.getChild(i));\n }\n // 2c. Update cells from rows above that overlap removed section. Similar to step 2 but does not involve moving cells.\n for (const { rowspan, cell } of cellsToTrim) {\n updateNumericAttribute('rowspan', rowspan, cell, writer);\n }\n // 2d. Adjust heading rows if removed rows were in a heading section.\n updateHeadingRows(table, indexesObject, writer);\n // 2e. Remove empty columns (without anchored cells) if there are any.\n if (!removeEmptyColumns(table, this)) {\n // If there wasn't any empty columns then we still need to check if this wasn't called\n // because of cleaning empty rows and we only removed one of them.\n removeEmptyRows(table, this);\n }\n // 3. If next rows are entirely header, adjust heading rows count.\n if (isTableCellTypeEnabled(this.editor)) {\n let headingRows = table.getAttribute('headingRows') || 0;\n const totalRows = this.getRows(table);\n while (headingRows < totalRows && isEntireCellsLineHeader({ table, row: headingRows })) {\n headingRows++;\n }\n this.setHeadingRowsCount(writer, table, headingRows, { shallow: true });\n }\n });\n }\n /**\n * Removes columns from the given `table`.\n *\n * This method re-calculates the table geometry including the `colspan` attribute of table cells overlapping removed columns\n * and table headings values.\n *\n * ```ts\n * editor.plugins.get( 'TableUtils' ).removeColumns( table, { at: 1, columns: 2 } );\n * ```\n *\n * Executing the above code in the context of the table on the left will transform its structure as presented on the right:\n *\n * 0 1 2 3 4 0 1 2\n * ┌───────────────┬───┐ ┌───────┬───┐\n * │ a │ b │ │ a │ b │\n * │ ├───┤ │ ├───┤\n * │ │ c │ │ │ c │\n * ├───┬───┬───┬───┼───┤ will give: ├───┬───┼───┤\n * │ d │ e │ f │ g │ h │ │ d │ g │ h │\n * ├───┼───┼───┤ ├───┤ ├───┤ ├───┤\n * │ i │ j │ k │ │ l │ │ i │ │ l │\n * ├───┴───┴───┴───┴───┤ ├───┴───┴───┤\n * │ m │ │ m │\n * └───────────────────┘ └───────────┘\n * ^---- remove from here, `at` = 1, `columns` = 2\n *\n * @param options.at The row index at which the removing columns will start.\n * @param options.columns The number of columns to remove.\n */\n removeColumns(table, options) {\n const model = this.editor.model;\n const first = options.at;\n const columnsToRemove = options.columns || 1;\n const last = options.at + columnsToRemove - 1;\n model.change(writer => {\n adjustHeadingColumns(table, { first, last }, writer);\n const tableColumns = getTableColumnElements(table);\n for (let removedColumnIndex = last; removedColumnIndex >= first; removedColumnIndex--) {\n for (const { cell, column, cellWidth } of [...new TableWalker(table)]) {\n // If colspaned cell overlaps removed column decrease its span.\n if (column <= removedColumnIndex && cellWidth > 1 && column + cellWidth > removedColumnIndex) {\n updateNumericAttribute('colspan', cellWidth - 1, cell, writer);\n }\n else if (column === removedColumnIndex) {\n // The cell in removed column has colspan of 1.\n writer.remove(cell);\n }\n }\n // If table has `tableColumn` elements, we need to update it manually.\n // See https://github.com/ckeditor/ckeditor5/issues/14521#issuecomment-1662102889 for details.\n if (tableColumns[removedColumnIndex]) {\n // If the removed column is the first one then we need to add its width to the next column.\n // Otherwise we add it to the previous column.\n const adjacentColumn = removedColumnIndex === 0 ? tableColumns[1] : tableColumns[removedColumnIndex - 1];\n const removedColumnWidth = parseFloat(tableColumns[removedColumnIndex].getAttribute('columnWidth'));\n const adjacentColumnWidth = parseFloat(adjacentColumn.getAttribute('columnWidth'));\n writer.remove(tableColumns[removedColumnIndex]);\n // Add the removed column width (in %) to the adjacent column.\n writer.setAttribute('columnWidth', removedColumnWidth + adjacentColumnWidth + '%', adjacentColumn);\n }\n }\n // Remove empty rows that could appear after removing columns.\n if (!removeEmptyRows(table, this)) {\n // If there wasn't any empty rows then we still need to check if this wasn't called\n // because of cleaning empty columns and we only removed one of them.\n removeEmptyColumns(table, this);\n }\n // If next columns are entirely header, adjust heading columns count.\n if (isTableCellTypeEnabled(this.editor)) {\n let headingColumns = table.getAttribute('headingColumns') || 0;\n const totalColumns = this.getColumns(table);\n while (headingColumns < totalColumns && isEntireCellsLineHeader({ table, column: headingColumns })) {\n headingColumns++;\n }\n this.setHeadingColumnsCount(writer, table, headingColumns, { shallow: true });\n }\n });\n }\n /**\n * Divides a table cell vertically into several ones.\n *\n * The cell will be visually split into more cells by updating colspans of other cells in a column\n * and inserting cells (columns) after that cell.\n *\n * In the table below, if cell \"a\" is split into 3 cells:\n *\n * +---+---+---+\n * | a | b | c |\n * +---+---+---+\n * | d | e | f |\n * +---+---+---+\n *\n * it will result in the table below:\n *\n * +---+---+---+---+---+\n * | a | | | b | c |\n * +---+---+---+---+---+\n * | d | e | f |\n * +---+---+---+---+---+\n *\n * So cell \"d\" will get its `colspan` updated to `3` and 2 cells will be added (2 columns will be created).\n *\n * Splitting a cell that already has a `colspan` attribute set will distribute the cell `colspan` evenly and the remainder\n * will be left to the original cell:\n *\n * +---+---+---+\n * | a |\n * +---+---+---+\n * | b | c | d |\n * +---+---+---+\n *\n * Splitting cell \"a\" with `colspan=3` into 2 cells will create 1 cell with a `colspan=a` and cell \"a\" that will have `colspan=2`:\n *\n * +---+---+---+\n * | a | |\n * +---+---+---+\n * | b | c | d |\n * +---+---+---+\n */\n splitCellVertically(tableCell, numberOfCells = 2) {\n const model = this.editor.model;\n const tableRow = tableCell.parent;\n const table = tableRow.parent;\n const rowspan = parseInt(tableCell.getAttribute('rowspan') || '1');\n const colspan = parseInt(tableCell.getAttribute('colspan') || '1');\n model.change(writer => {\n // First check - the cell spans over multiple rows so before doing anything else just split this cell.\n if (colspan > 1) {\n // Get spans of new (inserted) cells and span to update of split cell.\n const { newCellsSpan, updatedSpan } = breakSpanEvenly(colspan, numberOfCells);\n updateNumericAttribute('colspan', updatedSpan, tableCell, writer);\n // Each inserted cell will have the same attributes:\n const newCellsAttributes = {};\n // Do not store default value in the model.\n if (newCellsSpan > 1) {\n newCellsAttributes.colspan = newCellsSpan;\n }\n // Copy rowspan of split cell.\n if (rowspan > 1) {\n newCellsAttributes.rowspan = rowspan;\n }\n const cellsToInsert = colspan > numberOfCells ? numberOfCells - 1 : colspan - 1;\n createCells(cellsToInsert, writer, writer.createPositionAfter(tableCell), newCellsAttributes);\n }\n // Second check - the cell has colspan of 1 or we need to create more cells then the currently one spans over.\n if (colspan < numberOfCells) {\n const cellsToInsert = numberOfCells - colspan;\n // First step: expand cells on the same column as split cell.\n const tableMap = [...new TableWalker(table)];\n // Get the column index of split cell.\n const { column: splitCellColumn } = tableMap.find(({ cell }) => cell === tableCell);\n // Find cells which needs to be expanded vertically - those on the same column or those that spans over split cell's column.\n const cellsToUpdate = tableMap.filter(({ cell, cellWidth, column }) => {\n const isOnSameColumn = cell !== tableCell && column === splitCellColumn;\n const spansOverColumn = (column < splitCellColumn && column + cellWidth > splitCellColumn);\n return isOnSameColumn || spansOverColumn;\n });\n // Expand cells vertically.\n for (const { cell, cellWidth } of cellsToUpdate) {\n writer.setAttribute('colspan', cellWidth + cellsToInsert, cell);\n }\n // Second step: create columns after split cell.\n // Each inserted cell will have the same attributes:\n const newCellsAttributes = {};\n // Do not store default value in the model.\n // Copy rowspan of split cell.\n if (rowspan > 1) {\n newCellsAttributes.rowspan = rowspan;\n }\n createCells(cellsToInsert, writer, writer.createPositionAfter(tableCell), newCellsAttributes);\n const headingColumns = table.getAttribute('headingColumns') || 0;\n // Update heading section if split cell is in heading section.\n if (headingColumns > splitCellColumn) {\n updateNumericAttribute('headingColumns', headingColumns + cellsToInsert, table, writer);\n }\n }\n });\n }\n /**\n * Divides a table cell horizontally into several ones.\n *\n * The cell will be visually split into more cells by updating rowspans of other cells in the row and inserting rows with a single cell\n * below.\n *\n * If in the table below cell \"b\" is split into 3 cells:\n *\n * +---+---+---+\n * | a | b | c |\n * +---+---+---+\n * | d | e | f |\n * +---+---+---+\n *\n * It will result in the table below:\n *\n * +---+---+---+\n * | a | b | c |\n * + +---+ +\n * | | | |\n * + +---+ +\n * | | | |\n * +---+---+---+\n * | d | e | f |\n * +---+---+---+\n *\n * So cells \"a\" and \"b\" will get their `rowspan` updated to `3` and 2 rows with a single cell will be added.\n *\n * Splitting a cell that already has a `rowspan` attribute set will distribute the cell `rowspan` evenly and the remainder\n * will be left to the original cell:\n *\n * +---+---+---+\n * | a | b | c |\n * + +---+---+\n * | | d | e |\n * + +---+---+\n * | | f | g |\n * + +---+---+\n * | | h | i |\n * +---+---+---+\n *\n * Splitting cell \"a\" with `rowspan=4` into 3 cells will create 2 cells with a `rowspan=1` and cell \"a\" will have `rowspan=2`:\n *\n * +---+---+---+\n * | a | b | c |\n * + +---+---+\n * | | d | e |\n * +---+---+---+\n * | | f | g |\n * +---+---+---+\n * | | h | i |\n * +---+---+---+\n */\n splitCellHorizontally(tableCell, numberOfCells = 2) {\n const model = this.editor.model;\n const tableRow = tableCell.parent;\n const table = tableRow.parent;\n const splitCellRow = table.getChildIndex(tableRow);\n const rowspan = parseInt(tableCell.getAttribute('rowspan') || '1');\n const colspan = parseInt(tableCell.getAttribute('colspan') || '1');\n model.change(writer => {\n // First check - the cell spans over multiple rows so before doing anything else just split this cell.\n if (rowspan > 1) {\n // Cache table map before updating table.\n const tableMap = [...new TableWalker(table, {\n startRow: splitCellRow,\n endRow: splitCellRow + rowspan - 1,\n includeAllSlots: true\n })];\n // Get spans of new (inserted) cells and span to update of split cell.\n const { newCellsSpan, updatedSpan } = breakSpanEvenly(rowspan, numberOfCells);\n updateNumericAttribute('rowspan', updatedSpan, tableCell, writer);\n const { column: cellColumn } = tableMap.find(({ cell }) => cell === tableCell);\n // Each inserted cell will have the same attributes:\n const newCellsAttributes = {};\n // Do not store default value in the model.\n if (newCellsSpan > 1) {\n newCellsAttributes.rowspan = newCellsSpan;\n }\n // Copy colspan of split cell.\n if (colspan > 1) {\n newCellsAttributes.colspan = colspan;\n }\n // Accumulator that stores distance from the last inserted cell span.\n // It helps with evenly splitting larger cell spans (for example 10 cells collapsing into 3 cells).\n // We split these cells into 3, 3, 4 cells and we have to call `createCells` only when distance between\n // these cells is equal or greater than the new cells span size.\n let distanceFromLastCellSpan = 0;\n for (const tableSlot of tableMap) {\n const { column, row } = tableSlot;\n // As both newly created cells and the split cell might have rowspan,\n // the insertion of new cells must go to appropriate rows:\n //\n // 1. It's a row after split cell + it's height.\n const isAfterSplitCell = row >= splitCellRow + updatedSpan;\n // 2. Is on the same column.\n const isOnSameColumn = column === cellColumn;\n // Reset distance from the last cell span if we are on the same column and we exceeded the new cells span size.\n if (distanceFromLastCellSpan >= newCellsSpan && isOnSameColumn) {\n distanceFromLastCellSpan = 0;\n }\n if (isAfterSplitCell && isOnSameColumn) {\n // Create new cells only if the distance from the last cell span is equal or greater than the new cells span.\n if (!distanceFromLastCellSpan) {\n createCells(1, writer, tableSlot.getPositionBefore(), newCellsAttributes);\n }\n // Increase the distance from the last cell span.\n distanceFromLastCellSpan++;\n }\n }\n }\n // Second check - the cell has rowspan of 1 or we need to create more cells than the current cell spans over.\n if (rowspan < numberOfCells) {\n // We already split the cell in check one so here we split to the remaining number of cells only.\n const cellsToInsert = numberOfCells - rowspan;\n // This check is needed since we need to check if there are any cells from previous rows than spans over this cell's row.\n const tableMap = [...new TableWalker(table, { startRow: 0, endRow: splitCellRow })];\n // First step: expand cells.\n for (const { cell, cellHeight, row } of tableMap) {\n // Expand rowspan of cells that are either:\n // - on the same row as current cell,\n // - or are below split cell row and overlaps that row.\n if (cell !== tableCell && row + cellHeight > splitCellRow) {\n const rowspanToSet = cellHeight + cellsToInsert;\n writer.setAttribute('rowspan', rowspanToSet, cell);\n }\n }\n // Second step: create rows with single cell below split cell.\n const newCellsAttributes = {};\n // Copy colspan of split cell.\n if (colspan > 1) {\n newCellsAttributes.colspan = colspan;\n }\n createEmptyRows(writer, table, splitCellRow + 1, cellsToInsert, 1, newCellsAttributes);\n // Update heading section if split cell is in heading section.\n const headingRows = table.getAttribute('headingRows') || 0;\n if (headingRows > splitCellRow) {\n updateNumericAttribute('headingRows', headingRows + cellsToInsert, table, writer);\n }\n }\n });\n }\n /**\n * Returns the number of columns for a given table.\n *\n * ```ts\n * editor.plugins.get( 'TableUtils' ).getColumns( table );\n * ```\n *\n * @param table The table to analyze.\n */\n getColumns(table) {\n // Analyze first row only as all the rows should have the same width.\n // Using the first row without checking if it's a tableRow because we expect\n // that table will have only tableRow model elements at the beginning.\n const row = table.getChild(0);\n return [...row.getChildren()]\n // $marker elements can also be children of a row too (when TrackChanges is on). Don't include them in the count.\n .filter(node => node.is('element', 'tableCell'))\n .reduce((columns, row) => {\n const columnWidth = parseInt(row.getAttribute('colspan') || '1');\n return columns + columnWidth;\n }, 0);\n }\n /**\n * Returns the number of rows for a given table. Any other element present in the table model is omitted.\n *\n * ```ts\n * editor.plugins.get( 'TableUtils' ).getRows( table );\n * ```\n *\n * @param table The table to analyze.\n */\n getRows(table) {\n // Rowspan not included due to #6427.\n return Array.from(table.getChildren())\n .reduce((rowCount, child) => child.is('element', 'tableRow') ? rowCount + 1 : rowCount, 0);\n }\n /**\n * Creates an instance of the table walker.\n *\n * The table walker iterates internally by traversing the table from row index = 0 and column index = 0.\n * It walks row by row and column by column in order to output values defined in the options.\n * By default it will output only the locations that are occupied by a cell. To include also spanned rows and columns,\n * pass the `includeAllSlots` option.\n *\n * @internal\n * @param table A table over which the walker iterates.\n * @param options An object with configuration.\n */\n createTableWalker(table, options = {}) {\n return new TableWalker(table, options);\n }\n /**\n * Returns all model table cells that are fully selected (from the outside)\n * within the provided model selection's ranges.\n *\n * To obtain the cells selected from the inside, use\n * {@link #getTableCellsContainingSelection}.\n */\n getSelectedTableCells(selection) {\n const cells = [];\n for (const range of this.sortRanges(selection.getRanges())) {\n const element = range.getContainedElement();\n if (element && element.is('element', 'tableCell')) {\n cells.push(element);\n }\n }\n return cells;\n }\n /**\n * Sets the number of heading rows for the given `table`.\n *\n * @param writer The model writer.\n * @param table The table model element.\n * @param headingRows The number of heading rows to set.\n * @param options Additional options.\n * @param options.shallow If set to `true` it will only update the `headingRows` attribute\n * without updating the cell types in the table. Default is `false`.\n * @param options.resetFormerHeadingCells If set to `true`, it will check if the rows that are no longer in the heading section\n * should be updated to body cells. Default is `true`.\n * @param options.autoExpand If set to `true`, it will check if the following rows look like a header and expand the heading section.\n * Default is `true`.\n */\n setHeadingRowsCount(writer, table, headingRows, options = {}) {\n const { shallow, resetFormerHeadingCells = true, autoExpand = true } = options;\n const oldHeadingRows = table.getAttribute('headingRows') || 0;\n if (headingRows === oldHeadingRows) {\n return;\n }\n updateNumericAttribute('headingRows', headingRows, table, writer, 0);\n if (shallow || !isTableCellTypeEnabled(this.editor)) {\n return;\n }\n // Set header type to all cells in new heading rows.\n for (const { cell, row, column } of new TableWalker(table, { endRow: headingRows - 1 })) {\n updateTableCellType({\n table,\n writer,\n cell,\n row,\n column\n });\n }\n // If heading rows were reduced, set body type to all cells in rows that are no longer in heading section.\n if (resetFormerHeadingCells && headingRows < oldHeadingRows) {\n for (let row = headingRows; row < oldHeadingRows; row++) {\n // Handle edge case when some cells were already changed to body type manually,\n // before changing heading rows count.\n if (!isEntireCellsLineHeader({ table, row })) {\n break;\n }\n for (const { cell, row: cellRow, column } of new TableWalker(table, { row })) {\n updateTableCellType({\n table,\n writer,\n cell,\n row: cellRow,\n column\n });\n }\n }\n }\n // If following rows looks like header, expand heading rows to cover them.\n if (autoExpand && headingRows > oldHeadingRows) {\n const totalRows = this.getRows(table);\n while (headingRows < totalRows && isEntireCellsLineHeader({ table, row: headingRows })) {\n headingRows++;\n }\n updateNumericAttribute('headingRows', headingRows, table, writer, 0);\n }\n }\n /**\n * Sets the number of heading columns for the given `table`.\n *\n * @param writer The model writer to use.\n * @param table The table model element.\n * @param headingColumns The number of heading columns to set.\n * @param options Additional options.\n * @param options.shallow If set to `true` it will only update the `headingColumns` attribute\n * without updating the cell types in the table. Default is `false`.\n * @param options.resetFormerHeadingCells If set to `true`, it will check if the columns that are no longer in the heading section\n * should be updated to body cells. Default is `true`.\n * @param options.autoExpand If set to `true`, it will check if the following columns look like a header and expand the heading section.\n * Default is `true`.\n */\n setHeadingColumnsCount(writer, table, headingColumns, options = {}) {\n const { shallow, resetFormerHeadingCells = true, autoExpand = true } = options;\n const oldHeadingColumns = table.getAttribute('headingColumns') || 0;\n if (headingColumns === oldHeadingColumns) {\n return;\n }\n updateNumericAttribute('headingColumns', headingColumns, table, writer, 0);\n if (shallow || !isTableCellTypeEnabled(this.editor)) {\n return;\n }\n // Set header type to all cells in new heading columns.\n for (const { cell, row, column } of new TableWalker(table, { endColumn: headingColumns - 1 })) {\n updateTableCellType({\n table,\n writer,\n cell,\n row,\n column\n });\n }\n // If heading columns were reduced, set body type to all cells in columns that are no longer in heading section.\n if (resetFormerHeadingCells && headingColumns < oldHeadingColumns) {\n for (let column = headingColumns; column < oldHeadingColumns; column++) {\n // Handle edge case when some cells were already changed to body type manually,\n // before changing heading columns count.\n if (!isEntireCellsLineHeader({ table, column })) {\n break;\n }\n for (const { cell, row, column: cellColumn } of new TableWalker(table, { column })) {\n updateTableCellType({\n table,\n writer,\n cell,\n row,\n column: cellColumn\n });\n }\n }\n }\n // If following columns looks like header, expand heading columns to cover them.\n if (autoExpand && headingColumns > oldHeadingColumns) {\n const totalColumns = this.getColumns(table);\n while (headingColumns < totalColumns && isEntireCellsLineHeader({ table, column: headingColumns })) {\n headingColumns++;\n }\n updateNumericAttribute('headingColumns', headingColumns, table, writer, 0);\n }\n }\n /**\n * Returns all model table cells that the provided model selection's ranges\n * {@link module:engine/model/range~ModelRange#start} inside.\n *\n * To obtain the cells selected from the outside, use\n * {@link #getSelectedTableCells}.\n */\n getTableCellsContainingSelection(selection) {\n const cells = [];\n for (const range of selection.getRanges()) {\n const cellWithSelection = range.start.findAncestor('tableCell');\n if (cellWithSelection) {\n cells.push(cellWithSelection);\n }\n }\n return cells;\n }\n /**\n * Returns all model table cells that are either completely selected\n * by selection ranges or host selection range\n * {@link module:engine/model/range~ModelRange#start start positions} inside them.\n *\n * Combines {@link #getTableCellsContainingSelection} and\n * {@link #getSelectedTableCells}.\n */\n getSelectionAffectedTableCells(selection) {\n const selectedCells = this.getSelectedTableCells(selection);\n if (selectedCells.length) {\n return selectedCells;\n }\n return this.getTableCellsContainingSelection(selection);\n }\n /**\n * Returns an object with the `first` and `last` row index contained in the given `tableCells`.\n *\n * ```ts\n * const selectedTableCells = getSelectedTableCells( editor.model.document.selection );\n *\n * const { first, last } = getRowIndexes( selectedTableCells );\n *\n * console.log( `Selected rows: ${ first } to ${ last }` );\n * ```\n *\n * @returns Returns an object with the `first` and `last` table row indexes.\n */\n getRowIndexes(tableCells) {\n const indexes = tableCells.map(cell => cell.parent.index);\n return this._getFirstLastIndexesObject(indexes);\n }\n /**\n * Returns an object with the `first` and `last` column index contained in the given `tableCells`.\n *\n * ```ts\n * const selectedTableCells = getSelectedTableCells( editor.model.document.selection );\n *\n * const { first, last } = getColumnIndexes( selectedTableCells );\n *\n * console.log( `Selected columns: ${ first } to ${ last }` );\n * ```\n *\n * @returns Returns an object with the `first` and `last` table column indexes.\n */\n getColumnIndexes(tableCells) {\n const table = tableCells[0].findAncestor('table');\n const tableMap = [...new TableWalker(table)];\n const indexes = tableMap\n .filter(entry => tableCells.includes(entry.cell))\n .map(entry => entry.column);\n return this._getFirstLastIndexesObject(indexes);\n }\n /**\n * Checks if the selection contains cells that do not exceed rectangular selection.\n *\n * In a table below:\n *\n * ┌───┬───┬───┬───┐\n * │ a │ b │ c │ d │\n * ├───┴───┼───┤ │\n * │ e │ f │ │\n * │ ├───┼───┤\n * │ │ g │ h │\n * └───────┴───┴───┘\n *\n * Valid selections are these which create a solid rectangle (without gaps), such as:\n * - a, b (two horizontal cells)\n * - c, f (two vertical cells)\n * - a, b, e (cell \"e\" spans over four cells)\n * - c, d, f (cell d spans over a cell in the row below)\n *\n * While an invalid selection would be:\n * - a, c (the unselected cell \"b\" creates a gap)\n * - f, g, h (cell \"d\" spans over a cell from the row of \"f\" cell - thus creates a gap)\n */\n isSelectionRectangular(selectedTableCells) {\n if (selectedTableCells.length < 2 || !this._areCellInTheSameTableSection(selectedTableCells)) {\n return false;\n }\n // A valid selection is a fully occupied rectangle composed of table cells.\n // Below we will calculate the area of a selected table cells and the area of valid selection.\n // The area of a valid selection is defined by top-left and bottom-right cells.\n const rows = new Set();\n const columns = new Set();\n let areaOfSelectedCells = 0;\n for (const tableCell of selectedTableCells) {\n const { row, column } = this.getCellLocation(tableCell);\n const rowspan = parseInt(tableCell.getAttribute('rowspan')) || 1;\n const colspan = parseInt(tableCell.getAttribute('colspan')) || 1;\n // Record row & column indexes of current cell.\n rows.add(row);\n columns.add(column);\n // For cells that spans over multiple rows add also the last row that this cell spans over.\n if (rowspan > 1) {\n rows.add(row + rowspan - 1);\n }\n // For cells that spans over multiple columns add also the last column that this cell spans over.\n if (colspan > 1) {\n columns.add(column + colspan - 1);\n }\n areaOfSelectedCells += (rowspan * colspan);\n }\n // We can only merge table cells that are in adjacent rows...\n const areaOfValidSelection = getBiggestRectangleArea(rows, columns);\n return areaOfValidSelection == areaOfSelectedCells;\n }\n /**\n * Returns array of sorted ranges.\n */\n sortRanges(ranges) {\n return Array.from(ranges).sort(compareRangeOrder);\n }\n /**\n * Helper method to get an object with `first` and `last` indexes from an unsorted array of indexes.\n */\n _getFirstLastIndexesObject(indexes) {\n const allIndexesSorted = indexes.sort((indexA, indexB) => indexA - indexB);\n const first = allIndexesSorted[0];\n const last = allIndexesSorted[allIndexesSorted.length - 1];\n return { first, last };\n }\n /**\n * Checks if the selection does not mix a header (column or row) with other cells.\n *\n * For instance, in the table below valid selections consist of cells with the same letter only.\n * So, a-a (same heading row and column) or d-d (body cells) are valid while c-d or a-b are not.\n *\n * header columns\n * ↓ ↓\n * ┌───┬───┬───┬───┐\n * │ a │ a │ b │ b │ ← header row\n * ├───┼───┼───┼───┤\n * │ c │ c │ d │ d │\n * ├───┼───┼───┼───┤\n * │ c │ c │ d │ d │\n * └───┴───┴───┴───┘\n */\n _areCellInTheSameTableSection(tableCells) {\n const table = tableCells[0].findAncestor('table');\n const rowIndexes = this.getRowIndexes(tableCells);\n const headingRows = parseInt(table.getAttribute('headingRows')) || 0;\n // Calculating row indexes is a bit cheaper so if this check fails we can't merge.\n if (!this._areIndexesInSameSection(rowIndexes, headingRows)) {\n return false;\n }\n const columnIndexes = this.getColumnIndexes(tableCells);\n const headingColumns = parseInt(table.getAttribute('headingColumns')) || 0;\n // Similarly cells must be in same column section.\n return this._areIndexesInSameSection(columnIndexes, headingColumns);\n }\n /**\n * Unified check if table rows/columns indexes are in the same heading/body section.\n */\n _areIndexesInSameSection({ first, last }, headingSectionSize) {\n const firstCellIsInHeading = first < headingSectionSize;\n const lastCellIsInHeading = last < headingSectionSize;\n return firstCellIsInHeading === lastCellIsInHeading;\n }\n}\n/**\n * Creates empty rows at the given index in an existing table.\n *\n * @param insertAt The row index of row insertion.\n * @param rows The number of rows to create.\n * @param tableCellToInsert The number of cells to insert in each row.\n */\nfunction createEmptyRows(writer, table, insertAt, rows, tableCellToInsert, attributes = {}) {\n const insertedRows = [];\n for (let i = 0; i < rows; i++) {\n const tableRow = writer.createElement('tableRow');\n writer.insert(tableRow, table, insertAt);\n insertedRows.push(createCells(tableCellToInsert, writer, writer.createPositionAt(tableRow, 'end'), attributes));\n }\n return insertedRows;\n}\n/**\n * Creates cells at a given position.\n *\n * @param cells The number of cells to create\n */\nfunction createCells(cells, writer, insertPosition, attributes = {}) {\n const createdCells = [];\n let currentPosition = insertPosition;\n for (let i = 0; i < cells; i++) {\n const cell = createEmptyTableCell(writer, currentPosition, attributes);\n createdCells.push(cell);\n currentPosition = writer.createPositionAfter(cell);\n }\n return createdCells;\n}\n/**\n * Evenly distributes the span of a cell to a number of provided cells.\n * The resulting spans will always be integer values.\n *\n * For instance breaking a span of 7 into 3 cells will return:\n *\n * ```ts\n * { newCellsSpan: 2, updatedSpan: 3 }\n * ```\n *\n * as two cells will have a span of 2 and the remainder will go the first cell so its span will change to 3.\n *\n * @param span The span value do break.\n * @param numberOfCells The number of resulting spans.\n */\nfunction breakSpanEvenly(span, numberOfCells) {\n if (span < numberOfCells) {\n return { newCellsSpan: 1, updatedSpan: 1 };\n }\n const newCellsSpan = Math.floor(span / numberOfCells);\n const updatedSpan = (span - newCellsSpan * numberOfCells) + newCellsSpan;\n return { newCellsSpan, updatedSpan };\n}\n/**\n * Updates heading columns attribute if removing a row from head section.\n */\nfunction adjustHeadingColumns(table, removedColumnIndexes, writer) {\n const headingColumns = table.getAttribute('headingColumns') || 0;\n if (headingColumns && removedColumnIndexes.first < headingColumns) {\n const headingsRemoved = Math.min(headingColumns - 1 /* Other numbers are 0-based */, removedColumnIndexes.last) -\n removedColumnIndexes.first + 1;\n writer.setAttribute('headingColumns', headingColumns - headingsRemoved, table);\n }\n}\n/**\n * Calculates a new heading rows value for removing rows from heading section.\n */\nfunction updateHeadingRows(table, { first, last }, writer) {\n const headingRows = table.getAttribute('headingRows') || 0;\n if (first < headingRows) {\n const newRows = last < headingRows ? headingRows - (last - first + 1) : first;\n updateNumericAttribute('headingRows', newRows, table, writer, 0);\n }\n}\n/**\n * Finds cells that will be:\n * - trimmed - Cells that are \"above\" removed rows sections and overlap the removed section - their rowspan must be trimmed.\n * - moved - Cells from removed rows section might stick out of. These cells are moved to the next row after a removed section.\n *\n * Sample table with overlapping & sticking out cells:\n *\n * +----+----+----+----+----+\n * | 00 | 01 | 02 | 03 | 04 |\n * +----+ + + + +\n * | 10 | | | | |\n * +----+----+ + + +\n * | 20 | 21 | | | | <-- removed row\n * + + +----+ + +\n * | | | 32 | | | <-- removed row\n * +----+ + +----+ +\n * | 40 | | | 43 | |\n * +----+----+----+----+----+\n *\n * In a table above:\n * - cells to trim: '02', '03' & '04'.\n * - cells to move: '21' & '32'.\n */\nfunction getCellsToMoveAndTrimOnRemoveRow(table, { first, last }) {\n const cellsToMove = new Map();\n const cellsToTrim = [];\n for (const { row, column, cellHeight, cell } of new TableWalker(table, { endRow: last })) {\n const lastRowOfCell = row + cellHeight - 1;\n const isCellStickingOutFromRemovedRows = row >= first && row <= last && lastRowOfCell > last;\n if (isCellStickingOutFromRemovedRows) {\n const rowspanInRemovedSection = last - row + 1;\n const rowSpanToSet = cellHeight - rowspanInRemovedSection;\n cellsToMove.set(column, {\n cell,\n rowspan: rowSpanToSet\n });\n }\n const isCellOverlappingRemovedRows = row < first && lastRowOfCell >= first;\n if (isCellOverlappingRemovedRows) {\n let rowspanAdjustment;\n // Cell fully covers removed section - trim it by removed rows count.\n if (lastRowOfCell >= last) {\n rowspanAdjustment = last - first + 1;\n }\n // Cell partially overlaps removed section - calculate cell's span that is in removed section.\n else {\n rowspanAdjustment = lastRowOfCell - first + 1;\n }\n cellsToTrim.push({\n cell,\n rowspan: cellHeight - rowspanAdjustment\n });\n }\n }\n return { cellsToMove, cellsToTrim };\n}\nfunction moveCellsToRow(table, targetRowIndex, cellsToMove, writer) {\n const tableWalker = new TableWalker(table, {\n includeAllSlots: true,\n row: targetRowIndex\n });\n const tableRowMap = [...tableWalker];\n const row = table.getChild(targetRowIndex);\n let previousCell;\n for (const { column, cell, isAnchor } of tableRowMap) {\n if (cellsToMove.has(column)) {\n const { cell: cellToMove, rowspan } = cellsToMove.get(column);\n const targetPosition = previousCell ?\n writer.createPositionAfter(previousCell) :\n writer.createPositionAt(row, 0);\n writer.move(writer.createRangeOn(cellToMove), targetPosition);\n updateNumericAttribute('rowspan', rowspan, cellToMove, writer);\n previousCell = cellToMove;\n }\n else if (isAnchor) {\n // If cell is spanned then `cell` holds reference to overlapping cell. See ckeditor/ckeditor5#6502.\n previousCell = cell;\n }\n }\n}\nfunction compareRangeOrder(rangeA, rangeB) {\n // Since table cell ranges are disjoint, it's enough to check their start positions.\n const posA = rangeA.start;\n const posB = rangeB.start;\n // Checking for equal position (returning 0) is not needed because this would be either:\n // a. Intersecting range (not allowed by model)\n // b. Collapsed range on the same position (allowed by model but should not happen).\n return posA.isBefore(posB) ? -1 : 1;\n}\n/**\n * Calculates the area of a maximum rectangle that can span over the provided row & column indexes.\n */\nfunction getBiggestRectangleArea(rows, columns) {\n const rowsIndexes = Array.from(rows.values());\n const columnIndexes = Array.from(columns.values());\n const lastRow = Math.max(...rowsIndexes);\n const firstRow = Math.min(...rowsIndexes);\n const lastColumn = Math.max(...columnIndexes);\n const firstColumn = Math.min(...columnIndexes);\n return (lastRow - firstRow + 1) * (lastColumn - firstColumn + 1);\n}\n/**\n * Updates the `tableCellType` attribute of a table cell based on its position in the table\n * and the table's `headingRows` and `headingColumns` attributes.\n */\nfunction updateTableCellType({ writer, table, row, column, cell }) {\n const headingRows = table.getAttribute('headingRows') || 0;\n const headingColumns = table.getAttribute('headingColumns') || 0;\n if (row >= headingRows && column >= headingColumns) {\n writer.removeAttribute('tableCellType', cell);\n }\n else {\n writer.setAttribute('tableCellType', 'header', cell);\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { TableUtils } from '../tableutils.js';\nimport { updateNumericAttribute } from '../utils/common.js';\nimport { removeEmptyRowsColumns } from '../utils/structure.js';\n/**\n * The merge cells command.\n *\n * The command is registered by {@link module:table/tableediting~TableEditing} as the `'mergeTableCells'` editor command.\n *\n * For example, to merge selected table cells:\n *\n * ```ts\n * editor.execute( 'mergeTableCells' );\n * ```\n */\nexport class MergeCellsCommand extends Command {\n /**\n * @inheritDoc\n */\n refresh() {\n const tableUtils = this.editor.plugins.get(TableUtils);\n const selectedTableCells = tableUtils.getSelectedTableCells(this.editor.model.document.selection);\n this.isEnabled = tableUtils.isSelectionRectangular(selectedTableCells);\n }\n /**\n * Executes the command.\n *\n * @fires execute\n */\n execute() {\n const model = this.editor.model;\n const tableUtils = this.editor.plugins.get(TableUtils);\n model.change(writer => {\n const selectedTableCells = tableUtils.getSelectedTableCells(model.document.selection);\n // All cells will be merged into the first one.\n const firstTableCell = selectedTableCells.shift();\n // Update target cell dimensions.\n const { mergeWidth, mergeHeight } = getMergeDimensions(firstTableCell, selectedTableCells, tableUtils);\n updateNumericAttribute('colspan', mergeWidth, firstTableCell, writer);\n updateNumericAttribute('rowspan', mergeHeight, firstTableCell, writer);\n for (const tableCell of selectedTableCells) {\n mergeTableCells(tableCell, firstTableCell, writer);\n }\n const table = firstTableCell.findAncestor('table');\n // Remove rows and columns that become empty (have no anchored cells).\n removeEmptyRowsColumns(table, tableUtils);\n writer.setSelection(firstTableCell, 'in');\n });\n }\n}\n/**\n * Merges two table cells. It will ensure that after merging cells with empty paragraphs the resulting table cell will only have one\n * paragraph. If one of the merged table cells is empty, the merged table cell will have contents of the non-empty table cell.\n * If both are empty, the merged table cell will have only one empty paragraph.\n */\nfunction mergeTableCells(cellBeingMerged, targetCell, writer) {\n if (!isEmpty(cellBeingMerged)) {\n if (isEmpty(targetCell)) {\n writer.remove(writer.createRangeIn(targetCell));\n }\n writer.move(writer.createRangeIn(cellBeingMerged), writer.createPositionAt(targetCell, 'end'));\n }\n // Remove merged table cell.\n writer.remove(cellBeingMerged);\n}\n/**\n * Checks if the passed table cell contains an empty paragraph.\n */\nfunction isEmpty(tableCell) {\n const firstTableChild = tableCell.getChild(0);\n return tableCell.childCount == 1 && firstTableChild.is('element', 'paragraph') && firstTableChild.isEmpty;\n}\nfunction getMergeDimensions(firstTableCell, selectedTableCells, tableUtils) {\n let maxWidthOffset = 0;\n let maxHeightOffset = 0;\n for (const tableCell of selectedTableCells) {\n const { row, column } = tableUtils.getCellLocation(tableCell);\n maxWidthOffset = getMaxOffset(tableCell, column, maxWidthOffset, 'colspan');\n maxHeightOffset = getMaxOffset(tableCell, row, maxHeightOffset, 'rowspan');\n }\n // Update table cell span attribute and merge set selection on a merged contents.\n const { row: firstCellRow, column: firstCellColumn } = tableUtils.getCellLocation(firstTableCell);\n const mergeWidth = maxWidthOffset - firstCellColumn;\n const mergeHeight = maxHeightOffset - firstCellRow;\n return { mergeWidth, mergeHeight };\n}\nfunction getMaxOffset(tableCell, start, currentMaxOffset, which) {\n const dimensionValue = parseInt(tableCell.getAttribute(which) || '1');\n return Math.max(currentMaxOffset, start + dimensionValue);\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/commands/selectrowcommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\n/**\n * The select row command.\n *\n * The command is registered by {@link module:table/tableediting~TableEditing} as the `'selectTableRow'` editor command.\n *\n * To select the rows containing the selected cells, execute the command:\n *\n * ```ts\n * editor.execute( 'selectTableRow' );\n * ```\n */\nexport class SelectRowCommand extends Command {\n /**\n * @inheritDoc\n */\n constructor(editor) {\n super(editor);\n // It does not affect data so should be enabled in read-only mode.\n this.affectsData = false;\n }\n /**\n * @inheritDoc\n */\n refresh() {\n const tableUtils = this.editor.plugins.get('TableUtils');\n const selectedCells = tableUtils.getSelectionAffectedTableCells(this.editor.model.document.selection);\n this.isEnabled = selectedCells.length > 0;\n }\n /**\n * @inheritDoc\n */\n execute() {\n const model = this.editor.model;\n const tableUtils = this.editor.plugins.get('TableUtils');\n const referenceCells = tableUtils.getSelectionAffectedTableCells(model.document.selection);\n const rowIndexes = tableUtils.getRowIndexes(referenceCells);\n const table = referenceCells[0].findAncestor('table');\n const rangesToSelect = [];\n for (let rowIndex = rowIndexes.first; rowIndex <= rowIndexes.last; rowIndex++) {\n for (const cell of table.getChild(rowIndex).getChildren()) {\n rangesToSelect.push(model.createRangeOn(cell));\n }\n }\n model.change(writer => {\n writer.setSelection(rangesToSelect);\n });\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/commands/selectcolumncommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { TableWalker } from '../tablewalker.js';\n/**\n * The select column command.\n *\n * The command is registered by {@link module:table/tableediting~TableEditing} as the `'selectTableColumn'` editor command.\n *\n * To select the columns containing the selected cells, execute the command:\n *\n * ```ts\n * editor.execute( 'selectTableColumn' );\n * ```\n */\nexport class SelectColumnCommand extends Command {\n /**\n * @inheritDoc\n */\n constructor(editor) {\n super(editor);\n // It does not affect data so should be enabled in read-only mode.\n this.affectsData = false;\n }\n /**\n * @inheritDoc\n */\n refresh() {\n const tableUtils = this.editor.plugins.get('TableUtils');\n const selectedCells = tableUtils.getSelectionAffectedTableCells(this.editor.model.document.selection);\n this.isEnabled = selectedCells.length > 0;\n }\n /**\n * @inheritDoc\n */\n execute() {\n const tableUtils = this.editor.plugins.get('TableUtils');\n const model = this.editor.model;\n const referenceCells = tableUtils.getSelectionAffectedTableCells(model.document.selection);\n const firstCell = referenceCells[0];\n const lastCell = referenceCells.pop();\n const table = firstCell.findAncestor('table');\n const startLocation = tableUtils.getCellLocation(firstCell);\n const endLocation = tableUtils.getCellLocation(lastCell);\n const startColumn = Math.min(startLocation.column, endLocation.column);\n const endColumn = Math.max(startLocation.column, endLocation.column);\n const rangesToSelect = [];\n for (const cellInfo of new TableWalker(table, { startColumn, endColumn })) {\n rangesToSelect.push(model.createRangeOn(cellInfo.cell));\n }\n model.change(writer => {\n writer.setSelection(rangesToSelect);\n });\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TableWalker } from './../tablewalker.js';\nimport { createEmptyTableCell, updateNumericAttribute } from '../utils/common.js';\n/**\n * Injects a table layout post-fixer into the model.\n *\n * The role of the table layout post-fixer is to ensure that the table rows have the correct structure\n * after a {@link module:engine/model/model~Model#change `change()`} block was executed.\n *\n * The correct structure means that:\n *\n * * All table rows have the same size.\n * * None of the table cells extend vertically beyond their section (either header or body).\n * * A table cell has always at least one element as a child.\n *\n * If the table structure is not correct, the post-fixer will automatically correct it in two steps:\n *\n * 1. It will clip table cells that extend beyond their section.\n * 2. It will add empty table cells to the rows that are narrower than the widest table row.\n *\n * ## Clipping overlapping table cells\n *\n * Such situation may occur when pasting a table (or a part of a table) to the editor from external sources.\n *\n * For example, see the following table which has a cell (FOO) with the rowspan attribute (2):\n *\n * ```xml\n *
\n * \n * FOO\n * BAR\n * \n * \n * BAZ\n * XYZ\n * \n *
\n * ```\n *\n * It will be rendered in the view as:\n *\n * ```xml\n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n *
FOOBAR
BAZXYZ
\n * ```\n *\n * In the above example the table will be rendered as a table with two rows: one in the header and second one in the body.\n * The table cell (FOO) cannot span over multiple rows as it would extend from the header to the body section.\n * The `rowspan` attribute must be changed to (1). The value (1) is the default value of the `rowspan` attribute\n * so the `rowspan` attribute will be removed from the model.\n *\n * The table cell with BAZ in the content will be in the first column of the table.\n *\n * ## Adding missing table cells\n *\n * The table post-fixer will insert empty table cells to equalize table row sizes (the number of columns).\n * The size of a table row is calculated by counting column spans of table cells, both horizontal (from the same row) and\n * vertical (from the rows above).\n *\n * In the above example, the table row in the body section of the table is narrower then the row from the header: it has two cells\n * with the default colspan (1). The header row has one cell with colspan (1) and the second with colspan (2).\n * The table cell (FOO) does not extend beyond the head section (and as such will be fixed in the first step of this post-fixer).\n * The post-fixer will add a missing table cell to the row in the body section of the table.\n *\n * The table from the above example will be fixed and rendered to the view as below:\n *\n * ```xml\n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n *
FOOBAR
BAZXYZ
\n * ```\n *\n * ## Collaboration and undo - Expectations vs post-fixer results\n *\n * The table post-fixer only ensures proper structure without a deeper analysis of the nature of the change. As such, it might lead\n * to a structure which was not intended by the user. In particular, it will also fix undo steps (in conjunction with collaboration)\n * in which the editor content might not return to the original state.\n *\n * This will usually happen when one or more users change the size of the table.\n *\n * As an example see the table below:\n *\n * ```xml\n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n *
1112
2122
\n * ```\n *\n * and the user actions:\n *\n * 1. Both users have a table with two rows and two columns.\n * 2. User A adds a column at the end of the table. This will insert empty table cells to two rows.\n * 3. User B adds a row at the end of the table. This will insert a row with two empty table cells.\n * 4. Both users will have a table as below:\n *\n * ```xml\n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n *
1112(empty, inserted by A)
2122(empty, inserted by A)
(empty, inserted by B)(empty, inserted by B)
\n * ```\n *\n * The last row is shorter then others so the table post-fixer will add an empty row to the last row:\n *\n * ```xml\n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n *
1112(empty, inserted by A)
2122(empty, inserted by A)
(empty, inserted by B)(empty, inserted by B)(empty, inserted by the post-fixer)
\n * ```\n *\n * Unfortunately undo does not know the nature of the changes and depending on which user applies the post-fixer changes, undoing them\n * might lead to a broken table. If User B undoes inserting the column to the table, the undo engine will undo only the operations of\n * inserting empty cells to rows from the initial table state (row 1 and 2) but the cell in the post-fixed row will remain:\n *\n * ```xml\n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n *
1112
2122
(empty, inserted by B)(empty, inserted by B)(empty, inserted by a post-fixer)
\n * ```\n *\n * After undo, the table post-fixer will detect that two rows are shorter than others and will fix the table to:\n *\n * ```xml\n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n *
1112(empty, inserted by a post-fixer after undo)
2122(empty, inserted by a post-fixer after undo)
(empty, inserted by B)(empty, inserted by B)(empty, inserted by a post-fixer)
\n * ```\n *\n * @internal\n */\nexport function injectTableLayoutPostFixer(model) {\n model.document.registerPostFixer(writer => tableLayoutPostFixer(writer, model));\n}\n/**\n * The table layout post-fixer.\n */\nfunction tableLayoutPostFixer(writer, model) {\n const changes = model.document.differ.getChanges();\n let wasFixed = false;\n // Do not analyze the same table more then once - may happen for multiple changes in the same table.\n const analyzedTables = new Set();\n for (const entry of changes) {\n let table = null;\n if (entry.type == 'insert' && entry.name == 'table') {\n table = entry.position.nodeAfter;\n }\n // Fix table on adding/removing table cells and rows.\n if ((entry.type == 'insert' || entry.type == 'remove') && (entry.name == 'tableRow' || entry.name == 'tableCell')) {\n table = entry.position.findAncestor('table');\n }\n // Fix table on any table's attribute change - including attributes of table cells.\n if (isTableAttributeEntry(entry)) {\n table = entry.range.start.findAncestor('table');\n }\n if (table && !analyzedTables.has(table)) {\n // Step 1: correct rowspans of table cells if necessary.\n // The wasFixed flag should be true if any of tables in batch was fixed - might be more then one.\n wasFixed = fixTableCellsRowspan(table, writer) || wasFixed;\n // Step 2: fix table rows sizes.\n wasFixed = fixTableRowsSizes(table, writer) || wasFixed;\n analyzedTables.add(table);\n }\n }\n return wasFixed;\n}\n/**\n * Fixes the invalid value of the `rowspan` attribute because a table cell cannot vertically extend beyond the table section it belongs to.\n *\n * @returns Returns `true` if the table was fixed.\n */\nfunction fixTableCellsRowspan(table, writer) {\n let wasFixed = false;\n const cellsToTrim = findCellsToTrim(table);\n if (cellsToTrim.length) {\n // @if CK_DEBUG_TABLE // console.log( `Post-fixing table: trimming cells row-spans (${ cellsToTrim.length }).` );\n wasFixed = true;\n for (const data of cellsToTrim) {\n updateNumericAttribute('rowspan', data.rowspan, data.cell, writer, 1);\n }\n }\n return wasFixed;\n}\n/**\n * Makes all table rows in a table the same size.\n *\n * @returns Returns `true` if the table was fixed.\n */\nfunction fixTableRowsSizes(table, writer) {\n let wasFixed = false;\n const childrenLengths = getChildrenLengths(table);\n const rowsToRemove = [];\n // Find empty rows.\n for (const [rowIndex, size] of childrenLengths.entries()) {\n // Ignore all non-row models.\n if (!size && table.getChild(rowIndex).is('element', 'tableRow')) {\n rowsToRemove.push(rowIndex);\n }\n }\n // Remove empty rows.\n if (rowsToRemove.length) {\n // @if CK_DEBUG_TABLE // console.log( `Post-fixing table: remove empty rows (${ rowsToRemove.length }).` );\n wasFixed = true;\n for (const rowIndex of rowsToRemove.reverse()) {\n writer.remove(table.getChild(rowIndex));\n childrenLengths.splice(rowIndex, 1);\n }\n }\n // Filter out everything that's not a table row.\n const rowsLengths = childrenLengths.filter((row, rowIndex) => table.getChild(rowIndex).is('element', 'tableRow'));\n // Verify if all the rows have the same number of columns.\n const tableSize = rowsLengths[0];\n const isValid = rowsLengths.every(length => length === tableSize);\n if (!isValid) {\n // @if CK_DEBUG_TABLE // console.log( 'Post-fixing table: adding missing cells.' );\n // Find the maximum number of columns.\n const maxColumns = rowsLengths.reduce((prev, current) => current > prev ? current : prev, 0);\n for (const [rowIndex, size] of rowsLengths.entries()) {\n const columnsToInsert = maxColumns - size;\n if (columnsToInsert) {\n for (let i = 0; i < columnsToInsert; i++) {\n createEmptyTableCell(writer, writer.createPositionAt(table.getChild(rowIndex), 'end'));\n }\n wasFixed = true;\n }\n }\n }\n return wasFixed;\n}\n/**\n * Searches for table cells that extend beyond the table section to which they belong to. It will return an array of objects\n * that stores table cells to be trimmed and the correct value of the `rowspan` attribute to set.\n */\nfunction findCellsToTrim(table) {\n const headingRows = parseInt(table.getAttribute('headingRows') || '0');\n const maxRows = Array.from(table.getChildren())\n .reduce((count, row) => row.is('element', 'tableRow') ? count + 1 : count, 0);\n const cellsToTrim = [];\n for (const { row, cell, cellHeight } of new TableWalker(table)) {\n // Skip cells that do not expand over its row.\n if (cellHeight < 2) {\n continue;\n }\n const isInHeader = row < headingRows;\n // Row limit is either end of header section or whole table as table body is after the header.\n const rowLimit = isInHeader ? headingRows : maxRows;\n // If table cell expands over its limit reduce it height to proper value.\n if (row + cellHeight > rowLimit) {\n const newRowspan = rowLimit - row;\n cellsToTrim.push({ cell, rowspan: newRowspan });\n }\n }\n return cellsToTrim;\n}\n/**\n * Returns an array with lengths of rows assigned to the corresponding row index.\n */\nfunction getChildrenLengths(table) {\n // TableWalker will not provide items for the empty rows, we need to pre-fill this array.\n const lengths = new Array(table.childCount).fill(0);\n for (const { rowIndex } of new TableWalker(table, { includeAllSlots: true })) {\n lengths[rowIndex]++;\n }\n return lengths;\n}\n/**\n * Checks if the differ entry for an attribute change is one of the table's attributes.\n */\nfunction isTableAttributeEntry(entry) {\n if (entry.type !== 'attribute') {\n return false;\n }\n const key = entry.attributeKey;\n return key === 'headingRows' || key === 'colspan' || key === 'rowspan';\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * Injects a table cell post-fixer into the model which inserts a `paragraph` element into empty table cells.\n *\n * A table cell must contain at least one block element as a child. An empty table cell will have an empty `paragraph` as a child.\n *\n * ```xml\n * \n * \n * \n * \n *
\n * ```\n *\n * Will be fixed to:\n *\n * ```xml\n * \n * \n * \n * \n *
\n * ```\n *\n * @internal\n */\nexport function injectTableCellParagraphPostFixer(model) {\n model.document.registerPostFixer(writer => tableCellContentsPostFixer(writer, model));\n}\n/**\n * The table cell contents post-fixer.\n */\nfunction tableCellContentsPostFixer(writer, model) {\n const changes = model.document.differ.getChanges();\n let wasFixed = false;\n for (const entry of changes) {\n if (entry.type == 'insert' && entry.name == 'table') {\n wasFixed = fixTable(entry.position.nodeAfter, writer) || wasFixed;\n }\n if (entry.type == 'insert' && entry.name == 'tableRow') {\n wasFixed = fixTableRow(entry.position.nodeAfter, writer) || wasFixed;\n }\n if (entry.type == 'insert' && entry.name == 'tableCell') {\n wasFixed = fixTableCellContent(entry.position.nodeAfter, writer) || wasFixed;\n }\n if ((entry.type == 'remove' || entry.type == 'insert') && checkTableCellChange(entry)) {\n wasFixed = fixTableCellContent(entry.position.parent, writer) || wasFixed;\n }\n }\n return wasFixed;\n}\n/**\n * Fixes all table cells in a table.\n */\nfunction fixTable(table, writer) {\n let wasFixed = false;\n for (const row of table.getChildren()) {\n if (row.is('element', 'tableRow')) {\n wasFixed = fixTableRow(row, writer) || wasFixed;\n }\n }\n return wasFixed;\n}\n/**\n * Fixes all table cells in a table row.\n */\nfunction fixTableRow(tableRow, writer) {\n let wasFixed = false;\n for (const tableCell of tableRow.getChildren()) {\n wasFixed = fixTableCellContent(tableCell, writer) || wasFixed;\n }\n return wasFixed;\n}\n/**\n * Fixes all table cell content by:\n * - Adding a paragraph to a table cell without any child.\n * - Wrapping direct $text in a ``.\n */\nfunction fixTableCellContent(tableCell, writer) {\n // Insert paragraph to an empty table cell.\n if (tableCell.childCount == 0) {\n // @if CK_DEBUG_TABLE // console.log( 'Post-fixing table: insert paragraph in empty cell.' );\n writer.insertElement('paragraph', tableCell);\n return true;\n }\n // Check table cell children for directly placed text nodes.\n // Temporary solution. See https://github.com/ckeditor/ckeditor5/issues/1464.\n const textNodes = Array.from(tableCell.getChildren()).filter(child => child.is('$text'));\n // @if CK_DEBUG_TABLE // textNodes.length && console.log( 'Post-fixing table: wrap cell content with paragraph.' );\n for (const child of textNodes) {\n writer.wrap(writer.createRangeOn(child), 'paragraph');\n }\n // Return true when there were text nodes to fix.\n return !!textNodes.length;\n}\n/**\n * Checks if a differ change should fix the table cell. This happens on:\n * - Removing content from the table cell (i.e. `tableCell` can be left empty).\n * - Adding a text node directly into a table cell.\n */\nfunction checkTableCellChange(entry) {\n if (!entry.position.parent.is('element', 'tableCell')) {\n return false;\n }\n return entry.type == 'insert' && entry.name == '$text' || entry.type == 'remove';\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { isSingleParagraphWithoutAttributes } from './downcast.js';\n/**\n * A table cell refresh handler which marks the table cell in the differ to have it re-rendered.\n *\n * Model `paragraph` inside a table cell can be rendered as `` or `

`. It is rendered as `` if this is the only block\n * element in that table cell and it does not have any attributes. It is rendered as `

` otherwise.\n *\n * When table cell content changes, for example a second `paragraph` element is added, we need to ensure that the first `paragraph` is\n * re-rendered so it changes from `` to `

`. The easiest way to do it is to re-render the entire table cell.\n *\n * @internal\n */\nexport function tableCellRefreshHandler(model, editing) {\n const differ = model.document.differ;\n // Stores cells to be refreshed, so the table cell will be refreshed once for multiple changes.\n const cellsToCheck = new Set();\n for (const change of differ.getChanges()) {\n const parent = change.type == 'attribute' ? change.range.start.parent : change.position.parent;\n if (parent.is('element', 'tableCell')) {\n cellsToCheck.add(parent);\n }\n }\n for (const tableCell of cellsToCheck.values()) {\n const paragraphsToRefresh = Array.from(tableCell.getChildren())\n .filter(child => shouldRefresh(child, editing.mapper));\n for (const paragraph of paragraphsToRefresh) {\n editing.reconvertItem(paragraph);\n }\n }\n}\n/**\n * Check if given model element needs refreshing.\n */\nfunction shouldRefresh(child, mapper) {\n if (!child.is('element', 'paragraph')) {\n return false;\n }\n const viewElement = mapper.toViewElement(child);\n if (!viewElement) {\n return false;\n }\n return isSingleParagraphWithoutAttributes(child) !== viewElement.is('element', 'span');\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tableediting\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { upcastTable, ensureParagraphInTableCell, skipEmptyTableRow, upcastTableFigure } from './converters/upcasttable.js';\nimport { convertParagraphInTableCell, downcastCell, downcastRow, downcastTable, downcastTableBorderAndBackgroundAttributes, convertPlainTable, convertPlainTableCaption } from './converters/downcast.js';\nimport { InsertTableCommand } from './commands/inserttablecommand.js';\nimport { InsertRowCommand } from './commands/insertrowcommand.js';\nimport { InsertColumnCommand } from './commands/insertcolumncommand.js';\nimport { SplitCellCommand } from './commands/splitcellcommand.js';\nimport { MergeCellCommand } from './commands/mergecellcommand.js';\nimport { RemoveRowCommand } from './commands/removerowcommand.js';\nimport { RemoveColumnCommand } from './commands/removecolumncommand.js';\nimport { SetHeaderRowCommand } from './commands/setheaderrowcommand.js';\nimport { SetHeaderColumnCommand } from './commands/setheadercolumncommand.js';\nimport { MergeCellsCommand } from './commands/mergecellscommand.js';\nimport { SelectRowCommand } from './commands/selectrowcommand.js';\nimport { SelectColumnCommand } from './commands/selectcolumncommand.js';\nimport { TableUtils } from '../src/tableutils.js';\nimport { injectTableLayoutPostFixer } from './converters/table-layout-post-fixer.js';\nimport { injectTableCellParagraphPostFixer } from './converters/table-cell-paragraph-post-fixer.js';\nimport { tableHeadingsRefreshHandler } from './converters/table-headings-refresh-handler.js';\nimport { tableCellRefreshHandler } from './converters/table-cell-refresh-handler.js';\nimport { isTableCellTypeEnabled } from './utils/common.js';\nimport '../theme/tableediting.css';\n/**\n * The table editing feature.\n */\nexport class TableEditing extends Plugin {\n /**\n * Handlers for creating additional slots in the table.\n */\n _additionalSlots;\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TableEditing';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get requires() {\n return [TableUtils];\n }\n /**\n * @inheritDoc\n */\n constructor(editor) {\n super(editor);\n this._additionalSlots = [];\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const model = editor.model;\n const schema = model.schema;\n const conversion = editor.conversion;\n const tableUtils = editor.plugins.get(TableUtils);\n schema.register('table', {\n inheritAllFrom: '$blockObject',\n allowAttributes: ['headingRows', 'headingColumns']\n });\n schema.register('tableRow', {\n allowIn: 'table',\n isLimit: true\n });\n schema.register('tableCell', {\n allowContentOf: '$container',\n allowIn: 'tableRow',\n allowAttributes: ['colspan', 'rowspan'],\n isLimit: true,\n isSelectable: true\n });\n // Figure conversion.\n conversion.for('upcast').add(upcastTableFigure());\n // Table conversion.\n conversion.for('upcast').add(upcastTable());\n conversion.for('editingDowncast').elementToStructure({\n model: {\n name: 'table',\n attributes: ['headingRows']\n },\n view: downcastTable(tableUtils, {\n asWidget: true,\n additionalSlots: this._additionalSlots\n })\n });\n conversion.for('dataDowncast').elementToStructure({\n model: {\n name: 'table',\n attributes: ['headingRows']\n },\n view: downcastTable(tableUtils, {\n additionalSlots: this._additionalSlots\n })\n });\n // Table row conversion.\n conversion.for('upcast').elementToElement({ model: 'tableRow', view: 'tr' });\n conversion.for('upcast').add(skipEmptyTableRow());\n conversion.for('downcast').elementToElement({\n model: 'tableRow',\n view: downcastRow()\n });\n // Table cell conversion.\n conversion.for('upcast').elementToElement({ model: 'tableCell', view: 'td' });\n conversion.for('upcast').elementToElement({ model: 'tableCell', view: 'th' });\n conversion.for('upcast').add(ensureParagraphInTableCell('td'));\n conversion.for('upcast').add(ensureParagraphInTableCell('th'));\n conversion.for('editingDowncast').elementToElement({\n model: 'tableCell',\n view: downcastCell({\n asWidget: true,\n cellTypeEnabled: () => isTableCellTypeEnabled(this.editor)\n })\n });\n conversion.for('dataDowncast').elementToElement({\n model: 'tableCell',\n view: downcastCell({\n cellTypeEnabled: () => isTableCellTypeEnabled(this.editor)\n })\n });\n // Duplicates code - needed to properly refresh paragraph inside a table cell.\n conversion.for('editingDowncast').elementToElement({\n model: 'paragraph',\n view: convertParagraphInTableCell({ asWidget: true }),\n converterPriority: 'high'\n });\n conversion.for('dataDowncast').elementToElement({\n model: 'paragraph',\n view: convertParagraphInTableCell(),\n converterPriority: 'high'\n });\n // Table attributes conversion.\n conversion.for('downcast').attributeToAttribute({ model: 'colspan', view: 'colspan' });\n conversion.for('upcast').attributeToAttribute({\n model: { key: 'colspan', value: upcastCellSpan('colspan') },\n view: 'colspan'\n });\n conversion.for('downcast').attributeToAttribute({ model: 'rowspan', view: 'rowspan' });\n conversion.for('upcast').attributeToAttribute({\n model: { key: 'rowspan', value: upcastCellSpan('rowspan') },\n view: 'rowspan'\n });\n // Plain table output converters (also used in the clipboard pipeline).\n this._addPlainTableOutputConverters();\n // Define the config.\n editor.config.define('table.defaultHeadings.rows', 0);\n editor.config.define('table.defaultHeadings.columns', 0);\n editor.config.define('table.showHiddenBorders', true);\n if (editor.config.get('table.showHiddenBorders')) {\n editor.editing.view.change(writer => {\n for (const root of editor.editing.view.document.roots) {\n writer.addClass('ck-table-show-hidden-borders', root);\n }\n });\n }\n // Define all the commands.\n editor.commands.add('insertTable', new InsertTableCommand(editor));\n editor.commands.add('insertTableRowAbove', new InsertRowCommand(editor, { order: 'above' }));\n editor.commands.add('insertTableRowBelow', new InsertRowCommand(editor, { order: 'below' }));\n editor.commands.add('insertTableColumnLeft', new InsertColumnCommand(editor, { order: 'left' }));\n editor.commands.add('insertTableColumnRight', new InsertColumnCommand(editor, { order: 'right' }));\n editor.commands.add('removeTableRow', new RemoveRowCommand(editor));\n editor.commands.add('removeTableColumn', new RemoveColumnCommand(editor));\n editor.commands.add('splitTableCellVertically', new SplitCellCommand(editor, { direction: 'vertically' }));\n editor.commands.add('splitTableCellHorizontally', new SplitCellCommand(editor, { direction: 'horizontally' }));\n editor.commands.add('mergeTableCells', new MergeCellsCommand(editor));\n editor.commands.add('mergeTableCellRight', new MergeCellCommand(editor, { direction: 'right' }));\n editor.commands.add('mergeTableCellLeft', new MergeCellCommand(editor, { direction: 'left' }));\n editor.commands.add('mergeTableCellDown', new MergeCellCommand(editor, { direction: 'down' }));\n editor.commands.add('mergeTableCellUp', new MergeCellCommand(editor, { direction: 'up' }));\n editor.commands.add('setTableColumnHeader', new SetHeaderColumnCommand(editor));\n editor.commands.add('setTableRowHeader', new SetHeaderRowCommand(editor));\n editor.commands.add('selectTableRow', new SelectRowCommand(editor));\n editor.commands.add('selectTableColumn', new SelectColumnCommand(editor));\n injectTableLayoutPostFixer(model);\n injectTableCellParagraphPostFixer(model);\n this.listenTo(model.document, 'change:data', () => {\n // It's no longer needed to refresh table headings on every data change if table cell type feature is enabled.\n // It's because headings rows / columns are updated based on cell types which triggers their own refresh handler.\n if (!isTableCellTypeEnabled(editor)) {\n tableHeadingsRefreshHandler(model, editor.editing);\n }\n tableCellRefreshHandler(model, editor.editing);\n });\n }\n /**\n * Registers downcast handler for the additional table slot.\n */\n registerAdditionalSlot(slotHandler) {\n this._additionalSlots.push(slotHandler);\n }\n /**\n * Adds converters for plain table output. These converters are used either when the `PlainTableOutput` plugin is loaded\n * or when content is processed by the clipboard pipeline, ensuring that pasted tables are not wrapped in a

element.\n */\n _addPlainTableOutputConverters() {\n const editor = this.editor;\n // Override default table data downcast converter.\n editor.conversion.for('dataDowncast').elementToStructure({\n model: 'table',\n view: convertPlainTable(editor),\n converterPriority: 'high'\n });\n // Make sure table is downcasted into in the data pipeline when necessary.\n if (editor.plugins.has('TableCaptionEditing')) {\n editor.conversion.for('dataDowncast').elementToElement({\n model: 'caption',\n view: convertPlainTableCaption(editor),\n converterPriority: 'high'\n });\n }\n // Handle border-style, border-color, border-width and background-color table attributes.\n if (editor.plugins.has('TablePropertiesEditing')) {\n downcastTableBorderAndBackgroundAttributes(editor);\n }\n }\n}\n/**\n * Returns fixed colspan and rowspan attrbutes values.\n *\n * @param type colspan or rowspan.\n * @returns conversion value function.\n */\nfunction upcastCellSpan(type) {\n return (cell) => {\n const span = parseInt(cell.getAttribute(type));\n if (Number.isNaN(span) || span <= 0) {\n return null;\n }\n return span;\n };\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TableWalker } from '../tablewalker.js';\n/**\n * A table headings refresh handler which marks the table cells or rows in the differ to have it re-rendered\n * if the headings attribute changed.\n *\n * Table heading rows and heading columns are represented in the model by a `headingRows` and `headingColumns` attributes.\n *\n * When table headings attribute changes, all the cells/rows are marked to re-render to change between `` and ``.\n *\n * @internal\n */\nexport function tableHeadingsRefreshHandler(model, editing) {\n const differ = model.document.differ;\n for (const change of differ.getChanges()) {\n let table;\n let isRowChange = false;\n if (change.type == 'attribute') {\n const element = change.range.start.nodeAfter;\n if (!element || !element.is('element', 'table')) {\n continue;\n }\n if (change.attributeKey != 'headingRows' && change.attributeKey != 'headingColumns') {\n continue;\n }\n table = element;\n isRowChange = change.attributeKey == 'headingRows';\n }\n else if (change.name == 'tableRow' || change.name == 'tableCell') {\n table = change.position.findAncestor('table');\n isRowChange = change.name == 'tableRow';\n }\n if (!table) {\n continue;\n }\n const headingRows = table.getAttribute('headingRows') || 0;\n const headingColumns = table.getAttribute('headingColumns') || 0;\n const tableWalker = new TableWalker(table);\n for (const tableSlot of tableWalker) {\n const isHeading = tableSlot.row < headingRows || tableSlot.column < headingColumns;\n const expectedElementName = isHeading ? 'th' : 'td';\n const viewElement = editing.mapper.toViewElement(tableSlot.cell);\n if (viewElement && viewElement.is('element') && viewElement.name != expectedElementName) {\n editing.reconvertItem((isRowChange ? tableSlot.cell.parent : tableSlot.cell));\n }\n }\n }\n}\n","export default \"\";","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/ui/inserttableview\n */\nimport { View, ButtonView, addKeyboardHandlingForGrid } from 'ckeditor5/src/ui.js';\nimport { KeystrokeHandler, FocusTracker } from 'ckeditor5/src/utils.js';\nimport './../../theme/inserttable.css';\n/**\n * The table size view.\n *\n * It renders a 10x10 grid to choose the inserted table size.\n *\n * @internal\n */\nexport class InsertTableView extends View {\n /**\n * A collection of table size box items.\n */\n items;\n /**\n * Listen to `keydown` events fired in this view's main element.\n */\n keystrokes;\n /**\n * Tracks information about the DOM focus in the grid.\n */\n focusTracker;\n /**\n * @inheritDoc\n */\n constructor(locale) {\n super(locale);\n const bind = this.bindTemplate;\n this.items = this._createGridCollection();\n this.keystrokes = new KeystrokeHandler();\n this.focusTracker = new FocusTracker();\n this.set('rows', 0);\n this.set('columns', 0);\n this.bind('label').to(this, 'columns', this, 'rows', (columns, rows) => `${rows} × ${columns}`);\n this.setTemplate({\n tag: 'div',\n attributes: {\n class: ['ck']\n },\n children: [\n {\n tag: 'div',\n attributes: {\n class: ['ck-insert-table-dropdown__grid']\n },\n on: {\n 'mouseover@.ck-insert-table-dropdown-grid-box': bind.to('boxover')\n },\n children: this.items\n },\n {\n tag: 'div',\n attributes: {\n class: [\n 'ck',\n 'ck-insert-table-dropdown__label'\n ],\n 'aria-hidden': true\n },\n children: [\n {\n text: bind.to('label')\n }\n ]\n }\n ],\n on: {\n mousedown: bind.to(evt => {\n evt.preventDefault();\n }),\n click: bind.to(() => {\n this.fire('execute');\n })\n }\n });\n // #rows and #columns are set via changes to #focusTracker on mouse over.\n this.on('boxover', (evt, domEvt) => {\n const { row, column } = domEvt.target.dataset;\n this.items.get((parseInt(row, 10) - 1) * 10 + (parseInt(column, 10) - 1)).focus();\n });\n // This allows the #rows and #columns to be updated when:\n // * the user navigates the grid using the keyboard,\n // * the user moves the mouse over grid items.\n this.focusTracker.on('change:focusedElement', (evt, name, focusedElement) => {\n if (!focusedElement) {\n return;\n }\n const { row, column } = focusedElement.dataset;\n // As row & column indexes are zero-based transform it to number of selected rows & columns.\n this.set({\n rows: parseInt(row),\n columns: parseInt(column)\n });\n });\n this.on('change:columns', () => this._highlightGridBoxes());\n this.on('change:rows', () => this._highlightGridBoxes());\n }\n render() {\n super.render();\n addKeyboardHandlingForGrid({\n keystrokeHandler: this.keystrokes,\n focusTracker: this.focusTracker,\n gridItems: this.items,\n numberOfColumns: 10,\n uiLanguageDirection: this.locale && this.locale.uiLanguageDirection\n });\n for (const item of this.items) {\n this.focusTracker.add(item.element);\n }\n this.keystrokes.listenTo(this.element);\n }\n /**\n * Resets the rows and columns selection.\n */\n reset() {\n this.set({\n rows: 1,\n columns: 1\n });\n }\n /**\n * @inheritDoc\n */\n focus() {\n this.items.get(0).focus();\n }\n /**\n * @inheritDoc\n */\n focusLast() {\n this.items.get(0).focus();\n }\n /**\n * Highlights grid boxes depending on rows and columns selected.\n */\n _highlightGridBoxes() {\n const rows = this.rows;\n const columns = this.columns;\n this.items.map((boxView, index) => {\n // Translate box index to the row & column index.\n const itemRow = Math.floor(index / 10);\n const itemColumn = index % 10;\n // Grid box is highlighted when its row & column index belongs to selected number of rows & columns.\n const isOn = itemRow < rows && itemColumn < columns;\n boxView.set('isOn', isOn);\n });\n }\n /**\n * Creates a new Button for the grid.\n *\n * @param locale The locale instance.\n * @param row Row number.\n * @param column Column number.\n * @param label The grid button label.\n */\n _createGridButton(locale, row, column, label) {\n const button = new ButtonView(locale);\n button.set({\n label,\n class: 'ck-insert-table-dropdown-grid-box'\n });\n button.extendTemplate({\n attributes: {\n 'data-row': row,\n 'data-column': column\n }\n });\n return button;\n }\n /**\n * @returns A view collection containing boxes to be placed in a table grid.\n */\n _createGridCollection() {\n const boxes = [];\n // Add grid boxes to table selection view.\n for (let index = 0; index < 100; index++) {\n const row = Math.floor(index / 10);\n const column = index % 10;\n const label = `${row + 1} × ${column + 1}`;\n boxes.push(this._createGridButton(this.locale, row + 1, column + 1, label));\n }\n return this.createCollection(boxes);\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tableui\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { IconTable, IconTableColumn, IconTableRow, IconTableMergeCell } from 'ckeditor5/src/icons.js';\nimport { addListToDropdown, createDropdown, UIModel, SplitButtonView, SwitchButtonView, MenuBarMenuView } from 'ckeditor5/src/ui.js';\nimport { Collection } from 'ckeditor5/src/utils.js';\nimport { InsertTableView } from './ui/inserttableview.js';\n/**\n * The table UI plugin. It introduces:\n *\n * * The `'insertTable'` dropdown,\n * * The `'menuBar:insertTable'` menu bar menu,\n * * The `'tableColumn'` dropdown,\n * * The `'tableRow'` dropdown,\n * * The `'mergeTableCells'` split button.\n *\n * The `'tableColumn'`, `'tableRow'` and `'mergeTableCells'` dropdowns work best with {@link module:table/tabletoolbar~TableToolbar}.\n */\nexport class TableUI extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TableUI';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const t = this.editor.t;\n const contentLanguageDirection = editor.locale.contentLanguageDirection;\n const isContentLtr = contentLanguageDirection === 'ltr';\n editor.ui.componentFactory.add('insertTable', locale => {\n const command = editor.commands.get('insertTable');\n const dropdownView = createDropdown(locale);\n dropdownView.bind('isEnabled').to(command);\n // Decorate dropdown's button.\n dropdownView.buttonView.set({\n icon: IconTable,\n label: t('Insert table'),\n tooltip: true\n });\n let insertTableView;\n dropdownView.on('change:isOpen', () => {\n if (insertTableView) {\n return;\n }\n // Prepare custom view for dropdown's panel.\n insertTableView = new InsertTableView(locale);\n dropdownView.panelView.children.add(insertTableView);\n insertTableView.delegate('execute').to(dropdownView);\n dropdownView.on('execute', () => {\n editor.execute('insertTable', { rows: insertTableView.rows, columns: insertTableView.columns });\n editor.editing.view.focus();\n });\n });\n return dropdownView;\n });\n editor.ui.componentFactory.add('menuBar:insertTable', locale => {\n const command = editor.commands.get('insertTable');\n const menuView = new MenuBarMenuView(locale);\n const insertTableView = new InsertTableView(locale);\n insertTableView.delegate('execute').to(menuView);\n menuView.on('change:isOpen', (event, name, isOpen) => {\n if (!isOpen) {\n insertTableView.reset();\n }\n });\n insertTableView.on('execute', () => {\n editor.execute('insertTable', { rows: insertTableView.rows, columns: insertTableView.columns });\n editor.editing.view.focus();\n });\n menuView.buttonView.set({\n label: t('Table'),\n icon: IconTable\n });\n menuView.panelView.children.add(insertTableView);\n menuView.bind('isEnabled').to(command);\n return menuView;\n });\n editor.ui.componentFactory.add('tableColumn', locale => {\n const options = [\n {\n type: 'switchbutton',\n model: {\n commandName: 'setTableColumnHeader',\n label: t('Header column'),\n bindIsOn: true\n }\n },\n { type: 'separator' },\n {\n type: 'button',\n model: {\n commandName: isContentLtr ? 'insertTableColumnLeft' : 'insertTableColumnRight',\n label: t('Insert column left')\n }\n },\n {\n type: 'button',\n model: {\n commandName: isContentLtr ? 'insertTableColumnRight' : 'insertTableColumnLeft',\n label: t('Insert column right')\n }\n },\n {\n type: 'button',\n model: {\n commandName: 'removeTableColumn',\n label: t('Delete column')\n }\n },\n {\n type: 'button',\n model: {\n commandName: 'selectTableColumn',\n label: t('Select column')\n }\n }\n ];\n return this._prepareDropdown(t('Column'), IconTableColumn, options, locale);\n });\n editor.ui.componentFactory.add('tableRow', locale => {\n const options = [\n {\n type: 'switchbutton',\n model: {\n commandName: 'setTableRowHeader',\n label: t('Header row'),\n bindIsOn: true\n }\n },\n { type: 'separator' },\n {\n type: 'button',\n model: {\n commandName: 'insertTableRowAbove',\n label: t('Insert row above')\n }\n },\n {\n type: 'button',\n model: {\n commandName: 'insertTableRowBelow',\n label: t('Insert row below')\n }\n },\n {\n type: 'button',\n model: {\n commandName: 'removeTableRow',\n label: t('Delete row')\n }\n },\n {\n type: 'button',\n model: {\n commandName: 'selectTableRow',\n label: t('Select row')\n }\n }\n ];\n return this._prepareDropdown(t('Row'), IconTableRow, options, locale);\n });\n editor.ui.componentFactory.add('mergeTableCells', locale => {\n const options = [\n {\n type: 'button',\n model: {\n commandName: 'mergeTableCellUp',\n label: t('Merge cell up')\n }\n },\n {\n type: 'button',\n model: {\n commandName: isContentLtr ? 'mergeTableCellRight' : 'mergeTableCellLeft',\n label: t('Merge cell right')\n }\n },\n {\n type: 'button',\n model: {\n commandName: 'mergeTableCellDown',\n label: t('Merge cell down')\n }\n },\n {\n type: 'button',\n model: {\n commandName: isContentLtr ? 'mergeTableCellLeft' : 'mergeTableCellRight',\n label: t('Merge cell left')\n }\n },\n { type: 'separator' },\n {\n type: 'button',\n model: {\n commandName: 'splitTableCellVertically',\n label: t('Split cell vertically')\n }\n },\n {\n type: 'button',\n model: {\n commandName: 'splitTableCellHorizontally',\n label: t('Split cell horizontally')\n }\n }\n ];\n return this._prepareMergeSplitButtonDropdown(t('Merge cells'), IconTableMergeCell, options, locale);\n });\n }\n /**\n * Creates a dropdown view from a set of options.\n *\n * @param label The dropdown button label.\n * @param icon An icon for the dropdown button.\n * @param options The list of options for the dropdown.\n */\n _prepareDropdown(label, icon, options, locale) {\n const editor = this.editor;\n const dropdownView = createDropdown(locale);\n const commands = this._fillDropdownWithListOptions(dropdownView, options);\n // Decorate dropdown's button.\n dropdownView.buttonView.set({\n label,\n icon,\n tooltip: true\n });\n // Make dropdown button disabled when all options are disabled.\n dropdownView.bind('isEnabled').toMany(commands, 'isEnabled', (...areEnabled) => {\n return areEnabled.some(isEnabled => isEnabled);\n });\n this.listenTo(dropdownView, 'execute', evt => {\n editor.execute(evt.source.commandName);\n // Toggling a switch button view should not move the focus to the editable.\n if (!(evt.source instanceof SwitchButtonView)) {\n editor.editing.view.focus();\n }\n });\n return dropdownView;\n }\n /**\n * Creates a dropdown view with a {@link module:ui/dropdown/button/splitbuttonview~SplitButtonView} for\n * merge (and split)–related commands.\n *\n * @param label The dropdown button label.\n * @param icon An icon for the dropdown button.\n * @param options The list of options for the dropdown.\n */\n _prepareMergeSplitButtonDropdown(label, icon, options, locale) {\n const editor = this.editor;\n const dropdownView = createDropdown(locale, SplitButtonView);\n const mergeCommandName = 'mergeTableCells';\n // Main command.\n const mergeCommand = editor.commands.get(mergeCommandName);\n // Subcommands in the dropdown.\n const commands = this._fillDropdownWithListOptions(dropdownView, options);\n dropdownView.buttonView.set({\n label,\n icon,\n tooltip: true,\n isEnabled: true\n });\n // Make dropdown button disabled when all options are disabled together with the main command.\n dropdownView.bind('isEnabled').toMany([mergeCommand, ...commands], 'isEnabled', (...areEnabled) => {\n return areEnabled.some(isEnabled => isEnabled);\n });\n // Merge selected table cells when the main part of the split button is clicked.\n this.listenTo(dropdownView.buttonView, 'execute', () => {\n editor.execute(mergeCommandName);\n editor.editing.view.focus();\n });\n // Execute commands for events coming from the list in the dropdown panel.\n this.listenTo(dropdownView, 'execute', evt => {\n editor.execute(evt.source.commandName);\n editor.editing.view.focus();\n });\n return dropdownView;\n }\n /**\n * Injects a {@link module:ui/list/listview~ListView} into the passed dropdown with buttons\n * which execute editor commands as configured in passed options.\n *\n * @param options The list of options for the dropdown.\n * @returns Commands the list options are interacting with.\n */\n _fillDropdownWithListOptions(dropdownView, options) {\n const editor = this.editor;\n const commands = [];\n const itemDefinitions = new Collection();\n for (const option of options) {\n addListOption(option, editor, commands, itemDefinitions);\n }\n addListToDropdown(dropdownView, itemDefinitions);\n return commands;\n }\n}\n/**\n * Adds an option to a list view.\n *\n * @param option A configuration option.\n * @param commands The list of commands to update.\n * @param itemDefinitions A collection of dropdown items to update with the given option.\n */\nfunction addListOption(option, editor, commands, itemDefinitions) {\n if (option.type === 'button' || option.type === 'switchbutton') {\n const model = option.model = new UIModel(option.model);\n const { commandName, bindIsOn } = option.model;\n const command = editor.commands.get(commandName);\n commands.push(command);\n model.set({ commandName });\n model.bind('isEnabled').to(command);\n if (bindIsOn) {\n model.bind('isOn').to(command, 'value');\n }\n model.set({\n withText: true\n });\n }\n itemDefinitions.add(option);\n}\n","export default \"\";","export default \"\";","export default \"\";","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tableselection\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { first } from 'ckeditor5/src/utils.js';\nimport { TableWalker } from './tablewalker.js';\nimport { TableUtils } from './tableutils.js';\nimport { cropTableToDimensions, adjustLastRowIndex, adjustLastColumnIndex } from './utils/structure.js';\nimport '../theme/tableselection.css';\n/**\n * This plugin enables the advanced table cells, rows and columns selection.\n * It is loaded automatically by the {@link module:table/table~Table} plugin.\n */\nexport class TableSelection extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TableSelection';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get requires() {\n return [TableUtils, TableUtils];\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const model = editor.model;\n const view = editor.editing.view;\n this.listenTo(model, 'deleteContent', (evt, args) => this._handleDeleteContent(evt, args), { priority: 'high' });\n this.listenTo(view.document, 'insertText', (evt, data) => this._handleInsertTextEvent(evt, data), { priority: 'high' });\n this._defineSelectionConverter();\n this._enablePluginDisabling(); // sic!\n }\n /**\n * Returns the currently selected table cells or `null` if it is not a table cells selection.\n */\n getSelectedTableCells() {\n const tableUtils = this.editor.plugins.get(TableUtils);\n const selection = this.editor.model.document.selection;\n const selectedCells = tableUtils.getSelectedTableCells(selection);\n if (selectedCells.length == 0) {\n return null;\n }\n // This should never happen, but let's know if it ever happens.\n // @if CK_DEBUG //\tif ( selectedCells.length != selection.rangeCount ) {\n // @if CK_DEBUG //\t\tconsole.warn( 'Mixed selection warning. The selection contains table cells and some other ranges.' );\n // @if CK_DEBUG //\t}\n return selectedCells;\n }\n /**\n * Returns the selected table fragment as a document fragment.\n */\n getSelectionAsFragment() {\n const tableUtils = this.editor.plugins.get(TableUtils);\n const selectedCells = this.getSelectedTableCells();\n if (!selectedCells) {\n return null;\n }\n return this.editor.model.change(writer => {\n const documentFragment = writer.createDocumentFragment();\n const { first: firstColumn, last: lastColumn } = tableUtils.getColumnIndexes(selectedCells);\n const { first: firstRow, last: lastRow } = tableUtils.getRowIndexes(selectedCells);\n const sourceTable = selectedCells[0].findAncestor('table');\n let adjustedLastRow = lastRow;\n let adjustedLastColumn = lastColumn;\n // If the selection is rectangular there could be a case of all cells in the last row/column spanned over\n // next row/column so the real lastRow/lastColumn should be updated.\n if (tableUtils.isSelectionRectangular(selectedCells)) {\n const dimensions = {\n firstColumn,\n lastColumn,\n firstRow,\n lastRow\n };\n adjustedLastRow = adjustLastRowIndex(sourceTable, dimensions);\n adjustedLastColumn = adjustLastColumnIndex(sourceTable, dimensions);\n }\n const cropDimensions = {\n startRow: firstRow,\n startColumn: firstColumn,\n endRow: adjustedLastRow,\n endColumn: adjustedLastColumn\n };\n const table = cropTableToDimensions(sourceTable, cropDimensions, writer);\n writer.insert(table, documentFragment, 0);\n return documentFragment;\n });\n }\n /**\n * Sets the model selection based on given anchor and target cells (can be the same cell).\n * Takes care of setting the backward flag.\n *\n * ```ts\n * const modelRoot = editor.model.document.getRoot();\n * const firstCell = modelRoot.getNodeByPath( [ 0, 0, 0 ] );\n * const lastCell = modelRoot.getNodeByPath( [ 0, 0, 1 ] );\n *\n * const tableSelection = editor.plugins.get( 'TableSelection' );\n * tableSelection.setCellSelection( firstCell, lastCell );\n * ```\n */\n setCellSelection(anchorCell, targetCell) {\n const cellsToSelect = this._getCellsToSelect(anchorCell, targetCell);\n this.editor.model.change(writer => {\n writer.setSelection(cellsToSelect.cells.map(cell => writer.createRangeOn(cell)), { backward: cellsToSelect.backward });\n });\n }\n /**\n * Returns the focus cell from the current selection.\n */\n getFocusCell() {\n const selection = this.editor.model.document.selection;\n const focusCellRange = [...selection.getRanges()].pop();\n const element = focusCellRange.getContainedElement();\n if (element && element.is('element', 'tableCell')) {\n return element;\n }\n return null;\n }\n /**\n * Returns the anchor cell from the current selection.\n */\n getAnchorCell() {\n const selection = this.editor.model.document.selection;\n const anchorCellRange = first(selection.getRanges());\n const element = anchorCellRange.getContainedElement();\n if (element && element.is('element', 'tableCell')) {\n return element;\n }\n return null;\n }\n /**\n * Defines a selection converter which marks the selected cells with a specific class.\n *\n * The real DOM selection is put in the last cell. Since the order of ranges is dependent on whether the\n * selection is backward or not, the last cell will usually be close to the \"focus\" end of the selection\n * (a selection has anchor and focus).\n *\n * The real DOM selection is then hidden with CSS.\n */\n _defineSelectionConverter() {\n const editor = this.editor;\n const highlighted = new Set();\n editor.conversion.for('editingDowncast').add(dispatcher => dispatcher.on('selection', (evt, data, conversionApi) => {\n const viewWriter = conversionApi.writer;\n clearHighlightedTableCells(viewWriter);\n const selectedCells = this.getSelectedTableCells();\n if (!selectedCells) {\n return;\n }\n for (const tableCell of selectedCells) {\n const viewElement = conversionApi.mapper.toViewElement(tableCell);\n viewWriter.addClass('ck-editor__editable_selected', viewElement);\n highlighted.add(viewElement);\n }\n const lastViewCell = conversionApi.mapper.toViewElement(selectedCells[selectedCells.length - 1]);\n viewWriter.setSelection(lastViewCell, 0);\n }, { priority: 'lowest' }));\n function clearHighlightedTableCells(viewWriter) {\n for (const previouslyHighlighted of highlighted) {\n viewWriter.removeClass('ck-editor__editable_selected', previouslyHighlighted);\n }\n highlighted.clear();\n }\n }\n /**\n * Creates a listener that reacts to changes in {@link #isEnabled} and, if the plugin was disabled,\n * it collapses the multi-cell selection to a regular selection placed inside a table cell.\n *\n * This listener helps features that disable the table selection plugin bring the selection\n * to a clear state they can work with (for instance, because they don't support multiple cell selection).\n */\n _enablePluginDisabling() {\n const editor = this.editor;\n this.on('change:isEnabled', () => {\n if (!this.isEnabled) {\n const selectedCells = this.getSelectedTableCells();\n if (!selectedCells) {\n return;\n }\n editor.model.change(writer => {\n const position = writer.createPositionAt(selectedCells[0], 0);\n const range = editor.model.schema.getNearestSelectionRange(position);\n writer.setSelection(range);\n });\n }\n });\n }\n /**\n * Overrides the default `model.deleteContent()` behavior over a selected table fragment.\n *\n * @param args Delete content method arguments.\n */\n _handleDeleteContent(event, args) {\n const tableUtils = this.editor.plugins.get(TableUtils);\n const selection = args[0];\n const options = args[1];\n const model = this.editor.model;\n const isBackward = !options || options.direction == 'backward';\n const selectedTableCells = tableUtils.getSelectedTableCells(selection);\n if (!selectedTableCells.length) {\n return;\n }\n event.stop();\n model.change(writer => {\n const tableCellToSelect = selectedTableCells[isBackward ? selectedTableCells.length - 1 : 0];\n model.change(writer => {\n for (const tableCell of selectedTableCells) {\n model.deleteContent(writer.createSelection(tableCell, 'in'));\n }\n });\n const rangeToSelect = model.schema.getNearestSelectionRange(writer.createPositionAt(tableCellToSelect, 0));\n // Note: we ignore the case where rangeToSelect may be null because deleteContent() will always (unless someone broke it)\n // create an empty paragraph to accommodate the selection.\n if (selection.is('documentSelection')) {\n writer.setSelection(rangeToSelect);\n }\n else {\n selection.setTo(rangeToSelect);\n }\n });\n }\n /**\n * This handler makes it possible to remove the content of all selected cells by starting to type.\n * If you take a look at {@link #_defineSelectionConverter} you will find out that despite the multi-cell selection being set\n * in the model, the view selection is collapsed in the last cell (because most browsers are unable to render multi-cell selections;\n * yes, it's a hack).\n *\n * When multiple cells are selected in the model and the user starts to type, the\n * {@link module:engine/view/document~ViewDocument#event:insertText} event carries information provided by the\n * beforeinput DOM event, that in turn only knows about this collapsed DOM selection in the last cell.\n *\n * As a result, the selected cells have no chance to be cleaned up. To fix this, this listener intercepts\n * the event and injects the custom view selection in the data that translates correctly to the actual state\n * of the multi-cell selection in the model.\n *\n * @param data Insert text event data.\n */\n _handleInsertTextEvent(evt, data) {\n const editor = this.editor;\n const selectedCells = this.getSelectedTableCells();\n if (!selectedCells) {\n return;\n }\n const view = editor.editing.view;\n const mapper = editor.editing.mapper;\n const viewRanges = selectedCells.map(tableCell => view.createRangeOn(mapper.toViewElement(tableCell)));\n data.selection = view.createSelection(viewRanges);\n // Do not let the browser handle it itself. We must modify the model and then apply changes to the view and DOM.\n data.preventDefault();\n }\n /**\n * Returns an array of table cells that should be selected based on the\n * given anchor cell and target (focus) cell.\n *\n * The cells are returned in a reverse direction if the selection is backward.\n */\n _getCellsToSelect(anchorCell, targetCell) {\n const tableUtils = this.editor.plugins.get('TableUtils');\n const startLocation = tableUtils.getCellLocation(anchorCell);\n const endLocation = tableUtils.getCellLocation(targetCell);\n const startRow = Math.min(startLocation.row, endLocation.row);\n const endRow = Math.max(startLocation.row, endLocation.row);\n const startColumn = Math.min(startLocation.column, endLocation.column);\n // Adjust the selection to include the entire row if a cell with colspan is selected.\n // This ensures that the selection covers the full width of the colspan cell.\n //\n // Example:\n // +---+---+---+---+\n // | A | B | C | D |\n // +---+---+---+---+\n // | E |\n // +---+---+---+---+\n //\n // If the selection starts at `B` and ends at `E`, the entire first row should be selected.\n //\n // In other words, the selection will represent the following cells:\n // \t* Without this adjustment, only `B`, `A` and `E` would be selected.\n // \t* With this adjustment, `A`, `B`, `C`, `D`, and `E` are selected.\n //\n // See: https://github.com/ckeditor/ckeditor5/issues/17538\n const endColumnExtraColspan = (parseInt(targetCell.getAttribute('colspan') || '1') - 1);\n const endColumn = Math.max(startLocation.column, endLocation.column + endColumnExtraColspan);\n // 2-dimensional array of the selected cells to ease flipping the order of cells for backward selections.\n const selectionMap = new Array(endRow - startRow + 1).fill(null).map(() => []);\n const walkerOptions = {\n startRow,\n endRow,\n startColumn,\n endColumn\n };\n for (const { row, cell } of new TableWalker(anchorCell.findAncestor('table'), walkerOptions)) {\n selectionMap[row - startRow].push(cell);\n }\n const flipVertically = endLocation.row < startLocation.row;\n const flipHorizontally = endLocation.column < startLocation.column;\n if (flipVertically) {\n selectionMap.reverse();\n }\n if (flipHorizontally) {\n selectionMap.forEach(row => row.reverse());\n }\n return {\n cells: selectionMap.flat(),\n backward: flipVertically || flipHorizontally\n };\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { ClipboardPipeline, ClipboardMarkersUtils } from 'ckeditor5/src/clipboard.js';\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { TableSelection } from './tableselection.js';\nimport { TableWalker } from './tablewalker.js';\nimport { TableUtils } from './tableutils.js';\nimport { cropTableToDimensions, getHorizontallyOverlappingCells, getVerticallyOverlappingCells, removeEmptyRowsColumns, splitHorizontally, splitVertically, trimTableCellIfNeeded, adjustLastRowIndex, adjustLastColumnIndex } from './utils/structure.js';\n/**\n * This plugin adds support for copying/cutting/pasting fragments of tables.\n * It is loaded automatically by the {@link module:table/table~Table} plugin.\n */\nexport class TableClipboard extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TableClipboard';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get requires() {\n return [ClipboardMarkersUtils, ClipboardPipeline, TableSelection, TableUtils];\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const viewDocument = editor.editing.view.document;\n this.listenTo(viewDocument, 'copy', (evt, data) => this._onCopyCut(evt, data));\n this.listenTo(viewDocument, 'cut', (evt, data) => this._onCopyCut(evt, data));\n this._listenToContentInsertion();\n this.decorate('_replaceTableSlotCell');\n }\n /**\n * Sets up listening for events from the clipboard pipeline to properly handle\n * table content merging during paste/drop operations.\n *\n * When a user is dragging and dropping a table, we want to insert the entire table into\n * a table cell instead of merging table contents. For paste and other events,\n * the normal table merge behavior is applied.\n */\n _listenToContentInsertion() {\n const { editor } = this;\n const clipboardPipeline = editor.plugins.get(ClipboardPipeline);\n const tableSelection = editor.plugins.get(TableSelection);\n let isPaste = false;\n clipboardPipeline.on('contentInsertion', (evt, data) => {\n isPaste = data.method === 'paste';\n });\n this.listenTo(editor.model, 'insertContent', (evt, [content, selectable]) => {\n // Handles drag-and-drop of tables, where tables are inserted into selected cells rather than merged.\n // The `isPaste` flag handles scenarios where other features (e.g., Templates) insert tables into specific cells.\n if (isPaste || tableSelection.getSelectedTableCells() !== null) {\n this._onInsertContent(evt, content, selectable);\n }\n }, { priority: 'high' });\n clipboardPipeline.on('contentInsertion', () => {\n isPaste = false;\n }, { priority: 'lowest' });\n }\n /**\n * Copies table content to a clipboard on \"copy\" & \"cut\" events.\n *\n * @param evt An object containing information about the handled event.\n * @param data Clipboard event data.\n */\n _onCopyCut(evt, data) {\n const view = this.editor.editing.view;\n const tableSelection = this.editor.plugins.get(TableSelection);\n const clipboardMarkersUtils = this.editor.plugins.get(ClipboardMarkersUtils);\n if (!tableSelection.getSelectedTableCells()) {\n return;\n }\n if (evt.name == 'cut' && !this.editor.model.canEditAt(this.editor.model.document.selection)) {\n return;\n }\n data.preventDefault();\n evt.stop();\n this.editor.model.enqueueChange({ isUndoable: evt.name === 'cut' }, () => {\n const documentFragment = clipboardMarkersUtils._copySelectedFragmentWithMarkers(evt.name, this.editor.model.document.selection, () => tableSelection.getSelectionAsFragment());\n view.document.fire('clipboardOutput', {\n dataTransfer: data.dataTransfer,\n content: this.editor.data.toView(documentFragment),\n method: evt.name\n });\n });\n }\n /**\n * Overrides default {@link module:engine/model/model~Model#insertContent `model.insertContent()`} method to handle pasting table inside\n * selected table fragment.\n *\n * Depending on selected table fragment:\n * - If a selected table fragment is smaller than paste table it will crop pasted table to match dimensions.\n * - If dimensions are equal it will replace selected table fragment with a pasted table contents.\n *\n * @param content The content to insert.\n * @param selectable The selection into which the content should be inserted.\n * If not provided the current model document selection will be used.\n */\n _onInsertContent(evt, content, selectable) {\n if (selectable && !selectable.is('documentSelection')) {\n return;\n }\n const model = this.editor.model;\n const tableUtils = this.editor.plugins.get(TableUtils);\n const clipboardMarkersUtils = this.editor.plugins.get(ClipboardMarkersUtils);\n // We might need to crop table before inserting so reference might change.\n const pastedTable = this.getTableIfOnlyTableInContent(content, model);\n if (!pastedTable) {\n return;\n }\n const selectedTableCells = tableUtils.getSelectionAffectedTableCells(model.document.selection);\n if (!selectedTableCells.length) {\n removeEmptyRowsColumns(pastedTable, tableUtils);\n return;\n }\n // Override default model.insertContent() handling at this point.\n evt.stop();\n if (content.is('documentFragment')) {\n clipboardMarkersUtils._pasteMarkersIntoTransformedElement(content.markers, writer => this._replaceSelectedCells(pastedTable, selectedTableCells, writer));\n }\n else {\n this.editor.model.change(writer => {\n this._replaceSelectedCells(pastedTable, selectedTableCells, writer);\n });\n }\n }\n /**\n * Inserts provided `selectedTableCells` into `pastedTable`.\n */\n _replaceSelectedCells(pastedTable, selectedTableCells, writer) {\n const tableUtils = this.editor.plugins.get(TableUtils);\n const pastedDimensions = {\n width: tableUtils.getColumns(pastedTable),\n height: tableUtils.getRows(pastedTable)\n };\n // Prepare the table for pasting.\n const selection = prepareTableForPasting(selectedTableCells, pastedDimensions, writer, tableUtils);\n // Beyond this point we operate on a fixed content table with rectangular selection and proper last row/column values.\n const selectionHeight = selection.lastRow - selection.firstRow + 1;\n const selectionWidth = selection.lastColumn - selection.firstColumn + 1;\n // Crop pasted table if:\n // - Pasted table dimensions exceeds selection area.\n // - Pasted table has broken layout (ie some cells sticks out by the table dimensions established by the first and last row).\n //\n // Note: The table dimensions are established by the width of the first row and the total number of rows.\n // It is possible to programmatically create a table that has rows which would have cells anchored beyond first row width but\n // such table will not be created by other editing solutions.\n const cropDimensions = {\n startRow: 0,\n startColumn: 0,\n endRow: Math.min(selectionHeight, pastedDimensions.height) - 1,\n endColumn: Math.min(selectionWidth, pastedDimensions.width) - 1\n };\n pastedTable = cropTableToDimensions(pastedTable, cropDimensions, writer);\n // Content table to which we insert a pasted table.\n const selectedTable = selectedTableCells[0].findAncestor('table');\n const cellsToSelect = this._replaceSelectedCellsWithPasted(pastedTable, pastedDimensions, selectedTable, selection, writer);\n if (this.editor.plugins.get('TableSelection').isEnabled) {\n // Selection ranges must be sorted because the first and last selection ranges are considered\n // as anchor/focus cell ranges for multi-cell selection.\n const selectionRanges = tableUtils.sortRanges(cellsToSelect.map(cell => writer.createRangeOn(cell)));\n writer.setSelection(selectionRanges);\n }\n else {\n // Set selection inside first cell if multi-cell selection is disabled.\n writer.setSelection(cellsToSelect[0], 0);\n }\n return selectedTable;\n }\n /**\n * Replaces the part of selectedTable with pastedTable.\n */\n _replaceSelectedCellsWithPasted(pastedTable, pastedDimensions, selectedTable, selection, writer) {\n const { width: pastedWidth, height: pastedHeight } = pastedDimensions;\n // Holds two-dimensional array that is addressed by [ row ][ column ] that stores cells anchored at given location.\n const pastedTableLocationMap = createLocationMap(pastedTable, pastedWidth, pastedHeight);\n const selectedTableMap = [...new TableWalker(selectedTable, {\n startRow: selection.firstRow,\n endRow: selection.lastRow,\n startColumn: selection.firstColumn,\n endColumn: selection.lastColumn,\n includeAllSlots: true\n })];\n // Selection must be set to pasted cells (some might be removed or new created).\n const cellsToSelect = [];\n // Store next cell insert position.\n let insertPosition;\n // Content table replace cells algorithm iterates over a selected table fragment and:\n //\n // - Removes existing table cells at current slot (location).\n // - Inserts cell from a pasted table for a matched slots.\n //\n // This ensures proper table geometry after the paste\n for (const tableSlot of selectedTableMap) {\n const { row, column } = tableSlot;\n // Save the insert position for current row start.\n if (column === selection.firstColumn) {\n insertPosition = tableSlot.getPositionBefore();\n }\n // Map current table slot location to an pasted table slot location.\n const pastedRow = row - selection.firstRow;\n const pastedColumn = column - selection.firstColumn;\n const pastedCell = pastedTableLocationMap[pastedRow % pastedHeight][pastedColumn % pastedWidth];\n // Clone cell to insert (to duplicate its attributes and children).\n // Cloning is required to support repeating pasted table content when inserting to a bigger selection.\n const cellToInsert = pastedCell ? writer.cloneElement(pastedCell) : null;\n // Replace the cell from the current slot with new table cell.\n const newTableCell = this._replaceTableSlotCell(tableSlot, cellToInsert, insertPosition, writer);\n // The cell was only removed.\n if (!newTableCell) {\n continue;\n }\n // Trim the cell if it's row/col-spans would exceed selection area.\n trimTableCellIfNeeded(newTableCell, row, column, selection.lastRow, selection.lastColumn, writer);\n cellsToSelect.push(newTableCell);\n insertPosition = writer.createPositionAfter(newTableCell);\n }\n // If there are any headings, all the cells that overlap from heading must be splitted.\n const headingRows = parseInt(selectedTable.getAttribute('headingRows') || '0');\n const headingColumns = parseInt(selectedTable.getAttribute('headingColumns') || '0');\n const areHeadingRowsIntersectingSelection = selection.firstRow < headingRows && headingRows <= selection.lastRow;\n const areHeadingColumnsIntersectingSelection = selection.firstColumn < headingColumns && headingColumns <= selection.lastColumn;\n if (areHeadingRowsIntersectingSelection) {\n const columnsLimit = { first: selection.firstColumn, last: selection.lastColumn };\n const newCells = doHorizontalSplit(selectedTable, headingRows, columnsLimit, writer, selection.firstRow);\n cellsToSelect.push(...newCells);\n }\n if (areHeadingColumnsIntersectingSelection) {\n const rowsLimit = { first: selection.firstRow, last: selection.lastRow };\n const newCells = doVerticalSplit(selectedTable, headingColumns, rowsLimit, writer);\n cellsToSelect.push(...newCells);\n }\n return cellsToSelect;\n }\n /**\n * Replaces a single table slot.\n *\n * @returns Inserted table cell or null if slot should remain empty.\n * @private\n */\n _replaceTableSlotCell(tableSlot, cellToInsert, insertPosition, writer) {\n const { cell, isAnchor } = tableSlot;\n // If the slot is occupied by a cell in a selected table - remove it.\n // The slot of this cell will be either:\n // - Replaced by a pasted table cell.\n // - Spanned by a previously pasted table cell.\n if (isAnchor) {\n writer.remove(cell);\n }\n // There is no cell to insert (might be spanned by other cell in a pasted table) - advance to the next content table slot.\n if (!cellToInsert) {\n return null;\n }\n writer.insert(cellToInsert, insertPosition);\n return cellToInsert;\n }\n /**\n * Extracts the table for pasting into a table.\n *\n * @param content The content to insert.\n * @param model The editor model.\n */\n getTableIfOnlyTableInContent(content, model) {\n if (!content.is('documentFragment') && !content.is('element')) {\n return null;\n }\n // Table passed directly.\n if (content.is('element', 'table')) {\n return content;\n }\n // We do not support mixed content when pasting table into table.\n // See: https://github.com/ckeditor/ckeditor5/issues/6817.\n if (content.childCount == 1 && content.getChild(0).is('element', 'table')) {\n return content.getChild(0);\n }\n // If there are only whitespaces around a table then use that table for pasting.\n const contentRange = model.createRangeIn(content);\n for (const element of contentRange.getItems()) {\n if (element.is('element', 'table')) {\n // Stop checking if there is some content before table.\n const rangeBefore = model.createRange(contentRange.start, model.createPositionBefore(element));\n if (model.hasContent(rangeBefore, { ignoreWhitespaces: true })) {\n return null;\n }\n // Stop checking if there is some content after table.\n const rangeAfter = model.createRange(model.createPositionAfter(element), contentRange.end);\n if (model.hasContent(rangeAfter, { ignoreWhitespaces: true })) {\n return null;\n }\n // There wasn't any content neither before nor after.\n return element;\n }\n }\n return null;\n }\n}\n/**\n * Prepares a table for pasting and returns adjusted selection dimensions.\n */\nfunction prepareTableForPasting(selectedTableCells, pastedDimensions, writer, tableUtils) {\n const selectedTable = selectedTableCells[0].findAncestor('table');\n const columnIndexes = tableUtils.getColumnIndexes(selectedTableCells);\n const rowIndexes = tableUtils.getRowIndexes(selectedTableCells);\n const selection = {\n firstColumn: columnIndexes.first,\n lastColumn: columnIndexes.last,\n firstRow: rowIndexes.first,\n lastRow: rowIndexes.last\n };\n // Single cell selected - expand selection to pasted table dimensions.\n const shouldExpandSelection = selectedTableCells.length === 1;\n if (shouldExpandSelection) {\n selection.lastRow += pastedDimensions.height - 1;\n selection.lastColumn += pastedDimensions.width - 1;\n expandTableSize(selectedTable, selection.lastRow + 1, selection.lastColumn + 1, tableUtils);\n }\n // In case of expanding selection we do not reset the selection so in this case we will always try to fix selection\n // like in the case of a non-rectangular area. This might be fixed by re-setting selected cells array but this shortcut is safe.\n if (shouldExpandSelection || !tableUtils.isSelectionRectangular(selectedTableCells)) {\n // For a non-rectangular selection (ie in which some cells sticks out from a virtual selection rectangle) we need to create\n // a table layout that has a rectangular selection. This will split cells so the selection become rectangular.\n // Beyond this point we will operate on fixed content table.\n splitCellsToRectangularSelection(selectedTable, selection, writer);\n }\n // However a selected table fragment might be invalid if examined alone. Ie such table fragment:\n //\n // +---+---+---+---+\n // 0 | a | b | c | d |\n // + + +---+---+\n // 1 | | e | f | g |\n // + +---+ +---+\n // 2 | | h | | i | <- last row, each cell has rowspan = 2,\n // + + + + + so we need to return 3, not 2\n // 3 | | | | |\n // +---+---+---+---+\n //\n // is invalid as the cells \"h\" and \"i\" have rowspans.\n // This case needs only adjusting the selection dimension as the rest of the algorithm operates on empty slots also.\n else {\n selection.lastRow = adjustLastRowIndex(selectedTable, selection);\n selection.lastColumn = adjustLastColumnIndex(selectedTable, selection);\n }\n return selection;\n}\n/**\n * Expand table (in place) to expected size.\n */\nfunction expandTableSize(table, expectedHeight, expectedWidth, tableUtils) {\n const tableWidth = tableUtils.getColumns(table);\n const tableHeight = tableUtils.getRows(table);\n if (expectedWidth > tableWidth) {\n tableUtils.insertColumns(table, {\n at: tableWidth,\n columns: expectedWidth - tableWidth\n });\n }\n if (expectedHeight > tableHeight) {\n tableUtils.insertRows(table, {\n at: tableHeight,\n rows: expectedHeight - tableHeight\n });\n }\n}\n/**\n * Returns two-dimensional array that is addressed by [ row ][ column ] that stores cells anchored at given location.\n *\n * At given row & column location it might be one of:\n *\n * * cell - cell from pasted table anchored at this location.\n * * null - if no cell is anchored at this location.\n *\n * For instance, from a table below:\n *\n * +----+----+----+----+\n * | 00 | 01 | 02 | 03 |\n * + +----+----+----+\n * | | 11 | 13 |\n * +----+ +----+\n * | 20 | | 23 |\n * +----+----+----+----+\n *\n * The method will return an array (numbers represents cell element):\n *\n * ```ts\n * const map = [\n * [ '00', '01', '02', '03' ],\n * [ null, '11', null, '13' ],\n * [ '20', null, null, '23' ]\n * ]\n * ```\n *\n * This allows for a quick access to table at give row & column. For instance to access table cell \"13\" from pasted table call:\n *\n * ```ts\n * const cell = map[ 1 ][ 3 ]\n * ```\n */\nfunction createLocationMap(table, width, height) {\n // Create height x width (row x column) two-dimensional table to store cells.\n const map = new Array(height).fill(null)\n .map(() => new Array(width).fill(null));\n for (const { column, row, cell } of new TableWalker(table)) {\n map[row][column] = cell;\n }\n return map;\n}\n/**\n * Make selected cells rectangular by splitting the cells that stand out from a rectangular selection.\n *\n * In the table below a selection is shown with \"::\" and slots with anchor cells are named.\n *\n * +----+----+----+----+----+ +----+----+----+----+----+\n * | 00 | 01 | 02 | 03 | | 00 | 01 | 02 | 03 |\n * + +----+ +----+----+ | ::::::::::::::::----+\n * | | 11 | | 13 | 14 | | ::11 | | 13:: 14 | <- first row\n * +----+----+ + +----+ +----::---| | ::----+\n * | 20 | 21 | | | 24 | select cells: | 20 ::21 | | :: 24 |\n * +----+----+ +----+----+ 11 -> 33 +----::---| |---::----+\n * | 30 | | 33 | 34 | | 30 :: | | 33:: 34 | <- last row\n * + + +----+ + | :::::::::::::::: +\n * | | | 43 | | | | | 43 | |\n * +----+----+----+----+----+ +----+----+----+----+----+\n * ^ ^\n * first & last columns\n *\n * Will update table to:\n *\n * +----+----+----+----+----+\n * | 00 | 01 | 02 | 03 |\n * + +----+----+----+----+\n * | | 11 | | 13 | 14 |\n * +----+----+ + +----+\n * | 20 | 21 | | | 24 |\n * +----+----+ +----+----+\n * | 30 | | | 33 | 34 |\n * + +----+----+----+ +\n * | | | | 43 | |\n * +----+----+----+----+----+\n *\n * In th example above:\n * - Cell \"02\" which have `rowspan = 4` must be trimmed at first and at after last row.\n * - Cell \"03\" which have `rowspan = 2` and `colspan = 2` must be trimmed at first column and after last row.\n * - Cells \"00\", \"03\" & \"30\" which cannot be cut by this algorithm as they are outside the trimmed area.\n * - Cell \"13\" cannot be cut as it is inside the trimmed area.\n */\nfunction splitCellsToRectangularSelection(table, dimensions, writer) {\n const { firstRow, lastRow, firstColumn, lastColumn } = dimensions;\n const rowIndexes = { first: firstRow, last: lastRow };\n const columnIndexes = { first: firstColumn, last: lastColumn };\n // 1. Split cells vertically in two steps as first step might create cells that needs to split again.\n doVerticalSplit(table, firstColumn, rowIndexes, writer);\n doVerticalSplit(table, lastColumn + 1, rowIndexes, writer);\n // 2. Split cells horizontally in two steps as first step might create cells that needs to split again.\n doHorizontalSplit(table, firstRow, columnIndexes, writer);\n doHorizontalSplit(table, lastRow + 1, columnIndexes, writer, firstRow);\n}\nfunction doHorizontalSplit(table, splitRow, limitColumns, writer, startRow = 0) {\n // If selection starts at first row then no split is needed.\n if (splitRow < 1) {\n return;\n }\n const overlappingCells = getVerticallyOverlappingCells(table, splitRow, startRow);\n // Filter out cells that are not touching insides of the rectangular selection.\n const cellsToSplit = overlappingCells.filter(({ column, cellWidth }) => isAffectedBySelection(column, cellWidth, limitColumns));\n return cellsToSplit.map(({ cell }) => splitHorizontally(cell, splitRow, writer));\n}\nfunction doVerticalSplit(table, splitColumn, limitRows, writer) {\n // If selection starts at first column then no split is needed.\n if (splitColumn < 1) {\n return;\n }\n const overlappingCells = getHorizontallyOverlappingCells(table, splitColumn);\n // Filter out cells that are not touching insides of the rectangular selection.\n const cellsToSplit = overlappingCells.filter(({ row, cellHeight }) => isAffectedBySelection(row, cellHeight, limitRows));\n return cellsToSplit.map(({ cell, column }) => splitVertically(cell, column, splitColumn, writer));\n}\n/**\n * Checks if cell at given row (column) is affected by a rectangular selection defined by first/last column (row).\n *\n * The same check is used for row as for column.\n */\nfunction isAffectedBySelection(index, span, limit) {\n const endIndex = index + span - 1;\n const { first, last } = limit;\n const isInsideSelection = index >= first && index <= last;\n const overlapsSelectionFromOutside = index < first && endIndex >= first;\n return isInsideSelection || overlapsSelectionFromOutside;\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tablekeyboard\n */\nimport { TableSelection } from './tableselection.js';\nimport { TableWalker } from './tablewalker.js';\nimport { TableUtils } from './tableutils.js';\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { getLocalizedArrowKeyCodeDirection } from 'ckeditor5/src/utils.js';\n/**\n * This plugin enables keyboard navigation for tables.\n * It is loaded automatically by the {@link module:table/table~Table} plugin.\n */\nexport class TableKeyboard extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TableKeyboard';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get requires() {\n return [TableSelection, TableUtils];\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const view = editor.editing.view;\n const viewDocument = view.document;\n const t = editor.t;\n this.listenTo(viewDocument, 'arrowKey', (...args) => this._onArrowKey(...args), { context: 'table' });\n this.listenTo(viewDocument, 'tab', (...args) => this._handleTabOnSelectedTable(...args), { context: 'figure' });\n this.listenTo(viewDocument, 'tab', (...args) => this._handleTab(...args), { context: ['th', 'td'] });\n // Add the information about the keystrokes to the accessibility database.\n editor.accessibility.addKeystrokeInfoGroup({\n id: 'table',\n label: t('Keystrokes that can be used in a table cell'),\n keystrokes: [\n {\n label: t('Move the selection to the next cell'),\n keystroke: 'Tab'\n },\n {\n label: t('Move the selection to the previous cell'),\n keystroke: 'Shift+Tab'\n },\n {\n label: t('Insert a new table row (when in the last cell of a table)'),\n keystroke: 'Tab'\n },\n {\n label: t('Navigate through the table'),\n keystroke: [['arrowup'], ['arrowright'], ['arrowdown'], ['arrowleft']]\n }\n ]\n });\n }\n /**\n * Handles {@link module:engine/view/document~ViewDocument#event:tab tab} events for the Tab key executed\n * when the table widget is selected.\n */\n _handleTabOnSelectedTable(bubblingEventInfo, domEventData) {\n const editor = this.editor;\n const selection = editor.model.document.selection;\n const selectedElement = selection.getSelectedElement();\n if (!selectedElement || !selectedElement.is('element', 'table')) {\n return;\n }\n // For backward compatibility stop propagation of this DOM event.\n // The default tab handling from widgets handles navigation.\n domEventData.stopPropagation();\n }\n /**\n * Handles {@link module:engine/view/document~ViewDocument#event:tab tab} events for the Tab key executed\n * inside table cells.\n */\n _handleTab(bubblingEventInfo, domEventData) {\n const editor = this.editor;\n const tableUtils = this.editor.plugins.get(TableUtils);\n const tableSelection = this.editor.plugins.get('TableSelection');\n const selection = editor.model.document.selection;\n const isForward = !domEventData.shiftKey;\n let tableCell = tableUtils.getTableCellsContainingSelection(selection)[0];\n if (!tableCell) {\n tableCell = tableSelection.getFocusCell();\n }\n if (!tableCell) {\n return;\n }\n // For backward compatibility stop propagation of this DOM event.\n // The default tab handling from widgets handles navigation.\n domEventData.stopPropagation();\n const tableRow = tableCell.parent;\n const table = tableRow.parent;\n const currentRowIndex = table.getChildIndex(tableRow);\n const currentCellIndex = tableRow.getChildIndex(tableCell);\n const isLastCellInRow = currentCellIndex === tableRow.childCount - 1;\n const isLastRow = currentRowIndex === tableUtils.getRows(table) - 1;\n if (isForward && isLastRow && isLastCellInRow) {\n editor.execute('insertTableRowBelow');\n }\n }\n /**\n * Handles {@link module:engine/view/document~ViewDocument#event:keydown keydown} events.\n */\n _onArrowKey(eventInfo, domEventData) {\n const editor = this.editor;\n const keyCode = domEventData.keyCode;\n const direction = getLocalizedArrowKeyCodeDirection(keyCode, editor.locale.contentLanguageDirection);\n const wasHandled = this._handleArrowKeys(direction, domEventData.shiftKey);\n if (wasHandled) {\n domEventData.preventDefault();\n domEventData.stopPropagation();\n eventInfo.stop();\n }\n }\n /**\n * Handles arrow keys to move the selection around the table.\n *\n * @param direction The direction of the arrow key.\n * @param expandSelection If the current selection should be expanded.\n * @returns Returns `true` if key was handled.\n */\n _handleArrowKeys(direction, expandSelection) {\n const tableUtils = this.editor.plugins.get(TableUtils);\n const tableSelection = this.editor.plugins.get('TableSelection');\n const model = this.editor.model;\n const selection = model.document.selection;\n const isForward = ['right', 'down'].includes(direction);\n // In case one or more table cells are selected (from outside),\n // move the selection to a cell adjacent to the selected table fragment.\n const selectedCells = tableUtils.getSelectedTableCells(selection);\n if (selectedCells.length) {\n let focusCell;\n if (expandSelection) {\n focusCell = tableSelection.getFocusCell();\n }\n else {\n focusCell = isForward ? selectedCells[selectedCells.length - 1] : selectedCells[0];\n }\n this._navigateFromCellInDirection(focusCell, direction, expandSelection);\n return true;\n }\n // Abort if we're not in a table cell.\n const tableCell = selection.focus.findAncestor('tableCell');\n /* istanbul ignore if: paranoid check -- @preserve */\n if (!tableCell) {\n return false;\n }\n // When the selection is not collapsed.\n if (!selection.isCollapsed) {\n if (expandSelection) {\n // Navigation is in the opposite direction than the selection direction so this is shrinking of the selection.\n // Selection for sure will not approach cell edge.\n //\n // With a special case when all cell content is selected - then selection should expand to the other cell.\n // Note: When the entire cell gets selected using CTRL+A, the selection is always forward.\n if (selection.isBackward == isForward && !selection.containsEntireContent(tableCell)) {\n return false;\n }\n }\n else {\n const selectedElement = selection.getSelectedElement();\n // It will collapse for non-object selected so it's not going to move to other cell.\n if (!selectedElement || !model.schema.isObject(selectedElement)) {\n return false;\n }\n }\n }\n // Let's check if the selection is at the beginning/end of the cell.\n if (this._isSelectionAtCellEdge(selection, tableCell, isForward)) {\n this._navigateFromCellInDirection(tableCell, direction, expandSelection);\n return true;\n }\n return false;\n }\n /**\n * Returns `true` if the selection is at the boundary of a table cell according to the navigation direction.\n *\n * @param selection The current selection.\n * @param tableCell The current table cell element.\n * @param isForward The expected navigation direction.\n */\n _isSelectionAtCellEdge(selection, tableCell, isForward) {\n const model = this.editor.model;\n const schema = this.editor.model.schema;\n const focus = isForward ? selection.getLastPosition() : selection.getFirstPosition();\n // If the current limit element is not table cell we are for sure not at the cell edge.\n // Also `modifySelection` will not let us out of it.\n if (!schema.getLimitElement(focus).is('element', 'tableCell')) {\n const boundaryPosition = model.createPositionAt(tableCell, isForward ? 'end' : 0);\n return boundaryPosition.isTouching(focus);\n }\n const probe = model.createSelection(focus);\n model.modifySelection(probe, { direction: isForward ? 'forward' : 'backward' });\n // If there was no change in the focus position, then it's not possible to move the selection there.\n return focus.isEqual(probe.focus);\n }\n /**\n * Moves the selection from the given table cell in the specified direction.\n *\n * @param focusCell The table cell that is current multi-cell selection focus.\n * @param direction Direction in which selection should move.\n * @param expandSelection If the current selection should be expanded. Default value is false.\n */\n _navigateFromCellInDirection(focusCell, direction, expandSelection = false) {\n const model = this.editor.model;\n const table = focusCell.findAncestor('table');\n const tableMap = [...new TableWalker(table, { includeAllSlots: true })];\n const { row: lastRow, column: lastColumn } = tableMap[tableMap.length - 1];\n const currentCellInfo = tableMap.find(({ cell }) => cell == focusCell);\n let { row, column } = currentCellInfo;\n switch (direction) {\n case 'left':\n column--;\n break;\n case 'up':\n row--;\n break;\n case 'right':\n column += currentCellInfo.cellWidth;\n break;\n case 'down':\n row += currentCellInfo.cellHeight;\n break;\n }\n const isOutsideVertically = row < 0 || row > lastRow;\n const isBeforeFirstCell = column < 0 && row <= 0;\n const isAfterLastCell = column > lastColumn && row >= lastRow;\n // Note that if the table cell at the end of a row is row-spanned then isAfterLastCell will never be true.\n // However, we don't know if user was navigating on the last row or not, so let's stay in the table.\n if (isOutsideVertically || isBeforeFirstCell || isAfterLastCell) {\n model.change(writer => {\n writer.setSelection(writer.createRangeOn(table));\n });\n return;\n }\n if (column < 0) {\n column = expandSelection ? 0 : lastColumn;\n row--;\n }\n else if (column > lastColumn) {\n column = expandSelection ? lastColumn : 0;\n row++;\n }\n const cellToSelect = tableMap.find(cellInfo => cellInfo.row == row && cellInfo.column == column).cell;\n const isForward = ['right', 'down'].includes(direction);\n const tableSelection = this.editor.plugins.get('TableSelection');\n if (expandSelection && tableSelection.isEnabled) {\n const anchorCell = tableSelection.getAnchorCell() || focusCell;\n tableSelection.setCellSelection(anchorCell, cellToSelect);\n }\n else {\n const positionToSelect = model.createPositionAt(cellToSelect, isForward ? 0 : 'end');\n model.change(writer => {\n writer.setSelection(positionToSelect);\n });\n }\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tablemouse/mouseeventsobserver\n */\nimport { DomEventObserver } from 'ckeditor5/src/engine.js';\n/**\n * The mouse selection event observer.\n *\n * It registers listeners for the following DOM events:\n *\n * - `'mousemove'`\n * - `'mouseleave'`\n *\n * Note that this observer is disabled by default. To enable this observer, it needs to be added to\n * {@link module:engine/view/view~EditingView} using the {@link module:engine/view/view~EditingView#addObserver} method.\n *\n * The observer is registered by the {@link module:table/tableselection~TableSelection} plugin.\n *\n * @internal\n */\nexport class MouseEventsObserver extends DomEventObserver {\n domEventType = [\n 'mousemove', 'mouseleave'\n ];\n /**\n * @inheritDoc\n */\n onDomEvent(domEvent) {\n this.fire(domEvent.type, domEvent);\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tablemouse\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { TableSelection } from './tableselection.js';\nimport { MouseEventsObserver } from './tablemouse/mouseeventsobserver.js';\nimport { TableUtils } from './tableutils.js';\n/**\n * This plugin enables a table cells' selection with the mouse.\n * It is loaded automatically by the {@link module:table/table~Table} plugin.\n */\nexport class TableMouse extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TableMouse';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get requires() {\n return [TableSelection, TableUtils];\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n // Currently the MouseObserver only handles `mousedown` and `mouseup` events.\n // TODO move to the engine?\n editor.editing.view.addObserver(MouseEventsObserver);\n this._enableShiftClickSelection();\n this._enableMouseDragSelection();\n }\n /**\n * Enables making cells selection by Shift+click. Creates a selection from the cell which previously held\n * the selection to the cell which was clicked. It can be the same cell, in which case it selects a single cell.\n */\n _enableShiftClickSelection() {\n const editor = this.editor;\n const tableUtils = editor.plugins.get(TableUtils);\n let blockSelectionChange = false;\n const tableSelection = editor.plugins.get(TableSelection);\n this.listenTo(editor.editing.view.document, 'mousedown', (evt, domEventData) => {\n const selection = editor.model.document.selection;\n if (!this.isEnabled || !tableSelection.isEnabled) {\n return;\n }\n if (!domEventData.domEvent.shiftKey) {\n return;\n }\n const anchorCell = tableSelection.getAnchorCell() || tableUtils.getTableCellsContainingSelection(selection)[0];\n if (!anchorCell) {\n return;\n }\n const targetCell = this._getModelTableCellFromDomEvent(domEventData);\n if (targetCell && haveSameTableParent(anchorCell, targetCell)) {\n blockSelectionChange = true;\n tableSelection.setCellSelection(anchorCell, targetCell);\n domEventData.preventDefault();\n }\n });\n this.listenTo(editor.editing.view.document, 'mouseup', () => {\n blockSelectionChange = false;\n });\n // We need to ignore a `selectionChange` event that is fired after we render our new table cells selection.\n // When downcasting table cells selection to the view, we put the view selection in the last selected cell\n // in a place that may not be natively a \"correct\" location. This is – we put it directly in the `` element.\n // All browsers fire the native `selectionchange` event.\n // However, all browsers except Safari return the selection in the exact place where we put it\n // (even though it's visually normalized). Safari returns `

^foo` that makes our selection observer\n // fire our `selectionChange` event (because the view selection that we set in the first step differs from the DOM selection).\n // Since `selectionChange` is fired, we automatically update the model selection that moves it that paragraph.\n // This breaks our dear cells selection.\n //\n // Theoretically this issue concerns only Safari that is the only browser that do normalize the selection.\n // However, to avoid code branching and to have a good coverage for this event blocker, I enabled it for all browsers.\n //\n // Note: I'm keeping the `blockSelectionChange` state separately for shift+click and mouse drag (exact same logic)\n // so I don't have to try to analyze whether they don't overlap in some weird cases. Probably they don't.\n // But I have other things to do, like writing this comment.\n this.listenTo(editor.editing.view.document, 'selectionChange', evt => {\n if (blockSelectionChange) {\n // @if CK_DEBUG // console.log( 'Blocked selectionChange to avoid breaking table cells selection.' );\n evt.stop();\n }\n }, { priority: 'highest' });\n }\n /**\n * Enables making cells selection by dragging.\n *\n * The selection is made only on mousemove. Mouse tracking is started on mousedown.\n * However, the cells selection is enabled only after the mouse cursor left the anchor cell.\n * Thanks to that normal text selection within one cell works just fine. However, you can still select\n * just one cell by leaving the anchor cell and moving back to it.\n */\n _enableMouseDragSelection() {\n const editor = this.editor;\n let anchorCell, targetCell;\n let beganCellSelection = false;\n let blockSelectionChange = false;\n const tableSelection = editor.plugins.get(TableSelection);\n this.listenTo(editor.editing.view.document, 'mousedown', (evt, domEventData) => {\n if (!this.isEnabled || !tableSelection.isEnabled) {\n return;\n }\n // Make sure to not conflict with the shift+click listener and any other possible handler.\n if (domEventData.domEvent.shiftKey || domEventData.domEvent.ctrlKey || domEventData.domEvent.altKey) {\n return;\n }\n anchorCell = this._getModelTableCellFromDomEvent(domEventData);\n });\n this.listenTo(editor.editing.view.document, 'mousemove', (evt, domEventData) => {\n if (!domEventData.domEvent.buttons) {\n return;\n }\n if (!anchorCell) {\n return;\n }\n const newTargetCell = this._getModelTableCellFromDomEvent(domEventData);\n if (newTargetCell && haveSameTableParent(anchorCell, newTargetCell)) {\n targetCell = newTargetCell;\n // Switch to the cell selection mode after the mouse cursor left the anchor cell.\n // Switch off only on mouseup (makes selecting a single cell possible).\n if (!beganCellSelection && targetCell != anchorCell) {\n beganCellSelection = true;\n }\n }\n // Yep, not making a cell selection yet. See method docs.\n if (!beganCellSelection) {\n return;\n }\n blockSelectionChange = true;\n tableSelection.setCellSelection(anchorCell, targetCell);\n domEventData.preventDefault();\n });\n this.listenTo(editor.editing.view.document, 'mouseup', () => {\n beganCellSelection = false;\n blockSelectionChange = false;\n anchorCell = null;\n targetCell = null;\n });\n // See the explanation in `_enableShiftClickSelection()`.\n this.listenTo(editor.editing.view.document, 'selectionChange', evt => {\n if (blockSelectionChange) {\n // @if CK_DEBUG // console.log( 'Blocked selectionChange to avoid breaking table cells selection.' );\n evt.stop();\n }\n }, { priority: 'highest' });\n }\n /**\n * Returns the model table cell element based on the target element of the passed DOM event.\n *\n * @returns Returns the table cell or `undefined`.\n */\n _getModelTableCellFromDomEvent(domEventData) {\n // Note: Work with positions (not element mapping) because the target element can be an attribute or other non-mapped element.\n const viewTargetElement = domEventData.target;\n const viewPosition = this.editor.editing.view.createPositionAt(viewTargetElement, 0);\n const modelPosition = this.editor.editing.mapper.toModelPosition(viewPosition);\n const modelElement = modelPosition.parent;\n return modelElement.findAncestor('tableCell', { includeSelf: true });\n }\n}\nfunction haveSameTableParent(cellA, cellB) {\n return cellA.parent.parent == cellB.parent.parent;\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { isWidget } from 'ckeditor5/src/widget.js';\n/**\n * Depending on the position of the selection either return the selected table or the table higher in the hierarchy.\n *\n * @internal\n */\nexport function getSelectionAffectedTableWidget(selection) {\n const selectedTable = getSelectedTableWidget(selection);\n if (selectedTable) {\n return selectedTable;\n }\n return getTableWidgetAncestor(selection);\n}\n/**\n * Returns a table widget editing view element if one is selected.\n *\n * @internal\n */\nexport function getSelectedTableWidget(selection) {\n const viewElement = selection.getSelectedElement();\n if (viewElement && isTableWidget(viewElement)) {\n return viewElement;\n }\n return null;\n}\n/**\n * Returns a table widget editing view element if one is among the selection's ancestors.\n *\n * @internal\n */\nexport function getTableWidgetAncestor(selection) {\n const selectionPosition = selection.getFirstPosition();\n if (!selectionPosition) {\n return null;\n }\n let parent = selectionPosition.parent;\n while (parent) {\n if (parent.is('element') && isTableWidget(parent)) {\n return parent;\n }\n parent = parent.parent;\n }\n return null;\n}\n/**\n * Checks if a given view element is a table widget.\n *\n * @internal\n */\nexport function isTableWidget(viewNode) {\n return viewNode.is('element') && !!viewNode.getCustomProperty('table') && isWidget(viewNode);\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { getSelectionAffectedTable } from '../../utils/common.js';\n/**\n * The table cell attribute command.\n *\n * This command is a base command for other table property commands.\n */\nexport class TablePropertyCommand extends Command {\n /**\n * The attribute that will be set by the command.\n */\n attributeName;\n /**\n * The default value for the attribute.\n *\n * @readonly\n */\n _defaultValue;\n /**\n * The default value for the attribute for the content table.\n */\n _defaultContentTableValue;\n /**\n * The default value for the attribute for the layout table.\n */\n _defaultLayoutTableValue;\n /**\n * Creates a new `TablePropertyCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param attributeName Table cell attribute name.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, attributeName, defaultValue) {\n super(editor);\n this.attributeName = attributeName;\n this._defaultContentTableValue = defaultValue;\n this._defaultLayoutTableValue = attributeName === 'tableBorderStyle' ? 'none' : undefined;\n }\n /**\n * @inheritDoc\n */\n refresh() {\n const editor = this.editor;\n const selection = editor.model.document.selection;\n const table = getSelectionAffectedTable(selection);\n this._defaultValue = !table || table.getAttribute('tableType') !== 'layout' ?\n this._defaultContentTableValue :\n this._defaultLayoutTableValue;\n this.isEnabled = !!table;\n this.value = this._getValue(table);\n }\n /**\n * Executes the command.\n *\n * @fires execute\n * @param options.value If set, the command will set the attribute on the selected table.\n * If not set, the command will remove the attribute from the selected table.\n * @param options.batch Pass the model batch instance to the command to aggregate changes,\n * for example, to allow a single undo step for multiple executions.\n */\n execute(options = {}) {\n const model = this.editor.model;\n const selection = model.document.selection;\n const { value, batch } = options;\n const table = getSelectionAffectedTable(selection);\n const valueToSet = this._getValueToSet(value);\n model.enqueueChange(batch, writer => {\n if (valueToSet) {\n writer.setAttribute(this.attributeName, valueToSet, table);\n }\n else {\n writer.removeAttribute(this.attributeName, table);\n }\n });\n }\n /**\n * Returns the attribute value for a table.\n */\n _getValue(table) {\n if (!table) {\n return;\n }\n const value = table.getAttribute(this.attributeName);\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n /**\n * Returns the proper model value. It can be used to add a default unit to numeric values.\n */\n _getValueToSet(value) {\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TablePropertyCommand } from './tablepropertycommand.js';\n/**\n * The table background color command.\n *\n * The command is registered by the {@link module:table/tableproperties/tablepropertiesediting~TablePropertiesEditing} as\n * the `'tableBackgroundColor'` editor command.\n *\n * To change the background color of the selected table, execute the command:\n *\n * ```ts\n * editor.execute( 'tableBackgroundColor', {\n * value: '#f00'\n * } );\n * ```\n */\nexport class TableBackgroundColorCommand extends TablePropertyCommand {\n /**\n * Creates a new `TableBackgroundColorCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableBackgroundColor', defaultValue);\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TablePropertyCommand } from './tablepropertycommand.js';\nimport { getSingleValue } from '../../utils/table-properties.js';\n/**\n * The table border color command.\n *\n * The command is registered by the {@link module:table/tableproperties/tablepropertiesediting~TablePropertiesEditing} as\n * the `'tableBorderColor'` editor command.\n *\n * To change the border color of the selected table, execute the command:\n *\n * ```ts\n * editor.execute( 'tableBorderColor', {\n * value: '#f00'\n * } );\n * ```\n */\nexport class TableBorderColorCommand extends TablePropertyCommand {\n /**\n * Creates a new `TableBorderColorCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableBorderColor', defaultValue);\n }\n /**\n * @inheritDoc\n */\n _getValue(table) {\n if (!table) {\n return;\n }\n const value = getSingleValue(table.getAttribute(this.attributeName));\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TablePropertyCommand } from './tablepropertycommand.js';\nimport { getSingleValue } from '../../utils/table-properties.js';\n/**\n * The table style border command.\n *\n * The command is registered by the {@link module:table/tableproperties/tablepropertiesediting~TablePropertiesEditing} as\n * the `'tableBorderStyle'` editor command.\n *\n * To change the border style of the selected table, execute the command:\n *\n * ```ts\n * editor.execute( 'tableBorderStyle', {\n * value: 'dashed'\n * } );\n * ```\n */\nexport class TableBorderStyleCommand extends TablePropertyCommand {\n /**\n * Creates a new `TableBorderStyleCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableBorderStyle', defaultValue);\n }\n /**\n * @inheritDoc\n */\n _getValue(table) {\n if (!table) {\n return;\n }\n const value = getSingleValue(table.getAttribute(this.attributeName));\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TablePropertyCommand } from './tablepropertycommand.js';\nimport { addDefaultUnitToNumericValue, getSingleValue } from '../../utils/table-properties.js';\n/**\n * The table width border command.\n *\n * The command is registered by the {@link module:table/tableproperties/tablepropertiesediting~TablePropertiesEditing} as\n * the `'tableBorderWidth'` editor command.\n *\n * To change the border width of the selected table, execute the command:\n *\n * ```ts\n * editor.execute( 'tableBorderWidth', {\n * value: '5px'\n * } );\n * ```\n *\n * **Note**: This command adds the default `'px'` unit to numeric values. Executing:\n *\n * ```ts\n * editor.execute( 'tableBorderWidth', {\n * value: '5'\n * } );\n * ```\n *\n * will set the `borderWidth` attribute to `'5px'` in the model.\n */\nexport class TableBorderWidthCommand extends TablePropertyCommand {\n /**\n * Creates a new `TableBorderWidthCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableBorderWidth', defaultValue);\n }\n /**\n * @inheritDoc\n */\n _getValue(table) {\n if (!table) {\n return;\n }\n const value = getSingleValue(table.getAttribute(this.attributeName));\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n /**\n * @inheritDoc\n */\n _getValueToSet(value) {\n const newValue = addDefaultUnitToNumericValue(value, 'px');\n if (newValue === this._defaultValue) {\n return;\n }\n return newValue;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tableproperties/commands/tablewidthcommand\n */\nimport { TablePropertyCommand } from './tablepropertycommand.js';\nimport { addDefaultUnitToNumericValue } from '../../utils/table-properties.js';\n/**\n * The table width command.\n *\n * The command is registered by the {@link module:table/tableproperties/tablepropertiesediting~TablePropertiesEditing} as\n * the `'tableWidth'` editor command.\n *\n * To change the width of the selected table, execute the command:\n *\n * ```ts\n * editor.execute( 'tableWidth', {\n * value: '400px'\n * } );\n * ```\n *\n * **Note**: This command adds the default `'px'` unit to numeric values. Executing:\n *\n * ```ts\n * editor.execute( 'tableWidth', {\n * value: '50'\n * } );\n * ```\n *\n * will set the `width` attribute to `'50px'` in the model.\n */\nexport class TableWidthCommand extends TablePropertyCommand {\n /**\n * Creates a new `TableWidthCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableWidth', defaultValue);\n }\n /**\n * @inheritDoc\n */\n _getValueToSet(value) {\n value = addDefaultUnitToNumericValue(value, 'px');\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tableproperties/commands/tableheightcommand\n */\nimport { TablePropertyCommand } from './tablepropertycommand.js';\nimport { addDefaultUnitToNumericValue } from '../../utils/table-properties.js';\n/**\n * The table height command.\n *\n * The command is registered by the {@link module:table/tableproperties/tablepropertiesediting~TablePropertiesEditing} as\n * the `'tableHeight'` editor command.\n *\n * To change the height of the selected table, execute the command:\n *\n * ```ts\n * editor.execute( 'tableHeight', {\n * value: '500px'\n * } );\n * ```\n *\n * **Note**: This command adds the default `'px'` unit to numeric values. Executing:\n *\n * ```ts\n * editor.execute( 'tableHeight', {\n * value: '50'\n * } );\n * ```\n *\n * will set the `height` attribute to `'50px'` in the model.\n */\nexport class TableHeightCommand extends TablePropertyCommand {\n /**\n * Creates a new `TableHeightCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableHeight', defaultValue);\n }\n /**\n * @inheritDoc\n */\n _getValueToSet(value) {\n value = addDefaultUnitToNumericValue(value, 'px');\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TablePropertyCommand } from './tablepropertycommand.js';\n/**\n * The table alignment command.\n *\n * The command is registered by the {@link module:table/tableproperties/tablepropertiesediting~TablePropertiesEditing} as\n * the `'tableAlignment'` editor command.\n *\n * To change the alignment of the selected table, execute the command:\n *\n * ```ts\n * editor.execute( 'tableAlignment', {\n * value: 'right'\n * } );\n * ```\n */\nexport class TableAlignmentCommand extends TablePropertyCommand {\n /**\n * Creates a new `TableAlignmentCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value for the \"alignment\" attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableAlignment', defaultValue);\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tableproperties/tablepropertiesediting\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { addBackgroundStylesRules, addBorderStylesRules, addMarginStylesRules } from 'ckeditor5/src/engine.js';\nimport { first } from 'ckeditor5/src/utils.js';\nimport { TableEditing } from '../tableediting.js';\nimport { downcastAttributeToStyle, downcastTableAttribute, getDefaultValueAdjusted, upcastBorderStyles, upcastStyleToAttribute, upcastTableAlignmentConfig, DEFAULT_TABLE_ALIGNMENT_OPTIONS } from '../converters/tableproperties.js';\nimport { TableBackgroundColorCommand } from './commands/tablebackgroundcolorcommand.js';\nimport { TableBorderColorCommand } from './commands/tablebordercolorcommand.js';\nimport { TableBorderStyleCommand } from './commands/tableborderstylecommand.js';\nimport { TableBorderWidthCommand } from './commands/tableborderwidthcommand.js';\nimport { TableWidthCommand } from './commands/tablewidthcommand.js';\nimport { TableHeightCommand } from './commands/tableheightcommand.js';\nimport { TableAlignmentCommand } from './commands/tablealignmentcommand.js';\nimport { getNormalizedDefaultTableProperties } from '../utils/table-properties.js';\nimport { getViewTableFromWrapper } from '../utils/structure.js';\n/**\n * The table properties editing feature.\n *\n * Introduces table's model attributes and their conversion:\n *\n * - border: `tableBorderStyle`, `tableBorderColor` and `tableBorderWidth`\n * - background color: `tableBackgroundColor`\n * - horizontal alignment: `tableAlignment`\n * - width & height: `tableWidth` & `tableHeight`\n *\n * It also registers commands used to manipulate the above attributes:\n *\n * - border: `'tableBorderStyle'`, `'tableBorderColor'` and `'tableBorderWidth'` commands\n * - background color: `'tableBackgroundColor'`\n * - horizontal alignment: `'tableAlignment'`\n * - width & height: `'tableWidth'` & `'tableHeight'`\n */\nexport class TablePropertiesEditing extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TablePropertiesEditing';\n }\n /**\n * @inheritDoc\n * @internal\n */\n static get licenseFeatureCode() {\n return 'TCP';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get isPremiumPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get requires() {\n return [TableEditing];\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n editor.config.define('table.tableProperties.defaultProperties', {});\n const defaultTableProperties = getNormalizedDefaultTableProperties(editor.config.get('table.tableProperties.defaultProperties'), {\n includeAlignmentProperty: true\n });\n const useInlineStyles = editor.config.get('table.tableProperties.alignment.useInlineStyles') !== false;\n editor.data.addStyleProcessorRules(addMarginStylesRules);\n editor.data.addStyleProcessorRules(addBorderStylesRules);\n enableBorderProperties(editor, {\n color: defaultTableProperties.borderColor,\n style: defaultTableProperties.borderStyle,\n width: defaultTableProperties.borderWidth\n });\n editor.commands.add('tableBorderColor', new TableBorderColorCommand(editor, defaultTableProperties.borderColor));\n editor.commands.add('tableBorderStyle', new TableBorderStyleCommand(editor, defaultTableProperties.borderStyle));\n editor.commands.add('tableBorderWidth', new TableBorderWidthCommand(editor, defaultTableProperties.borderWidth));\n if (editor.config.get('experimentalFlags.useExtendedTableBlockAlignment')) {\n enableExtendedAlignmentProperty(schema, conversion, defaultTableProperties.alignment, useInlineStyles);\n }\n else {\n enableAlignmentProperty(schema, conversion, defaultTableProperties.alignment);\n }\n editor.commands.add('tableAlignment', new TableAlignmentCommand(editor, defaultTableProperties.alignment));\n enableTableToFigureProperty(schema, conversion, {\n modelAttribute: 'tableWidth',\n styleName: 'width',\n attributeName: 'width',\n attributeType: 'length',\n defaultValue: defaultTableProperties.width\n });\n editor.commands.add('tableWidth', new TableWidthCommand(editor, defaultTableProperties.width));\n enableTableToFigureProperty(schema, conversion, {\n modelAttribute: 'tableHeight',\n styleName: 'height',\n attributeName: 'height',\n attributeType: 'length',\n defaultValue: defaultTableProperties.height\n });\n editor.commands.add('tableHeight', new TableHeightCommand(editor, defaultTableProperties.height));\n editor.data.addStyleProcessorRules(addBackgroundStylesRules);\n enableProperty(schema, conversion, {\n modelAttribute: 'tableBackgroundColor',\n styleName: 'background-color',\n attributeName: 'bgcolor',\n attributeType: 'color',\n defaultValue: defaultTableProperties.backgroundColor\n });\n editor.commands.add('tableBackgroundColor', new TableBackgroundColorCommand(editor, defaultTableProperties.backgroundColor));\n if (editor.config.get('experimentalFlags.useExtendedTableBlockAlignment')) {\n const viewDoc = editor.editing.view.document;\n // Adjust clipboard output to wrap tables in divs if needed (for alignment).\n this.listenTo(viewDoc, 'clipboardOutput', (evt, data) => {\n editor.editing.view.change(writer => {\n for (const { item } of writer.createRangeIn(data.content)) {\n wrapInDivIfNeeded(item, writer);\n }\n data.dataTransfer.setData('text/html', this.editor.data.htmlProcessor.toData(data.content));\n });\n }, { priority: 'lowest' });\n }\n }\n}\n/**\n * Checks whether the view element is a table and if it needs to be wrapped in a div for alignment purposes.\n * If so, it wraps it in a div and inserts it into the data content.\n */\nfunction wrapInDivIfNeeded(viewItem, writer) {\n if (!viewItem.is('element', 'table')) {\n return;\n }\n const alignAttribute = viewItem.getAttribute('align');\n const floatAttribute = viewItem.getStyle('float');\n const marginLeft = viewItem.getStyle('margin-left');\n const marginRight = viewItem.getStyle('margin-right');\n if (\n // Align center.\n (alignAttribute && alignAttribute === 'center') ||\n // Align right with text wrapping.\n (floatAttribute && floatAttribute === 'right' && alignAttribute && alignAttribute === 'right')) {\n insertWrapperWithAlignment(writer, alignAttribute, viewItem);\n return;\n }\n // Align right with no text wrapping.\n if (floatAttribute === undefined && marginLeft === 'auto' && marginRight === '0') {\n insertWrapperWithAlignment(writer, 'right', viewItem);\n }\n}\nfunction insertWrapperWithAlignment(writer, align, table) {\n const position = writer.createPositionBefore(table);\n const wrapper = writer.createContainerElement('div', { align }, table);\n writer.insert(position, wrapper);\n}\n/**\n * Enables `tableBorderStyle'`, `tableBorderColor'` and `tableBorderWidth'` attributes for table.\n *\n * @param defaultBorder The default border values.\n * @param defaultBorder.color The default `tableBorderColor` value.\n * @param defaultBorder.style The default `tableBorderStyle` value.\n * @param defaultBorder.width The default `tableBorderWidth` value.\n */\nfunction enableBorderProperties(editor, defaultBorder) {\n const { conversion } = editor;\n const { schema } = editor.model;\n const modelAttributes = {\n width: 'tableBorderWidth',\n color: 'tableBorderColor',\n style: 'tableBorderStyle'\n };\n schema.extend('table', {\n allowAttributes: Object.values(modelAttributes)\n });\n for (const modelAttribute of Object.values(modelAttributes)) {\n schema.setAttributeProperties(modelAttribute, { isFormatting: true });\n }\n upcastBorderStyles(editor, 'table', modelAttributes, defaultBorder);\n downcastTableAttribute(conversion, { modelAttribute: modelAttributes.color, styleName: 'border-color' });\n downcastTableAttribute(conversion, { modelAttribute: modelAttributes.style, styleName: 'border-style' });\n downcastTableAttribute(conversion, { modelAttribute: modelAttributes.width, styleName: 'border-width' });\n}\n/**\n * Enables the extended block`'alignment'` attribute for table.\n *\n * @param defaultValue The default alignment value.\n */\nfunction enableExtendedAlignmentProperty(schema, conversion, defaultValue, useInlineStyles) {\n schema.extend('table', {\n allowAttributes: ['tableAlignment']\n });\n schema.setAttributeProperties('tableAlignment', { isFormatting: true });\n conversion.for('downcast')\n .attributeToAttribute({\n model: {\n name: 'table',\n key: 'tableAlignment',\n values: ['left', 'center', 'right', 'blockLeft', 'blockRight']\n },\n view: {\n left: useInlineStyles ? {\n key: 'style',\n value: {\n float: 'left',\n 'margin-right': 'var(--ck-content-table-style-spacing, 1.5em)'\n }\n } : {\n key: 'class',\n value: DEFAULT_TABLE_ALIGNMENT_OPTIONS.left.className\n },\n right: useInlineStyles ? {\n key: 'style',\n value: {\n float: 'right',\n 'margin-left': 'var(--ck-content-table-style-spacing, 1.5em)'\n }\n } : {\n key: 'class',\n value: DEFAULT_TABLE_ALIGNMENT_OPTIONS.right.className\n },\n center: useInlineStyles ? {\n key: 'style',\n value: {\n 'margin-left': 'auto',\n 'margin-right': 'auto'\n }\n } : {\n key: 'class',\n value: DEFAULT_TABLE_ALIGNMENT_OPTIONS.center.className\n },\n blockLeft: useInlineStyles ? {\n key: 'style',\n value: {\n 'margin-left': '0',\n 'margin-right': 'auto'\n }\n } : {\n key: 'class',\n value: DEFAULT_TABLE_ALIGNMENT_OPTIONS.blockLeft.className\n },\n blockRight: useInlineStyles ? {\n key: 'style',\n value: {\n 'margin-left': 'auto',\n 'margin-right': '0'\n }\n } : {\n key: 'class',\n value: DEFAULT_TABLE_ALIGNMENT_OPTIONS.blockRight.className\n }\n },\n converterPriority: 'high'\n });\n /**\n * Enables upcasting of the `tableAlignment` attribute.\n */\n upcastTableAlignmentConfig.forEach(config => {\n conversion.for('upcast').attributeToAttribute({\n view: config.view,\n model: {\n key: 'tableAlignment',\n value: (viewElement, conversionApi, data) => {\n if (isNonTableFigureElement(viewElement)) {\n return;\n }\n const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);\n const align = config.getAlign(viewElement);\n const consumables = config.getConsumables(viewElement);\n conversionApi.consumable.consume(viewElement, consumables);\n if (align !== localDefaultValue) {\n return align;\n }\n }\n }\n });\n });\n conversion.for('upcast').add(upcastTableAlignedDiv(defaultValue));\n}\n/**\n * Enables the `'alignment'` attribute for table.\n *\n * @param defaultValue The default alignment value.\n */\nfunction enableAlignmentProperty(schema, conversion, defaultValue) {\n const ALIGN_VALUES_REG_EXP = /^(left|center|right)$/;\n const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;\n schema.extend('table', {\n allowAttributes: ['tableAlignment']\n });\n schema.setAttributeProperties('tableAlignment', { isFormatting: true });\n conversion.for('downcast')\n .attributeToAttribute({\n model: {\n name: 'table',\n key: 'tableAlignment',\n values: ['left', 'center', 'right']\n },\n view: {\n left: {\n key: 'style',\n value: {\n float: 'left'\n }\n },\n right: {\n key: 'style',\n value: {\n float: 'right'\n }\n },\n center: (alignment, conversionApi, data) => {\n const value = data.item.getAttribute('tableType') !== 'layout' ? {\n // Model: `alignment:center` => CSS: `float:none`.\n float: 'none'\n } : {\n 'margin-left': 'auto',\n 'margin-right': 'auto'\n };\n return {\n key: 'style',\n value\n };\n }\n },\n converterPriority: 'high'\n });\n conversion.for('upcast')\n // Support for the `float:*;` CSS definition for the table alignment.\n .attributeToAttribute({\n view: {\n name: /^(table|figure)$/,\n styles: {\n float: FLOAT_VALUES_REG_EXP\n }\n },\n model: {\n key: 'tableAlignment',\n value: (viewElement, conversionApi, data) => {\n // Ignore other figure elements.\n if (viewElement.name == 'figure' && !viewElement.hasClass('table')) {\n return;\n }\n const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);\n let align = viewElement.getStyle('float');\n // CSS: `float:none` => Model: `alignment:center`.\n if (align === 'none') {\n align = 'center';\n }\n if (align !== localDefaultValue) {\n return align;\n }\n // Consume the style even if not applied to the element so it won't be processed by other converters.\n conversionApi.consumable.consume(viewElement, { styles: 'float' });\n }\n }\n })\n // Support for the `margin-left:auto; margin-right:auto;` CSS definition for the table alignment.\n .attributeToAttribute({\n view: {\n name: /^(table|figure)$/,\n styles: {\n 'margin-left': 'auto',\n 'margin-right': 'auto'\n }\n },\n model: {\n key: 'tableAlignment',\n value: (viewElement, conversionApi, data) => {\n // Ignore other figure elements.\n if (viewElement.name == 'figure' && !viewElement.hasClass('table')) {\n return;\n }\n const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);\n const align = 'center';\n if (align !== localDefaultValue) {\n return align;\n }\n // Consume the styles even if not applied to the element so it won't be processed by other converters.\n conversionApi.consumable.consume(viewElement, { styles: ['margin-left', 'margin-right'] });\n }\n }\n })\n // Support for the `align` attribute as the backward compatibility while pasting from other sources.\n .attributeToAttribute({\n view: {\n name: 'table',\n attributes: {\n align: ALIGN_VALUES_REG_EXP\n }\n },\n model: {\n key: 'tableAlignment',\n value: (viewElement, conversionApi, data) => {\n const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);\n const align = viewElement.getAttribute('align');\n if (align !== localDefaultValue) {\n return align;\n }\n // Consume the attribute even if not applied to the element so it won't be processed by other converters.\n conversionApi.consumable.consume(viewElement, { attributes: 'align' });\n }\n }\n });\n}\n/**\n * Returns a function that converts the table view representation:\n *\n * ```html\n *

...
\n * \n *
...
\n * \n *
...
\n * ```\n *\n * to the model representation:\n *\n * ```xml\n *
\n * ```\n *\n * @internal\n */\nfunction upcastTableAlignedDiv(defaultValue) {\n return (dispatcher) => {\n dispatcher.on('element:div', (evt, data, conversionApi) => {\n // Do not convert if this is not a \"table wrapped in div with align attribute\".\n if (!conversionApi.consumable.test(data.viewItem, { name: true, attributes: 'align' })) {\n return;\n }\n // Find a table element inside the div element.\n const viewTable = getViewTableFromWrapper(data.viewItem);\n // Do not convert if table element is absent or was already converted.\n if (!viewTable || !conversionApi.consumable.test(viewTable, { name: true })) {\n return;\n }\n // Consume the div to prevent other converters from processing it again.\n conversionApi.consumable.consume(data.viewItem, { name: true, attributes: 'align' });\n // Convert view table to model table.\n const conversionResult = conversionApi.convertItem(viewTable, data.modelCursor);\n // Get table element from conversion result.\n const modelTable = first(conversionResult.modelRange.getItems());\n // When table wasn't successfully converted then finish conversion.\n if (!modelTable || !modelTable.is('element', 'table')) {\n // Revert consumed div so other features can convert it.\n conversionApi.consumable.revert(data.viewItem, { name: true, attributes: 'align' });\n // If anyway some table content was converted, we have to pass the model range and cursor.\n if (conversionResult.modelRange && !conversionResult.modelRange.isCollapsed) {\n data.modelRange = conversionResult.modelRange;\n data.modelCursor = conversionResult.modelCursor;\n }\n return;\n }\n const alignAttributeFromDiv = data.viewItem.getAttribute('align');\n const alignAttributeFromTable = viewTable.getAttribute('align');\n const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);\n const align = convertToTableAlignment(alignAttributeFromDiv, alignAttributeFromTable, localDefaultValue);\n if (align) {\n conversionApi.writer.setAttribute('tableAlignment', align, modelTable);\n }\n conversionApi.convertChildren(data.viewItem, conversionApi.writer.createPositionAt(modelTable, 'end'));\n conversionApi.updateConversionResult(modelTable, data);\n });\n };\n}\n/**\n * Converts div `align` and table `align` attributes to the model `tableAlignment` attribute.\n *\n * @param divAlign The value of the div `align` attribute.\n * @param tableAlign The value of the table `align` attribute.\n * @param defaultValue The default alignment value.\n * @returns The model `tableAlignment` value or `undefined` if no conversion is needed.\n */\nfunction convertToTableAlignment(divAlign, tableAlign, defaultValue) {\n if (divAlign) {\n switch (divAlign) {\n case 'right':\n if (tableAlign === 'right') {\n return 'right';\n }\n else if (tableAlign === 'left') {\n return 'left';\n }\n else {\n return 'blockRight';\n }\n case 'center':\n return 'center';\n case 'left':\n return tableAlign === undefined ? 'blockLeft' : 'left';\n default:\n return defaultValue;\n }\n }\n return undefined;\n}\n/**\n * Enables conversion for an attribute for simple view-model mappings.\n *\n * @param options.defaultValue The default value for the specified `modelAttribute`.\n */\nfunction enableProperty(schema, conversion, options) {\n const { modelAttribute } = options;\n schema.extend('table', {\n allowAttributes: [modelAttribute]\n });\n schema.setAttributeProperties(modelAttribute, { isFormatting: true });\n upcastStyleToAttribute(conversion, { viewElement: 'table', ...options });\n downcastTableAttribute(conversion, options);\n}\n/**\n * Enables conversion for an attribute for simple view (figure) to model (table) mappings.\n */\nfunction enableTableToFigureProperty(schema, conversion, options) {\n const { modelAttribute } = options;\n schema.extend('table', {\n allowAttributes: [modelAttribute]\n });\n schema.setAttributeProperties(modelAttribute, { isFormatting: true });\n upcastStyleToAttribute(conversion, {\n viewElement: /^(table|figure)$/,\n shouldUpcast: (viewElement) => !(viewElement.name == 'table' && viewElement.parent.name == 'figure' ||\n viewElement.name == 'figure' && !viewElement.hasClass('table')),\n ...options\n });\n downcastAttributeToStyle(conversion, { modelElement: 'table', ...options });\n}\n/**\n * Checks whether a given figure element should be ignored when upcasting table properties.\n */\nfunction isNonTableFigureElement(viewElement) {\n return viewElement.name == 'figure' && !viewElement.hasClass('table');\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/ui/colorinputview\n */\nimport { View, InputTextView, createDropdown, FocusCycler, ViewCollection, ColorSelectorView } from 'ckeditor5/src/ui.js';\nimport { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';\nimport '../../theme/colorinput.css';\n/**\n * The color input view class. It allows the user to type in a color (hex, rgb, etc.)\n * or choose it from the configurable color palette with a preview.\n *\n * @internal\n */\nexport class ColorInputView extends View {\n /**\n * A cached reference to the options passed to the constructor.\n */\n options;\n /**\n * Tracks information about the DOM focus in the view.\n */\n focusTracker;\n /**\n * Helps cycling over focusable children in the input view.\n */\n focusCycler;\n /**\n * A collection of views that can be focused in the view.\n */\n _focusables;\n /**\n * An instance of the dropdown allowing to select a color from a grid.\n */\n dropdownView;\n /**\n * An instance of the input allowing the user to type a color value.\n */\n inputView;\n /**\n * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.\n */\n keystrokes;\n /**\n * The flag that indicates whether the user is still typing.\n * If set to true, it means that the text input field ({@link #inputView}) still has the focus.\n * So, we should interrupt the user by replacing the input's value.\n */\n _stillTyping;\n /**\n * Creates an instance of the color input view.\n *\n * @param locale The locale instance.\n * @param options The input options.\n * @param options.colorDefinitions The colors to be displayed in the palette inside the input's dropdown.\n * @param options.columns The number of columns in which the colors will be displayed.\n * @param options.defaultColorValue If specified, the color input view will replace the \"Remove color\" button with\n * the \"Restore default\" button. Instead of clearing the input field, the default color value will be set.\n */\n constructor(locale, options) {\n super(locale);\n this.set('value', '');\n this.set('isReadOnly', false);\n this.set('isFocused', false);\n this.set('isEmpty', true);\n this.options = options;\n this.focusTracker = new FocusTracker();\n this._focusables = new ViewCollection();\n this.dropdownView = this._createDropdownView();\n this.inputView = this._createInputTextView();\n this.keystrokes = new KeystrokeHandler();\n this._stillTyping = false;\n this.focusCycler = new FocusCycler({\n focusables: this._focusables,\n focusTracker: this.focusTracker,\n keystrokeHandler: this.keystrokes,\n actions: {\n // Navigate items backwards using the Shift + Tab keystroke.\n focusPrevious: 'shift + tab',\n // Navigate items forwards using the Tab key.\n focusNext: 'tab'\n }\n });\n this.setTemplate({\n tag: 'div',\n attributes: {\n class: [\n 'ck',\n 'ck-input-color'\n ]\n },\n children: [\n this.dropdownView,\n this.inputView\n ]\n });\n this.on('change:value', (evt, name, inputValue) => this._setInputValue(inputValue));\n }\n /**\n * @inheritDoc\n */\n render() {\n super.render();\n [this.inputView, this.dropdownView.buttonView].forEach(view => {\n this.focusTracker.add(view.element);\n this._focusables.add(view);\n });\n this.keystrokes.listenTo(this.element);\n }\n /**\n * Focuses the view.\n */\n focus(direction) {\n if (direction === -1) {\n this.focusCycler.focusLast();\n }\n else {\n this.focusCycler.focusFirst();\n }\n }\n /**\n * @inheritDoc\n */\n destroy() {\n super.destroy();\n this.focusTracker.destroy();\n this.keystrokes.destroy();\n }\n /**\n * Creates and configures the {@link #dropdownView}.\n */\n _createDropdownView() {\n const locale = this.locale;\n const t = locale.t;\n const bind = this.bindTemplate;\n const colorSelector = this._createColorSelector(locale);\n const dropdown = createDropdown(locale);\n const colorPreview = new View();\n colorPreview.setTemplate({\n tag: 'span',\n attributes: {\n class: [\n 'ck',\n 'ck-input-color__button__preview'\n ],\n style: {\n backgroundColor: bind.to('value')\n }\n },\n children: [{\n tag: 'span',\n attributes: {\n class: [\n 'ck',\n 'ck-input-color__button__preview__no-color-indicator',\n bind.if('value', 'ck-hidden', value => value != '')\n ]\n }\n }]\n });\n dropdown.buttonView.extendTemplate({\n attributes: {\n class: 'ck-input-color__button'\n }\n });\n dropdown.buttonView.children.add(colorPreview);\n dropdown.buttonView.label = t('Color picker');\n dropdown.buttonView.tooltip = true;\n dropdown.panelPosition = locale.uiLanguageDirection === 'rtl' ? 'se' : 'sw';\n dropdown.panelView.children.add(colorSelector);\n dropdown.bind('isEnabled').to(this, 'isReadOnly', value => !value);\n dropdown.on('change:isOpen', (evt, name, isVisible) => {\n if (isVisible) {\n colorSelector.updateSelectedColors();\n colorSelector.showColorGridsFragment();\n }\n });\n return dropdown;\n }\n /**\n * Creates and configures an instance of {@link module:ui/inputtext/inputtextview~InputTextView}.\n *\n * @returns A configured instance to be set as {@link #inputView}.\n */\n _createInputTextView() {\n const locale = this.locale;\n const inputView = new InputTextView(locale);\n inputView.extendTemplate({\n on: {\n blur: inputView.bindTemplate.to('blur')\n }\n });\n inputView.value = this.value;\n inputView.bind('isReadOnly', 'hasError').to(this);\n this.bind('isFocused', 'isEmpty').to(inputView);\n inputView.on('input', () => {\n const inputValue = inputView.element.value;\n // Check if the value matches one of our defined colors' label.\n const mappedColor = this.options.colorDefinitions.find(def => inputValue === def.label);\n this._stillTyping = true;\n this.value = mappedColor && mappedColor.color || inputValue;\n });\n inputView.on('blur', () => {\n this._stillTyping = false;\n this._setInputValue(inputView.element.value);\n });\n inputView.delegate('input').to(this);\n return inputView;\n }\n /**\n * Creates and configures the panel with \"color grid\" and \"color picker\" inside the {@link #dropdownView}.\n */\n _createColorSelector(locale) {\n const t = locale.t;\n const defaultColor = this.options.defaultColorValue || '';\n const removeColorButtonLabel = defaultColor ? t('Restore default') : t('Remove color');\n const colorSelector = new ColorSelectorView(locale, {\n colors: this.options.colorDefinitions,\n columns: this.options.columns,\n removeButtonLabel: removeColorButtonLabel,\n colorPickerLabel: t('Color picker'),\n colorPickerViewConfig: this.options.colorPickerConfig === false ? false : {\n ...this.options.colorPickerConfig,\n hideInput: true\n }\n });\n colorSelector.appendUI();\n colorSelector.on('execute', (evt, data) => {\n if (data.source === 'colorPickerSaveButton') {\n this.dropdownView.isOpen = false;\n return;\n }\n this.value = data.value || defaultColor;\n // Trigger the listener that actually applies the set value.\n this.fire('input');\n if (data.source !== 'colorPicker') {\n this.dropdownView.isOpen = false;\n }\n });\n /**\n * Color is saved before changes in color picker. In case \"cancel button\" is pressed\n * this color will be applied.\n */\n let backupColor = this.value;\n colorSelector.on('colorPicker:cancel', () => {\n /**\n * Revert color to previous value before changes in color picker.\n */\n this.value = backupColor;\n this.fire('input');\n this.dropdownView.isOpen = false;\n });\n colorSelector.colorGridsFragmentView.colorPickerButtonView.on('execute', () => {\n /**\n * Save color value before changes in color picker.\n */\n backupColor = this.value;\n });\n colorSelector.bind('selectedColor').to(this, 'value');\n return colorSelector;\n }\n /**\n * Sets {@link #inputView}'s value property to the color value or color label,\n * if there is one and the user is not typing.\n *\n * Handles cases like:\n *\n * * Someone picks the color in the grid.\n * * The color is set from the plugin level.\n *\n * @param inputValue Color value to be set.\n */\n _setInputValue(inputValue) {\n if (!this._stillTyping) {\n const normalizedInputValue = normalizeColor(inputValue);\n // Check if the value matches one of our defined colors.\n const mappedColor = this.options.colorDefinitions.find(def => normalizedInputValue === normalizeColor(def.color));\n if (mappedColor) {\n this.inputView.value = mappedColor.label;\n }\n else {\n this.inputView.value = inputValue || '';\n }\n }\n }\n}\n/**\n * Normalizes color value, by stripping extensive whitespace.\n * For example., transforms:\n * * ` rgb( 25 50 0 )` to `rgb(25 50 0)`,\n * * \"\\t rgb( 25 , 50,0 )\t\t\" to `rgb(25 50 0)`.\n *\n * @param colorString The value to be normalized.\n */\nfunction normalizeColor(colorString) {\n return colorString\n // Remove any whitespace right after `(` or `,`.\n .replace(/([(,])\\s+/g, '$1')\n // Remove any whitespace at the beginning or right before the end, `)`, `,`, or another whitespace.\n .replace(/^\\s+|\\s+(?=[),\\s]|$)/g, '')\n // Then, replace `,` or whitespace with a single space.\n .replace(/,|\\s/g, ' ');\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/utils/ui/table-properties\n */\nimport { ButtonView, UIModel } from 'ckeditor5/src/ui.js';\nimport { Collection } from 'ckeditor5/src/utils.js';\nimport { isColorStyleValue, isLengthStyleValue, isPercentageStyleValue } from 'ckeditor5/src/engine.js';\nimport { ColorInputView } from '../../ui/colorinputview.js';\nconst isEmpty = (val) => val === '';\n/**\n * Returns an object containing pairs of CSS border style values and their localized UI\n * labels. Used by {@link module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView}\n * and {@link module:table/tableproperties/ui/tablepropertiesview~TablePropertiesView}.\n *\n * @internal\n * @param t The \"t\" function provided by the editor that is used to localize strings.\n */\nexport function getBorderStyleLabels(t) {\n return {\n none: t('None'),\n solid: t('Solid'),\n dotted: t('Dotted'),\n dashed: t('Dashed'),\n double: t('Double'),\n groove: t('Groove'),\n ridge: t('Ridge'),\n inset: t('Inset'),\n outset: t('Outset')\n };\n}\n/**\n * Returns a localized error string that can be displayed next to color (background, border)\n * fields that have an invalid value.\n *\n * @internal\n * @param t The \"t\" function provided by the editor that is used to localize strings.\n */\nexport function getLocalizedColorErrorText(t) {\n return t('The color is invalid. Try \"#FF0000\" or \"rgb(255,0,0)\" or \"red\".');\n}\n/**\n * Returns a localized error string that can be displayed next to length (padding, border width)\n * fields that have an invalid value.\n *\n * @internal\n * @param t The \"t\" function provided by the editor that is used to localize strings.\n */\nexport function getLocalizedLengthErrorText(t) {\n return t('The value is invalid. Try \"10px\" or \"2em\" or simply \"2\".');\n}\n/**\n * Returns `true` when the passed value is an empty string or a valid CSS color expression.\n * Otherwise, `false` is returned.\n *\n * See {@link module:engine/view/styles/utils~isColorStyleValue}.\n *\n * @internal\n */\nexport function colorFieldValidator(value) {\n value = value.trim().toLowerCase();\n return isEmpty(value) || isColorStyleValue(value);\n}\n/**\n * Returns `true` when the passed value is an empty string, a number without a unit or a valid CSS length expression.\n * Otherwise, `false` is returned.\n *\n * See {@link module:engine/view/styles/utils~isLengthStyleValue}.\n * See {@link module:engine/view/styles/utils~isPercentageStyleValue}.\n *\n * @internal\n */\nexport function lengthFieldValidator(value) {\n value = value.trim();\n return isEmpty(value) || isNumberString(value) || isLengthStyleValue(value) || isPercentageStyleValue(value);\n}\n/**\n * Returns `true` when the passed value is an empty string, a number without a unit or a valid CSS length expression.\n * Otherwise, `false` is returned.\n *\n * See {@link module:engine/view/styles/utils~isLengthStyleValue}.\n *\n * @internal\n */\nexport function lineWidthFieldValidator(value) {\n value = value.trim();\n return isEmpty(value) || isNumberString(value) || isLengthStyleValue(value);\n}\n/**\n * Generates item definitions for a UI dropdown that allows changing the border style of a table or a table cell.\n *\n * @internal\n * @param defaultStyle The default border.\n */\nexport function getBorderStyleDefinitions(view, defaultStyle) {\n const itemDefinitions = new Collection();\n const styleLabels = getBorderStyleLabels(view.t);\n for (const style in styleLabels) {\n const definition = {\n type: 'button',\n model: new UIModel({\n _borderStyleValue: style,\n label: styleLabels[style],\n role: 'menuitemradio',\n withText: true\n })\n };\n if (style === 'none') {\n definition.model.bind('isOn').to(view, 'borderStyle', value => {\n if (defaultStyle === 'none') {\n return !value;\n }\n return value === style;\n });\n }\n else {\n definition.model.bind('isOn').to(view, 'borderStyle', value => {\n return value === style;\n });\n }\n itemDefinitions.add(definition);\n }\n return itemDefinitions;\n}\n/**\n * A helper that fills a toolbar with buttons that:\n *\n * * have some labels,\n * * have some icons,\n * * set a certain UI view property value upon execution.\n *\n * @internal\n * @param options Configuration options\n * @param options.view The view that has the observable property.\n * @param options.icons Object with button icons.\n * @param options.toolbar The toolbar to fill with buttons.\n * @param options.labels Object with button labels.\n * @param options.propertyName The name of the observable property in the view.\n * @param options.nameToValue A function that maps a button name to a value. By default names are the same as values.\n * @param options.defaultValue Default value for the property.\n */\nexport function fillToolbar(options) {\n const { view, icons, toolbar, labels, propertyName, nameToValue, defaultValue } = options;\n for (const name in labels) {\n const button = new ButtonView(view.locale);\n button.set({\n role: 'radio',\n isToggleable: true,\n label: labels[name],\n icon: icons[name],\n tooltip: labels[name]\n });\n // If specified the `nameToValue()` callback, map the value based on the option's name.\n const buttonValue = nameToValue ? nameToValue(name) : name;\n button.bind('isOn').to(view, propertyName, value => {\n // `value` comes from `view[ propertyName ]`.\n let valueToCompare = value;\n // If it's empty, and the `defaultValue` is specified, use it instead.\n if (value === '' && defaultValue) {\n valueToCompare = defaultValue;\n }\n return buttonValue === valueToCompare;\n });\n button.on('execute', () => {\n // Allow toggling alignment if there is no default value specified (especially for layout tables).\n if (!defaultValue && buttonValue && view[propertyName] === buttonValue) {\n view[propertyName] = undefined;\n }\n else {\n view[propertyName] = buttonValue;\n }\n });\n toolbar.items.add(button);\n }\n}\n/**\n * A default color palette used by various user interfaces related to tables, for instance,\n * by {@link module:table/tablecellproperties/tablecellpropertiesui~TableCellPropertiesUI} or\n * {@link module:table/tableproperties/tablepropertiesui~TablePropertiesUI}.\n *\n * The color palette follows the {@link module:table/tableconfig~TableColorConfig table color configuration format}\n * and contains the following color definitions:\n *\n * ```ts\n * const defaultColors = [\n * {\n * color: 'hsl(0, 0%, 0%)',\n * label: 'Black'\n * },\n * {\n * color: 'hsl(0, 0%, 30%)',\n * label: 'Dim grey'\n * },\n * {\n * color: 'hsl(0, 0%, 60%)',\n * label: 'Grey'\n * },\n * {\n * color: 'hsl(0, 0%, 90%)',\n * label: 'Light grey'\n * },\n * {\n * color: 'hsl(0, 0%, 100%)',\n * label: 'White',\n * hasBorder: true\n * },\n * {\n * color: 'hsl(0, 75%, 60%)',\n * label: 'Red'\n * },\n * {\n * color: 'hsl(30, 75%, 60%)',\n * label: 'Orange'\n * },\n * {\n * color: 'hsl(60, 75%, 60%)',\n * label: 'Yellow'\n * },\n * {\n * color: 'hsl(90, 75%, 60%)',\n * label: 'Light green'\n * },\n * {\n * color: 'hsl(120, 75%, 60%)',\n * label: 'Green'\n * },\n * {\n * color: 'hsl(150, 75%, 60%)',\n * label: 'Aquamarine'\n * },\n * {\n * color: 'hsl(180, 75%, 60%)',\n * label: 'Turquoise'\n * },\n * {\n * color: 'hsl(210, 75%, 60%)',\n * label: 'Light blue'\n * },\n * {\n * color: 'hsl(240, 75%, 60%)',\n * label: 'Blue'\n * },\n * {\n * color: 'hsl(270, 75%, 60%)',\n * label: 'Purple'\n * }\n * ];\n * ```\n *\n * @internal\n */\nexport const defaultColors = [\n {\n color: 'hsl(0, 0%, 0%)',\n label: 'Black'\n },\n {\n color: 'hsl(0, 0%, 30%)',\n label: 'Dim grey'\n },\n {\n color: 'hsl(0, 0%, 60%)',\n label: 'Grey'\n },\n {\n color: 'hsl(0, 0%, 90%)',\n label: 'Light grey'\n },\n {\n color: 'hsl(0, 0%, 100%)',\n label: 'White',\n hasBorder: true\n },\n {\n color: 'hsl(0, 75%, 60%)',\n label: 'Red'\n },\n {\n color: 'hsl(30, 75%, 60%)',\n label: 'Orange'\n },\n {\n color: 'hsl(60, 75%, 60%)',\n label: 'Yellow'\n },\n {\n color: 'hsl(90, 75%, 60%)',\n label: 'Light green'\n },\n {\n color: 'hsl(120, 75%, 60%)',\n label: 'Green'\n },\n {\n color: 'hsl(150, 75%, 60%)',\n label: 'Aquamarine'\n },\n {\n color: 'hsl(180, 75%, 60%)',\n label: 'Turquoise'\n },\n {\n color: 'hsl(210, 75%, 60%)',\n label: 'Light blue'\n },\n {\n color: 'hsl(240, 75%, 60%)',\n label: 'Blue'\n },\n {\n color: 'hsl(270, 75%, 60%)',\n label: 'Purple'\n }\n];\n/**\n * Returns a creator for a color input with a label.\n *\n * For given options, it returns a function that creates an instance of a\n * {@link module:table/ui/colorinputview~ColorInputView color input} logically related to\n * a {@link module:ui/labeledfield/labeledfieldview~LabeledFieldView labeled view} in the DOM.\n *\n * The helper does the following:\n *\n * * It sets the color input `id` and `ariaDescribedById` attributes.\n * * It binds the color input `isReadOnly` to the labeled view.\n * * It binds the color input `hasError` to the labeled view.\n * * It enables a logic that cleans up the error when the user starts typing in the color input.\n *\n * Usage:\n *\n * ```ts\n * const colorInputCreator = getLabeledColorInputCreator( {\n * colorConfig: [ ... ],\n * columns: 3,\n * } );\n *\n * const labeledInputView = new LabeledFieldView( locale, colorInputCreator );\n * console.log( labeledInputView.view ); // A color input instance.\n * ```\n *\n * @internal\n * @param options Color input options.\n * @param options.colorConfig The configuration of the color palette displayed in the input's dropdown.\n * @param options.columns The configuration of the number of columns the color palette consists of in the input's dropdown.\n * @param options.defaultColorValue If specified, the color input view will replace the \"Remove color\" button with\n * the \"Restore default\" button. Instead of clearing the input field, the default color value will be set.\n * @param options.colorPickerConfig The configuration of the color picker. You could disable it or define your output format.\n */\nexport function getLabeledColorInputCreator(options) {\n return (labeledFieldView, viewUid, statusUid) => {\n const colorInputView = new ColorInputView(labeledFieldView.locale, {\n colorDefinitions: colorConfigToColorGridDefinitions(options.colorConfig),\n columns: options.columns,\n defaultColorValue: options.defaultColorValue,\n colorPickerConfig: options.colorPickerConfig\n });\n colorInputView.inputView.set({\n id: viewUid,\n ariaDescribedById: statusUid\n });\n colorInputView.bind('isReadOnly').to(labeledFieldView, 'isEnabled', value => !value);\n colorInputView.bind('hasError').to(labeledFieldView, 'errorText', value => !!value);\n colorInputView.on('input', () => {\n // UX: Make the error text disappear and disable the error indicator as the user\n // starts fixing the errors.\n labeledFieldView.errorText = null;\n });\n labeledFieldView.bind('isEmpty', 'isFocused').to(colorInputView);\n return colorInputView;\n };\n}\n/**\n * A simple helper method to detect number strings.\n * I allows full number notation, so omitting 0 is not allowed:\n */\nfunction isNumberString(value) {\n const parsedValue = parseFloat(value);\n return !Number.isNaN(parsedValue) && value === String(parsedValue);\n}\nfunction colorConfigToColorGridDefinitions(colorConfig) {\n return colorConfig.map(item => ({\n color: item.model,\n label: item.label,\n options: {\n hasBorder: item.hasBorder\n }\n }));\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tableproperties/ui/tablepropertiesview\n */\nimport { addListToDropdown, ButtonView, createLabeledDropdown, createLabeledInputText, FocusCycler, FormRowView, FormHeaderView, LabeledFieldView, LabelView, submitHandler, ToolbarView, View, ViewCollection } from 'ckeditor5/src/ui.js';\nimport { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';\nimport { IconCancel, IconCheck, IconObjectCenter, IconObjectInlineLeft, IconObjectInlineRight } from 'ckeditor5/src/icons.js';\nimport { fillToolbar, getBorderStyleDefinitions, getBorderStyleLabels, getLabeledColorInputCreator } from '../../utils/ui/table-properties.js';\n// eslint-disable-next-line ckeditor5-rules/ckeditor-imports\nimport '@ckeditor/ckeditor5-ui/theme/components/form/form.css';\nimport '../../../theme/formrow.css';\nimport '../../../theme/tableform.css';\nimport '../../../theme/tableproperties.css';\n/**\n * The class representing a table properties form, allowing users to customize\n * certain style aspects of a table, for instance, border, background color, alignment, etc..\n */\nexport class TablePropertiesView extends View {\n /**\n * Options passed to the view. See {@link #constructor} to learn more.\n */\n options;\n /**\n * Tracks information about the DOM focus in the form.\n */\n focusTracker;\n /**\n * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.\n */\n keystrokes;\n /**\n * A collection of child views in the form.\n */\n children;\n /**\n * A dropdown that allows selecting the style of the table border.\n */\n borderStyleDropdown;\n /**\n * An input that allows specifying the width of the table border.\n */\n borderWidthInput;\n /**\n * An input that allows specifying the color of the table border.\n */\n borderColorInput;\n /**\n * An input that allows specifying the table background color.\n */\n backgroundInput;\n /**\n * An input that allows specifying the table width.\n */\n widthInput;\n /**\n * An input that allows specifying the table height.\n */\n heightInput;\n /**\n * A toolbar with buttons that allow changing the alignment of an entire table.\n */\n alignmentToolbar;\n /**\n * The \"Save\" button view.\n */\n saveButtonView;\n /**\n * The \"Cancel\" button view.\n */\n cancelButtonView;\n /**\n * A collection of views that can be focused in the form.\n */\n _focusables;\n /**\n * Helps cycling over {@link #_focusables} in the form.\n */\n _focusCycler;\n /**\n * @param locale The {@link module:core/editor/editor~Editor#locale} instance.\n * @param options Additional configuration of the view.\n */\n constructor(locale, options) {\n super(locale);\n this.set({\n borderStyle: '',\n borderWidth: '',\n borderColor: '',\n backgroundColor: '',\n width: '',\n height: '',\n alignment: ''\n });\n this.options = options;\n const { borderStyleDropdown, borderWidthInput, borderColorInput, borderRowLabel } = this._createBorderFields();\n const { backgroundRowLabel, backgroundInput } = this._createBackgroundFields();\n const { widthInput, operatorLabel, heightInput, dimensionsLabel } = this._createDimensionFields();\n const { alignmentToolbar, alignmentLabel } = this._createAlignmentFields();\n this.focusTracker = new FocusTracker();\n this.keystrokes = new KeystrokeHandler();\n this.children = this.createCollection();\n this.borderStyleDropdown = borderStyleDropdown;\n this.borderWidthInput = borderWidthInput;\n this.borderColorInput = borderColorInput;\n this.backgroundInput = backgroundInput;\n this.widthInput = widthInput;\n this.heightInput = heightInput;\n this.alignmentToolbar = alignmentToolbar;\n // Defer creating to make sure other fields are present and the Save button can\n // bind its #isEnabled to their error messages so there's no way to save unless all\n // fields are valid.\n const { saveButtonView, cancelButtonView } = this._createActionButtons();\n this.saveButtonView = saveButtonView;\n this.cancelButtonView = cancelButtonView;\n this._focusables = new ViewCollection();\n this._focusCycler = new FocusCycler({\n focusables: this._focusables,\n focusTracker: this.focusTracker,\n keystrokeHandler: this.keystrokes,\n actions: {\n // Navigate form fields backwards using the Shift + Tab keystroke.\n focusPrevious: 'shift + tab',\n // Navigate form fields forwards using the Tab key.\n focusNext: 'tab'\n }\n });\n // Form header.\n this.children.add(new FormHeaderView(locale, {\n label: this.t('Table properties')\n }));\n // Border row.\n this.children.add(new FormRowView(locale, {\n labelView: borderRowLabel,\n children: [\n borderRowLabel,\n borderStyleDropdown,\n borderColorInput,\n borderWidthInput\n ],\n class: 'ck-table-form__border-row'\n }));\n // Background row.\n this.children.add(new FormRowView(locale, {\n labelView: backgroundRowLabel,\n children: [\n backgroundRowLabel,\n backgroundInput\n ],\n class: 'ck-table-form__background-row'\n }));\n this.children.add(new FormRowView(locale, {\n children: [\n // Dimensions row.\n new FormRowView(locale, {\n labelView: dimensionsLabel,\n children: [\n dimensionsLabel,\n widthInput,\n operatorLabel,\n heightInput\n ],\n class: 'ck-table-form__dimensions-row'\n }),\n // Alignment row.\n new FormRowView(locale, {\n labelView: alignmentLabel,\n children: [\n alignmentLabel,\n alignmentToolbar\n ],\n class: 'ck-table-properties-form__alignment-row'\n })\n ]\n }));\n // Action row.\n this.children.add(new FormRowView(locale, {\n children: [\n this.saveButtonView,\n this.cancelButtonView\n ],\n class: 'ck-table-form__action-row'\n }));\n this.setTemplate({\n tag: 'form',\n attributes: {\n class: [\n 'ck',\n 'ck-form',\n 'ck-table-form',\n 'ck-table-properties-form'\n ],\n // https://github.com/ckeditor/ckeditor5-link/issues/90\n tabindex: '-1'\n },\n children: this.children\n });\n }\n /**\n * @inheritDoc\n */\n render() {\n super.render();\n // Enable the \"submit\" event for this view. It can be triggered by the #saveButtonView\n // which is of the \"submit\" DOM \"type\".\n submitHandler({\n view: this\n });\n // Maintain continuous focus cycling over views that have focusable children and focus cyclers themselves.\n [this.borderColorInput, this.backgroundInput].forEach(view => {\n this._focusCycler.chain(view.fieldView.focusCycler);\n });\n [\n this.borderStyleDropdown,\n this.borderColorInput,\n this.borderWidthInput,\n this.backgroundInput,\n this.widthInput,\n this.heightInput,\n this.alignmentToolbar,\n this.saveButtonView,\n this.cancelButtonView\n ].forEach(view => {\n // Register the view as focusable.\n this._focusables.add(view);\n // Register the view in the focus tracker.\n this.focusTracker.add(view.element);\n });\n // Mainly for closing using \"Esc\" and navigation using \"Tab\".\n this.keystrokes.listenTo(this.element);\n }\n /**\n * @inheritDoc\n */\n destroy() {\n super.destroy();\n this.focusTracker.destroy();\n this.keystrokes.destroy();\n }\n /**\n * Focuses the fist focusable field in the form.\n */\n focus() {\n this._focusCycler.focusFirst();\n }\n /**\n * Creates the following form fields:\n *\n * * {@link #borderStyleDropdown},\n * * {@link #borderWidthInput},\n * * {@link #borderColorInput}.\n */\n _createBorderFields() {\n const defaultTableProperties = this.options.defaultTableProperties;\n const defaultBorder = {\n style: defaultTableProperties.borderStyle,\n width: defaultTableProperties.borderWidth,\n color: defaultTableProperties.borderColor\n };\n const colorInputCreator = getLabeledColorInputCreator({\n colorConfig: this.options.borderColors,\n columns: 5,\n defaultColorValue: defaultBorder.color,\n colorPickerConfig: this.options.colorPickerConfig\n });\n const locale = this.locale;\n const t = this.t;\n const accessibleLabel = t('Style');\n // -- Group label ---------------------------------------------\n const borderRowLabel = new LabelView(locale);\n borderRowLabel.text = t('Border');\n // -- Style ---------------------------------------------------\n const styleLabels = getBorderStyleLabels(t);\n const borderStyleDropdown = new LabeledFieldView(locale, createLabeledDropdown);\n borderStyleDropdown.set({\n label: accessibleLabel,\n class: 'ck-table-form__border-style'\n });\n borderStyleDropdown.fieldView.buttonView.set({\n ariaLabel: accessibleLabel,\n ariaLabelledBy: undefined,\n isOn: false,\n withText: true,\n tooltip: accessibleLabel\n });\n borderStyleDropdown.fieldView.buttonView.bind('label').to(this, 'borderStyle', value => {\n return styleLabels[value ? value : 'none'];\n });\n borderStyleDropdown.fieldView.on('execute', evt => {\n this.borderStyle = evt.source._borderStyleValue;\n });\n borderStyleDropdown.bind('isEmpty').to(this, 'borderStyle', value => !value);\n addListToDropdown(borderStyleDropdown.fieldView, getBorderStyleDefinitions(this, defaultBorder.style), {\n role: 'menu',\n ariaLabel: accessibleLabel\n });\n // -- Width ---------------------------------------------------\n const borderWidthInput = new LabeledFieldView(locale, createLabeledInputText);\n borderWidthInput.set({\n label: t('Width'),\n class: 'ck-table-form__border-width'\n });\n borderWidthInput.fieldView.bind('value').to(this, 'borderWidth');\n borderWidthInput.bind('isEnabled').to(this, 'borderStyle', isBorderStyleSet);\n borderWidthInput.fieldView.on('input', () => {\n this.borderWidth = borderWidthInput.fieldView.element.value;\n });\n // -- Color ---------------------------------------------------\n const borderColorInput = new LabeledFieldView(locale, colorInputCreator);\n borderColorInput.set({\n label: t('Color'),\n class: 'ck-table-form__border-color'\n });\n borderColorInput.fieldView.bind('value').to(this, 'borderColor');\n borderColorInput.bind('isEnabled').to(this, 'borderStyle', isBorderStyleSet);\n borderColorInput.fieldView.on('input', () => {\n this.borderColor = borderColorInput.fieldView.value;\n });\n // Reset the border color and width fields depending on the `border-style` value.\n this.on('change:borderStyle', (evt, name, newValue, oldValue) => {\n // When removing the border (`border-style:none`), clear the remaining `border-*` properties.\n // See: https://github.com/ckeditor/ckeditor5/issues/6227.\n if (!isBorderStyleSet(newValue)) {\n this.borderColor = '';\n this.borderWidth = '';\n }\n // When setting the `border-style` from `none`, set the default `border-color` and `border-width` properties.\n if (!isBorderStyleSet(oldValue)) {\n this.borderColor = defaultBorder.color;\n this.borderWidth = defaultBorder.width;\n }\n });\n return {\n borderRowLabel,\n borderStyleDropdown,\n borderColorInput,\n borderWidthInput\n };\n }\n /**\n * Creates the following form fields:\n *\n * * {@link #backgroundInput}.\n */\n _createBackgroundFields() {\n const locale = this.locale;\n const t = this.t;\n // -- Group label ---------------------------------------------\n const backgroundRowLabel = new LabelView(locale);\n backgroundRowLabel.text = t('Background');\n // -- Background color input -----------------------------------\n const backgroundInputCreator = getLabeledColorInputCreator({\n colorConfig: this.options.backgroundColors,\n columns: 5,\n defaultColorValue: this.options.defaultTableProperties.backgroundColor,\n colorPickerConfig: this.options.colorPickerConfig\n });\n const backgroundInput = new LabeledFieldView(locale, backgroundInputCreator);\n backgroundInput.set({\n label: t('Color'),\n class: 'ck-table-properties-form__background'\n });\n backgroundInput.fieldView.bind('value').to(this, 'backgroundColor');\n backgroundInput.fieldView.on('input', () => {\n this.backgroundColor = backgroundInput.fieldView.value;\n });\n return {\n backgroundRowLabel,\n backgroundInput\n };\n }\n /**\n * Creates the following form fields:\n *\n * * {@link #widthInput},\n * * {@link #heightInput}.\n */\n _createDimensionFields() {\n const locale = this.locale;\n const t = this.t;\n // -- Label ---------------------------------------------------\n const dimensionsLabel = new LabelView(locale);\n dimensionsLabel.text = t('Dimensions');\n // -- Width ---------------------------------------------------\n const widthInput = new LabeledFieldView(locale, createLabeledInputText);\n widthInput.set({\n label: t('Width'),\n class: 'ck-table-form__dimensions-row__width'\n });\n widthInput.fieldView.bind('value').to(this, 'width');\n widthInput.fieldView.on('input', () => {\n this.width = widthInput.fieldView.element.value;\n });\n // -- Operator ---------------------------------------------------\n const operatorLabel = new View(locale);\n operatorLabel.setTemplate({\n tag: 'span',\n attributes: {\n class: [\n 'ck-table-form__dimension-operator'\n ]\n },\n children: [\n { text: '×' }\n ]\n });\n // -- Height ---------------------------------------------------\n const heightInput = new LabeledFieldView(locale, createLabeledInputText);\n heightInput.set({\n label: t('Height'),\n class: 'ck-table-form__dimensions-row__height'\n });\n heightInput.fieldView.bind('value').to(this, 'height');\n heightInput.fieldView.on('input', () => {\n this.height = heightInput.fieldView.element.value;\n });\n return {\n dimensionsLabel,\n widthInput,\n operatorLabel,\n heightInput\n };\n }\n /**\n * Creates the following form fields:\n *\n * * {@link #alignmentToolbar}.\n */\n _createAlignmentFields() {\n const locale = this.locale;\n const t = this.t;\n // -- Label ---------------------------------------------------\n const alignmentLabel = new LabelView(locale);\n alignmentLabel.text = t('Alignment');\n // -- Toolbar ---------------------------------------------------\n const alignmentToolbar = new ToolbarView(locale);\n alignmentToolbar.set({\n role: 'radiogroup',\n isCompact: true,\n ariaLabel: t('Table alignment toolbar')\n });\n fillToolbar({\n view: this,\n icons: {\n left: IconObjectInlineLeft,\n center: IconObjectCenter,\n right: IconObjectInlineRight\n },\n toolbar: alignmentToolbar,\n labels: this._alignmentLabels,\n propertyName: 'alignment',\n defaultValue: this.options.defaultTableProperties.alignment\n });\n return {\n alignmentLabel,\n alignmentToolbar\n };\n }\n /**\n * Creates the following form controls:\n *\n * * {@link #saveButtonView},\n * * {@link #cancelButtonView}.\n */\n _createActionButtons() {\n const locale = this.locale;\n const t = this.t;\n const saveButtonView = new ButtonView(locale);\n const cancelButtonView = new ButtonView(locale);\n const fieldsThatShouldValidateToSave = [\n this.borderWidthInput,\n this.borderColorInput,\n this.backgroundInput,\n this.widthInput,\n this.heightInput\n ];\n saveButtonView.set({\n label: t('Save'),\n icon: IconCheck,\n class: 'ck-button-save',\n type: 'submit',\n withText: true\n });\n saveButtonView.bind('isEnabled').toMany(fieldsThatShouldValidateToSave, 'errorText', (...errorTexts) => {\n return errorTexts.every(errorText => !errorText);\n });\n cancelButtonView.set({\n label: t('Cancel'),\n icon: IconCancel,\n class: 'ck-button-cancel',\n withText: true\n });\n cancelButtonView.delegate('execute').to(this, 'cancel');\n return {\n saveButtonView, cancelButtonView\n };\n }\n /**\n * Provides localized labels for {@link #alignmentToolbar} buttons.\n */\n get _alignmentLabels() {\n const locale = this.locale;\n const t = this.t;\n const left = t('Align table to the left');\n const center = t('Center table');\n const right = t('Align table to the right');\n // Returns object with a proper order of labels.\n if (locale.uiLanguageDirection === 'rtl') {\n return { right, center, left };\n }\n else {\n return { left, center, right };\n }\n }\n}\nfunction isBorderStyleSet(value) {\n return value !== 'none';\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/utils/ui/contextualballoon\n */\nimport { Rect } from 'ckeditor5/src/utils.js';\nimport { BalloonPanelView } from 'ckeditor5/src/ui.js';\nimport { getSelectionAffectedTableWidget, getTableWidgetAncestor } from './widget.js';\nimport { getSelectionAffectedTable } from '../common.js';\nconst BALLOON_POSITIONS = /* #__PURE__ */ (() => [\n BalloonPanelView.defaultPositions.northArrowSouth,\n BalloonPanelView.defaultPositions.northArrowSouthWest,\n BalloonPanelView.defaultPositions.northArrowSouthEast,\n BalloonPanelView.defaultPositions.southArrowNorth,\n BalloonPanelView.defaultPositions.southArrowNorthWest,\n BalloonPanelView.defaultPositions.southArrowNorthEast,\n BalloonPanelView.defaultPositions.viewportStickyNorth\n])();\n/**\n * A helper utility that positions the\n * {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon} instance\n * with respect to the table in the editor content, if one is selected.\n *\n * @internal\n * @param editor The editor instance.\n * @param target Either \"cell\" or \"table\". Determines the target the balloon will be attached to.\n */\nexport function repositionContextualBalloon(editor, target) {\n const balloon = editor.plugins.get('ContextualBalloon');\n const selection = editor.editing.view.document.selection;\n let position;\n if (target === 'cell') {\n if (getTableWidgetAncestor(selection)) {\n position = getBalloonCellPositionData(editor);\n }\n }\n else if (getSelectionAffectedTableWidget(selection)) {\n position = getBalloonTablePositionData(editor);\n }\n if (position) {\n balloon.updatePosition(position);\n }\n}\n/**\n * Returns the positioning options that control the geometry of the\n * {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon} with respect\n * to the selected table in the editor content.\n *\n * @param editor The editor instance.\n */\nexport function getBalloonTablePositionData(editor) {\n const selection = editor.model.document.selection;\n const modelTable = getSelectionAffectedTable(selection);\n const viewTable = editor.editing.mapper.toViewElement(modelTable);\n return {\n target: editor.editing.view.domConverter.mapViewToDom(viewTable),\n positions: BALLOON_POSITIONS\n };\n}\n/**\n * Returns the positioning options that control the geometry of the\n * {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon} with respect\n * to the selected table cell in the editor content.\n *\n * @param editor The editor instance.\n * @internal\n */\nexport function getBalloonCellPositionData(editor) {\n const mapper = editor.editing.mapper;\n const domConverter = editor.editing.view.domConverter;\n const selection = editor.model.document.selection;\n if (selection.rangeCount > 1) {\n return {\n target: () => createBoundingRect(selection.getRanges(), editor),\n positions: BALLOON_POSITIONS\n };\n }\n const modelTableCell = getTableCellAtPosition(selection.getFirstPosition());\n const viewTableCell = mapper.toViewElement(modelTableCell);\n return {\n target: domConverter.mapViewToDom(viewTableCell),\n positions: BALLOON_POSITIONS\n };\n}\n/**\n * Returns the first selected table cell from a multi-cell or in-cell selection.\n *\n * @param position Document position.\n */\nfunction getTableCellAtPosition(position) {\n const isTableCellSelected = position.nodeAfter && position.nodeAfter.is('element', 'tableCell');\n return isTableCellSelected ? position.nodeAfter : position.findAncestor('tableCell');\n}\n/**\n * Returns bounding rectangle for given model ranges.\n *\n * @param ranges Model ranges that the bounding rect should be returned for.\n * @param editor The editor instance.\n */\nfunction createBoundingRect(ranges, editor) {\n const mapper = editor.editing.mapper;\n const domConverter = editor.editing.view.domConverter;\n const rects = Array.from(ranges).map(range => {\n const modelTableCell = getTableCellAtPosition(range.start);\n const viewTableCell = mapper.toViewElement(modelTableCell);\n return new Rect(domConverter.mapViewToDom(viewTableCell));\n });\n return Rect.getBoundingRect(rects);\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tableproperties/tablepropertiesui\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { IconTableProperties } from 'ckeditor5/src/icons.js';\nimport { ButtonView, ContextualBalloon, clickOutsideHandler, getLocalizedColorOptions, normalizeColorOptions } from 'ckeditor5/src/ui.js';\nimport { debounce } from 'es-toolkit/compat';\nimport { TablePropertiesView } from './ui/tablepropertiesview.js';\nimport { colorFieldValidator, getLocalizedColorErrorText, getLocalizedLengthErrorText, lengthFieldValidator, lineWidthFieldValidator, defaultColors } from '../utils/ui/table-properties.js';\nimport { getSelectionAffectedTableWidget } from '../utils/ui/widget.js';\nimport { getBalloonTablePositionData, repositionContextualBalloon } from '../utils/ui/contextualballoon.js';\nimport { getNormalizedDefaultProperties, getNormalizedDefaultTableProperties } from '../utils/table-properties.js';\nconst ERROR_TEXT_TIMEOUT = 500;\n// Map of view properties and related commands.\nconst propertyToCommandMap = {\n borderStyle: 'tableBorderStyle',\n borderColor: 'tableBorderColor',\n borderWidth: 'tableBorderWidth',\n backgroundColor: 'tableBackgroundColor',\n width: 'tableWidth',\n height: 'tableHeight',\n alignment: 'tableAlignment'\n};\n/**\n * The table properties UI plugin. It introduces the `'tableProperties'` button\n * that opens a form allowing to specify visual styling of an entire table.\n *\n * It uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon plugin}.\n */\nexport class TablePropertiesUI extends Plugin {\n /**\n * The default table properties.\n */\n _defaultContentTableProperties;\n /**\n * The default layout table properties.\n */\n _defaultLayoutTableProperties;\n /**\n * The contextual balloon plugin instance.\n */\n _balloon;\n /**\n * The properties form view displayed inside the balloon.\n */\n view = null;\n /**\n * The properties form view displayed inside the balloon (content table).\n */\n _viewWithContentTableDefaults = null;\n /**\n * The properties form view displayed inside the balloon (layout table).\n */\n _viewWithLayoutTableDefaults = null;\n /**\n * The batch used to undo all changes made by the form (which are live, as the user types)\n * when \"Cancel\" was pressed. Each time the view is shown, a new batch is created.\n */\n _undoStepBatch;\n /**\n * Flag used to indicate whether view is ready to execute update commands\n * (it finished loading initial data).\n */\n _isReady;\n /**\n * @inheritDoc\n */\n static get requires() {\n return [ContextualBalloon];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TablePropertiesUI';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n constructor(editor) {\n super(editor);\n editor.config.define('table.tableProperties', {\n borderColors: defaultColors,\n backgroundColors: defaultColors\n });\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n this._defaultContentTableProperties = getNormalizedDefaultTableProperties(editor.config.get('table.tableProperties.defaultProperties'), {\n includeAlignmentProperty: true\n });\n this._defaultLayoutTableProperties = getNormalizedDefaultProperties();\n this._balloon = editor.plugins.get(ContextualBalloon);\n editor.ui.componentFactory.add('tableProperties', () => this._createTablePropertiesButton());\n }\n /**\n * Creates the table properties button.\n *\n * @internal\n */\n _createTablePropertiesButton() {\n const editor = this.editor;\n const t = editor.t;\n const view = new ButtonView(editor.locale);\n view.set({\n label: t('Table properties'),\n icon: IconTableProperties,\n tooltip: true\n });\n this.listenTo(view, 'execute', () => this._showView());\n const commands = Object.values(propertyToCommandMap)\n .map(commandName => editor.commands.get(commandName));\n view.bind('isEnabled').toMany(commands, 'isEnabled', (...areEnabled) => (areEnabled.some(isCommandEnabled => isCommandEnabled)));\n return view;\n }\n /**\n * @inheritDoc\n */\n destroy() {\n super.destroy();\n // Destroy created UI components as they are not automatically destroyed.\n // See https://github.com/ckeditor/ckeditor5/issues/1341.\n if (this.view) {\n this.view.destroy();\n }\n }\n /**\n * Creates the {@link module:table/tableproperties/ui/tablepropertiesview~TablePropertiesView} instance.\n *\n * @returns The table properties form view instance.\n */\n _createPropertiesView(defaultTableProperties) {\n const editor = this.editor;\n const config = editor.config.get('table.tableProperties');\n const borderColorsConfig = normalizeColorOptions(config.borderColors);\n const localizedBorderColors = getLocalizedColorOptions(editor.locale, borderColorsConfig);\n const backgroundColorsConfig = normalizeColorOptions(config.backgroundColors);\n const localizedBackgroundColors = getLocalizedColorOptions(editor.locale, backgroundColorsConfig);\n const hasColorPicker = config.colorPicker !== false;\n const view = new TablePropertiesView(editor.locale, {\n borderColors: localizedBorderColors,\n backgroundColors: localizedBackgroundColors,\n defaultTableProperties,\n colorPickerConfig: hasColorPicker ? (config.colorPicker || {}) : false\n });\n const t = editor.t;\n // Render the view so its #element is available for the clickOutsideHandler.\n view.render();\n this.listenTo(view, 'submit', () => {\n this._hideView();\n });\n this.listenTo(view, 'cancel', () => {\n // https://github.com/ckeditor/ckeditor5/issues/6180\n if (this._undoStepBatch.operations.length) {\n editor.execute('undo', this._undoStepBatch);\n }\n this._hideView();\n });\n // Close the balloon on Esc key press.\n view.keystrokes.set('Esc', (data, cancel) => {\n this._hideView();\n cancel();\n });\n // Close on click outside of balloon panel element.\n clickOutsideHandler({\n emitter: view,\n activator: () => this._isViewInBalloon,\n contextElements: [this._balloon.view.element],\n callback: () => this._hideView()\n });\n const colorErrorText = getLocalizedColorErrorText(t);\n const lengthErrorText = getLocalizedLengthErrorText(t);\n // Create the \"UI -> editor data\" binding.\n // These listeners update the editor data (via table commands) when any observable\n // property of the view has changed. They also validate the value and display errors in the UI\n // when necessary. This makes the view live, which means the changes are\n // visible in the editing as soon as the user types or changes fields' values.\n view.on('change:borderStyle', this._getPropertyChangeCallback('tableBorderStyle'));\n view.on('change:borderColor', this._getValidatedPropertyChangeCallback({\n viewField: view.borderColorInput,\n commandName: 'tableBorderColor',\n errorText: colorErrorText,\n validator: colorFieldValidator\n }));\n view.on('change:borderWidth', this._getValidatedPropertyChangeCallback({\n viewField: view.borderWidthInput,\n commandName: 'tableBorderWidth',\n errorText: lengthErrorText,\n validator: lineWidthFieldValidator\n }));\n view.on('change:backgroundColor', this._getValidatedPropertyChangeCallback({\n viewField: view.backgroundInput,\n commandName: 'tableBackgroundColor',\n errorText: colorErrorText,\n validator: colorFieldValidator\n }));\n view.on('change:width', this._getValidatedPropertyChangeCallback({\n viewField: view.widthInput,\n commandName: 'tableWidth',\n errorText: lengthErrorText,\n validator: lengthFieldValidator\n }));\n view.on('change:height', this._getValidatedPropertyChangeCallback({\n viewField: view.heightInput,\n commandName: 'tableHeight',\n errorText: lengthErrorText,\n validator: lengthFieldValidator\n }));\n view.on('change:alignment', this._getPropertyChangeCallback('tableAlignment'));\n return view;\n }\n /**\n * In this method the \"editor data -> UI\" binding is happening.\n *\n * When executed, this method obtains selected table property values from various table commands\n * and passes them to the {@link #view}.\n *\n * This way, the UI stays up–to–date with the editor data.\n */\n _fillViewFormFromCommandValues() {\n const commands = this.editor.commands;\n const borderStyleCommand = commands.get('tableBorderStyle');\n Object.entries(propertyToCommandMap)\n .map(([property, commandName]) => {\n const propertyKey = property;\n const defaultValue = this.view === this._viewWithContentTableDefaults ?\n this._defaultContentTableProperties[propertyKey] || '' :\n this._defaultLayoutTableProperties[propertyKey] || '';\n return [propertyKey, (commands.get(commandName).value || defaultValue)];\n })\n .forEach(([property, value]) => {\n // Do not set the `border-color` and `border-width` fields if `border-style:none`.\n if ((property === 'borderColor' || property === 'borderWidth') && borderStyleCommand.value === 'none') {\n return;\n }\n this.view.set(property, value);\n });\n this._isReady = true;\n }\n /**\n * Shows the {@link #view} in the {@link #_balloon}.\n *\n * **Note**: Each time a view is shown, the new {@link #_undoStepBatch} is created that contains\n * all changes made to the document when the view is visible, allowing a single undo step\n * for all of them.\n */\n _showView() {\n const editor = this.editor;\n const viewTable = getSelectionAffectedTableWidget(editor.editing.view.document.selection);\n const modelTable = viewTable && editor.editing.mapper.toModelElement(viewTable);\n const useDefaults = !modelTable || modelTable.getAttribute('tableType') !== 'layout';\n if (useDefaults && !this._viewWithContentTableDefaults) {\n this._viewWithContentTableDefaults = this._createPropertiesView(this._defaultContentTableProperties);\n }\n else if (!useDefaults && !this._viewWithLayoutTableDefaults) {\n this._viewWithLayoutTableDefaults = this._createPropertiesView(this._defaultLayoutTableProperties);\n }\n this.view = useDefaults ? this._viewWithContentTableDefaults : this._viewWithLayoutTableDefaults;\n this.listenTo(editor.ui, 'update', () => {\n this._updateView();\n });\n // Update the view with the model values.\n this._fillViewFormFromCommandValues();\n this._balloon.add({\n view: this.view,\n position: getBalloonTablePositionData(editor)\n });\n // Create a new batch. Clicking \"Cancel\" will undo this batch.\n this._undoStepBatch = editor.model.createBatch();\n // Basic a11y.\n this.view.focus();\n }\n /**\n * Removes the {@link #view} from the {@link #_balloon}.\n */\n _hideView() {\n const editor = this.editor;\n this.stopListening(editor.ui, 'update');\n this._isReady = false;\n // Blur any input element before removing it from DOM to prevent issues in some browsers.\n // See https://github.com/ckeditor/ckeditor5/issues/1501.\n this.view.saveButtonView.focus();\n this._balloon.remove(this.view);\n // Make sure the focus is not lost in the process by putting it directly\n // into the editing view.\n this.editor.editing.view.focus();\n }\n /**\n * Repositions the {@link #_balloon} or hides the {@link #view} if a table is no longer selected.\n */\n _updateView() {\n const editor = this.editor;\n const viewDocument = editor.editing.view.document;\n if (!getSelectionAffectedTableWidget(viewDocument.selection)) {\n this._hideView();\n }\n else if (this._isViewVisible) {\n repositionContextualBalloon(editor, 'table');\n }\n }\n /**\n * Returns `true` when the {@link #view} is the visible in the {@link #_balloon}.\n */\n get _isViewVisible() {\n return !!this.view && this._balloon.visibleView === this.view;\n }\n /**\n * Returns `true` when the {@link #view} is in the {@link #_balloon}.\n */\n get _isViewInBalloon() {\n return !!this.view && this._balloon.hasView(this.view);\n }\n /**\n * Creates a callback that when executed upon {@link #view view's} property change\n * executes a related editor command with the new property value.\n *\n * If new value will be set to the default value, the command will not be executed.\n *\n * @param commandName The command that will be executed.\n */\n _getPropertyChangeCallback(commandName) {\n return (evt, propertyName, newValue) => {\n // Do not execute the command on initial call (opening the table properties view).\n if (!this._isReady) {\n return;\n }\n this.editor.execute(commandName, {\n value: newValue,\n batch: this._undoStepBatch\n });\n };\n }\n /**\n * Creates a callback that when executed upon {@link #view view's} property change:\n * * executes a related editor command with the new property value if the value is valid,\n * * or sets the error text next to the invalid field, if the value did not pass the validation.\n */\n _getValidatedPropertyChangeCallback(options) {\n const { commandName, viewField, validator, errorText } = options;\n const setErrorTextDebounced = debounce(() => {\n viewField.errorText = errorText;\n }, ERROR_TEXT_TIMEOUT);\n return (evt, propertyName, newValue) => {\n setErrorTextDebounced.cancel();\n // Do not execute the command on initial call (opening the table properties view).\n if (!this._isReady) {\n return;\n }\n if (validator(newValue)) {\n this.editor.execute(commandName, {\n value: newValue,\n batch: this._undoStepBatch\n });\n viewField.errorText = null;\n }\n else {\n setErrorTextDebounced();\n }\n };\n }\n}\n","export default \"\";","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tablecellproperties/ui/tablecellpropertiesview\n */\nimport { addListToDropdown, ButtonView, createLabeledDropdown, createLabeledInputText, FocusCycler, FormRowView, FormHeaderView, LabeledFieldView, LabelView, submitHandler, ToolbarView, View, ViewCollection } from 'ckeditor5/src/ui.js';\nimport { KeystrokeHandler, FocusTracker } from 'ckeditor5/src/utils.js';\nimport { IconAlignBottom, IconAlignCenter, IconAlignJustify, IconAlignLeft, IconAlignMiddle, IconAlignRight, IconAlignTop, IconCancel, IconCheck } from 'ckeditor5/src/icons.js';\nimport { fillToolbar, getBorderStyleDefinitions, getBorderStyleLabels, getLabeledColorInputCreator } from '../../utils/ui/table-properties.js';\n// eslint-disable-next-line ckeditor5-rules/ckeditor-imports\nimport '@ckeditor/ckeditor5-ui/theme/components/form/form.css';\nimport '../../../theme/formrow.css';\nimport '../../../theme/tableform.css';\nimport '../../../theme/tablecellproperties.css';\n/**\n * The class representing a table cell properties form, allowing users to customize\n * certain style aspects of a table cell, for instance, border, padding, text alignment, etc..\n */\nexport class TableCellPropertiesView extends View {\n /**\n * Options passed to the view. See {@link #constructor} to learn more.\n */\n options;\n /**\n * Tracks information about the DOM focus in the form.\n */\n focusTracker;\n /**\n * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.\n */\n keystrokes;\n /**\n * A collection of child views in the form.\n */\n children;\n /**\n * A dropdown that allows selecting the style of the table cell border.\n */\n borderStyleDropdown;\n /**\n * An input that allows specifying the width of the table cell border.\n */\n borderWidthInput;\n /**\n * An input that allows specifying the color of the table cell border.\n */\n borderColorInput;\n /**\n * An input that allows specifying the table cell background color.\n */\n backgroundInput;\n /**\n * An input that allows specifying the table cell padding.\n */\n paddingInput;\n /**\n * An input that allows specifying the table cell width.\n */\n widthInput;\n /**\n * An input that allows specifying the table cell height.\n */\n heightInput;\n /**\n * A toolbar with buttons that allow changing the horizontal text alignment in a table cell.\n */\n horizontalAlignmentToolbar;\n /**\n * A toolbar with buttons that allow changing the vertical text alignment in a table cell.\n */\n verticalAlignmentToolbar;\n /**\n * The \"Save\" button view.\n */\n saveButtonView;\n /**\n * The \"Cancel\" button view.\n */\n cancelButtonView;\n /**\n * A collection of views that can be focused in the form.\n */\n _focusables;\n /**\n * Helps cycling over {@link #_focusables} in the form.\n */\n _focusCycler;\n /**\n * @param locale The {@link module:core/editor/editor~Editor#locale} instance.\n * @param options Additional configuration of the view.\n * @param options.borderColors A configuration of the border color palette used by the\n * {@link module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView#borderColorInput}.\n * @param options.backgroundColors A configuration of the background color palette used by the\n * {@link module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView#backgroundInput}.\n * @param options.defaultTableCellProperties The default table cell properties.\n */\n constructor(locale, options) {\n super(locale);\n this.set({\n borderStyle: '',\n borderWidth: '',\n borderColor: '',\n padding: '',\n backgroundColor: '',\n width: '',\n height: '',\n horizontalAlignment: '',\n verticalAlignment: ''\n });\n this.options = options;\n const { borderStyleDropdown, borderWidthInput, borderColorInput, borderRowLabel } = this._createBorderFields();\n const { backgroundRowLabel, backgroundInput } = this._createBackgroundFields();\n const { widthInput, operatorLabel, heightInput, dimensionsLabel } = this._createDimensionFields();\n const { horizontalAlignmentToolbar, verticalAlignmentToolbar, alignmentLabel } = this._createAlignmentFields();\n this.focusTracker = new FocusTracker();\n this.keystrokes = new KeystrokeHandler();\n this.children = this.createCollection();\n this.borderStyleDropdown = borderStyleDropdown;\n this.borderWidthInput = borderWidthInput;\n this.borderColorInput = borderColorInput;\n this.backgroundInput = backgroundInput;\n this.paddingInput = this._createPaddingField();\n this.widthInput = widthInput;\n this.heightInput = heightInput;\n this.horizontalAlignmentToolbar = horizontalAlignmentToolbar;\n this.verticalAlignmentToolbar = verticalAlignmentToolbar;\n // Defer creating to make sure other fields are present and the Save button can\n // bind its #isEnabled to their error messages so there's no way to save unless all\n // fields are valid.\n const { saveButtonView, cancelButtonView } = this._createActionButtons();\n this.saveButtonView = saveButtonView;\n this.cancelButtonView = cancelButtonView;\n this._focusables = new ViewCollection();\n this._focusCycler = new FocusCycler({\n focusables: this._focusables,\n focusTracker: this.focusTracker,\n keystrokeHandler: this.keystrokes,\n actions: {\n // Navigate form fields backwards using the Shift + Tab keystroke.\n focusPrevious: 'shift + tab',\n // Navigate form fields forwards using the Tab key.\n focusNext: 'tab'\n }\n });\n // Form header.\n this.children.add(new FormHeaderView(locale, {\n label: this.t('Cell properties')\n }));\n // Border row.\n this.children.add(new FormRowView(locale, {\n labelView: borderRowLabel,\n children: [\n borderRowLabel,\n borderStyleDropdown,\n borderColorInput,\n borderWidthInput\n ],\n class: 'ck-table-form__border-row'\n }));\n // Background.\n this.children.add(new FormRowView(locale, {\n labelView: backgroundRowLabel,\n children: [\n backgroundRowLabel,\n backgroundInput\n ],\n class: 'ck-table-form__background-row'\n }));\n // Dimensions row and padding.\n this.children.add(new FormRowView(locale, {\n children: [\n // Dimensions row.\n new FormRowView(locale, {\n labelView: dimensionsLabel,\n children: [\n dimensionsLabel,\n widthInput,\n operatorLabel,\n heightInput\n ],\n class: 'ck-table-form__dimensions-row'\n }),\n // Padding row.\n new FormRowView(locale, {\n children: [\n this.paddingInput\n ],\n class: 'ck-table-cell-properties-form__padding-row'\n })\n ]\n }));\n // Text alignment row.\n this.children.add(new FormRowView(locale, {\n labelView: alignmentLabel,\n children: [\n alignmentLabel,\n horizontalAlignmentToolbar,\n verticalAlignmentToolbar\n ],\n class: 'ck-table-cell-properties-form__alignment-row'\n }));\n // Action row.\n this.children.add(new FormRowView(locale, {\n children: [\n this.saveButtonView,\n this.cancelButtonView\n ],\n class: 'ck-table-form__action-row'\n }));\n this.setTemplate({\n tag: 'form',\n attributes: {\n class: [\n 'ck',\n 'ck-form',\n 'ck-table-form',\n 'ck-table-cell-properties-form'\n ],\n // https://github.com/ckeditor/ckeditor5-link/issues/90\n tabindex: '-1'\n },\n children: this.children\n });\n }\n /**\n * @inheritDoc\n */\n render() {\n super.render();\n // Enable the \"submit\" event for this view. It can be triggered by the #saveButtonView\n // which is of the \"submit\" DOM \"type\".\n submitHandler({\n view: this\n });\n // Maintain continuous focus cycling over views that have focusable children and focus cyclers themselves.\n [this.borderColorInput, this.backgroundInput].forEach(view => {\n this._focusCycler.chain(view.fieldView.focusCycler);\n });\n [\n this.borderStyleDropdown,\n this.borderColorInput,\n this.borderWidthInput,\n this.backgroundInput,\n this.widthInput,\n this.heightInput,\n this.paddingInput,\n this.horizontalAlignmentToolbar,\n this.verticalAlignmentToolbar,\n this.saveButtonView,\n this.cancelButtonView\n ].forEach(view => {\n // Register the view as focusable.\n this._focusables.add(view);\n // Register the view in the focus tracker.\n this.focusTracker.add(view.element);\n });\n // Mainly for closing using \"Esc\" and navigation using \"Tab\".\n this.keystrokes.listenTo(this.element);\n }\n /**\n * @inheritDoc\n */\n destroy() {\n super.destroy();\n this.focusTracker.destroy();\n this.keystrokes.destroy();\n }\n /**\n * Focuses the fist focusable field in the form.\n */\n focus() {\n this._focusCycler.focusFirst();\n }\n /**\n * Creates the following form fields:\n *\n * * {@link #borderStyleDropdown},\n * * {@link #borderWidthInput},\n * * {@link #borderColorInput}.\n */\n _createBorderFields() {\n const defaultTableCellProperties = this.options.defaultTableCellProperties;\n const defaultBorder = {\n style: defaultTableCellProperties.borderStyle,\n width: defaultTableCellProperties.borderWidth,\n color: defaultTableCellProperties.borderColor\n };\n const colorInputCreator = getLabeledColorInputCreator({\n colorConfig: this.options.borderColors,\n columns: 5,\n defaultColorValue: defaultBorder.color,\n colorPickerConfig: this.options.colorPickerConfig\n });\n const locale = this.locale;\n const t = this.t;\n const accessibleLabel = t('Style');\n // -- Group label ---------------------------------------------\n const borderRowLabel = new LabelView(locale);\n borderRowLabel.text = t('Border');\n // -- Style ---------------------------------------------------\n const styleLabels = getBorderStyleLabels(t);\n const borderStyleDropdown = new LabeledFieldView(locale, createLabeledDropdown);\n borderStyleDropdown.set({\n label: accessibleLabel,\n class: 'ck-table-form__border-style'\n });\n borderStyleDropdown.fieldView.buttonView.set({\n ariaLabel: accessibleLabel,\n ariaLabelledBy: undefined,\n isOn: false,\n withText: true,\n tooltip: accessibleLabel\n });\n borderStyleDropdown.fieldView.buttonView.bind('label').to(this, 'borderStyle', value => {\n return styleLabels[value ? value : 'none'];\n });\n borderStyleDropdown.fieldView.on('execute', evt => {\n this.borderStyle = evt.source._borderStyleValue;\n });\n borderStyleDropdown.bind('isEmpty').to(this, 'borderStyle', value => !value);\n addListToDropdown(borderStyleDropdown.fieldView, getBorderStyleDefinitions(this, defaultBorder.style), {\n role: 'menu',\n ariaLabel: accessibleLabel\n });\n // -- Width ---------------------------------------------------\n const borderWidthInput = new LabeledFieldView(locale, createLabeledInputText);\n borderWidthInput.set({\n label: t('Width'),\n class: 'ck-table-form__border-width'\n });\n borderWidthInput.fieldView.bind('value').to(this, 'borderWidth');\n borderWidthInput.bind('isEnabled').to(this, 'borderStyle', isBorderStyleSet);\n borderWidthInput.fieldView.on('input', () => {\n this.borderWidth = borderWidthInput.fieldView.element.value;\n });\n // -- Color ---------------------------------------------------\n const borderColorInput = new LabeledFieldView(locale, colorInputCreator);\n borderColorInput.set({\n label: t('Color'),\n class: 'ck-table-form__border-color'\n });\n borderColorInput.fieldView.bind('value').to(this, 'borderColor');\n borderColorInput.bind('isEnabled').to(this, 'borderStyle', isBorderStyleSet);\n borderColorInput.fieldView.on('input', () => {\n this.borderColor = borderColorInput.fieldView.value;\n });\n // Reset the border color and width fields depending on the `border-style` value.\n this.on('change:borderStyle', (evt, name, newValue, oldValue) => {\n // When removing the border (`border-style:none`), clear the remaining `border-*` properties.\n // See: https://github.com/ckeditor/ckeditor5/issues/6227.\n if (!isBorderStyleSet(newValue)) {\n this.borderColor = '';\n this.borderWidth = '';\n }\n // When setting the `border-style` from `none`, set the default `border-color` and `border-width` properties.\n if (!isBorderStyleSet(oldValue)) {\n this.borderColor = defaultBorder.color;\n this.borderWidth = defaultBorder.width;\n }\n });\n return {\n borderRowLabel,\n borderStyleDropdown,\n borderColorInput,\n borderWidthInput\n };\n }\n /**\n * Creates the following form fields:\n *\n * * {@link #backgroundInput}.\n */\n _createBackgroundFields() {\n const locale = this.locale;\n const t = this.t;\n // -- Group label ---------------------------------------------\n const backgroundRowLabel = new LabelView(locale);\n backgroundRowLabel.text = t('Background');\n // -- Background color input -----------------------------------\n const colorInputCreator = getLabeledColorInputCreator({\n colorConfig: this.options.backgroundColors,\n columns: 5,\n defaultColorValue: this.options.defaultTableCellProperties.backgroundColor,\n colorPickerConfig: this.options.colorPickerConfig\n });\n const backgroundInput = new LabeledFieldView(locale, colorInputCreator);\n backgroundInput.set({\n label: t('Color'),\n class: 'ck-table-cell-properties-form__background'\n });\n backgroundInput.fieldView.bind('value').to(this, 'backgroundColor');\n backgroundInput.fieldView.on('input', () => {\n this.backgroundColor = backgroundInput.fieldView.value;\n });\n return {\n backgroundRowLabel,\n backgroundInput\n };\n }\n /**\n * Creates the following form fields:\n *\n * * {@link #widthInput}.\n * * {@link #heightInput}.\n */\n _createDimensionFields() {\n const locale = this.locale;\n const t = this.t;\n // -- Label ---------------------------------------------------\n const dimensionsLabel = new LabelView(locale);\n dimensionsLabel.text = t('Dimensions');\n // -- Width ---------------------------------------------------\n const widthInput = new LabeledFieldView(locale, createLabeledInputText);\n widthInput.set({\n label: t('Width'),\n class: 'ck-table-form__dimensions-row__width'\n });\n widthInput.fieldView.bind('value').to(this, 'width');\n widthInput.fieldView.on('input', () => {\n this.width = widthInput.fieldView.element.value;\n });\n // -- Operator ---------------------------------------------------\n const operatorLabel = new View(locale);\n operatorLabel.setTemplate({\n tag: 'span',\n attributes: {\n class: [\n 'ck-table-form__dimension-operator'\n ]\n },\n children: [\n { text: '×' }\n ]\n });\n // -- Height ---------------------------------------------------\n const heightInput = new LabeledFieldView(locale, createLabeledInputText);\n heightInput.set({\n label: t('Height'),\n class: 'ck-table-form__dimensions-row__height'\n });\n heightInput.fieldView.bind('value').to(this, 'height');\n heightInput.fieldView.on('input', () => {\n this.height = heightInput.fieldView.element.value;\n });\n return {\n dimensionsLabel,\n widthInput,\n operatorLabel,\n heightInput\n };\n }\n /**\n * Creates the following form fields:\n *\n * * {@link #paddingInput}.\n */\n _createPaddingField() {\n const locale = this.locale;\n const t = this.t;\n const paddingInput = new LabeledFieldView(locale, createLabeledInputText);\n paddingInput.set({\n label: t('Padding'),\n class: 'ck-table-cell-properties-form__padding'\n });\n paddingInput.fieldView.bind('value').to(this, 'padding');\n paddingInput.fieldView.on('input', () => {\n this.padding = paddingInput.fieldView.element.value;\n });\n return paddingInput;\n }\n /**\n * Creates the following form fields:\n *\n * * {@link #horizontalAlignmentToolbar},\n * * {@link #verticalAlignmentToolbar}.\n */\n _createAlignmentFields() {\n const locale = this.locale;\n const t = this.t;\n const alignmentLabel = new LabelView(locale);\n const ALIGNMENT_ICONS = {\n left: IconAlignLeft,\n center: IconAlignCenter,\n right: IconAlignRight,\n justify: IconAlignJustify,\n top: IconAlignTop,\n middle: IconAlignMiddle,\n bottom: IconAlignBottom\n };\n alignmentLabel.text = t('Table cell text alignment');\n // -- Horizontal ---------------------------------------------------\n const horizontalAlignmentToolbar = new ToolbarView(locale);\n const isContentRTL = locale.contentLanguageDirection === 'rtl';\n horizontalAlignmentToolbar.set({\n isCompact: true,\n role: 'radiogroup',\n ariaLabel: t('Horizontal text alignment toolbar')\n });\n fillToolbar({\n view: this,\n icons: ALIGNMENT_ICONS,\n toolbar: horizontalAlignmentToolbar,\n labels: this._horizontalAlignmentLabels,\n propertyName: 'horizontalAlignment',\n nameToValue: name => {\n // For the RTL content, we want to swap the buttons \"align to the left\" and \"align to the right\".\n if (isContentRTL) {\n if (name === 'left') {\n return 'right';\n }\n else if (name === 'right') {\n return 'left';\n }\n }\n return name;\n },\n defaultValue: this.options.defaultTableCellProperties.horizontalAlignment\n });\n // -- Vertical -----------------------------------------------------\n const verticalAlignmentToolbar = new ToolbarView(locale);\n verticalAlignmentToolbar.set({\n isCompact: true,\n role: 'radiogroup',\n ariaLabel: t('Vertical text alignment toolbar')\n });\n fillToolbar({\n view: this,\n icons: ALIGNMENT_ICONS,\n toolbar: verticalAlignmentToolbar,\n labels: this._verticalAlignmentLabels,\n propertyName: 'verticalAlignment',\n defaultValue: this.options.defaultTableCellProperties.verticalAlignment\n });\n return {\n horizontalAlignmentToolbar,\n verticalAlignmentToolbar,\n alignmentLabel\n };\n }\n /**\n * Creates the following form controls:\n *\n * * {@link #saveButtonView},\n * * {@link #cancelButtonView}.\n */\n _createActionButtons() {\n const locale = this.locale;\n const t = this.t;\n const saveButtonView = new ButtonView(locale);\n const cancelButtonView = new ButtonView(locale);\n const fieldsThatShouldValidateToSave = [\n this.borderWidthInput,\n this.borderColorInput,\n this.backgroundInput,\n this.paddingInput\n ];\n saveButtonView.set({\n label: t('Save'),\n icon: IconCheck,\n class: 'ck-button-save',\n type: 'submit',\n withText: true\n });\n saveButtonView.bind('isEnabled').toMany(fieldsThatShouldValidateToSave, 'errorText', (...errorTexts) => {\n return errorTexts.every(errorText => !errorText);\n });\n cancelButtonView.set({\n label: t('Cancel'),\n icon: IconCancel,\n class: 'ck-button-cancel',\n withText: true\n });\n cancelButtonView.delegate('execute').to(this, 'cancel');\n return {\n saveButtonView, cancelButtonView\n };\n }\n /**\n * Provides localized labels for {@link #horizontalAlignmentToolbar} buttons.\n */\n get _horizontalAlignmentLabels() {\n const locale = this.locale;\n const t = this.t;\n const left = t('Align cell text to the left');\n const center = t('Align cell text to the center');\n const right = t('Align cell text to the right');\n const justify = t('Justify cell text');\n // Returns object with a proper order of labels.\n if (locale.uiLanguageDirection === 'rtl') {\n return { right, center, left, justify };\n }\n else {\n return { left, center, right, justify };\n }\n }\n /**\n * Provides localized labels for {@link #verticalAlignmentToolbar} buttons.\n */\n get _verticalAlignmentLabels() {\n const t = this.t;\n return {\n top: t('Align cell text to the top'),\n middle: t('Align cell text to the middle'),\n bottom: t('Align cell text to the bottom')\n };\n }\n}\nfunction isBorderStyleSet(value) {\n return value !== 'none';\n}\n","export default \"\";","export default \"\";","export default \"\";","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tablecellproperties/tablecellpropertiesui\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { IconTableCellProperties } from 'ckeditor5/src/icons.js';\nimport { ButtonView, clickOutsideHandler, ContextualBalloon, getLocalizedColorOptions, normalizeColorOptions } from 'ckeditor5/src/ui.js';\nimport { TableCellPropertiesView } from './ui/tablecellpropertiesview.js';\nimport { colorFieldValidator, getLocalizedColorErrorText, getLocalizedLengthErrorText, defaultColors, lengthFieldValidator, lineWidthFieldValidator } from '../utils/ui/table-properties.js';\nimport { debounce } from 'es-toolkit/compat';\nimport { getSelectionAffectedTableWidget, getTableWidgetAncestor } from '../utils/ui/widget.js';\nimport { getBalloonCellPositionData, repositionContextualBalloon } from '../utils/ui/contextualballoon.js';\nimport { getNormalizedDefaultCellProperties, getNormalizedDefaultProperties } from '../utils/table-properties.js';\nconst ERROR_TEXT_TIMEOUT = 500;\n// Map of view properties and related commands.\nconst propertyToCommandMap = {\n borderStyle: 'tableCellBorderStyle',\n borderColor: 'tableCellBorderColor',\n borderWidth: 'tableCellBorderWidth',\n height: 'tableCellHeight',\n width: 'tableCellWidth',\n padding: 'tableCellPadding',\n backgroundColor: 'tableCellBackgroundColor',\n horizontalAlignment: 'tableCellHorizontalAlignment',\n verticalAlignment: 'tableCellVerticalAlignment'\n};\n/**\n * The table cell properties UI plugin. It introduces the `'tableCellProperties'` button\n * that opens a form allowing to specify the visual styling of a table cell.\n *\n * It uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon plugin}.\n */\nexport class TableCellPropertiesUI extends Plugin {\n /**\n * The default table cell properties.\n */\n _defaultContentTableCellProperties;\n /**\n * The default layout table cell properties.\n */\n _defaultLayoutTableCellProperties;\n /**\n * The contextual balloon plugin instance.\n */\n _balloon;\n /**\n * The cell properties form view displayed inside the balloon.\n */\n view;\n /**\n * The cell properties form view displayed inside the balloon (content table).\n */\n _viewWithContentTableDefaults;\n /**\n * The cell properties form view displayed inside the balloon (layout table).\n */\n _viewWithLayoutTableDefaults;\n /**\n * The batch used to undo all changes made by the form (which are live, as the user types)\n * when \"Cancel\" was pressed. Each time the view is shown, a new batch is created.\n */\n _undoStepBatch;\n /**\n * Flag used to indicate whether view is ready to execute update commands\n * (it finished loading initial data).\n */\n _isReady;\n /**\n * @inheritDoc\n */\n static get requires() {\n return [ContextualBalloon];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TableCellPropertiesUI';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n constructor(editor) {\n super(editor);\n editor.config.define('table.tableCellProperties', {\n borderColors: defaultColors,\n backgroundColors: defaultColors\n });\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const t = editor.t;\n this._defaultContentTableCellProperties = getNormalizedDefaultCellProperties(editor.config.get('table.tableCellProperties.defaultProperties'), {\n includeVerticalAlignmentProperty: true,\n includeHorizontalAlignmentProperty: true,\n includePaddingProperty: true,\n isRightToLeftContent: editor.locale.contentLanguageDirection === 'rtl'\n });\n this._defaultLayoutTableCellProperties = getNormalizedDefaultProperties(undefined, {\n includeVerticalAlignmentProperty: true,\n includeHorizontalAlignmentProperty: true,\n isRightToLeftContent: editor.locale.contentLanguageDirection === 'rtl'\n });\n this._balloon = editor.plugins.get(ContextualBalloon);\n this.view = null;\n this._isReady = false;\n editor.ui.componentFactory.add('tableCellProperties', locale => {\n const view = new ButtonView(locale);\n view.set({\n label: t('Cell properties'),\n icon: IconTableCellProperties,\n tooltip: true\n });\n this.listenTo(view, 'execute', () => this._showView());\n const commands = Object.values(propertyToCommandMap)\n .map(commandName => editor.commands.get(commandName));\n view.bind('isEnabled').toMany(commands, 'isEnabled', (...areEnabled) => (areEnabled.some(isCommandEnabled => isCommandEnabled)));\n return view;\n });\n }\n /**\n * @inheritDoc\n */\n destroy() {\n super.destroy();\n // Destroy created UI components as they are not automatically destroyed.\n // See https://github.com/ckeditor/ckeditor5/issues/1341.\n if (this.view) {\n this.view.destroy();\n }\n }\n /**\n * Creates the {@link module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView} instance.\n *\n * @returns The cell properties form view instance.\n */\n _createPropertiesView(defaultTableCellProperties) {\n const editor = this.editor;\n const config = editor.config.get('table.tableCellProperties');\n const borderColorsConfig = normalizeColorOptions(config.borderColors);\n const localizedBorderColors = getLocalizedColorOptions(editor.locale, borderColorsConfig);\n const backgroundColorsConfig = normalizeColorOptions(config.backgroundColors);\n const localizedBackgroundColors = getLocalizedColorOptions(editor.locale, backgroundColorsConfig);\n const hasColorPicker = config.colorPicker !== false;\n const view = new TableCellPropertiesView(editor.locale, {\n borderColors: localizedBorderColors,\n backgroundColors: localizedBackgroundColors,\n defaultTableCellProperties,\n colorPickerConfig: hasColorPicker ? (config.colorPicker || {}) : false\n });\n const t = editor.t;\n // Render the view so its #element is available for the clickOutsideHandler.\n view.render();\n this.listenTo(view, 'submit', () => {\n this._hideView();\n });\n this.listenTo(view, 'cancel', () => {\n // https://github.com/ckeditor/ckeditor5/issues/6180\n if (this._undoStepBatch.operations.length) {\n editor.execute('undo', this._undoStepBatch);\n }\n this._hideView();\n });\n // Close the balloon on Esc key press.\n view.keystrokes.set('Esc', (data, cancel) => {\n this._hideView();\n cancel();\n });\n // Close on click outside of balloon panel element.\n clickOutsideHandler({\n emitter: view,\n activator: () => this._isViewInBalloon,\n contextElements: [this._balloon.view.element],\n callback: () => this._hideView()\n });\n const colorErrorText = getLocalizedColorErrorText(t);\n const lengthErrorText = getLocalizedLengthErrorText(t);\n // Create the \"UI -> editor data\" binding.\n // These listeners update the editor data (via table commands) when any observable\n // property of the view has changed. They also validate the value and display errors in the UI\n // when necessary. This makes the view live, which means the changes are\n // visible in the editing as soon as the user types or changes fields' values.\n view.on('change:borderStyle', this._getPropertyChangeCallback('tableCellBorderStyle'));\n view.on('change:borderColor', this._getValidatedPropertyChangeCallback({\n viewField: view.borderColorInput,\n commandName: 'tableCellBorderColor',\n errorText: colorErrorText,\n validator: colorFieldValidator\n }));\n view.on('change:borderWidth', this._getValidatedPropertyChangeCallback({\n viewField: view.borderWidthInput,\n commandName: 'tableCellBorderWidth',\n errorText: lengthErrorText,\n validator: lineWidthFieldValidator\n }));\n view.on('change:padding', this._getValidatedPropertyChangeCallback({\n viewField: view.paddingInput,\n commandName: 'tableCellPadding',\n errorText: lengthErrorText,\n validator: lengthFieldValidator\n }));\n view.on('change:width', this._getValidatedPropertyChangeCallback({\n viewField: view.widthInput,\n commandName: 'tableCellWidth',\n errorText: lengthErrorText,\n validator: lengthFieldValidator\n }));\n view.on('change:height', this._getValidatedPropertyChangeCallback({\n viewField: view.heightInput,\n commandName: 'tableCellHeight',\n errorText: lengthErrorText,\n validator: lengthFieldValidator\n }));\n view.on('change:backgroundColor', this._getValidatedPropertyChangeCallback({\n viewField: view.backgroundInput,\n commandName: 'tableCellBackgroundColor',\n errorText: colorErrorText,\n validator: colorFieldValidator\n }));\n view.on('change:horizontalAlignment', this._getPropertyChangeCallback('tableCellHorizontalAlignment'));\n view.on('change:verticalAlignment', this._getPropertyChangeCallback('tableCellVerticalAlignment'));\n return view;\n }\n /**\n * In this method the \"editor data -> UI\" binding is happening.\n *\n * When executed, this method obtains selected cell property values from various table commands\n * and passes them to the {@link #view}.\n *\n * This way, the UI stays up–to–date with the editor data.\n */\n _fillViewFormFromCommandValues() {\n const commands = this.editor.commands;\n const borderStyleCommand = commands.get('tableCellBorderStyle');\n Object.entries(propertyToCommandMap)\n .map(([property, commandName]) => {\n const propertyKey = property;\n const defaultValue = this.view === this._viewWithContentTableDefaults ?\n this._defaultContentTableCellProperties[propertyKey] || '' :\n this._defaultLayoutTableCellProperties[propertyKey] || '';\n return [\n property,\n commands.get(commandName).value || defaultValue\n ];\n })\n .forEach(([property, value]) => {\n // Do not set the `border-color` and `border-width` fields if `border-style:none`.\n if ((property === 'borderColor' || property === 'borderWidth') && borderStyleCommand.value === 'none') {\n return;\n }\n this.view.set(property, value);\n });\n this._isReady = true;\n }\n /**\n * Shows the {@link #view} in the {@link #_balloon}.\n *\n * **Note**: Each time a view is shown, a new {@link #_undoStepBatch} is created. It contains\n * all changes made to the document when the view is visible, allowing a single undo step\n * for all of them.\n */\n _showView() {\n const editor = this.editor;\n const viewTable = getSelectionAffectedTableWidget(editor.editing.view.document.selection);\n const modelTable = viewTable && editor.editing.mapper.toModelElement(viewTable);\n const useDefaults = !modelTable || modelTable.getAttribute('tableType') !== 'layout';\n if (useDefaults && !this._viewWithContentTableDefaults) {\n this._viewWithContentTableDefaults = this._createPropertiesView(this._defaultContentTableCellProperties);\n }\n else if (!useDefaults && !this._viewWithLayoutTableDefaults) {\n this._viewWithLayoutTableDefaults = this._createPropertiesView(this._defaultLayoutTableCellProperties);\n }\n this.view = useDefaults ? this._viewWithContentTableDefaults : this._viewWithLayoutTableDefaults;\n this.listenTo(editor.ui, 'update', () => {\n this._updateView();\n });\n // Update the view with the model values.\n this._fillViewFormFromCommandValues();\n this._balloon.add({\n view: this.view,\n position: getBalloonCellPositionData(editor)\n });\n // Create a new batch. Clicking \"Cancel\" will undo this batch.\n this._undoStepBatch = editor.model.createBatch();\n // Basic a11y.\n this.view.focus();\n }\n /**\n * Removes the {@link #view} from the {@link #_balloon}.\n */\n _hideView() {\n const editor = this.editor;\n this.stopListening(editor.ui, 'update');\n this._isReady = false;\n // Blur any input element before removing it from DOM to prevent issues in some browsers.\n // See https://github.com/ckeditor/ckeditor5/issues/1501.\n this.view.saveButtonView.focus();\n this._balloon.remove(this.view);\n // Make sure the focus is not lost in the process by putting it directly\n // into the editing view.\n this.editor.editing.view.focus();\n }\n /**\n * Repositions the {@link #_balloon} or hides the {@link #view} if a table cell is no longer selected.\n */\n _updateView() {\n const editor = this.editor;\n const viewDocument = editor.editing.view.document;\n if (!getTableWidgetAncestor(viewDocument.selection)) {\n this._hideView();\n }\n else if (this._isViewVisible) {\n repositionContextualBalloon(editor, 'cell');\n }\n }\n /**\n * Returns `true` when the {@link #view} is visible in the {@link #_balloon}.\n */\n get _isViewVisible() {\n return !!this.view && this._balloon.visibleView === this.view;\n }\n /**\n * Returns `true` when the {@link #view} is in the {@link #_balloon}.\n */\n get _isViewInBalloon() {\n return !!this.view && this._balloon.hasView(this.view);\n }\n /**\n * Creates a callback that when executed upon the {@link #view view's} property change\n * executes a related editor command with the new property value.\n *\n * @param commandName The default value of the command.\n */\n _getPropertyChangeCallback(commandName) {\n return (evt, propertyName, newValue) => {\n if (!this._isReady) {\n return;\n }\n this.editor.execute(commandName, {\n value: newValue,\n batch: this._undoStepBatch\n });\n };\n }\n /**\n * Creates a callback that when executed upon the {@link #view view's} property change:\n * * Executes a related editor command with the new property value if the value is valid,\n * * Or sets the error text next to the invalid field, if the value did not pass the validation.\n */\n _getValidatedPropertyChangeCallback(options) {\n const { commandName, viewField, validator, errorText } = options;\n const setErrorTextDebounced = debounce(() => {\n viewField.errorText = errorText;\n }, ERROR_TEXT_TIMEOUT);\n return (evt, propertyName, newValue) => {\n setErrorTextDebounced.cancel();\n // Do not execute the command on initial call (opening the table properties view).\n if (!this._isReady) {\n return;\n }\n if (validator(newValue)) {\n this.editor.execute(commandName, {\n value: newValue,\n batch: this._undoStepBatch\n });\n viewField.errorText = null;\n }\n else {\n setErrorTextDebounced();\n }\n };\n }\n}\n","export default \"\";","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tablecellproperties/commands/tablecellpropertycommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { getSelectionAffectedTable } from '../../utils/common.js';\n/**\n * The table cell attribute command.\n *\n * The command is a base command for other table cell property commands.\n */\nexport class TableCellPropertyCommand extends Command {\n /**\n * The attribute that will be set by the command.\n */\n attributeName;\n /**\n * The default value for the attribute.\n *\n * @readonly\n */\n _defaultValue;\n /**\n * The default value for the attribute for the content table.\n */\n _defaultContentTableValue;\n /**\n * The default value for the attribute for the layout table.\n */\n _defaultLayoutTableValue;\n /**\n * Creates a new `TableCellPropertyCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param attributeName Table cell attribute name.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, attributeName, defaultValue) {\n super(editor);\n this.attributeName = attributeName;\n this._defaultContentTableValue = defaultValue;\n // Hardcoded defaults for layout table.\n switch (attributeName) {\n case 'tableCellType':\n this._defaultLayoutTableValue = 'data';\n break;\n case 'tableCellBorderStyle':\n this._defaultLayoutTableValue = 'none';\n break;\n case 'tableCellHorizontalAlignment':\n this._defaultLayoutTableValue = 'left';\n break;\n case 'tableCellVerticalAlignment':\n this._defaultLayoutTableValue = 'middle';\n break;\n default:\n this._defaultLayoutTableValue = undefined;\n }\n }\n /**\n * @inheritDoc\n */\n refresh() {\n const editor = this.editor;\n const selection = editor.model.document.selection;\n const tableUtils = this.editor.plugins.get('TableUtils');\n const selectedTableCells = tableUtils.getSelectionAffectedTableCells(selection);\n const table = getSelectionAffectedTable(selection);\n this._defaultValue = !table || table.getAttribute('tableType') !== 'layout' ?\n this._defaultContentTableValue :\n this._defaultLayoutTableValue;\n this.isEnabled = !!selectedTableCells.length;\n this.value = this._getSingleValue(selectedTableCells);\n }\n /**\n * Executes the command.\n *\n * @fires execute\n * @param options.value If set, the command will set the attribute on selected table cells.\n * If it is not set, the command will remove the attribute from the selected table cells.\n * @param options.batch Pass the model batch instance to the command to aggregate changes,\n * for example to allow a single undo step for multiple executions.\n */\n execute(options = {}) {\n const { value, batch } = options;\n const model = this.editor.model;\n const tableUtils = this.editor.plugins.get('TableUtils');\n const tableCells = tableUtils.getSelectionAffectedTableCells(model.document.selection);\n const valueToSet = this._getValueToSet(value);\n model.enqueueChange(batch, writer => {\n if (valueToSet) {\n tableCells.forEach(tableCell => writer.setAttribute(this.attributeName, valueToSet, tableCell));\n }\n else {\n tableCells.forEach(tableCell => writer.removeAttribute(this.attributeName, tableCell));\n }\n this.fire('afterExecute', {\n writer,\n tableCells,\n valueToSet\n });\n });\n }\n /**\n * Returns the attribute value for a table cell.\n */\n _getAttribute(tableCell) {\n if (!tableCell) {\n return;\n }\n const value = tableCell.getAttribute(this.attributeName);\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n /**\n * Returns the proper model value. It can be used to add a default unit to numeric values.\n */\n _getValueToSet(value) {\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n /**\n * Returns a single value for all selected table cells. If the value is the same for all cells,\n * it will be returned (`undefined` otherwise).\n */\n _getSingleValue(tableCells) {\n const firstCellValue = this._getAttribute(tableCells[0]);\n const everyCellHasAttribute = tableCells.every(tableCells => this._getAttribute(tableCells) === firstCellValue);\n return everyCellHasAttribute ? firstCellValue : undefined;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TableCellPropertyCommand } from '../../tablecellproperties/commands/tablecellpropertycommand.js';\nimport { addDefaultUnitToNumericValue } from '../../utils/table-properties.js';\n/**\n * The table cell width command.\n *\n * The command is registered by the {@link module:table/tablecellwidth/tablecellwidthediting~TableCellWidthEditing} as\n * the `'tableCellWidth'` editor command.\n *\n * To change the width of selected cells, execute the command:\n *\n * ```ts\n * editor.execute( 'tableCellWidth', {\n * value: '50px'\n * } );\n * ```\n *\n * **Note**: This command adds a default `'px'` unit to numeric values. Executing:\n *\n * ```ts\n * editor.execute( 'tableCellWidth', {\n * value: '50'\n * } );\n * ```\n *\n * will set the `width` attribute to `'50px'` in the model.\n */\nexport class TableCellWidthCommand extends TableCellPropertyCommand {\n /**\n * Creates a new `TableCellWidthCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableCellWidth', defaultValue);\n }\n /**\n * @inheritDoc\n */\n _getValueToSet(value) {\n value = addDefaultUnitToNumericValue(value, 'px');\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tablecellwidth/tablecellwidthediting\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { TableEditing } from './../tableediting.js';\nimport { TableCellWidthCommand } from './commands/tablecellwidthcommand.js';\nimport { getNormalizedDefaultCellProperties } from '../utils/table-properties.js';\nimport { enableProperty } from '../utils/common.js';\n/**\n * The table cell width editing feature.\n *\n * Introduces `tableCellWidth` table cell model attribute alongside with its converters\n * and a command.\n */\nexport class TableCellWidthEditing extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TableCellWidthEditing';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get requires() {\n return [TableEditing];\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const defaultTableCellProperties = getNormalizedDefaultCellProperties(editor.config.get('table.tableCellProperties.defaultProperties'));\n enableProperty(editor.model.schema, editor.conversion, {\n modelAttribute: 'tableCellWidth',\n styleName: 'width',\n attributeName: 'width',\n attributeType: 'length',\n defaultValue: defaultTableCellProperties.width\n });\n editor.commands.add('tableCellWidth', new TableCellWidthCommand(editor, defaultTableCellProperties.width));\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TableCellPropertyCommand } from './tablecellpropertycommand.js';\nimport { addDefaultUnitToNumericValue, getSingleValue } from '../../utils/table-properties.js';\n/**\n * The table cell padding command.\n *\n * The command is registered by the {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing} as\n * the `'tableCellPadding'` editor command.\n *\n * To change the padding of selected cells, execute the command:\n *\n * ```ts\n * editor.execute( 'tableCellPadding', {\n * value: '5px'\n * } );\n * ```\n *\n * **Note**: This command adds the default `'px'` unit to numeric values. Executing:\n *\n * ```ts\n * editor.execute( 'tableCellPadding', {\n * value: '5'\n * } );\n * ```\n *\n * will set the `padding` attribute to `'5px'` in the model.\n */\nexport class TableCellPaddingCommand extends TableCellPropertyCommand {\n /**\n * Creates a new `TableCellPaddingCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableCellPadding', defaultValue);\n }\n /**\n * @inheritDoc\n */\n _getAttribute(tableCell) {\n if (!tableCell) {\n return;\n }\n const value = getSingleValue(tableCell.getAttribute(this.attributeName));\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n /**\n * @inheritDoc\n */\n _getValueToSet(value) {\n const newValue = addDefaultUnitToNumericValue(value, 'px');\n if (newValue === this._defaultValue) {\n return;\n }\n return newValue;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TableCellPropertyCommand } from './tablecellpropertycommand.js';\nimport { addDefaultUnitToNumericValue } from '../../utils/table-properties.js';\n/**\n * The table cell height command.\n *\n * The command is registered by the {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing} as\n * the `'tableCellHeight'` editor command.\n *\n * To change the height of selected cells, execute the command:\n *\n * ```ts\n * editor.execute( 'tableCellHeight', {\n * value: '50px'\n * } );\n * ```\n *\n * **Note**: This command adds the default `'px'` unit to numeric values. Executing:\n *\n * ```ts\n * editor.execute( 'tableCellHeight', {\n * value: '50'\n * } );\n * ```\n *\n * will set the `height` attribute to `'50px'` in the model.\n */\nexport class TableCellHeightCommand extends TableCellPropertyCommand {\n /**\n * Creates a new `TableCellHeightCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableCellHeight', defaultValue);\n }\n /**\n * @inheritDoc\n */\n _getValueToSet(value) {\n const newValue = addDefaultUnitToNumericValue(value, 'px');\n if (newValue === this._defaultValue) {\n return;\n }\n return newValue;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TableCellPropertyCommand } from './tablecellpropertycommand.js';\n/**\n * The table cell background color command.\n *\n * The command is registered by the {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing} as\n * the `'tableCellBackgroundColor'` editor command.\n *\n * To change the background color of selected cells, execute the command:\n *\n * ```ts\n * editor.execute( 'tableCellBackgroundColor', {\n * value: '#f00'\n * } );\n * ```\n */\nexport class TableCellBackgroundColorCommand extends TableCellPropertyCommand {\n /**\n * Creates a new `TableCellBackgroundColorCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableCellBackgroundColor', defaultValue);\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TableCellPropertyCommand } from './tablecellpropertycommand.js';\n/**\n * The table cell vertical alignment command.\n *\n * The command is registered by the {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing} as\n * the `'tableCellVerticalAlignment'` editor command.\n *\n * To change the vertical text alignment of selected cells, execute the command:\n *\n * ```ts\n * editor.execute( 'tableCellVerticalAlignment', {\n * value: 'top'\n * } );\n * ```\n *\n * The following values, corresponding to the\n * [`vertical-align` CSS attribute](https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align), are allowed:\n *\n * * `'top'`\n * * `'bottom'`\n *\n * The `'middle'` value is the default one so there is no need to set it.\n */\nexport class TableCellVerticalAlignmentCommand extends TableCellPropertyCommand {\n /**\n * Creates a new `TableCellVerticalAlignmentCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value for the \"alignment\" attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableCellVerticalAlignment', defaultValue);\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TableCellPropertyCommand } from './tablecellpropertycommand.js';\n/**\n * The table cell horizontal alignment command.\n *\n * The command is registered by the {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing} as\n * the `'tableCellHorizontalAlignment'` editor command.\n *\n * To change the horizontal text alignment of selected cells, execute the command:\n *\n * ```ts\n * editor.execute( 'tableCellHorizontalAlignment', {\n * value: 'right'\n * } );\n * ```\n */\nexport class TableCellHorizontalAlignmentCommand extends TableCellPropertyCommand {\n /**\n * Creates a new `TableCellHorizontalAlignmentCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value for the \"alignment\" attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableCellHorizontalAlignment', defaultValue);\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TableCellPropertyCommand } from './tablecellpropertycommand.js';\nimport { getSingleValue } from '../../utils/table-properties.js';\n/**\n * The table cell border style command.\n *\n * The command is registered by the {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing} as\n * the `'tableCellBorderStyle'` editor command.\n *\n * To change the border style of selected cells, execute the command:\n *\n * ```ts\n * editor.execute( 'tableCellBorderStyle', {\n * value: 'dashed'\n * } );\n * ```\n */\nexport class TableCellBorderStyleCommand extends TableCellPropertyCommand {\n /**\n * Creates a new `TableCellBorderStyleCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableCellBorderStyle', defaultValue);\n }\n /**\n * @inheritDoc\n */\n _getAttribute(tableCell) {\n if (!tableCell) {\n return;\n }\n const value = getSingleValue(tableCell.getAttribute(this.attributeName));\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TableCellPropertyCommand } from './tablecellpropertycommand.js';\nimport { getSingleValue } from '../../utils/table-properties.js';\n/**\n * The table cell border color command.\n *\n * The command is registered by the {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing} as\n * the `'tableCellBorderColor'` editor command.\n *\n * To change the border color of selected cells, execute the command:\n *\n * ```ts\n * editor.execute( 'tableCellBorderColor', {\n * value: '#f00'\n * } );\n * ```\n */\nexport class TableCellBorderColorCommand extends TableCellPropertyCommand {\n /**\n * Creates a new `TableCellBorderColorCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableCellBorderColor', defaultValue);\n }\n /**\n * @inheritDoc\n */\n _getAttribute(tableCell) {\n if (!tableCell) {\n return;\n }\n const value = getSingleValue(tableCell.getAttribute(this.attributeName));\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TableCellPropertyCommand } from './tablecellpropertycommand.js';\nimport { addDefaultUnitToNumericValue, getSingleValue } from '../../utils/table-properties.js';\n/**\n * The table cell border width command.\n *\n * The command is registered by the {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing} as\n * the `'tableCellBorderWidth'` editor command.\n *\n * To change the border width of selected cells, execute the command:\n *\n * ```ts\n * editor.execute( 'tableCellBorderWidth', {\n * value: '5px'\n * } );\n * ```\n *\n * **Note**: This command adds the default `'px'` unit to numeric values. Executing:\n *\n * ```ts\n * editor.execute( 'tableCellBorderWidth', {\n * value: '5'\n * } );\n * ```\n *\n * will set the `borderWidth` attribute to `'5px'` in the model.\n */\nexport class TableCellBorderWidthCommand extends TableCellPropertyCommand {\n /**\n * Creates a new `TableCellBorderWidthCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n * @param defaultValue The default value of the attribute.\n */\n constructor(editor, defaultValue) {\n super(editor, 'tableCellBorderWidth', defaultValue);\n }\n /**\n * @inheritDoc\n */\n _getAttribute(tableCell) {\n if (!tableCell) {\n return;\n }\n const value = getSingleValue(tableCell.getAttribute(this.attributeName));\n if (value === this._defaultValue) {\n return;\n }\n return value;\n }\n /**\n * @inheritDoc\n */\n _getValueToSet(value) {\n const newValue = addDefaultUnitToNumericValue(value, 'px');\n if (newValue === this._defaultValue) {\n return;\n }\n return newValue;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { TableUtils } from '../../tableutils.js';\nimport { TableCellPropertyCommand } from './tablecellpropertycommand.js';\nimport { groupCellsByTable, getSelectionAffectedTable } from '../../utils/common.js';\nimport { TableWalker } from '../../tablewalker.js';\n/**\n * The table cell type command.\n *\n * The command is registered by the {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing} as\n * the `'tableCellType'` editor command.\n *\n * To change the type of selected cells, execute the command:\n *\n * ```ts\n * editor.execute( 'tableCellType', {\n * value: 'header'\n * } );\n * ```\n *\n * The `value` can be either `'header'` or `'data'`.\n * It'll return `undefined` if multiple types are selected.\n */\nexport class TableCellTypeCommand extends TableCellPropertyCommand {\n /**\n * Creates a new `TableCellTypeCommand` instance.\n *\n * @param editor An editor in which this command will be used.\n */\n constructor(editor) {\n super(editor, 'tableCellType', 'data');\n this.on('afterExecute', (_, data) => {\n const { writer, tableCells } = data;\n const tableUtils = this.editor.plugins.get(TableUtils);\n const tablesMap = groupCellsByTable(tableCells);\n updateTablesHeadingAttributes(tableUtils, writer, tablesMap.keys());\n });\n }\n /**\n * @inheritDoc\n */\n refresh() {\n super.refresh();\n const table = getSelectionAffectedTable(this.editor.model.document.selection);\n if (this.isEnabled && table && table.getAttribute('tableType') === 'layout') {\n this.isEnabled = false;\n }\n }\n /**\n * Returns the attribute value for a table cell.\n */\n _getAttribute(tableCell) {\n return tableCell?.getAttribute(this.attributeName) || 'data';\n }\n}\n/**\n * Updates the `headingRows` and `headingColumns` attributes of the given tables\n * based on the `tableCellType` of their cells.\n */\nexport function updateTablesHeadingAttributes(tableUtils, writer, tables) {\n let changed = false;\n for (const table of tables) {\n let headingRows = table.getAttribute('headingRows') || 0;\n let headingColumns = table.getAttribute('headingColumns') || 0;\n // Prioritize the dimension that is already larger to prevent the other dimension from\n // aggressively consuming \"orphaned\" header cells. In other words, if table has three\n // heading columns (which fills entire table), we should not count all rows as heading rows.\n // User might later add column to the right which should not be heading.\n //\n // The other example, in a 2x2 table where all cells are headers (e.g. due to concurrent edits),\n // if headingColumns=0 and headingRows=0 (but all cells are headers):\n // - Processing rows first would expand headingRows to 2 (covering all cells), leaving headingColumns at 0.\n // - Processing columns first expands headingColumns to 2, leaving headingRows at 0.\n //\n // It should be good enough to resolve conflicts in most cases.\n const processColumnsFirst = headingColumns > headingRows;\n if (processColumnsFirst) {\n const newHeadingColumns = getAdjustedHeadingSectionSize(tableUtils, table, 'column', headingColumns, headingRows);\n if (newHeadingColumns !== headingColumns) {\n tableUtils.setHeadingColumnsCount(writer, table, newHeadingColumns, { shallow: true });\n headingColumns = newHeadingColumns;\n changed = true;\n }\n }\n const newHeadingRows = getAdjustedHeadingSectionSize(tableUtils, table, 'row', headingRows, headingColumns);\n if (newHeadingRows !== headingRows) {\n tableUtils.setHeadingRowsCount(writer, table, newHeadingRows, { shallow: true });\n headingRows = newHeadingRows;\n changed = true;\n }\n if (!processColumnsFirst) {\n const newHeadingColumns = getAdjustedHeadingSectionSize(tableUtils, table, 'column', headingColumns, headingRows);\n if (newHeadingColumns !== headingColumns) {\n tableUtils.setHeadingColumnsCount(writer, table, newHeadingColumns, { shallow: true });\n changed = true;\n }\n }\n }\n return changed;\n}\n/**\n * Calculates the adjusted size of a heading section (rows or columns).\n *\n * The algorithm iterates through rows (or columns) to determine if they should be part of the heading section.\n * A row/column is included if:\n * 1. All its cells are of type 'header'.\n * 2. AND it contains at least one header cell that is NOT already covered by the perpendicular heading section.\n *\n * This check prevents the algorithm from aggressively expanding the heading section when cells are already\n * headers due to the other dimension.\n *\n * Consider a 2x2 table where all cells are headers:\n *\n * ```\n * C0 C1\n * +---+---+\n * R0| H | H |\n * +---+---+\n * R1| H | H |\n * +---+---+\n * ```\n *\n * If `headingColumns=2`, both C0 and C1 are heading columns.\n * If we want `headingRows=1` (only R0), the algorithm must NOT include R1, even though R1 consists of header cells.\n * R1's cells are headers because of C0 and C1.\n *\n * Without this check, the algorithm would see that R1 is all headers and force `headingRows` to 2.\n * This would prevent the user from reducing `headingRows` from 2 to 1 without converting R1 cells to 'data'\n * (which would incorrectly break C0 and C1).\n */\nfunction getAdjustedHeadingSectionSize(tableUtils, table, mode, currentSize, perpendicularHeadingSize) {\n const totalRowsOrColumns = mode === 'row' ? tableUtils.getRows(table) : tableUtils.getColumns(table);\n let size = currentSize;\n // Iterate through each row/column to check if all cells are headers.\n for (let currentIndex = 0; currentIndex < totalRowsOrColumns; currentIndex++) {\n const walker = new TableWalker(table, { [mode]: currentIndex });\n let allCellsAreHeaders = true;\n let hasHeaderOutsidePerpendicularSection = false;\n // Check each cell in the current row/column.\n for (const { cell, row, column } of walker) {\n // If we find a non-header cell, this row/column can't be part of the heading section.\n if (cell.getAttribute('tableCellType') !== 'header') {\n allCellsAreHeaders = false;\n break;\n }\n // Check if this header cell extends beyond the perpendicular heading section.\n // E.g., when checking rows, see if the cell extends beyond headingColumns.\n const perpendicularIndex = mode === 'row' ? column : row;\n if (perpendicularIndex >= perpendicularHeadingSize) {\n hasHeaderOutsidePerpendicularSection = true;\n }\n }\n // If not all cells are headers, we can't extend the heading section any further.\n if (!allCellsAreHeaders) {\n // The section cannot extend beyond the last valid header row/column.\n return Math.min(size, currentIndex);\n }\n // If there's a header extending beyond the perpendicular section,\n // we must include this row/column in the heading section.\n if (hasHeaderOutsidePerpendicularSection) {\n size = Math.max(size, currentIndex + 1);\n }\n }\n return Math.min(size, totalRowsOrColumns);\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module table/tablecellproperties/tablecellpropertiesediting\n */\nimport { priorities } from 'ckeditor5/src/utils.js';\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { addBorderStylesRules, addPaddingStylesRules, addBackgroundStylesRules } from 'ckeditor5/src/engine.js';\nimport { downcastAttributeToStyle, getDefaultValueAdjusted, upcastBorderStyles } from '../converters/tableproperties.js';\nimport { TableEditing } from './../tableediting.js';\nimport { TableCellWidthEditing } from '../tablecellwidth/tablecellwidthediting.js';\nimport { TableCellPaddingCommand } from './commands/tablecellpaddingcommand.js';\nimport { TableCellHeightCommand } from './commands/tablecellheightcommand.js';\nimport { TableCellBackgroundColorCommand } from './commands/tablecellbackgroundcolorcommand.js';\nimport { TableCellVerticalAlignmentCommand } from './commands/tablecellverticalalignmentcommand.js';\nimport { TableCellHorizontalAlignmentCommand } from './commands/tablecellhorizontalalignmentcommand.js';\nimport { TableCellBorderStyleCommand } from './commands/tablecellborderstylecommand.js';\nimport { TableCellBorderColorCommand } from './commands/tablecellbordercolorcommand.js';\nimport { TableCellBorderWidthCommand } from './commands/tablecellborderwidthcommand.js';\nimport { TableCellTypeCommand, updateTablesHeadingAttributes } from './commands/tablecelltypecommand.js';\nimport { getNormalizedDefaultCellProperties } from '../utils/table-properties.js';\nimport { enableProperty } from '../utils/common.js';\nimport { TableUtils } from '../tableutils.js';\nimport { TableWalker } from '../tablewalker.js';\nconst VALIGN_VALUES_REG_EXP = /^(top|middle|bottom)$/;\nconst ALIGN_VALUES_REG_EXP = /^(left|center|right|justify)$/;\n/**\n * The table cell properties editing feature.\n *\n * Introduces table cell model attributes and their conversion:\n *\n * - border: `tableCellBorderStyle`, `tableCellBorderColor` and `tableCellBorderWidth`\n * - background color: `tableCellBackgroundColor`\n * - cell padding: `tableCellPadding`\n * - horizontal and vertical alignment: `tableCellHorizontalAlignment`, `tableCellVerticalAlignment`\n * - cell width and height: `tableCellWidth`, `tableCellHeight`\n *\n * It also registers commands used to manipulate the above attributes:\n *\n * - border: the `'tableCellBorderStyle'`, `'tableCellBorderColor'` and `'tableCellBorderWidth'` commands\n * - background color: the `'tableCellBackgroundColor'` command\n * - cell padding: the `'tableCellPadding'` command\n * - horizontal and vertical alignment: the `'tableCellHorizontalAlignment'` and `'tableCellVerticalAlignment'` commands\n * - width and height: the `'tableCellWidth'` and `'tableCellHeight'` commands\n */\nexport class TableCellPropertiesEditing extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TableCellPropertiesEditing';\n }\n /**\n * @inheritDoc\n * @internal\n */\n static get licenseFeatureCode() {\n return 'TCP';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get isPremiumPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get requires() {\n return [TableEditing, TableCellWidthEditing];\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n editor.config.define('table.tableCellProperties.defaultProperties', {});\n const defaultTableCellProperties = getNormalizedDefaultCellProperties(editor.config.get('table.tableCellProperties.defaultProperties'), {\n includeVerticalAlignmentProperty: true,\n includeHorizontalAlignmentProperty: true,\n includePaddingProperty: true,\n isRightToLeftContent: editor.locale.contentLanguageDirection === 'rtl'\n });\n editor.data.addStyleProcessorRules(addBorderStylesRules);\n enableBorderProperties(editor, {\n color: defaultTableCellProperties.borderColor,\n style: defaultTableCellProperties.borderStyle,\n width: defaultTableCellProperties.borderWidth\n });\n editor.commands.add('tableCellBorderStyle', new TableCellBorderStyleCommand(editor, defaultTableCellProperties.borderStyle));\n editor.commands.add('tableCellBorderColor', new TableCellBorderColorCommand(editor, defaultTableCellProperties.borderColor));\n editor.commands.add('tableCellBorderWidth', new TableCellBorderWidthCommand(editor, defaultTableCellProperties.borderWidth));\n enableProperty(schema, conversion, {\n modelAttribute: 'tableCellHeight',\n styleName: 'height',\n attributeName: 'height',\n attributeType: 'length',\n defaultValue: defaultTableCellProperties.height\n });\n editor.commands.add('tableCellHeight', new TableCellHeightCommand(editor, defaultTableCellProperties.height));\n editor.data.addStyleProcessorRules(addPaddingStylesRules);\n enableProperty(schema, conversion, {\n modelAttribute: 'tableCellPadding',\n styleName: 'padding',\n reduceBoxSides: true,\n defaultValue: defaultTableCellProperties.padding\n });\n editor.commands.add('tableCellPadding', new TableCellPaddingCommand(editor, defaultTableCellProperties.padding));\n editor.data.addStyleProcessorRules(addBackgroundStylesRules);\n enableProperty(schema, conversion, {\n modelAttribute: 'tableCellBackgroundColor',\n styleName: 'background-color',\n attributeName: 'bgcolor',\n attributeType: 'color',\n defaultValue: defaultTableCellProperties.backgroundColor\n });\n editor.commands.add('tableCellBackgroundColor', new TableCellBackgroundColorCommand(editor, defaultTableCellProperties.backgroundColor));\n enableHorizontalAlignmentProperty(schema, conversion, defaultTableCellProperties.horizontalAlignment);\n editor.commands.add('tableCellHorizontalAlignment', new TableCellHorizontalAlignmentCommand(editor, defaultTableCellProperties.horizontalAlignment));\n enableVerticalAlignmentProperty(schema, conversion, defaultTableCellProperties.verticalAlignment);\n editor.commands.add('tableCellVerticalAlignment', new TableCellVerticalAlignmentCommand(editor, defaultTableCellProperties.verticalAlignment));\n if (editor.config.get('experimentalFlags.tableCellTypeSupport')) {\n enableCellTypeProperty(editor);\n editor.commands.add('tableCellType', new TableCellTypeCommand(editor));\n }\n }\n}\n/**\n * Enables the `'tableCellBorderStyle'`, `'tableCellBorderColor'` and `'tableCellBorderWidth'` attributes for table cells.\n *\n * @param editor The editor instance.\n * @param defaultBorder The default border values.\n * @param defaultBorder.color The default `tableCellBorderColor` value.\n * @param defaultBorder.style The default `tableCellBorderStyle` value.\n * @param defaultBorder.width The default `tableCellBorderWidth` value.\n */\nfunction enableBorderProperties(editor, defaultBorder) {\n const { conversion } = editor;\n const { schema } = editor.model;\n const modelAttributes = {\n width: 'tableCellBorderWidth',\n color: 'tableCellBorderColor',\n style: 'tableCellBorderStyle'\n };\n schema.extend('tableCell', {\n allowAttributes: Object.values(modelAttributes)\n });\n for (const modelAttribute of Object.values(modelAttributes)) {\n schema.setAttributeProperties(modelAttribute, { isFormatting: true });\n }\n upcastBorderStyles(editor, 'td', modelAttributes, defaultBorder);\n upcastBorderStyles(editor, 'th', modelAttributes, defaultBorder);\n downcastAttributeToStyle(conversion, { modelElement: 'tableCell', modelAttribute: modelAttributes.style, styleName: 'border-style' });\n downcastAttributeToStyle(conversion, { modelElement: 'tableCell', modelAttribute: modelAttributes.color, styleName: 'border-color' });\n downcastAttributeToStyle(conversion, { modelElement: 'tableCell', modelAttribute: modelAttributes.width, styleName: 'border-width' });\n}\n/**\n * Enables the `'tableCellHorizontalAlignment'` attribute for table cells.\n *\n * @param defaultValue The default horizontal alignment value.\n */\nfunction enableHorizontalAlignmentProperty(schema, conversion, defaultValue) {\n schema.extend('tableCell', {\n allowAttributes: ['tableCellHorizontalAlignment']\n });\n schema.setAttributeProperties('tableCellHorizontalAlignment', { isFormatting: true });\n conversion.for('downcast')\n .attributeToAttribute({\n model: {\n name: 'tableCell',\n key: 'tableCellHorizontalAlignment'\n },\n view: alignment => ({\n key: 'style',\n value: {\n 'text-align': alignment\n }\n })\n });\n conversion.for('upcast')\n // Support for the `text-align:*;` CSS definition for the table cell alignment.\n .attributeToAttribute({\n view: {\n name: /^(td|th)$/,\n styles: {\n 'text-align': ALIGN_VALUES_REG_EXP\n }\n },\n model: {\n key: 'tableCellHorizontalAlignment',\n value: (viewElement, conversionApi, data) => {\n const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'left', data);\n const align = viewElement.getStyle('text-align');\n if (align !== localDefaultValue) {\n return align;\n }\n // Consume the style even if not applied to the element so it won't be processed by other converters.\n conversionApi.consumable.consume(viewElement, { styles: 'text-align' });\n }\n }\n })\n // Support for the `align` attribute as the backward compatibility while pasting from other sources.\n .attributeToAttribute({\n view: {\n name: /^(td|th)$/,\n attributes: {\n align: ALIGN_VALUES_REG_EXP\n }\n },\n model: {\n key: 'tableCellHorizontalAlignment',\n value: (viewElement, conversionApi, data) => {\n const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'left', data);\n const align = viewElement.getAttribute('align');\n if (align !== localDefaultValue) {\n return align;\n }\n // Consume the style even if not applied to the element so it won't be processed by other converters.\n conversionApi.consumable.consume(viewElement, { attributes: 'align' });\n }\n }\n });\n}\n/**\n * Enables the `'verticalAlignment'` attribute for table cells.\n *\n * @param defaultValue The default vertical alignment value.\n */\nfunction enableVerticalAlignmentProperty(schema, conversion, defaultValue) {\n schema.extend('tableCell', {\n allowAttributes: ['tableCellVerticalAlignment']\n });\n schema.setAttributeProperties('tableCellVerticalAlignment', { isFormatting: true });\n conversion.for('downcast')\n .attributeToAttribute({\n model: {\n name: 'tableCell',\n key: 'tableCellVerticalAlignment'\n },\n view: alignment => ({\n key: 'style',\n value: {\n 'vertical-align': alignment\n }\n })\n });\n conversion.for('upcast')\n // Support for the `vertical-align:*;` CSS definition for the table cell alignment.\n .attributeToAttribute({\n view: {\n name: /^(td|th)$/,\n styles: {\n 'vertical-align': VALIGN_VALUES_REG_EXP\n }\n },\n model: {\n key: 'tableCellVerticalAlignment',\n value: (viewElement, conversionApi, data) => {\n const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'middle', data);\n const align = viewElement.getStyle('vertical-align');\n if (align !== localDefaultValue) {\n return align;\n }\n // Consume the style even if not applied to the element so it won't be processed by other converters.\n conversionApi.consumable.consume(viewElement, { styles: 'vertical-align' });\n }\n }\n })\n // Support for the `align` attribute as the backward compatibility while pasting from other sources.\n .attributeToAttribute({\n view: {\n name: /^(td|th)$/,\n attributes: {\n valign: VALIGN_VALUES_REG_EXP\n }\n },\n model: {\n key: 'tableCellVerticalAlignment',\n value: (viewElement, conversionApi, data) => {\n const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'middle', data);\n const valign = viewElement.getAttribute('valign');\n if (valign !== localDefaultValue) {\n return valign;\n }\n // Consume the attribute even if not applied to the element so it won't be processed by other converters.\n conversionApi.consumable.consume(viewElement, { attributes: 'valign' });\n }\n }\n });\n}\n/**\n * Enables the `tableCellType` attribute for table cells.\n */\nfunction enableCellTypeProperty(editor) {\n const { model, conversion, editing } = editor;\n const { schema } = model;\n const tableUtils = editor.plugins.get(TableUtils);\n schema.extend('tableCell', {\n allowAttributes: ['tableCellType']\n });\n schema.setAttributeProperties('tableCellType', {\n isFormatting: true\n });\n // Do not allow setting `tableCellType` in layout tables.\n schema.addAttributeCheck(context => {\n const nearestTable = Array.from(context).reverse().find(item => item.name === 'table');\n if (nearestTable?.getAttribute('tableType') === 'layout') {\n return false;\n }\n }, 'tableCellType');\n // Upcast conversion for td/th elements.\n conversion.for('upcast').add(dispatcher => {\n dispatcher.on('element:th', (evt, data, conversionApi) => {\n const { writer } = conversionApi;\n const { modelRange } = data;\n const modelElement = modelRange?.start.nodeAfter;\n if (modelElement?.is('element', 'tableCell')) {\n writer.setAttribute('tableCellType', 'header', modelElement);\n }\n });\n // Table type is examined after all other cell converters, on low priority, so\n // we double check if there is any `th` left in the table. If so, the table is converted to a content table.\n dispatcher.on('element:table', (evt, data, conversionApi) => {\n const { writer } = conversionApi;\n const { modelRange } = data;\n const modelElement = modelRange?.start.nodeAfter;\n if (modelElement?.is('element', 'table') && modelElement.getAttribute('tableType') === 'layout') {\n for (const { cell } of new TableWalker(modelElement)) {\n if (cell.getAttribute('tableCellType') === 'header') {\n writer.setAttribute('tableType', 'content', modelElement);\n break;\n }\n }\n }\n }, { priority: priorities.low - 1 });\n });\n // Registers a post-fixer that ensures the `headingRows` and `headingColumns` attributes\n // are consistent with the `tableCellType` attribute of the cells. `tableCellType` has priority\n // over `headingRows` and `headingColumns` and we use it to adjust the heading sections of the table.\n model.document.registerPostFixer(writer => {\n // 1. Collect all tables that need to be checked.\n const changes = model.document.differ.getChanges();\n const tablesToCheck = new Set();\n for (const change of changes) {\n // Check if headingRows or headingColumns changed.\n if (change.type === 'attribute' && (change.attributeKey === 'headingRows' || change.attributeKey === 'headingColumns')) {\n const table = change.range.start.nodeAfter;\n if (table?.is('element', 'table') && table.root.rootName !== '$graveyard') {\n tablesToCheck.add(table);\n }\n }\n // Check if tableCellType changed.\n if (change.type === 'attribute' && change.attributeKey === 'tableCellType') {\n const cell = change.range.start.nodeAfter;\n if (cell?.is('element', 'tableCell') && cell.root.rootName !== '$graveyard') {\n const table = cell.findAncestor('table');\n if (table) {\n tablesToCheck.add(table);\n }\n }\n }\n // Check if new headers were inserted.\n if (change.type === 'insert' && change.position.nodeAfter) {\n for (const { item } of model.createRangeOn(change.position.nodeAfter)) {\n if (item.is('element', 'tableCell') &&\n item.getAttribute('tableCellType') &&\n item.root.rootName !== '$graveyard') {\n const table = item.findAncestor('table');\n if (table) {\n tablesToCheck.add(table);\n }\n }\n }\n }\n }\n // 2. Update the attributes of the collected tables.\n return updateTablesHeadingAttributes(tableUtils, writer, tablesToCheck);\n });\n // Refresh the table cells in the editing view when their `tableCellType` attribute changes.\n model.document.on('change:data', () => {\n const { differ } = model.document;\n const cellsToReconvert = new Set();\n for (const change of differ.getChanges()) {\n // If the `tableCellType` attribute changed, the entire cell needs to be re-rendered.\n if (change.type === 'attribute' && change.attributeKey === 'tableCellType') {\n const tableCell = change.range.start.nodeAfter;\n if (tableCell.is('element', 'tableCell')) {\n cellsToReconvert.add(tableCell);\n }\n }\n }\n // Reconvert table cells that had their `tableCellType` attribute changed.\n for (const tableCell of cellsToReconvert) {\n const viewElement = editing.mapper.toViewElement(tableCell);\n const cellType = tableCell.getAttribute('tableCellType');\n const expectedElementName = cellType === 'header' ? 'th' : 'td';\n if (viewElement?.name !== expectedElementName) {\n editing.reconvertItem(tableCell);\n }\n }\n });\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module indent/indentediting\n */\nimport { Plugin, MultiCommand } from 'ckeditor5/src/core.js';\n/**\n * The indent editing feature.\n *\n * This plugin registers the `'indent'` and `'outdent'` commands.\n *\n * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in the\n * {@link module:indent/indent~Indent indent feature} API documentation.\n */\nexport class IndentEditing extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'IndentEditing';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n editor.commands.add('indent', new MultiCommand(editor));\n editor.commands.add('outdent', new MultiCommand(editor));\n }\n}\n","export default \"\";","export default \"\";","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module indent/indentui\n */\nimport { ButtonView, MenuBarMenuListItemButtonView } from 'ckeditor5/src/ui.js';\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { IconIndent, IconOutdent } from 'ckeditor5/src/icons.js';\n/**\n * The indent UI feature.\n *\n * This plugin registers the `'indent'` and `'outdent'` buttons.\n *\n * **Note**: In order for the commands to work, at least one of the compatible features is required. Read more in\n * the {@link module:indent/indent~Indent indent feature} API documentation.\n */\nexport class IndentUI extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'IndentUI';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const locale = editor.locale;\n const t = editor.t;\n const localizedIndentIcon = locale.uiLanguageDirection == 'ltr' ? IconIndent : IconOutdent;\n const localizedOutdentIcon = locale.uiLanguageDirection == 'ltr' ? IconOutdent : IconIndent;\n this._defineButton('indent', t('Increase indent'), localizedIndentIcon);\n this._defineButton('outdent', t('Decrease indent'), localizedOutdentIcon);\n }\n /**\n * Defines UI buttons for both toolbar and menu bar.\n */\n _defineButton(commandName, label, icon) {\n const editor = this.editor;\n editor.ui.componentFactory.add(commandName, () => {\n const buttonView = this._createButton(ButtonView, commandName, label, icon);\n buttonView.set({\n tooltip: true\n });\n return buttonView;\n });\n editor.ui.componentFactory.add('menuBar:' + commandName, () => {\n return this._createButton(MenuBarMenuListItemButtonView, commandName, label, icon);\n });\n }\n /**\n * Creates a button to use either in toolbar or in menu bar.\n */\n _createButton(ButtonClass, commandName, label, icon) {\n const editor = this.editor;\n const command = editor.commands.get(commandName);\n const view = new ButtonClass(editor.locale);\n view.set({\n label,\n icon\n });\n view.bind('isEnabled').to(command, 'isEnabled');\n // Execute the command.\n this.listenTo(view, 'execute', () => {\n editor.execute(commandName);\n editor.editing.view.focus();\n });\n return view;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module indent/indentblockcommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { first } from 'ckeditor5/src/utils.js';\n/**\n * The indent block command.\n *\n * The command is registered by the {@link module:indent/indentblock~IndentBlock} as `'indentBlock'` for indenting blocks and\n * `'outdentBlock'` for outdenting blocks.\n *\n * To increase block indentation at the current selection, execute the command:\n *\n * ```ts\n * editor.execute( 'indentBlock' );\n * ```\n *\n * To decrease block indentation at the current selection, execute the command:\n *\n * ```ts\n * editor.execute( 'outdentBlock' );\n * ```\n */\nexport class IndentBlockCommand extends Command {\n /**\n * The command's indentation behavior.\n */\n _indentBehavior;\n /**\n * Creates an instance of the command.\n */\n constructor(editor, indentBehavior) {\n super(editor);\n this._indentBehavior = indentBehavior;\n }\n /**\n * @inheritDoc\n */\n refresh() {\n const editor = this.editor;\n const model = editor.model;\n const block = first(model.document.selection.getSelectedBlocks());\n if (!block || !this._isIndentationChangeAllowed(block)) {\n this.isEnabled = false;\n return;\n }\n this.isEnabled = this._indentBehavior.checkEnabled(block.getAttribute('blockIndent'));\n }\n /**\n * @inheritDoc\n */\n execute() {\n const model = this.editor.model;\n const blocksToChange = this._getBlocksToChange();\n model.change(writer => {\n for (const block of blocksToChange) {\n const currentIndent = block.getAttribute('blockIndent');\n const nextIndent = this._indentBehavior.getNextIndent(currentIndent);\n if (nextIndent) {\n writer.setAttribute('blockIndent', nextIndent, block);\n }\n else {\n writer.removeAttribute('blockIndent', block);\n }\n }\n });\n }\n /**\n * Returns blocks from selection that should have blockIndent selection set.\n */\n _getBlocksToChange() {\n const model = this.editor.model;\n const selection = model.document.selection;\n const blocksInSelection = Array.from(selection.getSelectedBlocks());\n return blocksInSelection.filter(block => this._isIndentationChangeAllowed(block));\n }\n /**\n * Returns false if indentation cannot be applied, i.e.:\n * - for blocks disallowed by schema declaration\n * - for blocks in Document Lists (disallowed forward indentation only). See https://github.com/ckeditor/ckeditor5/issues/14155.\n * Otherwise returns true.\n */\n _isIndentationChangeAllowed(element) {\n const editor = this.editor;\n if (!editor.model.schema.checkAttribute(element, 'blockIndent')) {\n return false;\n }\n if (!editor.plugins.has('ListUtils')) {\n return true;\n }\n // Only forward indentation is disallowed in list items. This allows the user to outdent blocks that are already indented.\n if (!this._indentBehavior.isForward) {\n return true;\n }\n const listUtils = editor.plugins.get('ListUtils');\n return !listUtils.isListItemBlock(element);\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * The block indentation behavior that uses offsets to set indentation.\n *\n * @internal\n */\nexport class IndentUsingOffset {\n /**\n * The direction of indentation.\n */\n isForward;\n /**\n * The offset of the next indentation step.\n */\n offset;\n /**\n * Indentation unit.\n */\n unit;\n /**\n * Creates an instance of the indentation behavior.\n *\n * @param config.direction The direction of indentation.\n * @param config.offset The offset of the next indentation step.\n * @param config.unit Indentation unit.\n */\n constructor(config) {\n this.isForward = config.direction === 'forward';\n this.offset = config.offset;\n this.unit = config.unit;\n }\n /**\n * @inheritDoc\n */\n checkEnabled(indentAttributeValue) {\n const currentOffset = parseFloat(indentAttributeValue || '0');\n // The command is always enabled for forward indentation.\n return this.isForward || currentOffset > 0;\n }\n /**\n * @inheritDoc\n */\n getNextIndent(indentAttributeValue) {\n const currentOffset = parseFloat(indentAttributeValue || '0');\n const isSameUnit = !indentAttributeValue || indentAttributeValue.endsWith(this.unit);\n if (!isSameUnit) {\n return this.isForward ? this.offset + this.unit : undefined;\n }\n const nextOffset = this.isForward ? this.offset : -this.offset;\n const offsetToSet = currentOffset + nextOffset;\n return offsetToSet > 0 ? offsetToSet + this.unit : undefined;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * The block indentation behavior that uses classes to set indentation.\n *\n * @internal\n */\nexport class IndentUsingClasses {\n /**\n * The direction of indentation.\n */\n isForward;\n /**\n * A list of classes used for indentation.\n */\n classes;\n /**\n * Creates an instance of the indentation behavior.\n *\n * @param config.direction The direction of indentation.\n * @param config.classes A list of classes used for indentation.\n */\n constructor(config) {\n this.isForward = config.direction === 'forward';\n this.classes = config.classes;\n }\n /**\n * @inheritDoc\n */\n checkEnabled(indentAttributeValue) {\n const currentIndex = this.classes.indexOf(indentAttributeValue);\n if (this.isForward) {\n return currentIndex < this.classes.length - 1;\n }\n else {\n return currentIndex >= 0;\n }\n }\n /**\n * @inheritDoc\n */\n getNextIndent(indentAttributeValue) {\n const currentIndex = this.classes.indexOf(indentAttributeValue);\n const indexStep = this.isForward ? 1 : -1;\n return this.classes[currentIndex + indexStep];\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module indent/indentblock\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { addMarginStylesRules } from 'ckeditor5/src/engine.js';\nimport { IndentBlockCommand } from './indentblockcommand.js';\nimport { IndentUsingOffset } from './indentcommandbehavior/indentusingoffset.js';\nimport { IndentUsingClasses } from './indentcommandbehavior/indentusingclasses.js';\nconst DEFAULT_ELEMENTS = ['paragraph', 'heading1', 'heading2', 'heading3', 'heading4', 'heading5', 'heading6'];\n/**\n * The block indentation feature.\n *\n * It registers the `'indentBlock'` and `'outdentBlock'` commands.\n *\n * If the plugin {@link module:indent/indent~Indent} is defined, it also attaches the `'indentBlock'` and `'outdentBlock'` commands to\n * the `'indent'` and `'outdent'` commands.\n */\nexport class IndentBlock extends Plugin {\n /**\n * @inheritDoc\n */\n constructor(editor) {\n super(editor);\n editor.config.define('indentBlock', {\n offset: 40,\n unit: 'px'\n });\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'IndentBlock';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const configuration = editor.config.get('indentBlock');\n if (configuration.classes && configuration.classes.length) {\n this._setupConversionUsingClasses(configuration.classes);\n editor.commands.add('indentBlock', new IndentBlockCommand(editor, new IndentUsingClasses({\n direction: 'forward',\n classes: configuration.classes\n })));\n editor.commands.add('outdentBlock', new IndentBlockCommand(editor, new IndentUsingClasses({\n direction: 'backward',\n classes: configuration.classes\n })));\n }\n else {\n editor.data.addStyleProcessorRules(addMarginStylesRules);\n this._setupConversionUsingOffset();\n editor.commands.add('indentBlock', new IndentBlockCommand(editor, new IndentUsingOffset({\n direction: 'forward',\n offset: configuration.offset,\n unit: configuration.unit\n })));\n editor.commands.add('outdentBlock', new IndentBlockCommand(editor, new IndentUsingOffset({\n direction: 'backward',\n offset: configuration.offset,\n unit: configuration.unit\n })));\n }\n }\n /**\n * @inheritDoc\n */\n afterInit() {\n const editor = this.editor;\n const schema = editor.model.schema;\n const indentCommand = editor.commands.get('indent');\n const outdentCommand = editor.commands.get('outdent');\n // Enable block indentation to heading configuration options. If it is not defined enable in paragraph and default headings.\n const options = editor.config.get('heading.options');\n const configuredElements = options && options.map(option => option.model);\n const knownElements = configuredElements || DEFAULT_ELEMENTS;\n knownElements.forEach(elementName => {\n if (schema.isRegistered(elementName)) {\n schema.extend(elementName, { allowAttributes: 'blockIndent' });\n }\n });\n schema.setAttributeProperties('blockIndent', { isFormatting: true });\n indentCommand.registerChildCommand(editor.commands.get('indentBlock'));\n outdentCommand.registerChildCommand(editor.commands.get('outdentBlock'));\n }\n /**\n * Setups conversion for using offset indents.\n */\n _setupConversionUsingOffset() {\n const conversion = this.editor.conversion;\n const locale = this.editor.locale;\n const marginProperty = locale.contentLanguageDirection === 'rtl' ? 'margin-right' : 'margin-left';\n conversion.for('upcast').attributeToAttribute({\n view: {\n styles: {\n [marginProperty]: /[\\s\\S]+/\n }\n },\n model: {\n key: 'blockIndent',\n value: (viewElement) => {\n // Do not indent block elements in Document Lists. See https://github.com/ckeditor/ckeditor5/issues/12466.\n if (!viewElement.is('element', 'li')) {\n return viewElement.getStyle(marginProperty);\n }\n }\n }\n });\n conversion.for('downcast').attributeToAttribute({\n model: 'blockIndent',\n view: modelAttributeValue => {\n return {\n key: 'style',\n value: {\n [marginProperty]: modelAttributeValue\n }\n };\n }\n });\n }\n /**\n * Setups conversion for using classes.\n */\n _setupConversionUsingClasses(classes) {\n const definition = {\n model: {\n key: 'blockIndent',\n values: []\n },\n view: {}\n };\n for (const className of classes) {\n definition.model.values.push(className);\n definition.view[className] = {\n key: 'class',\n value: [className]\n };\n }\n this.editor.conversion.attributeToAttribute(definition);\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module highlight/highlightcommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { ModelDocumentSelection } from 'ckeditor5/src/engine.js';\n/**\n * The highlight command. It is used by the {@link module:highlight/highlightediting~HighlightEditing highlight feature}\n * to apply the text highlighting.\n *\n * ```ts\n * editor.execute( 'highlight', { value: 'greenMarker' } );\n * ```\n *\n * **Note**: Executing the command without a value removes the attribute from the model. If the selection is collapsed\n * inside a text with the highlight attribute, the command will remove the attribute from the entire range\n * of that text.\n */\nexport class HighlightCommand extends Command {\n /**\n * @inheritDoc\n */\n refresh() {\n const model = this.editor.model;\n const doc = model.document;\n this.value = doc.selection.getAttribute('highlight');\n this.isEnabled = model.schema.checkAttributeInSelection(doc.selection, 'highlight');\n }\n /**\n * Executes the command.\n *\n * @param options Options for the executed command.\n * @param options.value The value to apply.\n *\n * @fires execute\n */\n execute(options = {}) {\n const model = this.editor.model;\n const document = model.document;\n const selection = document.selection;\n const highlighter = options.value;\n model.change(writer => {\n if (selection.isCollapsed) {\n const position = selection.getFirstPosition();\n // When selection is inside text with `highlight` attribute.\n if (selection.hasAttribute('highlight')) {\n // Find the full highlighted range.\n const isSameHighlight = (value) => {\n return value.item.hasAttribute('highlight') && value.item.getAttribute('highlight') === this.value;\n };\n const highlightStart = position.getLastMatchingPosition(isSameHighlight, { direction: 'backward' });\n const highlightEnd = position.getLastMatchingPosition(isSameHighlight);\n const highlightRange = writer.createRange(highlightStart, highlightEnd);\n // Then depending on current value...\n if (!highlighter || this.value === highlighter) {\n // ...remove attribute when passing highlighter different then current or executing \"eraser\".\n // If we're at the end of the highlighted range, we don't want to remove highlight of the range.\n if (!position.isEqual(highlightEnd)) {\n writer.removeAttribute('highlight', highlightRange);\n }\n writer.removeSelectionAttribute('highlight');\n }\n else {\n // ...update `highlight` value.\n // If we're at the end of the highlighted range, we don't want to change the highlight of the range.\n if (!position.isEqual(highlightEnd)) {\n writer.setAttribute('highlight', highlighter, highlightRange);\n }\n writer.setSelectionAttribute('highlight', highlighter);\n }\n }\n else if (highlighter) {\n writer.setSelectionAttribute('highlight', highlighter);\n }\n }\n else {\n const ranges = model.schema.getValidRanges(selection.getRanges(), 'highlight', {\n includeEmptyRanges: true\n });\n for (const range of ranges) {\n let itemOrRange = range;\n let attributeKey = 'highlight';\n if (range.isCollapsed) {\n itemOrRange = range.start.parent;\n attributeKey = ModelDocumentSelection._getStoreAttributeKey('highlight');\n }\n if (highlighter) {\n writer.setAttribute(attributeKey, highlighter, itemOrRange);\n }\n else {\n writer.removeAttribute(attributeKey, itemOrRange);\n }\n }\n }\n });\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module highlight/highlightediting\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { HighlightCommand } from './highlightcommand.js';\n/**\n * The highlight editing feature. It introduces the {@link module:highlight/highlightcommand~HighlightCommand command} and the `highlight`\n * attribute in the {@link module:engine/model/model~Model model} which renders in the {@link module:engine/view/view view}\n * as a `` element with a `class` attribute (`...`) depending\n * on the {@link module:highlight/highlightconfig~HighlightConfig configuration}.\n */\nexport class HighlightEditing extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'HighlightEditing';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n constructor(editor) {\n super(editor);\n editor.config.define('highlight', {\n options: [\n {\n model: 'yellowMarker',\n class: 'marker-yellow',\n title: 'Yellow marker',\n color: 'var(--ck-content-highlight-marker-yellow)',\n type: 'marker'\n },\n {\n model: 'greenMarker',\n class: 'marker-green',\n title: 'Green marker',\n color: 'var(--ck-content-highlight-marker-green)',\n type: 'marker'\n },\n {\n model: 'pinkMarker',\n class: 'marker-pink',\n title: 'Pink marker',\n color: 'var(--ck-content-highlight-marker-pink)',\n type: 'marker'\n },\n {\n model: 'blueMarker',\n class: 'marker-blue',\n title: 'Blue marker',\n color: 'var(--ck-content-highlight-marker-blue)',\n type: 'marker'\n },\n {\n model: 'redPen',\n class: 'pen-red',\n title: 'Red pen',\n color: 'var(--ck-content-highlight-pen-red)',\n type: 'pen'\n },\n {\n model: 'greenPen',\n class: 'pen-green',\n title: 'Green pen',\n color: 'var(--ck-content-highlight-pen-green)',\n type: 'pen'\n }\n ]\n });\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n // Allow highlight attribute on text nodes.\n editor.model.schema.extend('$text', { allowAttributes: 'highlight' });\n const options = editor.config.get('highlight.options');\n // Set-up the two-way conversion.\n editor.conversion.attributeToElement(_buildDefinition(options));\n editor.commands.add('highlight', new HighlightCommand(editor));\n }\n}\n/**\n * Converts the options array to a converter definition.\n *\n * @param options An array with configured options.\n */\nfunction _buildDefinition(options) {\n const definition = {\n model: {\n key: 'highlight',\n values: []\n },\n view: {}\n };\n for (const option of options) {\n definition.model.values.push(option.model);\n definition.view[option.model] = {\n name: 'mark',\n classes: option.class\n };\n }\n return definition;\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module highlight/highlightui\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { IconEraser, IconMarker, IconPen } from 'ckeditor5/src/icons.js';\nimport { addToolbarToDropdown, createDropdown, ButtonView, ListSeparatorView, MenuBarMenuView, MenuBarMenuListView, MenuBarMenuListItemView, MenuBarMenuListItemButtonView, SplitButtonView, ToolbarSeparatorView } from 'ckeditor5/src/ui.js';\nimport './../theme/highlight.css';\n/**\n * The default highlight UI plugin. It introduces:\n *\n * * The `'highlight'` dropdown,\n * * The `'removeHighlight'` and `'highlight:*'` buttons.\n *\n * The default configuration includes the following buttons:\n *\n * * `'highlight:yellowMarker'`\n * * `'highlight:greenMarker'`\n * * `'highlight:pinkMarker'`\n * * `'highlight:blueMarker'`\n * * `'highlight:redPen'`\n * * `'highlight:greenPen'`\n *\n * See the {@link module:highlight/highlightconfig~HighlightConfig#options configuration} to learn more\n * about the defaults.\n */\nexport class HighlightUI extends Plugin {\n /**\n * Returns the localized option titles provided by the plugin.\n *\n * The following localized titles corresponding with default\n * {@link module:highlight/highlightconfig~HighlightConfig#options} are available:\n *\n * * `'Yellow marker'`,\n * * `'Green marker'`,\n * * `'Pink marker'`,\n * * `'Blue marker'`,\n * * `'Red pen'`,\n * * `'Green pen'`.\n */\n get localizedOptionTitles() {\n const t = this.editor.t;\n return {\n 'Yellow marker': t('Yellow marker'),\n 'Green marker': t('Green marker'),\n 'Pink marker': t('Pink marker'),\n 'Blue marker': t('Blue marker'),\n 'Red pen': t('Red pen'),\n 'Green pen': t('Green pen')\n };\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'HighlightUI';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const options = this.editor.config.get('highlight.options');\n for (const option of options) {\n this._addHighlighterButton(option);\n }\n this._addRemoveHighlightButton();\n this._addDropdown(options);\n this._addMenuBarButton(options);\n }\n /**\n * Creates the \"Remove highlight\" button.\n */\n _addRemoveHighlightButton() {\n const t = this.editor.t;\n const command = this.editor.commands.get('highlight');\n this._addButton('removeHighlight', t('Remove highlight'), IconEraser, null, button => {\n button.bind('isEnabled').to(command, 'isEnabled');\n });\n }\n /**\n * Creates a toolbar button from the provided highlight option.\n */\n _addHighlighterButton(option) {\n const command = this.editor.commands.get('highlight');\n // TODO: change naming\n this._addButton('highlight:' + option.model, option.title, getIconForType(option.type), option.model, decorateHighlightButton);\n function decorateHighlightButton(button) {\n button.bind('isEnabled').to(command, 'isEnabled');\n button.bind('isOn').to(command, 'value', value => value === option.model);\n button.iconView.fillColor = option.color;\n button.isToggleable = true;\n }\n }\n /**\n * Internal method for creating highlight buttons.\n *\n * @param name The name of the button.\n * @param label The label for the button.\n * @param icon The button icon.\n * @param value The `value` property passed to the executed command.\n * @param decorateButton A callback getting ButtonView instance so that it can be further customized.\n */\n _addButton(name, label, icon, value, decorateButton) {\n const editor = this.editor;\n editor.ui.componentFactory.add(name, locale => {\n const buttonView = new ButtonView(locale);\n const localized = this.localizedOptionTitles[label] ? this.localizedOptionTitles[label] : label;\n buttonView.set({\n label: localized,\n icon,\n tooltip: true\n });\n buttonView.on('execute', () => {\n editor.execute('highlight', { value });\n editor.editing.view.focus();\n });\n // Add additional behavior for buttonView.\n decorateButton(buttonView);\n return buttonView;\n });\n }\n /**\n * Creates the split button dropdown UI from the provided highlight options.\n */\n _addDropdown(options) {\n const editor = this.editor;\n const t = editor.t;\n const componentFactory = editor.ui.componentFactory;\n const startingHighlighter = options[0];\n const optionsMap = options.reduce((retVal, option) => {\n retVal[option.model] = option;\n return retVal;\n }, {});\n componentFactory.add('highlight', locale => {\n const command = editor.commands.get('highlight');\n const dropdownView = createDropdown(locale, SplitButtonView);\n const splitButtonView = dropdownView.buttonView;\n splitButtonView.set({\n label: t('Highlight'),\n tooltip: true,\n // Holds last executed highlighter.\n lastExecuted: startingHighlighter.model,\n // Holds current highlighter to execute (might be different then last used).\n commandValue: startingHighlighter.model,\n isToggleable: true\n });\n // Dropdown button changes to selection (command.value):\n // - If selection is in highlight it get active highlight appearance (icon, color) and is activated.\n // - Otherwise it gets appearance (icon, color) of last executed highlight.\n splitButtonView.bind('icon').to(command, 'value', value => getIconForType(getActiveOption(value, 'type')));\n splitButtonView.bind('color').to(command, 'value', value => getActiveOption(value, 'color'));\n splitButtonView.bind('commandValue').to(command, 'value', value => getActiveOption(value, 'model'));\n splitButtonView.bind('isOn').to(command, 'value', value => !!value);\n splitButtonView.delegate('execute').to(dropdownView);\n // Create buttons array.\n const buttonsCreator = () => {\n const buttons = options.map(option => {\n // Get existing highlighter button.\n const buttonView = componentFactory.create('highlight:' + option.model);\n // Update lastExecutedHighlight on execute.\n this.listenTo(buttonView, 'execute', () => {\n dropdownView.buttonView.set({ lastExecuted: option.model });\n });\n return buttonView;\n });\n // Add separator and eraser buttons to dropdown.\n buttons.push(new ToolbarSeparatorView());\n buttons.push(componentFactory.create('removeHighlight'));\n return buttons;\n };\n // Make toolbar button enabled when any button in dropdown is enabled before adding separator and eraser.\n dropdownView.bind('isEnabled').to(command, 'isEnabled');\n addToolbarToDropdown(dropdownView, buttonsCreator, {\n enableActiveItemFocusOnDropdownOpen: true,\n ariaLabel: t('Text highlight toolbar')\n });\n bindToolbarIconStyleToActiveColor(dropdownView);\n // Execute current action from dropdown's split button action button.\n splitButtonView.on('execute', () => {\n editor.execute('highlight', { value: splitButtonView.commandValue });\n });\n // Focus the editable after executing the command.\n // It overrides a default behaviour where the focus is moved to the dropdown button (#12125).\n this.listenTo(dropdownView, 'execute', () => {\n editor.editing.view.focus();\n });\n /**\n * Returns active highlighter option depending on current command value.\n * If current is not set or it is the same as last execute this method will return the option key (like icon or color)\n * of last executed highlighter. Otherwise it will return option key for current one.\n */\n function getActiveOption(current, key) {\n const whichHighlighter = !current ||\n current === splitButtonView.lastExecuted ? splitButtonView.lastExecuted : current;\n return optionsMap[whichHighlighter][key];\n }\n return dropdownView;\n });\n }\n /**\n * Creates the menu bar button for highlight including submenu with available options.\n */\n _addMenuBarButton(options) {\n const editor = this.editor;\n const t = editor.t;\n const command = editor.commands.get('highlight');\n editor.ui.componentFactory.add('menuBar:highlight', locale => {\n const menuView = new MenuBarMenuView(locale);\n menuView.buttonView.set({\n label: t('Highlight'),\n icon: getIconForType('marker')\n });\n menuView.bind('isEnabled').to(command);\n menuView.buttonView.iconView.fillColor = 'transparent';\n const listView = new MenuBarMenuListView(locale);\n for (const option of options) {\n const listItemView = new MenuBarMenuListItemView(locale, menuView);\n const buttonView = new MenuBarMenuListItemButtonView(locale);\n buttonView.set({\n label: option.title,\n icon: getIconForType(option.type),\n role: 'menuitemradio',\n isToggleable: true\n });\n buttonView.iconView.fillColor = option.color;\n buttonView.delegate('execute').to(menuView);\n buttonView.bind('isOn').to(command, 'value', value => value === option.model);\n buttonView.on('execute', () => {\n editor.execute('highlight', { value: option.model });\n editor.editing.view.focus();\n });\n listItemView.children.add(buttonView);\n listView.items.add(listItemView);\n }\n // Add remove highlight button\n listView.items.add(new ListSeparatorView(locale));\n const listItemView = new MenuBarMenuListItemView(locale, menuView);\n const buttonView = new MenuBarMenuListItemButtonView(locale);\n buttonView.set({\n label: t('Remove highlight'),\n icon: IconEraser\n });\n buttonView.delegate('execute').to(menuView);\n buttonView.on('execute', () => {\n editor.execute('highlight', { value: null });\n editor.editing.view.focus();\n });\n listItemView.children.add(buttonView);\n listView.items.add(listItemView);\n menuView.panelView.children.add(listView);\n return menuView;\n });\n }\n}\n/**\n * Extends split button icon style to reflect last used button style.\n */\nfunction bindToolbarIconStyleToActiveColor(dropdownView) {\n const actionView = dropdownView.buttonView.actionView;\n actionView.iconView.bind('fillColor').to(dropdownView.buttonView, 'color');\n}\n/**\n * Returns icon for given highlighter type.\n */\nfunction getIconForType(type) {\n return type === 'marker' ? IconMarker : IconPen;\n}\n","export default \"\";","export default \"\";","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module list/todolist/checktodolistcommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { getAllListItemBlocks } from '../list/utils/model.js';\n/**\n * The check to-do command.\n *\n * The command is registered by the {@link module:list/todolist/todolistediting~TodoListEditing} as\n * the `checkTodoList` editor command.\n */\nexport class CheckTodoListCommand extends Command {\n /**\n * @inheritDoc\n */\n constructor(editor) {\n super(editor);\n // Refresh command before executing to be sure all values are up to date.\n // It is needed when selection has changed before command execution, in the same change block.\n this.on('execute', () => {\n this.refresh();\n }, { priority: 'highest' });\n }\n /**\n * Updates the command's {@link #value} and {@link #isEnabled} properties based on the current selection.\n */\n refresh() {\n const selectedElements = this._getSelectedItems();\n this.value = this._getValue(selectedElements);\n this.isEnabled = !!selectedElements.length;\n }\n /**\n * Executes the command.\n *\n * @param options.forceValue If set, it will force the command behavior. If `true`, the command will apply\n * the attribute. Otherwise, the command will remove the attribute. If not set, the command will look for its current\n * value to decide what it should do.\n */\n execute(options = {}) {\n this.editor.model.change(writer => {\n const selectedElements = this._getSelectedItems();\n const value = (options.forceValue === undefined) ? !this._getValue(selectedElements) : options.forceValue;\n for (const element of selectedElements) {\n if (value) {\n writer.setAttribute('todoListChecked', true, element);\n }\n else {\n writer.removeAttribute('todoListChecked', element);\n }\n }\n });\n }\n /**\n * Returns a value for the command.\n */\n _getValue(selectedElements) {\n return selectedElements.every(element => element.getAttribute('todoListChecked'));\n }\n /**\n * Gets all to-do list items selected by the {@link module:engine/model/selection~ModelSelection}.\n */\n _getSelectedItems() {\n const model = this.editor.model;\n const schema = model.schema;\n const selectionRange = model.document.selection.getFirstRange();\n const startElement = selectionRange.start.parent;\n const elements = [];\n if (schema.checkAttribute(startElement, 'todoListChecked')) {\n elements.push(...getAllListItemBlocks(startElement));\n }\n for (const item of selectionRange.getItems({ shallow: true })) {\n if (schema.checkAttribute(item, 'todoListChecked') && !elements.includes(item)) {\n elements.push(...getAllListItemBlocks(item));\n }\n }\n return elements;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module list/todolist/todocheckboxchangeobserver\n */\nimport { DomEventObserver } from 'ckeditor5/src/engine.js';\n/**\n * Observes all to-do list checkboxes state changes.\n *\n * Note that this observer is not available by default. To make it available it needs to be added to\n * {@link module:engine/view/view~EditingView} by {@link module:engine/view/view~EditingView#addObserver} method.\n *\n * @internal\n */\nexport class TodoCheckboxChangeObserver extends DomEventObserver {\n /**\n * @inheritDoc\n */\n domEventType = ['change'];\n /**\n * @inheritDoc\n */\n onDomEvent(domEvent) {\n if (domEvent.target) {\n const viewTarget = this.view.domConverter.mapDomToView(domEvent.target);\n if (viewTarget &&\n viewTarget.is('element', 'input') &&\n viewTarget.getAttribute('type') == 'checkbox' &&\n viewTarget.findAncestor({ classes: 'todo-list__label' })) {\n this.fire('todoCheckboxChange', domEvent);\n }\n }\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module list/todolist/todolistediting\n */\nimport { Matcher } from 'ckeditor5/src/engine.js';\nimport { getCode, parseKeystroke, getLocalizedArrowKeyCodeDirection } from 'ckeditor5/src/utils.js';\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { getAllListItemBlocks, isFirstBlockOfListItem, isListItemBlock } from '../list/utils/model.js';\nimport { ListEditing } from '../list/listediting.js';\nimport { ListCommand } from '../list/listcommand.js';\nimport { CheckTodoListCommand } from './checktodolistcommand.js';\nimport { TodoCheckboxChangeObserver } from './todocheckboxchangeobserver.js';\nconst ITEM_TOGGLE_KEYSTROKE = /* #__PURE__ */ parseKeystroke('Ctrl+Enter');\n/**\n * The engine of the to-do list feature. It handles creating, editing and removing to-do lists and their items.\n *\n * It registers the entire functionality of the {@link module:list/list/listediting~ListEditing list editing plugin}\n * and extends it with the commands:\n *\n * - `'todoList'`,\n * - `'checkTodoList'`,\n */\nexport class TodoListEditing extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TodoListEditing';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get requires() {\n return [ListEditing];\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const model = editor.model;\n const editing = editor.editing;\n const listEditing = editor.plugins.get(ListEditing);\n const multiBlock = editor.config.get('list.multiBlock');\n const elementName = multiBlock ? 'paragraph' : 'listItem';\n editor.commands.add('todoList', new ListCommand(editor, 'todo'));\n editor.commands.add('checkTodoList', new CheckTodoListCommand(editor));\n editing.view.addObserver(TodoCheckboxChangeObserver);\n model.schema.extend('$listItem', { allowAttributes: 'todoListChecked' });\n model.schema.addAttributeCheck(context => {\n const item = context.last;\n // Don't allow `todoListChecked` attribute on elements which are not todo list items.\n if (!item.getAttribute('listItemId') || item.getAttribute('listType') != 'todo') {\n return false;\n }\n }, 'todoListChecked');\n editor.conversion.for('upcast').add(dispatcher => {\n // Upcast of to-do list item is based on a checkbox at the beginning of a
  • to keep compatibility with markdown input.\n dispatcher.on('element:input', todoItemInputConverter());\n // Priority is set to low to allow generic list item converter to run first.\n dispatcher.on('element:li', todoListItemUpcastConverter(), {\n priority: 'low'\n });\n // Consume other elements that are normally generated in data downcast, so they won't get captured by GHS.\n dispatcher.on('element:label', elementUpcastConsumingConverter({ name: 'label', classes: 'todo-list__label' }));\n dispatcher.on('element:label', elementUpcastConsumingConverter({ name: 'label', classes: ['todo-list__label', 'todo-list__label_without-description'] }));\n dispatcher.on('element:span', elementUpcastConsumingConverter({ name: 'span', classes: 'todo-list__label__description' }));\n dispatcher.on('element:ul', attributeUpcastConsumingConverter({ name: 'ul', classes: 'todo-list' }));\n });\n editor.conversion.for('downcast').elementToElement({\n model: elementName,\n view: (element, { writer }) => {\n if (isDescriptionBlock(element, listEditing.getListAttributeNames())) {\n return writer.createContainerElement('span', { class: 'todo-list__label__description' });\n }\n },\n converterPriority: 'highest'\n });\n listEditing.registerDowncastStrategy({\n scope: 'list',\n attributeName: 'listType',\n setAttributeOnDowncast(writer, value, element) {\n if (value == 'todo') {\n writer.addClass('todo-list', element);\n }\n else {\n writer.removeClass('todo-list', element);\n }\n }\n });\n listEditing.registerDowncastStrategy({\n scope: 'itemMarker',\n attributeName: 'todoListChecked',\n createElement(writer, modelElement, { dataPipeline }) {\n if (modelElement.getAttribute('listType') != 'todo') {\n return null;\n }\n const viewElement = writer.createUIElement('input', {\n type: 'checkbox',\n ...(modelElement.getAttribute('todoListChecked') ?\n { checked: 'checked' } :\n null),\n ...(dataPipeline ?\n { disabled: 'disabled' } :\n { tabindex: '-1' })\n });\n if (dataPipeline) {\n return viewElement;\n }\n const wrapper = writer.createContainerElement('span', { contenteditable: 'false' }, viewElement);\n wrapper.getFillerOffset = () => null;\n return wrapper;\n },\n canWrapElement(modelElement) {\n return isDescriptionBlock(modelElement, listEditing.getListAttributeNames());\n },\n createWrapperElement(writer, modelElement, { dataPipeline }) {\n const classes = ['todo-list__label'];\n if (!isDescriptionBlock(modelElement, listEditing.getListAttributeNames())) {\n classes.push('todo-list__label_without-description');\n }\n return writer.createAttributeElement(dataPipeline ? 'label' : 'span', {\n class: classes.join(' ')\n });\n }\n });\n // Verifies if a to-do list block requires reconversion of a first item downcasted as an item description.\n listEditing.on('checkElement', (evt, { modelElement, viewElement }) => {\n const isFirstTodoModelParagraphBlock = isDescriptionBlock(modelElement, listEditing.getListAttributeNames());\n const hasViewClass = viewElement.hasClass('todo-list__label__description');\n if (hasViewClass != isFirstTodoModelParagraphBlock) {\n evt.return = true;\n evt.stop();\n }\n });\n // Verifies if a to-do list block requires reconversion of a checkbox element\n // (for example there is a new paragraph inserted as a first block of a list item).\n listEditing.on('checkElement', (evt, { modelElement, viewElement }) => {\n const isFirstTodoModelItemBlock = modelElement.getAttribute('listType') == 'todo' && isFirstBlockOfListItem(modelElement);\n let hasViewItemMarker = false;\n const viewWalker = editor.editing.view.createPositionBefore(viewElement).getWalker({ direction: 'backward' });\n for (const { item } of viewWalker) {\n if (item.is('element') && editor.editing.mapper.toModelElement(item)) {\n break;\n }\n if (item.is('element', 'input') && item.getAttribute('type') == 'checkbox') {\n hasViewItemMarker = true;\n }\n }\n if (hasViewItemMarker != isFirstTodoModelItemBlock) {\n evt.return = true;\n evt.stop();\n }\n });\n // Make sure that all blocks of the same list item have the same todoListChecked attribute.\n listEditing.on('postFixer', (evt, { listNodes, writer }) => {\n for (const { node, previousNodeInList } of listNodes) {\n // This is a first item of a nested list.\n if (!previousNodeInList) {\n continue;\n }\n if (previousNodeInList.getAttribute('listItemId') != node.getAttribute('listItemId')) {\n continue;\n }\n const previousHasAttribute = previousNodeInList.hasAttribute('todoListChecked');\n const nodeHasAttribute = node.hasAttribute('todoListChecked');\n if (nodeHasAttribute && !previousHasAttribute) {\n writer.removeAttribute('todoListChecked', node);\n evt.return = true;\n }\n else if (!nodeHasAttribute && previousHasAttribute) {\n writer.setAttribute('todoListChecked', true, node);\n evt.return = true;\n }\n }\n });\n // Make sure that todoListChecked attribute is only present for to-do list items.\n model.document.registerPostFixer(writer => {\n const changes = model.document.differ.getChanges();\n let wasFixed = false;\n for (const change of changes) {\n if (change.type == 'attribute' && change.attributeKey == 'listType') {\n const element = change.range.start.nodeAfter;\n if (change.attributeOldValue == 'todo' && element.hasAttribute('todoListChecked')) {\n writer.removeAttribute('todoListChecked', element);\n wasFixed = true;\n }\n }\n else if (change.type == 'insert' && change.name != '$text') {\n for (const { item } of writer.createRangeOn(change.position.nodeAfter)) {\n if (item.is('element') && item.getAttribute('listType') != 'todo' && item.hasAttribute('todoListChecked')) {\n writer.removeAttribute('todoListChecked', item);\n wasFixed = true;\n }\n }\n }\n }\n return wasFixed;\n });\n // Toggle check state of selected to-do list items on keystroke.\n this.listenTo(editing.view.document, 'keydown', (evt, data) => {\n if (getCode(data) === ITEM_TOGGLE_KEYSTROKE) {\n editor.execute('checkTodoList');\n evt.stop();\n }\n }, { priority: 'high' });\n // Toggle check state of a to-do list item clicked on the checkbox.\n this.listenTo(editing.view.document, 'todoCheckboxChange', (evt, data) => {\n const viewTarget = data.target;\n if (!viewTarget || !viewTarget.is('element', 'input')) {\n return;\n }\n const viewPositionAfter = editing.view.createPositionAfter(viewTarget);\n const modelPositionAfter = editing.mapper.toModelPosition(viewPositionAfter);\n const modelElement = modelPositionAfter.parent;\n if (modelElement && isListItemBlock(modelElement) && modelElement.getAttribute('listType') == 'todo') {\n this._handleCheckmarkChange(modelElement);\n }\n });\n // Jump at the start/end of the next node on right arrow key press, when selection is before the checkbox.\n //\n //

    Foo{}

    \n //
    • Bar
    \n //\n // press: `->`\n //\n //

    Foo

    \n //
    • {}Bar
    \n //\n this.listenTo(editing.view.document, 'arrowKey', jumpOverCheckmarkOnSideArrowKeyPress(model, editor.locale), { context: '$text' });\n // Map view positions inside the checkbox and wrappers to the position in the first block of the list item.\n this.listenTo(editing.mapper, 'viewToModelPosition', (evt, data) => {\n const viewParent = data.viewPosition.parent;\n const isStartOfListItem = viewParent.is('attributeElement', 'li') && data.viewPosition.offset == 0;\n const isStartOfListLabel = isLabelElement(viewParent) && data.viewPosition.offset <= 1;\n const isInInputWrapper = viewParent.is('element', 'span') &&\n viewParent.getAttribute('contenteditable') == 'false' &&\n isLabelElement(viewParent.parent);\n if (!isStartOfListItem && !isStartOfListLabel && !isInInputWrapper) {\n return;\n }\n const nodeAfter = data.modelPosition.nodeAfter;\n if (nodeAfter && nodeAfter.getAttribute('listType') == 'todo') {\n data.modelPosition = model.createPositionAt(nodeAfter, 0);\n }\n }, { priority: 'low' });\n this._initAriaAnnouncements();\n }\n /**\n * Handles the checkbox element change, moves the selection to the corresponding model item to make it possible\n * to toggle the `todoListChecked` attribute using the command, and restores the selection position.\n *\n * Some say it's a hack :) Moving the selection only for executing the command on a certain node and restoring it after,\n * is not a clear solution. We need to design an API for using commands beyond the selection range.\n * See https://github.com/ckeditor/ckeditor5/issues/1954.\n */\n _handleCheckmarkChange(listItem) {\n const editor = this.editor;\n const model = editor.model;\n const previousSelectionRanges = Array.from(model.document.selection.getRanges());\n model.change(writer => {\n writer.setSelection(listItem, 'end');\n editor.execute('checkTodoList');\n writer.setSelection(previousSelectionRanges);\n });\n }\n /**\n * Observe when user enters or leaves todo list and set proper aria value in global live announcer.\n * This allows screen readers to indicate when the user has entered and left the specified todo list.\n *\n * @internal\n */\n _initAriaAnnouncements() {\n const { model, ui, t } = this.editor;\n let lastFocusedCodeBlock = null;\n if (!ui) {\n return;\n }\n model.document.selection.on('change:range', () => {\n const focusParent = model.document.selection.focus.parent;\n const lastElementIsTodoList = isTodoListItemElement(lastFocusedCodeBlock);\n const currentElementIsTodoList = isTodoListItemElement(focusParent);\n if (lastElementIsTodoList && !currentElementIsTodoList) {\n ui.ariaLiveAnnouncer.announce(t('Leaving a to-do list'));\n }\n else if (!lastElementIsTodoList && currentElementIsTodoList) {\n ui.ariaLiveAnnouncer.announce(t('Entering a to-do list'));\n }\n lastFocusedCodeBlock = focusParent;\n });\n }\n}\n/**\n * Returns an upcast converter for to-do list items.\n */\nfunction todoListItemUpcastConverter() {\n return (evt, data, conversionApi) => {\n const { writer, schema } = conversionApi;\n if (!data.modelRange) {\n return;\n }\n // Group to-do list items by their listItemId attribute to ensure that all items of the same list item have the same checked state.\n const groupedItems = Array\n .from(data.modelRange.getItems({ shallow: true }))\n .filter((item) => item.getAttribute('listType') === 'todo' && schema.checkAttribute(item, 'listItemId'))\n .reduce((acc, item) => {\n const listItemId = item.getAttribute('listItemId');\n if (!acc.has(listItemId)) {\n acc.set(listItemId, getAllListItemBlocks(item));\n }\n return acc;\n }, new Map());\n // During the upcast, we need to ensure that all items of the same list have the same checked state. From time to time\n // the checked state of the items can be different when the user pastes content from the clipboard with \n // that has checked state set to true. In such cases, we need to ensure that all items of the same list have the same checked state.\n // See more: https://github.com/ckeditor/ckeditor5/issues/15602\n for (const [, items] of groupedItems.entries()) {\n if (items.some(item => item.getAttribute('todoListChecked'))) {\n for (const item of items) {\n writer.setAttribute('todoListChecked', true, item);\n }\n }\n }\n };\n}\n/**\n * Returns an upcast converter that detects a to-do list checkbox and marks the list item as a to-do list.\n */\nfunction todoItemInputConverter() {\n return (evt, data, conversionApi) => {\n const modelCursor = data.modelCursor;\n const modelItem = modelCursor.parent;\n const viewItem = data.viewItem;\n if (!conversionApi.consumable.test(viewItem, { name: true })) {\n return;\n }\n if (viewItem.getAttribute('type') != 'checkbox' || !modelCursor.isAtStart || !modelItem.hasAttribute('listType')) {\n return;\n }\n conversionApi.consumable.consume(viewItem, { name: true });\n const writer = conversionApi.writer;\n writer.setAttribute('listType', 'todo', modelItem);\n if (data.viewItem.hasAttribute('checked')) {\n writer.setAttribute('todoListChecked', true, modelItem);\n }\n data.modelRange = writer.createRange(modelCursor);\n };\n}\n/**\n * Returns an upcast converter that consumes element matching the given matcher pattern.\n */\nfunction elementUpcastConsumingConverter(matcherPattern) {\n const matcher = new Matcher(matcherPattern);\n return (evt, data, conversionApi) => {\n const matcherResult = matcher.match(data.viewItem);\n if (!matcherResult) {\n return;\n }\n if (!conversionApi.consumable.consume(data.viewItem, matcherResult.match)) {\n return;\n }\n Object.assign(data, conversionApi.convertChildren(data.viewItem, data.modelCursor));\n };\n}\n/**\n * Returns an upcast converter that consumes attributes matching the given matcher pattern.\n */\nfunction attributeUpcastConsumingConverter(matcherPattern) {\n const matcher = new Matcher(matcherPattern);\n return (evt, data, conversionApi) => {\n const matcherResult = matcher.match(data.viewItem);\n if (!matcherResult) {\n return;\n }\n const match = matcherResult.match;\n match.name = false;\n conversionApi.consumable.consume(data.viewItem, match);\n };\n}\n/**\n * Returns true if the given list item block should be converted as a description block of a to-do list item.\n */\nfunction isDescriptionBlock(modelElement, listAttributeNames) {\n return (modelElement.is('element', 'paragraph') || modelElement.is('element', 'listItem')) &&\n modelElement.getAttribute('listType') == 'todo' &&\n isFirstBlockOfListItem(modelElement) &&\n hasOnlyListAttributes(modelElement, listAttributeNames);\n}\n/**\n * Returns true if only attributes from the given list are present on the model element.\n */\nfunction hasOnlyListAttributes(modelElement, attributeNames) {\n for (const attributeKey of modelElement.getAttributeKeys()) {\n // Ignore selection attributes stored on block elements.\n if (attributeKey.startsWith('selection:')) {\n continue;\n }\n if (!attributeNames.includes(attributeKey)) {\n return false;\n }\n }\n return true;\n}\n/**\n * Jump at the start and end of a to-do list item.\n */\nfunction jumpOverCheckmarkOnSideArrowKeyPress(model, locale) {\n return (eventInfo, domEventData) => {\n const direction = getLocalizedArrowKeyCodeDirection(domEventData.keyCode, locale.contentLanguageDirection);\n const schema = model.schema;\n const selection = model.document.selection;\n if (!selection.isCollapsed) {\n return;\n }\n const position = selection.getFirstPosition();\n const parent = position.parent;\n // Right arrow before a to-do list item.\n if (direction == 'right' && position.isAtEnd) {\n const newRange = schema.getNearestSelectionRange(model.createPositionAfter(parent), 'forward');\n if (!newRange) {\n return;\n }\n const newRangeParent = newRange.start.parent;\n if (newRangeParent && isListItemBlock(newRangeParent) && newRangeParent.getAttribute('listType') == 'todo') {\n model.change(writer => writer.setSelection(newRange));\n domEventData.preventDefault();\n domEventData.stopPropagation();\n eventInfo.stop();\n }\n }\n // Left arrow at the beginning of a to-do list item.\n else if (direction == 'left' && position.isAtStart && isListItemBlock(parent) && parent.getAttribute('listType') == 'todo') {\n const newRange = schema.getNearestSelectionRange(model.createPositionBefore(parent), 'backward');\n if (!newRange) {\n return;\n }\n model.change(writer => writer.setSelection(newRange));\n domEventData.preventDefault();\n domEventData.stopPropagation();\n eventInfo.stop();\n }\n };\n}\n/**\n * Returns true if the given element is a label element of a to-do list item.\n */\nfunction isLabelElement(viewElement) {\n return !!viewElement && viewElement.is('attributeElement') && viewElement.hasClass('todo-list__label');\n}\n/**\n * Returns true if the given element is a list item model element of a to-do list.\n */\nfunction isTodoListItemElement(element) {\n if (!element) {\n return false;\n }\n if (!element.is('element', 'paragraph') && !element.is('element', 'listItem')) {\n return false;\n }\n return element.getAttribute('listType') == 'todo';\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module list/todolist/todolistui\n */\nimport { createUIComponents } from '../list/utils.js';\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { IconTodoList } from 'ckeditor5/src/icons.js';\n/**\n * The to-do list UI feature. It introduces the `'todoList'` button that\n * allows to convert elements to and from to-do list items and to indent or outdent them.\n */\nexport class TodoListUI extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TodoListUI';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const t = this.editor.t;\n createUIComponents(this.editor, 'todoList', t('To-do List'), IconTodoList);\n }\n}\n","export default \"\";","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { first } from 'ckeditor5/src/utils.js';\n/**\n * Returns code block languages as defined in `config.codeBlock.languages` but processed:\n *\n * * To consider the editor localization, i.e. to display {@link module:code-block/codeblockconfig~CodeBlockLanguageDefinition}\n * in the correct language. There is no way to use {@link module:utils/locale~Locale#t} when the user\n * configuration is defined because the editor does not exist yet.\n * * To make sure each definition has a CSS class associated with it even if not specified\n * in the original configuration.\n *\n * @internal\n */\nexport function getNormalizedAndLocalizedLanguageDefinitions(editor) {\n const t = editor.t;\n const languageDefs = editor.config.get('codeBlock.languages');\n for (const def of languageDefs) {\n if (def.label === 'Plain text') {\n def.label = t('Plain text');\n }\n if (def.class === undefined) {\n def.class = `language-${def.language}`;\n }\n }\n return languageDefs;\n}\n/**\n * Returns an object associating certain language definition properties with others. For instance:\n *\n * For:\n *\n * ```ts\n * const definitions = {\n * \t{ language: 'php', class: 'language-php', label: 'PHP' },\n * \t{ language: 'javascript', class: 'js', label: 'JavaScript' },\n * };\n *\n * getPropertyAssociation( definitions, 'class', 'language' );\n * ```\n *\n * returns:\n *\n * ```ts\n * {\n * \t'language-php': 'php',\n * \t'js': 'javascript'\n * }\n * ```\n *\n * and\n *\n * ```ts\n * getPropertyAssociation( definitions, 'language', 'label' );\n * ```\n *\n * returns:\n *\n * ```ts\n * {\n * \t'php': 'PHP',\n * \t'javascript': 'JavaScript'\n * }\n * ```\n *\n * @internal\n */\nexport function getPropertyAssociation(languageDefs, key, value) {\n const association = {};\n for (const def of languageDefs) {\n if (key === 'class') {\n // Only the first class is considered.\n const newKey = (def[key]).split(' ').shift();\n association[newKey] = def[value];\n }\n else {\n association[def[key]] = def[value];\n }\n }\n return association;\n}\n/**\n * For a given model text node, it returns white spaces that precede other characters in that node.\n * This corresponds to the indentation part of the code block line.\n *\n * @internal\n */\nexport function getLeadingWhiteSpaces(textNode) {\n return textNode.data.match(/^(\\s*)/)[0];\n}\n/**\n * For plain text containing the code (a snippet), it returns a document fragment containing\n * view text nodes separated by `
    ` elements (in place of new line characters \"\\n\"), for instance:\n *\n * Input:\n *\n * ```ts\n * \"foo()\\n\n * bar()\"\n * ```\n *\n * Output:\n *\n * ```html\n * \n * \t\"foo()\"\n * \t
    \n * \t\"bar()\"\n *
    \n * ```\n *\n * @param text The raw code text to be converted.\n * @internal\n */\nexport function rawSnippetTextToViewDocumentFragment(writer, text) {\n const fragment = writer.createDocumentFragment();\n const textLines = text.split('\\n');\n const items = textLines.reduce((nodes, line, lineIndex) => {\n nodes.push(line);\n if (lineIndex < textLines.length - 1) {\n nodes.push(writer.createElement('br'));\n }\n return nodes;\n }, []);\n writer.appendChild(items, fragment);\n return fragment;\n}\n/**\n * Returns an array of all model positions within the selection that represent code block lines.\n *\n * If the selection is collapsed, it returns the exact selection anchor position:\n *\n * ```html\n * []foo -> ^foo\n * foo[]bar -> foo^bar\n * ```\n *\n * Otherwise, it returns positions **before** each text node belonging to all code blocks contained by the selection:\n *\n * ```html\n * \n * foo[bar ^foobar\n * -> \n * baz]qux ^bazqux\n * \n * ```\n *\n * It also works across other non–code blocks:\n *\n * ```html\n * \n * foo[bar ^foobar\n * \n * text -> text\n * \n * baz]qux ^bazqux\n * \n * ```\n *\n * **Note:** The positions are in reverse order so they do not get outdated when iterating over them and\n * the writer inserts or removes elements at the same time.\n *\n * **Note:** The position is located after the leading white spaces in the text node.\n *\n * @internal\n */\nexport function getIndentOutdentPositions(model) {\n const selection = model.document.selection;\n const positions = [];\n // When the selection is collapsed, there's only one position we can indent or outdent.\n if (selection.isCollapsed) {\n return [selection.anchor];\n }\n // When the selection is NOT collapsed, collect all positions starting before text nodes\n // (code lines) in any within the selection.\n // Walk backward so positions we are about to collect here do not get outdated when\n // inserting or deleting using the writer.\n const walker = selection.getFirstRange().getWalker({\n ignoreElementEnd: true,\n direction: 'backward'\n });\n for (const { item } of walker) {\n let node = item.is('$textProxy') ? item.textNode : item;\n const parent = node.parent;\n if (!parent.is('element', 'codeBlock') || node.is('element', 'softBreak')) {\n continue;\n }\n // For each item in code block, move backwards until the beginning of the line it is in is found.\n while (node.previousSibling && !node.previousSibling.is('element', 'softBreak')) {\n node = node.previousSibling;\n }\n // Take the leading white spaces into account (only for text nodes).\n const startOffset = !node.is('$text') ? node.startOffset : node.startOffset + getLeadingWhiteSpaces(node).length;\n const position = model.createPositionAt(parent, startOffset);\n // Do not add the same position twice. Unfortunately using set doesn't deduplicate positions because\n // they are different objects.\n if (positions.every(pos => !pos.isEqual(position))) {\n positions.push(position);\n }\n }\n return positions;\n}\n/**\n * Checks if any of the blocks within the model selection is a code block.\n *\n * @internal\n */\nexport function isModelSelectionInCodeBlock(selection) {\n const firstBlock = first(selection.getSelectedBlocks());\n return !!firstBlock && firstBlock.is('element', 'codeBlock');\n}\n/**\n * Checks if an {@link module:engine/model/element~ModelElement Element} can become a code block.\n *\n * @param schema Model's schema.\n * @param element The element to be checked.\n * @returns Check result.\n * @internal\n */\nexport function canBeCodeBlock(schema, element) {\n if (element.is('rootElement') || schema.isLimit(element)) {\n return false;\n }\n return schema.checkChild(element.parent, 'codeBlock');\n}\n/**\n * Get the translated message read by the screen reader when you enter or exit an element with your cursor.\n *\n * @internal\n */\nexport function getCodeBlockAriaAnnouncement(t, languageDefs, element, direction) {\n const languagesToLabels = getPropertyAssociation(languageDefs, 'language', 'label');\n const codeBlockLanguage = element.getAttribute('language');\n if (codeBlockLanguage in languagesToLabels) {\n const language = languagesToLabels[codeBlockLanguage];\n if (direction === 'enter') {\n return t('Entering %0 code snippet', language);\n }\n return t('Leaving %0 code snippet', language);\n }\n if (direction === 'enter') {\n return t('Entering code snippet');\n }\n return t('Leaving code snippet');\n}\n/**\n * For given position, finds the closest position that is at the beginning of a line of code and returns a text node that is at the\n * beginning of the line (or `null` if there's no text node at the beginning of a given line).\n *\n * Line beings at the start of a code block element and after each `softBreak` element.\n *\n * Note: even though code block doesn't allow inline elements other than `` by default, some features may overwrite this rule,\n * so such inline elements are taken into account.\n *\n * Some examples of expected results:\n *\n * ```\n * ^ -> null\n * ^foobar -> [foobar]\n * foobar^ -> [foobar]\n * foo^bar -> [foobar]\n * foo^bar -> [foo]bar\n * foobar^ -> foo[bar]\n * foob^ar -> foo[bar]\n * foo^bar -> foo[bar]\n * ^ -> null\n * ^ -> null\n * foo^ -> [foo]\n * foo^ -> [foo]\n * foobar^ -> [foo]bar\n * bar^ -> null\n * foo^ -> null\n * foo^ -> null\n * foo^ -> null\n * foobar^ -> foo[bar]\n * fooba^r -> null\n * ```\n *\n * @internal\n */\nexport function getTextNodeAtLineStart(position, model) {\n // First, move position before a text node, if it is inside a text node.\n if (position.textNode) {\n position = model.createPositionBefore(position.textNode);\n }\n // Then, jump-back the position until it is before a `softBreak` or at the beginning of the `codeBlock`.\n while (position.nodeBefore && !position.nodeBefore.is('element', 'softBreak')) {\n position = model.createPositionBefore(position.nodeBefore);\n }\n // Now, the position is at the beginning of a line.\n // Return a text node after the position, if there is one.\n const nodeAtStart = position.nodeAfter;\n return nodeAtStart && nodeAtStart.is('$text') ? nodeAtStart : null;\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { first } from 'ckeditor5/src/utils.js';\nimport { getNormalizedAndLocalizedLanguageDefinitions, canBeCodeBlock } from './utils.js';\n/**\n * The code block command plugin.\n */\nexport class CodeBlockCommand extends Command {\n /**\n * Contains the last used language.\n */\n _lastLanguage;\n /**\n * @inheritDoc\n */\n constructor(editor) {\n super(editor);\n this._lastLanguage = null;\n }\n /**\n * @inheritDoc\n */\n refresh() {\n this.value = this._getValue();\n this.isEnabled = this._checkEnabled();\n }\n /**\n * Executes the command. When the command {@link #value is on}, all topmost code blocks within\n * the selection will be removed. If it is off, all selected blocks will be flattened and\n * wrapped by a code block.\n *\n * @fires execute\n * @param options Command options.\n * @param options.language The code block language.\n * @param options.forceValue If set, it will force the command behavior. If `true`, the command will apply a code block,\n * otherwise the command will remove the code block. If not set, the command will act basing on its current value.\n * @param options.usePreviousLanguageChoice If set on `true` and the `options.language` is not specified, the command\n * will apply the previous language (if the command was already executed) when inserting the `codeBlock` element.\n */\n execute(options = {}) {\n const editor = this.editor;\n const model = editor.model;\n const selection = model.document.selection;\n const normalizedLanguagesDefs = getNormalizedAndLocalizedLanguageDefinitions(editor);\n const firstLanguageInConfig = normalizedLanguagesDefs[0];\n const blocks = Array.from(selection.getSelectedBlocks());\n const value = options.forceValue == undefined ? !this.value : options.forceValue;\n const language = getLanguage(options, this._lastLanguage, firstLanguageInConfig.language);\n model.change(writer => {\n if (value) {\n this._applyCodeBlock(writer, blocks, language);\n }\n else {\n this._removeCodeBlock(writer, blocks);\n }\n });\n }\n /**\n * Checks the command's {@link #value}.\n *\n * @returns The current value.\n */\n _getValue() {\n const selection = this.editor.model.document.selection;\n const firstBlock = first(selection.getSelectedBlocks());\n const isCodeBlock = !!firstBlock?.is('element', 'codeBlock');\n return isCodeBlock ? firstBlock.getAttribute('language') : false;\n }\n /**\n * Checks whether the command can be enabled in the current context.\n *\n * @returns Whether the command should be enabled.\n */\n _checkEnabled() {\n if (this.value) {\n return true;\n }\n const selection = this.editor.model.document.selection;\n const schema = this.editor.model.schema;\n const firstBlock = first(selection.getSelectedBlocks());\n if (!firstBlock) {\n return false;\n }\n return canBeCodeBlock(schema, firstBlock);\n }\n _applyCodeBlock(writer, blocks, language) {\n this._lastLanguage = language;\n const schema = this.editor.model.schema;\n const allowedBlocks = blocks.filter(block => canBeCodeBlock(schema, block));\n for (const block of allowedBlocks) {\n writer.rename(block, 'codeBlock');\n writer.setAttribute('language', language, block);\n schema.removeDisallowedAttributes([block], writer);\n // Remove children of the `codeBlock` element that are not allowed. See #9567.\n Array.from(block.getChildren())\n .filter(child => !schema.checkChild(block, child))\n .forEach(child => writer.remove(child));\n }\n allowedBlocks.reverse().forEach((currentBlock, i) => {\n const nextBlock = allowedBlocks[i + 1];\n if (currentBlock.previousSibling === nextBlock) {\n writer.appendElement('softBreak', nextBlock);\n writer.merge(writer.createPositionBefore(currentBlock));\n }\n });\n }\n _removeCodeBlock(writer, blocks) {\n const codeBlocks = blocks.filter(block => block.is('element', 'codeBlock'));\n for (const block of codeBlocks) {\n const range = writer.createRangeOn(block);\n for (const item of Array.from(range.getItems()).reverse()) {\n if (item.is('element', 'softBreak') && item.parent.is('element', 'codeBlock')) {\n const { position } = writer.split(writer.createPositionBefore(item));\n const elementAfter = position.nodeAfter;\n writer.rename(elementAfter, 'paragraph');\n writer.removeAttribute('language', elementAfter);\n writer.remove(item);\n }\n }\n writer.rename(block, 'paragraph');\n writer.removeAttribute('language', block);\n }\n }\n}\n/**\n * Picks the language for the new code block. If any language is passed as an option,\n * it will be returned. Else, if option usePreviousLanguageChoice is true and some\n * code block was already created (lastLanguage is not null) then previously used\n * language will be returned. If not, it will return default language.\n */\nfunction getLanguage(options, lastLanguage, defaultLanguage) {\n if (options.language) {\n return options.language;\n }\n if (options.usePreviousLanguageChoice && lastLanguage) {\n return lastLanguage;\n }\n return defaultLanguage;\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module code-block/indentcodeblockcommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { getIndentOutdentPositions, isModelSelectionInCodeBlock } from './utils.js';\n/**\n * The code block indentation increase command plugin.\n */\nexport class IndentCodeBlockCommand extends Command {\n /**\n * A sequence of characters added to the line when the command is executed.\n */\n _indentSequence;\n constructor(editor) {\n super(editor);\n this._indentSequence = editor.config.get('codeBlock.indentSequence');\n }\n /**\n * @inheritDoc\n */\n refresh() {\n this.isEnabled = this._checkEnabled();\n }\n /**\n * Executes the command. When the command {@link #isEnabled is enabled}, the indentation of the\n * code lines in the selection will be increased.\n *\n * @fires execute\n */\n execute() {\n const editor = this.editor;\n const model = editor.model;\n model.change(writer => {\n const positions = getIndentOutdentPositions(model);\n // Indent all positions, for instance assuming the indent sequence is 4x space (\" \"):\n //\n //\t\t^foo -> foo\n //\n //\t\tfoo^bar -> foo bar\n //\n // Also, when there is more than one position:\n //\n //\t\t\n //\t\t\t^foobar\n //\t\t\t\n //\t\t\t^bazqux\n //\t\t\n //\n //\t\t->\n //\n //\t\t\n //\t\t\t foobar\n //\t\t\t\n //\t\t\t bazqux\n //\t\t\n //\n for (const position of positions) {\n const indentSequenceTextElement = writer.createText(this._indentSequence);\n // Previously insertion was done by writer.insertText(). It was changed to insertContent() to enable\n // integration of code block with track changes. It's the easiest way of integration because insertContent()\n // is already integrated with track changes, but if it ever cause any troubles it can be reverted, however\n // some additional work will be required in track changes integration of code block.\n model.insertContent(indentSequenceTextElement, position);\n }\n });\n }\n /**\n * Checks whether the command can be enabled in the current context.\n */\n _checkEnabled() {\n if (!this._indentSequence) {\n return false;\n }\n // Indent (forward) command is always enabled when there's any code block in the selection\n // because you can always indent code lines.\n return isModelSelectionInCodeBlock(this.editor.model.document.selection);\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { getLeadingWhiteSpaces, getIndentOutdentPositions, isModelSelectionInCodeBlock, getTextNodeAtLineStart } from './utils.js';\n/**\n * The code block indentation decrease command plugin.\n */\nexport class OutdentCodeBlockCommand extends Command {\n /**\n * A sequence of characters removed from the line when the command is executed.\n */\n _indentSequence;\n constructor(editor) {\n super(editor);\n this._indentSequence = editor.config.get('codeBlock.indentSequence');\n }\n /**\n * @inheritDoc\n */\n refresh() {\n this.isEnabled = this._checkEnabled();\n }\n /**\n * Executes the command. When the command {@link #isEnabled is enabled}, the indentation of the\n * code lines in the selection will be decreased.\n *\n * @fires execute\n */\n execute() {\n const editor = this.editor;\n const model = editor.model;\n model.change(() => {\n const positions = getIndentOutdentPositions(model);\n // Outdent all positions, for instance assuming the indent sequence is 4x space (\" \"):\n //\n //\t\t^foo -> foo\n //\n //\t\t ^bar -> bar\n //\n // Also, when there is more than one position:\n //\n //\t\t\n //\t\t\t ^foobar\n //\t\t\t\n //\t\t\t ^bazqux\n //\t\t\n //\n //\t\t->\n //\n //\t\t\n //\t\t\tfoobar\n //\t\t\t\n //\t\t\tbazqux\n //\t\t\n for (const position of positions) {\n const range = getLastOutdentableSequenceRange(model, position, this._indentSequence);\n if (range) {\n // Previously deletion was done by writer.remove(). It was changed to deleteContent() to enable\n // integration of code block with track changes. It's the easiest way of integration because deleteContent()\n // is already integrated with track changes, but if it ever cause any troubles it can be reverted, however\n // some additional work will be required in track changes integration of code block.\n model.deleteContent(model.createSelection(range));\n }\n }\n });\n }\n /**\n * Checks whether the command can be enabled in the current context.\n *\n * @private\n * @returns {Boolean} Whether the command should be enabled.\n */\n _checkEnabled() {\n if (!this._indentSequence) {\n return false;\n }\n const model = this.editor.model;\n if (!isModelSelectionInCodeBlock(model.document.selection)) {\n return false;\n }\n // Outdent command can execute only when there is an indent character sequence\n // in some of the lines.\n return getIndentOutdentPositions(model).some(position => {\n return getLastOutdentableSequenceRange(model, position, this._indentSequence);\n });\n }\n}\n// For a position coming from `getIndentOutdentPositions()`, it returns the range representing\n// the last occurrence of the indent sequence among the leading whitespaces of the code line the\n// position represents.\n//\n// For instance, assuming the indent sequence is 4x space (\" \"):\n//\n//\t\tfoo^ -> null\n//\t\tfoo^bar -> null\n//\t\t ^foo -> null\n//\t\t ^foo -> [ ]foo\n//\t\t ^foo bar -> [ ]foo bar\n//\n// @param {} model\n// @param {} position\n// @param {String} sequence\n// @returns {|null}\nfunction getLastOutdentableSequenceRange(model, position, sequence) {\n // Positions start before each text node (code line). Get the node corresponding to the position.\n const nodeAtPosition = getTextNodeAtLineStart(position, model);\n if (!nodeAtPosition) {\n return null;\n }\n const leadingWhiteSpaces = getLeadingWhiteSpaces(nodeAtPosition);\n const lastIndexOfSequence = leadingWhiteSpaces.lastIndexOf(sequence);\n // For instance, assuming the indent sequence is 4x space (\" \"):\n //\n //\t\t \t^foo -> null\n //\n if (lastIndexOfSequence + sequence.length !== leadingWhiteSpaces.length) {\n return null;\n }\n // For instance, assuming the indent sequence is 4x space (\" \"):\n //\n //\t\t ^foo -> null\n //\n if (lastIndexOfSequence === -1) {\n return null;\n }\n const { parent, startOffset } = nodeAtPosition;\n // Create a range that contains the **last** indent sequence among the leading whitespaces\n // of the line.\n //\n // For instance, assuming the indent sequence is 4x space (\" \"):\n //\n //\t\t ^foo -> [ ]foo\n //\n return model.createRange(model.createPositionAt(parent, startOffset + lastIndexOfSequence), model.createPositionAt(parent, startOffset + lastIndexOfSequence + sequence.length));\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { getPropertyAssociation } from './utils.js';\n/**\n * A model-to-view (both editing and data) converter for the `codeBlock` element.\n *\n * Sample input:\n *\n * ```html\n * foo();bar();\n * ```\n *\n * Sample output (editing):\n *\n * ```html\n *
    foo();
    bar();
    \n * ```\n *\n * Sample output (data, see {@link module:code-block/converters~modelToDataViewSoftBreakInsertion}):\n *\n * ```html\n *
    foo();\\nbar();
    \n * ```\n *\n * @param languageDefs The normalized language configuration passed to the feature.\n * @param useLabels When `true`, the `
    ` element will get a `data-language` attribute with a\n * human–readable label of the language. Used only in the editing.\n * @returns Returns a conversion callback.\n * @internal\n */\nexport function modelToViewCodeBlockInsertion(model, languageDefs, useLabels = false) {\n    // Language CSS classes:\n    //\n    //\t\t{\n    //\t\t\tphp: 'language-php',\n    //\t\t\tpython: 'language-python',\n    //\t\t\tjavascript: 'js',\n    //\t\t\t...\n    //\t\t}\n    const languagesToClasses = getPropertyAssociation(languageDefs, 'language', 'class');\n    // Language labels:\n    //\n    //\t\t{\n    //\t\t\tphp: 'PHP',\n    //\t\t\tpython: 'Python',\n    //\t\t\tjavascript: 'JavaScript',\n    //\t\t\t...\n    //\t\t}\n    const languagesToLabels = getPropertyAssociation(languageDefs, 'language', 'label');\n    return (evt, data, conversionApi) => {\n        const { writer, mapper, consumable } = conversionApi;\n        if (!consumable.consume(data.item, 'insert')) {\n            return;\n        }\n        const codeBlockLanguage = data.item.getAttribute('language');\n        const targetViewPosition = mapper.toViewPosition(model.createPositionBefore(data.item));\n        const preAttributes = {};\n        // Attributes added only in the editing view.\n        if (useLabels) {\n            preAttributes['data-language'] = languagesToLabels[codeBlockLanguage];\n            preAttributes.spellcheck = 'false';\n        }\n        const codeAttributes = languagesToClasses[codeBlockLanguage] ? {\n            class: languagesToClasses[codeBlockLanguage]\n        } : undefined;\n        const code = writer.createContainerElement('code', codeAttributes);\n        const pre = writer.createContainerElement('pre', preAttributes, code);\n        writer.insert(targetViewPosition, pre);\n        mapper.bindElements(data.item, code);\n    };\n}\n/**\n * A model-to-data view converter for the new line (`softBreak`) separator.\n *\n * Sample input:\n *\n * ```html\n * foo();bar();\n * ```\n *\n * Sample output:\n *\n * ```html\n * 
    foo();\\nbar();
    \n * ```\n *\n * @returns Returns a conversion callback.\n * @internal\n */\nexport function modelToDataViewSoftBreakInsertion(model) {\n return (evt, data, conversionApi) => {\n if (data.item.parent.name !== 'codeBlock') {\n return;\n }\n const { writer, mapper, consumable } = conversionApi;\n if (!consumable.consume(data.item, 'insert')) {\n return;\n }\n const position = mapper.toViewPosition(model.createPositionBefore(data.item));\n writer.insert(position, writer.createText('\\n'));\n };\n}\n/**\n * A view-to-model converter for `
    ` with the `` HTML.\n *\n * Sample input:\n *\n * ```html\n * 
    foo();bar();
    \n * ```\n *\n * Sample output:\n *\n * ```html\n * foo();bar();\n * ```\n *\n * @param languageDefs The normalized language configuration passed to the feature.\n * @returns Returns a conversion callback.\n * @internal\n */\nexport function dataViewToModelCodeBlockInsertion(editingView, languageDefs) {\n // Language names associated with CSS classes:\n //\n //\t\t{\n //\t\t\t'language-php': 'php',\n //\t\t\t'language-python': 'python',\n //\t\t\tjs: 'javascript',\n //\t\t\t...\n //\t\t}\n const classesToLanguages = getPropertyAssociation(languageDefs, 'class', 'language');\n const defaultLanguageName = languageDefs[0].language;\n return (evt, data, conversionApi) => {\n const viewCodeElement = data.viewItem;\n const viewPreElement = viewCodeElement.parent;\n if (!viewPreElement || !viewPreElement.is('element', 'pre')) {\n return;\n }\n // In case of nested code blocks we don't want to convert to another code block.\n if (data.modelCursor.findAncestor('codeBlock')) {\n return;\n }\n const { consumable, writer } = conversionApi;\n if (!consumable.test(viewCodeElement, { name: true })) {\n return;\n }\n const codeBlock = writer.createElement('codeBlock');\n const viewChildClasses = [...viewCodeElement.getClassNames()];\n // As we're to associate each class with a model language, a lack of class (empty class) can be\n // also associated with a language if the language definition was configured so. Pushing an empty\n // string to make sure the association will work.\n if (!viewChildClasses.length) {\n viewChildClasses.push('');\n }\n // Figure out if any of the element's class names is a valid programming\n // language class. If so, use it on the model element (becomes the language of the entire block).\n for (const className of viewChildClasses) {\n const language = classesToLanguages[className];\n if (language) {\n consumable.consume(viewCodeElement, { classes: [className] });\n writer.setAttribute('language', language, codeBlock);\n break;\n }\n }\n // If no language value was set, use the default language from the config.\n if (!codeBlock.hasAttribute('language')) {\n writer.setAttribute('language', defaultLanguageName, codeBlock);\n }\n // Convert children before inserting the code block element\n // to make sure that code block won't be splitted by any block.\n conversionApi.convertChildren(viewCodeElement, codeBlock);\n // Let's try to insert code block.\n if (!conversionApi.safeInsert(codeBlock, data.modelCursor)) {\n return;\n }\n consumable.consume(viewCodeElement, { name: true });\n conversionApi.updateConversionResult(codeBlock, data);\n };\n}\n/**\n * A view-to-model converter for new line characters in `
    `.\n *\n * Sample input:\n *\n * ```html\n * 
    foo();\\nbar();
    \n * ```\n *\n * Sample output:\n *\n * ```html\n * foo();bar();\n * ```\n *\n * @returns {Function} Returns a conversion callback.\n * @internal\n */\nexport function dataViewToModelTextNewlinesInsertion() {\n return (evt, data, { consumable, writer }) => {\n let position = data.modelCursor;\n // When node is already converted then do nothing.\n if (!consumable.test(data.viewItem)) {\n return;\n }\n // When not inside `codeBlock` then do nothing.\n if (!position.findAncestor('codeBlock')) {\n return;\n }\n consumable.consume(data.viewItem);\n const text = data.viewItem.data;\n const textLines = text.split('\\n').map(data => writer.createText(data));\n const lastLine = textLines[textLines.length - 1];\n for (const node of textLines) {\n writer.insert(node, position);\n position = position.getShiftedBy(node.offsetSize);\n if (node !== lastLine) {\n const softBreak = writer.createElement('softBreak');\n writer.insert(softBreak, position);\n position = writer.createPositionAfter(softBreak);\n }\n }\n data.modelRange = writer.createRange(data.modelCursor, position);\n data.modelCursor = position;\n };\n}\n/**\n * A view-to-model converter that handles orphan text nodes (white spaces, new lines, etc.)\n * that surround `` inside `
    `.\n *\n * Sample input:\n *\n * ```html\n * // White spaces\n * 
     foo() 
    \n *\n * // White spaces\n *
          foo()      
    \n *\n * // White spaces\n *
    \t\t\tfoo()\t\t\t
    \n *\n * // New lines\n *
    \n * \tfoo()\n * 
    \n *\n * // Redundant text\n *
    ABCfoo()DEF
    \n * ```\n *\n * Unified output for each case:\n *\n * ```html\n * foo()\n * ```\n *\n * @returns Returns a conversion callback.\n * @internal\n */\nexport function dataViewToModelOrphanNodeConsumer() {\n return (evt, data, { consumable }) => {\n const preElement = data.viewItem;\n // Don't clean up nested pre elements. Their content should stay as it is, they are not upcasted\n // to code blocks.\n if (preElement.findAncestor('pre')) {\n return;\n }\n const preChildren = Array.from(preElement.getChildren());\n const childCodeElement = preChildren.find(node => node.is('element', 'code'));\n // -less
    . It will not upcast to code block in the model, skipping.\n        if (!childCodeElement) {\n            return;\n        }\n        for (const child of preChildren) {\n            if (child === childCodeElement || !child.is('$text')) {\n                continue;\n            }\n            // Consuming the orphan to remove it from the input data.\n            // Second argument in `consumable.consume` is discarded for text nodes.\n            consumable.consume(child, { name: true });\n        }\n    };\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module code-block/codeblockediting\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { ShiftEnter } from 'ckeditor5/src/enter.js';\nimport { ViewUpcastWriter } from 'ckeditor5/src/engine.js';\nimport { ClipboardPipeline } from 'ckeditor5/src/clipboard.js';\nimport { CodeBlockCommand } from './codeblockcommand.js';\nimport { IndentCodeBlockCommand } from './indentcodeblockcommand.js';\nimport { OutdentCodeBlockCommand } from './outdentcodeblockcommand.js';\nimport { getNormalizedAndLocalizedLanguageDefinitions, getLeadingWhiteSpaces, rawSnippetTextToViewDocumentFragment, getCodeBlockAriaAnnouncement, getTextNodeAtLineStart } from './utils.js';\nimport { modelToViewCodeBlockInsertion, modelToDataViewSoftBreakInsertion, dataViewToModelCodeBlockInsertion, dataViewToModelTextNewlinesInsertion, dataViewToModelOrphanNodeConsumer } from './converters.js';\nconst DEFAULT_ELEMENT = 'paragraph';\n/**\n * The editing part of the code block feature.\n *\n * Introduces the `'codeBlock'` command and the `'codeBlock'` model element.\n */\nexport class CodeBlockEditing extends Plugin {\n    /**\n     * @inheritDoc\n     */\n    static get pluginName() {\n        return 'CodeBlockEditing';\n    }\n    /**\n     * @inheritDoc\n     */\n    static get isOfficialPlugin() {\n        return true;\n    }\n    /**\n     * @inheritDoc\n     */\n    static get requires() {\n        return [ShiftEnter];\n    }\n    /**\n     * @inheritDoc\n     */\n    constructor(editor) {\n        super(editor);\n        editor.config.define('codeBlock', {\n            languages: [\n                { language: 'plaintext', label: 'Plain text' },\n                { language: 'c', label: 'C' },\n                { language: 'cs', label: 'C#' },\n                { language: 'cpp', label: 'C++' },\n                { language: 'css', label: 'CSS' },\n                { language: 'diff', label: 'Diff' },\n                { language: 'go', label: 'Go' },\n                { language: 'html', label: 'HTML' },\n                { language: 'java', label: 'Java' },\n                { language: 'javascript', label: 'JavaScript' },\n                { language: 'php', label: 'PHP' },\n                { language: 'python', label: 'Python' },\n                { language: 'ruby', label: 'Ruby' },\n                { language: 'typescript', label: 'TypeScript' },\n                { language: 'xml', label: 'XML' }\n            ],\n            // A single tab.\n            indentSequence: '\\t'\n        });\n    }\n    /**\n     * @inheritDoc\n     */\n    init() {\n        const editor = this.editor;\n        const schema = editor.model.schema;\n        const model = editor.model;\n        const view = editor.editing.view;\n        const normalizedLanguagesDefs = getNormalizedAndLocalizedLanguageDefinitions(editor);\n        // The main command.\n        editor.commands.add('codeBlock', new CodeBlockCommand(editor));\n        // Commands that change the indentation.\n        editor.commands.add('indentCodeBlock', new IndentCodeBlockCommand(editor));\n        editor.commands.add('outdentCodeBlock', new OutdentCodeBlockCommand(editor));\n        this.listenTo(view.document, 'tab', (evt, data) => {\n            const commandName = data.shiftKey ? 'outdentCodeBlock' : 'indentCodeBlock';\n            const command = editor.commands.get(commandName);\n            if (!command.isEnabled) {\n                return;\n            }\n            editor.execute(commandName);\n            data.stopPropagation();\n            data.preventDefault();\n            evt.stop();\n        }, { context: 'pre' });\n        schema.register('codeBlock', {\n            allowWhere: '$block',\n            allowChildren: '$text',\n            // Disallow `$inlineObject` and its derivatives like `inlineWidget` inside `codeBlock` to ensure that only text,\n            // not other inline elements like inline images, are allowed. This maintains the semantic integrity of code blocks.\n            disallowChildren: '$inlineObject',\n            allowAttributes: ['language'],\n            allowAttributesOf: '$listItem',\n            isBlock: true\n        });\n        // Disallow formatting attributes on `codeBlock` children.\n        schema.addAttributeCheck((context, attributeName) => {\n            const parent = context.getItem(context.length - 2);\n            const isFormatting = schema.getAttributeProperties(attributeName).isFormatting;\n            if (isFormatting && parent && parent.name == 'codeBlock') {\n                return false;\n            }\n        });\n        // Conversion.\n        editor.editing.downcastDispatcher.on('insert:codeBlock', modelToViewCodeBlockInsertion(model, normalizedLanguagesDefs, true));\n        editor.data.downcastDispatcher.on('insert:codeBlock', modelToViewCodeBlockInsertion(model, normalizedLanguagesDefs));\n        editor.data.downcastDispatcher.on('insert:softBreak', modelToDataViewSoftBreakInsertion(model), { priority: 'high' });\n        editor.data.upcastDispatcher.on('element:code', dataViewToModelCodeBlockInsertion(view, normalizedLanguagesDefs));\n        editor.data.upcastDispatcher.on('text', dataViewToModelTextNewlinesInsertion());\n        editor.data.upcastDispatcher.on('element:pre', dataViewToModelOrphanNodeConsumer(), { priority: 'high' });\n        // Intercept the clipboard input (paste) when the selection is anchored in the code block and force the clipboard\n        // data to be pasted as a single plain text. Otherwise, the code lines will split the code block and\n        // \"spill out\" as separate paragraphs.\n        this.listenTo(editor.editing.view.document, 'clipboardInput', (evt, data) => {\n            let insertionRange = model.createRange(model.document.selection.anchor);\n            // Use target ranges in case this is a drop.\n            if (data.targetRanges) {\n                insertionRange = editor.editing.mapper.toModelRange(data.targetRanges[0]);\n            }\n            if (!insertionRange.start.parent.is('element', 'codeBlock')) {\n                return;\n            }\n            const text = data.dataTransfer.getData('text/plain');\n            const writer = new ViewUpcastWriter(editor.editing.view.document);\n            // Pass the view fragment to the default clipboardInput handler.\n            data.content = rawSnippetTextToViewDocumentFragment(writer, text);\n        });\n        if (editor.plugins.has('ClipboardPipeline')) {\n            // Elements may have a plain textual representation (hence be present in the 'text/plain' data transfer),\n            // but not be allowed in the code block.\n            // Filter them out before inserting the content to the model.\n            editor.plugins.get(ClipboardPipeline).on('contentInsertion', (evt, data) => {\n                const model = editor.model;\n                const selection = model.document.selection;\n                if (!selection.anchor.parent.is('element', 'codeBlock')) {\n                    return;\n                }\n                model.change(writer => {\n                    const contentRange = writer.createRangeIn(data.content);\n                    for (const item of [...contentRange.getItems()]) {\n                        // Remove all nodes disallowed in the code block.\n                        if (item.is('node') && !schema.checkChild(selection.anchor, item)) {\n                            writer.remove(item);\n                        }\n                    }\n                });\n            });\n        }\n        // Make sure multi–line selection is always wrapped in a code block when `getSelectedContent()`\n        // is used (e.g. clipboard copy). Otherwise, only the raw text will be copied to the clipboard and,\n        // upon next paste, this bare text will not be inserted as a code block, which is not the best UX.\n        // Similarly, when the selection in a single line, the selected content should be an inline code\n        // so it can be pasted later on and retain it's preformatted nature.\n        this.listenTo(model, 'getSelectedContent', (evt, [selection]) => {\n            const anchor = selection.anchor;\n            if (selection.isCollapsed || !anchor.parent.is('element', 'codeBlock') || !anchor.hasSameParentAs(selection.focus)) {\n                return;\n            }\n            model.change(writer => {\n                const docFragment = evt.return;\n                // fo[ob]ar  ->   [ob]\n                if (anchor.parent.is('element') &&\n                    (docFragment.childCount > 1 || selection.containsEntireContent(anchor.parent))) {\n                    const codeBlock = writer.createElement('codeBlock', anchor.parent.getAttributes());\n                    writer.append(docFragment, codeBlock);\n                    const newDocumentFragment = writer.createDocumentFragment();\n                    writer.append(codeBlock, newDocumentFragment);\n                    evt.return = newDocumentFragment;\n                    return;\n                }\n                // \"f[oo]\"                          ->   <$text code=\"true\">oo\n                const textNode = docFragment.getChild(0);\n                if (schema.checkAttribute(textNode, 'code')) {\n                    writer.setAttribute('code', true, textNode);\n                }\n            });\n        });\n    }\n    /**\n     * @inheritDoc\n     */\n    afterInit() {\n        const editor = this.editor;\n        const commands = editor.commands;\n        const indent = commands.get('indent');\n        const outdent = commands.get('outdent');\n        if (indent) {\n            // Priority is highest due to integration with `IndentList` command of `List` plugin.\n            // If selection is in a code block we give priority to it. This way list item cannot be indented\n            // but if we would give priority to indenting list item then user would have to indent list item\n            // as much as possible and only then he could indent code block.\n            indent.registerChildCommand(commands.get('indentCodeBlock'), { priority: 'highest' });\n        }\n        if (outdent) {\n            outdent.registerChildCommand(commands.get('outdentCodeBlock'));\n        }\n        // Customize the response to the Enter and Shift+Enter\n        // key press when the selection is in the code block. Upon enter key press we can either\n        // leave the block if it's \"two or three enters\" in a row or create a new code block line, preserving\n        // previous line's indentation.\n        this.listenTo(editor.editing.view.document, 'enter', (evt, data) => {\n            const positionParent = editor.model.document.selection.getLastPosition().parent;\n            if (!positionParent.is('element', 'codeBlock')) {\n                return;\n            }\n            if (!leaveBlockStartOnEnter(editor, data.isSoft) && !leaveBlockEndOnEnter(editor, data.isSoft)) {\n                breakLineOnEnter(editor);\n            }\n            data.preventDefault();\n            evt.stop();\n        }, { context: 'pre' });\n        this._initAriaAnnouncements();\n    }\n    /**\n     * Observe when user enters or leaves code block and set proper aria value in global live announcer.\n     * This allows screen readers to indicate when the user has entered and left the specified code block.\n     *\n     * @internal\n     */\n    _initAriaAnnouncements() {\n        const { model, ui, t } = this.editor;\n        const languageDefs = getNormalizedAndLocalizedLanguageDefinitions(this.editor);\n        let lastFocusedCodeBlock = null;\n        model.document.selection.on('change:range', () => {\n            const focusParent = model.document.selection.focus.parent;\n            if (!ui || lastFocusedCodeBlock === focusParent || !focusParent.is('element')) {\n                return;\n            }\n            if (lastFocusedCodeBlock && lastFocusedCodeBlock.is('element', 'codeBlock')) {\n                ui.ariaLiveAnnouncer.announce(getCodeBlockAriaAnnouncement(t, languageDefs, lastFocusedCodeBlock, 'leave'));\n            }\n            if (focusParent.is('element', 'codeBlock')) {\n                ui.ariaLiveAnnouncer.announce(getCodeBlockAriaAnnouncement(t, languageDefs, focusParent, 'enter'));\n            }\n            lastFocusedCodeBlock = focusParent;\n        });\n    }\n}\n/**\n * Normally, when the Enter (or Shift+Enter) key is pressed, a soft line break is to be added to the\n * code block. Let's try to follow the indentation of the previous line when possible, for instance:\n *\n * ```html\n * // Before pressing enter (or shift enter)\n * \n * \"    foo()\"[]                   // Indent of 4 spaces.\n * \n *\n * // After pressing:\n * \n * \"    foo()\"                 // Indent of 4 spaces.\n *      // A new soft break created by pressing enter.\n * \"    \"[]                    // Retain the indent of 4 spaces.\n * \n * ```\n */\nfunction breakLineOnEnter(editor) {\n    const model = editor.model;\n    const modelDoc = model.document;\n    // Use last position as other mechanisms (e.g. condition deciding whether this function should be called) also check that.\n    const lastSelectionPosition = modelDoc.selection.getLastPosition();\n    let leadingWhiteSpaces;\n    const node = getTextNodeAtLineStart(lastSelectionPosition, model);\n    // Figure out the indentation (white space chars) at the beginning of the line.\n    if (node && node.is('$text')) {\n        leadingWhiteSpaces = getLeadingWhiteSpaces(node);\n    }\n    // Keeping everything in a change block for a single undo step.\n    editor.model.change(writer => {\n        editor.execute('shiftEnter');\n        // If the line before being broken in two had some indentation, let's retain it\n        // in the new line.\n        if (leadingWhiteSpaces) {\n            writer.insertText(leadingWhiteSpaces, modelDoc.selection.anchor);\n        }\n    });\n}\n/**\n * Leave the code block when Enter (but NOT Shift+Enter) has been pressed twice at the beginning\n * of the code block:\n *\n * ```html\n * // Before:\n * []foo\n *\n * // After pressing:\n * []foo\n * ```\n *\n * @param isSoftEnter When `true`, enter was pressed along with Shift.\n * @returns `true` when selection left the block. `false` if stayed.\n */\nfunction leaveBlockStartOnEnter(editor, isSoftEnter) {\n    const model = editor.model;\n    const modelDoc = model.document;\n    const view = editor.editing.view;\n    const lastSelectionPosition = modelDoc.selection.getLastPosition();\n    const nodeAfter = lastSelectionPosition.nodeAfter;\n    if (isSoftEnter || !modelDoc.selection.isCollapsed || !lastSelectionPosition.isAtStart) {\n        return false;\n    }\n    if (!isSoftBreakNode(nodeAfter)) {\n        return false;\n    }\n    // We're doing everything in a single change block to have a single undo step.\n    editor.model.change(writer => {\n        // \"Clone\" the  in the standard way.\n        editor.execute('enter');\n        // The cloned block exists now before the original code block.\n        const newBlock = modelDoc.selection.anchor.parent.previousSibling;\n        // Make the cloned  a regular  (with clean attributes, so no language).\n        writer.rename(newBlock, DEFAULT_ELEMENT);\n        writer.setSelection(newBlock, 'in');\n        editor.model.schema.removeDisallowedAttributes([newBlock], writer);\n        // Remove the  that originally followed the selection position.\n        writer.remove(nodeAfter);\n    });\n    // Eye candy.\n    view.scrollToTheSelection();\n    return true;\n}\n/**\n * Leave the code block when Enter (but NOT Shift+Enter) has been pressed twice at the end\n * of the code block:\n *\n * ```html\n * // Before:\n * foo[]\n *\n * // After first press:\n * foo[]\n *\n * // After second press:\n * foo[]\n * ```\n *\n * @param isSoftEnter When `true`, enter was pressed along with Shift.\n * @returns `true` when selection left the block. `false` if stayed.\n */\nfunction leaveBlockEndOnEnter(editor, isSoftEnter) {\n    const model = editor.model;\n    const modelDoc = model.document;\n    const view = editor.editing.view;\n    const lastSelectionPosition = modelDoc.selection.getLastPosition();\n    const nodeBefore = lastSelectionPosition.nodeBefore;\n    let emptyLineRangeToRemoveOnEnter;\n    if (isSoftEnter || !modelDoc.selection.isCollapsed || !lastSelectionPosition.isAtEnd || !nodeBefore || !nodeBefore.previousSibling) {\n        return false;\n    }\n    // When the position is directly preceded by two soft breaks\n    //\n    //\t\tfoo[]\n    //\n    // it creates the following range that will be cleaned up before leaving:\n    //\n    //\t\tfoo[]\n    //\n    if (isSoftBreakNode(nodeBefore) && isSoftBreakNode(nodeBefore.previousSibling)) {\n        emptyLineRangeToRemoveOnEnter = model.createRange(model.createPositionBefore(nodeBefore.previousSibling), model.createPositionAfter(nodeBefore));\n    }\n    // When there's some text before the position that is\n    // preceded by two soft breaks and made purely of white–space characters\n    //\n    //\t\tfoo    []\n    //\n    // it creates the following range to clean up before leaving:\n    //\n    //\t\tfoo[    ]\n    //\n    else if (isEmptyishTextNode(nodeBefore) &&\n        isSoftBreakNode(nodeBefore.previousSibling) &&\n        isSoftBreakNode(nodeBefore.previousSibling.previousSibling)) {\n        emptyLineRangeToRemoveOnEnter = model.createRange(model.createPositionBefore(nodeBefore.previousSibling.previousSibling), model.createPositionAfter(nodeBefore));\n    }\n    // When there's some text before the position that is made purely of white–space characters\n    // and is preceded by some other text made purely of white–space characters\n    //\n    //\t\tfoo        []\n    //\n    // it creates the following range to clean up before leaving:\n    //\n    //\t\tfoo[        ]\n    //\n    else if (isEmptyishTextNode(nodeBefore) &&\n        isSoftBreakNode(nodeBefore.previousSibling) &&\n        isEmptyishTextNode(nodeBefore.previousSibling.previousSibling) &&\n        nodeBefore.previousSibling.previousSibling &&\n        isSoftBreakNode(nodeBefore.previousSibling.previousSibling.previousSibling)) {\n        emptyLineRangeToRemoveOnEnter = model.createRange(model.createPositionBefore(nodeBefore.previousSibling.previousSibling.previousSibling), model.createPositionAfter(nodeBefore));\n    }\n    // Not leaving the block in the following cases:\n    //\n    //\t\t    []\n    //\t\t  a []\n    //\t\tfoo[]\n    //\t\tfoobar[]\n    //\t\tfoo a []\n    //\n    else {\n        return false;\n    }\n    // We're doing everything in a single change block to have a single undo step.\n    editor.model.change(writer => {\n        // Remove the last s and all white space characters that followed them.\n        writer.remove(emptyLineRangeToRemoveOnEnter);\n        // \"Clone\" the  in the standard way.\n        editor.execute('enter');\n        const newBlock = modelDoc.selection.anchor.parent;\n        // Make the cloned  a regular  (with clean attributes, so no language).\n        writer.rename(newBlock, DEFAULT_ELEMENT);\n        editor.model.schema.removeDisallowedAttributes([newBlock], writer);\n    });\n    // Eye candy.\n    view.scrollToTheSelection();\n    return true;\n}\nfunction isEmptyishTextNode(node) {\n    return node && node.is('$text') && !node.data.match(/\\S/);\n}\nfunction isSoftBreakNode(node) {\n    return node && node.is('element', 'softBreak');\n}\n","export default \"\";","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module code-block/codeblockui\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { Collection } from 'ckeditor5/src/utils.js';\nimport { UIModel, SplitButtonView, createDropdown, addListToDropdown, MenuBarMenuListItemButtonView, MenuBarMenuListView, MenuBarMenuView, MenuBarMenuListItemView } from 'ckeditor5/src/ui.js';\nimport { IconCodeBlock } from 'ckeditor5/src/icons.js';\nimport { getNormalizedAndLocalizedLanguageDefinitions } from './utils.js';\nimport '../theme/codeblock.css';\n/**\n * The code block UI plugin.\n *\n * Introduces the `'codeBlock'` dropdown.\n */\nexport class CodeBlockUI extends Plugin {\n    /**\n     * @inheritDoc\n     */\n    static get pluginName() {\n        return 'CodeBlockUI';\n    }\n    /**\n     * @inheritDoc\n     */\n    static get isOfficialPlugin() {\n        return true;\n    }\n    /**\n     * @inheritDoc\n     */\n    init() {\n        const editor = this.editor;\n        const t = editor.t;\n        const componentFactory = editor.ui.componentFactory;\n        const normalizedLanguageDefs = getNormalizedAndLocalizedLanguageDefinitions(editor);\n        const itemDefinitions = this._getLanguageListItemDefinitions(normalizedLanguageDefs);\n        const command = editor.commands.get('codeBlock');\n        componentFactory.add('codeBlock', locale => {\n            const dropdownView = createDropdown(locale, SplitButtonView);\n            const splitButtonView = dropdownView.buttonView;\n            const accessibleLabel = t('Insert code block');\n            splitButtonView.set({\n                label: accessibleLabel,\n                tooltip: true,\n                icon: IconCodeBlock,\n                isToggleable: true\n            });\n            splitButtonView.bind('isOn').to(command, 'value', value => !!value);\n            splitButtonView.on('execute', () => {\n                editor.execute('codeBlock', {\n                    usePreviousLanguageChoice: true\n                });\n                editor.editing.view.focus();\n            });\n            dropdownView.on('execute', evt => {\n                editor.execute('codeBlock', {\n                    language: evt.source._codeBlockLanguage,\n                    forceValue: true\n                });\n                editor.editing.view.focus();\n            });\n            dropdownView.class = 'ck-code-block-dropdown';\n            dropdownView.bind('isEnabled').to(command);\n            addListToDropdown(dropdownView, itemDefinitions, {\n                role: 'menu',\n                ariaLabel: accessibleLabel\n            });\n            return dropdownView;\n        });\n        componentFactory.add('menuBar:codeBlock', locale => {\n            const menuView = new MenuBarMenuView(locale);\n            menuView.buttonView.set({\n                role: 'menuitem',\n                label: t('Code block'),\n                icon: IconCodeBlock\n            });\n            menuView.bind('isEnabled').to(command);\n            const listView = new MenuBarMenuListView(locale);\n            listView.set({\n                ariaLabel: t('Insert code block')\n            });\n            for (const definition of itemDefinitions) {\n                const listItemView = new MenuBarMenuListItemView(locale, menuView);\n                const buttonView = new MenuBarMenuListItemButtonView(locale);\n                buttonView.bind(...Object.keys(definition.model)).to(definition.model);\n                buttonView.set({\n                    isToggleable: true,\n                    role: 'menuitemcheckbox'\n                });\n                buttonView.delegate('execute').to(menuView);\n                buttonView.on('execute', () => {\n                    editor.execute('codeBlock', {\n                        language: definition.model._codeBlockLanguage,\n                        forceValue: command.value == definition.model._codeBlockLanguage ? false : true\n                    });\n                    editor.editing.view.focus();\n                });\n                listItemView.children.add(buttonView);\n                listView.items.add(listItemView);\n            }\n            menuView.panelView.children.add(listView);\n            return menuView;\n        });\n    }\n    /**\n     * A helper returning a collection of the `codeBlock` dropdown items representing languages\n     * available for the user to choose from.\n     */\n    _getLanguageListItemDefinitions(normalizedLanguageDefs) {\n        const editor = this.editor;\n        const command = editor.commands.get('codeBlock');\n        const itemDefinitions = new Collection();\n        for (const languageDef of normalizedLanguageDefs) {\n            const definition = {\n                type: 'button',\n                model: new UIModel({\n                    _codeBlockLanguage: languageDef.language,\n                    label: languageDef.label,\n                    role: 'menuitemradio',\n                    withText: true\n                })\n            };\n            definition.model.bind('isOn').to(command, 'value', value => {\n                return value === definition.model._codeBlockLanguage;\n            });\n            itemDefinitions.add(definition);\n        }\n        return itemDefinitions;\n    }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module list/listproperties/liststartcommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { first } from 'ckeditor5/src/utils.js';\nimport { expandListBlocksToCompleteList, isListItemBlock, isNumberedListType } from '../list/utils/model.js';\n/**\n * The list start index command. It changes the `listStart` attribute of the selected list items,\n * letting the user to choose the starting point of an ordered list.\n * It is used by the {@link module:list/listproperties~ListProperties list properties feature}.\n */\nexport class ListStartCommand extends Command {\n    /**\n     * @inheritDoc\n     */\n    refresh() {\n        const value = this._getValue();\n        this.value = value;\n        this.isEnabled = value != null;\n    }\n    /**\n     * Executes the command.\n     *\n     * @fires execute\n     * @param options Execute options.\n     * @param options.startIndex The list start index.\n     */\n    execute({ startIndex = 1 } = {}) {\n        const model = this.editor.model;\n        const document = model.document;\n        let blocks = Array.from(document.selection.getSelectedBlocks())\n            .filter(block => isListItemBlock(block) &&\n            isNumberedListType(block.getAttribute('listType')));\n        blocks = expandListBlocksToCompleteList(blocks);\n        model.change(writer => {\n            for (const block of blocks) {\n                writer.setAttribute('listStart', startIndex >= 0 ? startIndex : 1, block);\n            }\n        });\n    }\n    /**\n     * Checks the command's {@link #value}.\n     *\n     * @returns The current value.\n     */\n    _getValue() {\n        const model = this.editor.model;\n        const document = model.document;\n        const block = first(document.selection.getSelectedBlocks());\n        if (block &&\n            isListItemBlock(block) &&\n            isNumberedListType(block.getAttribute('listType'))) {\n            return block.getAttribute('listStart');\n        }\n        return null;\n    }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n* @module list/listproperties/utils/style\n*/\nconst LIST_STYLE_TO_LIST_TYPE = {};\nconst LIST_STYLE_TO_TYPE_ATTRIBUTE = {};\nconst TYPE_ATTRIBUTE_TO_LIST_STYLE = {};\nconst LIST_STYLE_TYPES = [\n    { listStyle: 'disc', typeAttribute: 'disc', listType: 'bulleted' },\n    { listStyle: 'circle', typeAttribute: 'circle', listType: 'bulleted' },\n    { listStyle: 'square', typeAttribute: 'square', listType: 'bulleted' },\n    { listStyle: 'decimal', typeAttribute: '1', listType: 'numbered' },\n    { listStyle: 'decimal-leading-zero', typeAttribute: null, listType: 'numbered' },\n    { listStyle: 'lower-roman', typeAttribute: 'i', listType: 'numbered' },\n    { listStyle: 'upper-roman', typeAttribute: 'I', listType: 'numbered' },\n    { listStyle: 'lower-alpha', typeAttribute: 'a', listType: 'numbered' },\n    { listStyle: 'upper-alpha', typeAttribute: 'A', listType: 'numbered' },\n    { listStyle: 'lower-latin', typeAttribute: 'a', listType: 'numbered' },\n    { listStyle: 'upper-latin', typeAttribute: 'A', listType: 'numbered' }\n];\nfor (const { listStyle, typeAttribute, listType } of LIST_STYLE_TYPES) {\n    LIST_STYLE_TO_LIST_TYPE[listStyle] = listType;\n    LIST_STYLE_TO_TYPE_ATTRIBUTE[listStyle] = typeAttribute;\n    if (typeAttribute) {\n        TYPE_ATTRIBUTE_TO_LIST_STYLE[typeAttribute] = listStyle;\n    }\n}\n/**\n * Gets all the style types supported by given list type.\n *\n * @internal\n */\nexport function getAllSupportedStyleTypes() {\n    return LIST_STYLE_TYPES.map(x => x.listStyle);\n}\n/**\n * Checks whether the given list-style-type is supported by numbered or bulleted list.\n *\n * @internal\n */\nexport function getListTypeFromListStyleType(listStyleType) {\n    return LIST_STYLE_TO_LIST_TYPE[listStyleType] || null;\n}\n/**\n * Converts `type` attribute of `
      ` or `
        ` elements to `list-style-type` equivalent.\n *\n * @internal\n */\nexport function getListStyleTypeFromTypeAttribute(value) {\n return TYPE_ATTRIBUTE_TO_LIST_STYLE[value] || null;\n}\n/**\n * Converts `list-style-type` style to `type` attribute of `
          ` or `
            ` elements.\n *\n * @internal\n */\nexport function getTypeAttributeFromListStyleType(value) {\n return LIST_STYLE_TO_TYPE_ATTRIBUTE[value] || null;\n}\n/**\n * Normalizes list style by converting aliases to their canonical form.\n *\n * @internal\n * @param listStyle The list style value to normalize.\n * @returns The canonical form of the list style.\n *\n * @example\n * normalizeListStyle( 'lower-alpha' ); // Returns 'lower-latin'\n * normalizeListStyle( 'upper-alpha' ); // Returns 'upper-latin'\n * normalizeListStyle( 'disc' ); // Returns 'disc'\n */\nexport function normalizeListStyle(listStyle) {\n switch (listStyle) {\n case 'lower-alpha':\n return 'lower-latin';\n case 'upper-alpha':\n return 'upper-latin';\n default:\n return listStyle;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module list/listproperties/liststylecommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { first } from 'ckeditor5/src/utils.js';\nimport { expandListBlocksToCompleteList, isListItemBlock } from '../list/utils/model.js';\nimport { getListTypeFromListStyleType } from './utils/style.js';\n/**\n * The list style command. It changes `listStyle` attribute of the selected list items,\n * letting the user choose styles for the list item markers.\n * It is used by the {@link module:list/listproperties~ListProperties list properties feature}.\n */\nexport class ListStyleCommand extends Command {\n /**\n * The default type of the list style.\n */\n defaultType;\n /**\n * The list of supported style types by this command.\n */\n _supportedTypes;\n /**\n * Creates an instance of the command.\n *\n * @param editor The editor instance.\n * @param defaultType The list type that will be used by default if the value was not specified during\n * the command execution.\n * @param supportedTypes The list of supported style types by this command.\n */\n constructor(editor, defaultType, supportedTypes) {\n super(editor);\n this.defaultType = defaultType;\n this._supportedTypes = supportedTypes;\n }\n /**\n * @inheritDoc\n */\n refresh() {\n this.value = this._getValue();\n this.isEnabled = this._checkEnabled();\n }\n /**\n * Executes the command.\n *\n * @fires execute\n * @param options.type The type of the list style, e.g. `'disc'` or `'square'`. If `null` is specified, the default\n * style will be applied.\n */\n execute(options = {}) {\n const model = this.editor.model;\n const document = model.document;\n model.change(writer => {\n this._tryToConvertItemsToList(options);\n let blocks = Array.from(document.selection.getSelectedBlocks())\n .filter(block => block.hasAttribute('listType'));\n if (!blocks.length) {\n return;\n }\n blocks = expandListBlocksToCompleteList(blocks);\n for (const block of blocks) {\n writer.setAttribute('listStyle', options.type || this.defaultType, block);\n }\n });\n }\n /**\n * Checks if the given style type is supported by this plugin.\n */\n isStyleTypeSupported(value) {\n if (!this._supportedTypes) {\n return true;\n }\n return this._supportedTypes.includes(value);\n }\n /**\n * Checks the command's {@link #value}.\n *\n * @returns The current value.\n */\n _getValue() {\n const listItem = first(this.editor.model.document.selection.getSelectedBlocks());\n if (isListItemBlock(listItem)) {\n return listItem.getAttribute('listStyle');\n }\n return null;\n }\n /**\n * Checks whether the command can be enabled in the current context.\n *\n * @returns Whether the command should be enabled.\n */\n _checkEnabled() {\n const editor = this.editor;\n const numberedList = editor.commands.get('numberedList');\n const bulletedList = editor.commands.get('bulletedList');\n return numberedList.isEnabled || bulletedList.isEnabled;\n }\n /**\n * Check if the provided list style is valid. Also change the selection to a list if it's not set yet.\n *\n * @param options.type The type of the list style. If `null` is specified, the function does nothing.\n */\n _tryToConvertItemsToList(options) {\n if (!options.type) {\n return;\n }\n const listType = getListTypeFromListStyleType(options.type);\n if (!listType) {\n return;\n }\n const editor = this.editor;\n const commandName = `${listType}List`;\n const command = editor.commands.get(commandName);\n if (!command.value) {\n editor.execute(commandName);\n }\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module list/listproperties/listreversedcommand\n */\nimport { Command } from 'ckeditor5/src/core.js';\nimport { first } from 'ckeditor5/src/utils.js';\nimport { expandListBlocksToCompleteList, isListItemBlock } from '../list/utils/model.js';\n/**\n * The list reversed command. It changes the `listReversed` attribute of the selected list items,\n * letting the user to choose the order of an ordered list.\n * It is used by the {@link module:list/listproperties~ListProperties list properties feature}.\n */\nexport class ListReversedCommand extends Command {\n /**\n * @inheritDoc\n */\n refresh() {\n const value = this._getValue();\n this.value = value;\n this.isEnabled = value != null;\n }\n /**\n * Executes the command.\n *\n * @fires execute\n * @param options.reversed Whether the list should be reversed.\n */\n execute(options = {}) {\n const model = this.editor.model;\n const document = model.document;\n let blocks = Array.from(document.selection.getSelectedBlocks())\n .filter(block => isListItemBlock(block) && block.getAttribute('listType') == 'numbered');\n blocks = expandListBlocksToCompleteList(blocks);\n model.change(writer => {\n for (const block of blocks) {\n writer.setAttribute('listReversed', !!options.reversed, block);\n }\n });\n }\n /**\n * Checks the command's {@link #value}.\n */\n _getValue() {\n const model = this.editor.model;\n const document = model.document;\n const block = first(document.selection.getSelectedBlocks());\n if (isListItemBlock(block) && block.getAttribute('listType') == 'numbered') {\n return block.getAttribute('listReversed');\n }\n return null;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * Returns a converter that consumes the `style`, `reversed`, and `start` attributes.\n * In `style`, it searches for the `list-style-type` definition.\n * If not found, the `\"default\"` value will be used.\n *\n * @internal\n * @param strategy\n */\nexport function listPropertiesUpcastConverter(strategy) {\n return (evt, data, conversionApi) => {\n const { writer, schema, consumable } = conversionApi;\n // If there is no view consumable to consume, set the default attribute value to be able to reconvert nested lists on parent change.\n // So abort converting if attribute was directly consumed.\n if (consumable.test(data.viewItem, strategy.viewConsumables) === false) {\n return;\n }\n if (!data.modelRange) {\n Object.assign(data, conversionApi.convertChildren(data.viewItem, data.modelCursor));\n }\n let applied = false;\n for (const item of data.modelRange.getItems({ shallow: true })) {\n if (!schema.checkAttribute(item, strategy.attributeName)) {\n continue;\n }\n if (!strategy.appliesToListItem(item)) {\n continue;\n }\n // Set list attributes only on same level items, those nested deeper are already handled by the recursive conversion.\n if (item.hasAttribute(strategy.attributeName)) {\n continue;\n }\n writer.setAttribute(strategy.attributeName, strategy.getAttributeOnUpcast(data.viewItem), item);\n applied = true;\n }\n if (applied) {\n consumable.consume(data.viewItem, strategy.viewConsumables);\n }\n };\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module list/listproperties/listpropertiesutils\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { getAllSupportedStyleTypes, getListStyleTypeFromTypeAttribute, getListTypeFromListStyleType, getTypeAttributeFromListStyleType } from './utils/style.js';\n/**\n * A set of helpers related to document lists.\n */\nexport class ListPropertiesUtils extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'ListPropertiesUtils';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * Gets all the style types supported by given list type.\n */\n getAllSupportedStyleTypes() {\n return getAllSupportedStyleTypes();\n }\n /**\n * Checks whether the given list-style-type is supported by numbered or bulleted list.\n */\n getListTypeFromListStyleType(listStyleType) {\n return getListTypeFromListStyleType(listStyleType);\n }\n /**\n * Converts `type` attribute of `
              ` or `
                ` elements to `list-style-type` equivalent.\n */\n getListStyleTypeFromTypeAttribute(value) {\n return getListStyleTypeFromTypeAttribute(value);\n }\n /**\n * Converts `list-style-type` style to `type` attribute of `
                  ` or `
                    ` elements.\n */\n getTypeAttributeFromListStyleType(value) {\n return getTypeAttributeFromListStyleType(value);\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module list/listproperties/utils/config\n */\nimport { toArray } from 'ckeditor5/src/utils.js';\n/**\n * Normalizes {@link module:list/listconfig~ListPropertiesConfig} in the configuration of the list properties feature.\n * The structure of normalized list properties options looks as follows:\n *\n * ```ts\n * {\n * \tstyles: {\n * \t\tlistTypes: [ 'bulleted', 'numbered' ],\n * \t\tuseAttribute: false\n * \t},\n * \tstartIndex: true,\n * \treversed: true\n * }\n * ```\n *\n * @internal\n * @param config The list properties {@link module:list/listconfig~ListPropertiesConfig config}.\n * @returns An object with normalized list properties options.\n */\nexport function getNormalizedConfig(config) {\n const { startIndex, reversed, styles } = config;\n return {\n styles: getNormalizedStylesConfig(styles),\n startIndex: startIndex || false,\n reversed: reversed || false\n };\n}\n/**\n * Normalizes styles in the configuration of the list properties feature.\n * The structure of normalized list properties options looks as follows:\n *\n * ```ts\n * {\n * \tlistTypes: [ 'bulleted', 'numbered' ],\n * \tuseAttribute: false\n * }\n * ```\n *\n * @param styles The list properties styles.\n * @returns An object with normalized list properties styles.\n */\nfunction getNormalizedStylesConfig(styles) {\n const normalizedConfig = {\n listTypes: ['bulleted', 'numbered'],\n useAttribute: false\n };\n if (styles === true) {\n return normalizedConfig;\n }\n if (!styles) {\n normalizedConfig.listTypes = [];\n }\n else if (Array.isArray(styles) || typeof styles == 'string') {\n normalizedConfig.listTypes = toArray(styles);\n }\n else {\n normalizedConfig.listTypes = styles.listTypes ?\n toArray(styles.listTypes) :\n normalizedConfig.listTypes;\n normalizedConfig.useAttribute = !!styles.useAttribute;\n if (styles.listStyleTypes) {\n normalizedConfig.listStyleTypes = styles.listStyleTypes;\n }\n }\n return normalizedConfig;\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module list/listproperties/listpropertiesediting\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { ListEditing } from '../list/listediting.js';\nimport { ListStartCommand } from './liststartcommand.js';\nimport { ListStyleCommand } from './liststylecommand.js';\nimport { ListReversedCommand } from './listreversedcommand.js';\nimport { listPropertiesUpcastConverter } from './converters.js';\nimport { getAllSupportedStyleTypes, getListTypeFromListStyleType, getListStyleTypeFromTypeAttribute, getTypeAttributeFromListStyleType, normalizeListStyle } from './utils/style.js';\nimport { ListPropertiesUtils } from './listpropertiesutils.js';\nimport { isNumberedListType } from '../list/utils/model.js';\nimport { getNormalizedConfig } from './utils/config.js';\nconst DEFAULT_LIST_TYPE = 'default';\n/**\n * The document list properties engine feature.\n *\n * It registers the `'listStyle'`, `'listReversed'` and `'listStart'` commands if they are enabled in the configuration.\n * Read more in {@link module:list/listconfig~ListPropertiesConfig}.\n */\nexport class ListPropertiesEditing extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [ListEditing, ListPropertiesUtils];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'ListPropertiesEditing';\n }\n /**\n * @inheritDoc\n * @internal\n */\n static get licenseFeatureCode() {\n return 'LP';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get isPremiumPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n constructor(editor) {\n super(editor);\n editor.config.define('list.properties', {\n styles: true,\n startIndex: false,\n reversed: false\n });\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n const model = editor.model;\n const listEditing = editor.plugins.get(ListEditing);\n const enabledProperties = editor.config.get('list.properties');\n const strategies = createAttributeStrategies(enabledProperties);\n for (const strategy of strategies) {\n strategy.addCommand(editor);\n model.schema.extend('$listItem', { allowAttributes: strategy.attributeName });\n // Register downcast strategy.\n listEditing.registerDowncastStrategy({\n scope: 'list',\n attributeName: strategy.attributeName,\n setAttributeOnDowncast(writer, attributeValue, viewElement) {\n strategy.setAttributeOnDowncast(writer, attributeValue, viewElement);\n }\n });\n }\n // Set up conversion.\n editor.conversion.for('upcast').add(dispatcher => {\n for (const strategy of strategies) {\n dispatcher.on('element:ol', listPropertiesUpcastConverter(strategy));\n dispatcher.on('element:ul', listPropertiesUpcastConverter(strategy));\n }\n });\n // Verify if the list view element (ul or ol) requires refreshing.\n listEditing.on('checkAttributes:list', (evt, { viewElement, modelAttributes, modelReferenceElement }) => {\n for (const strategy of strategies) {\n if (!strategy.appliesToListItem(modelReferenceElement)) {\n continue;\n }\n if (strategy.getAttributeOnUpcast(viewElement) != modelAttributes[strategy.attributeName]) {\n evt.return = true;\n evt.stop();\n }\n }\n });\n // Reset list properties after indenting list items.\n this.listenTo(editor.commands.get('indentList'), 'afterExecute', (evt, changedBlocks) => {\n model.change(writer => {\n for (const node of changedBlocks) {\n for (const strategy of strategies) {\n if (strategy.appliesToListItem(node)) {\n // Just reset the attribute.\n // If there is a previous indented list that this node should be merged into,\n // the postfixer will unify all the attributes of both sub-lists.\n writer.setAttribute(strategy.attributeName, strategy.defaultValue, node);\n }\n }\n }\n });\n });\n // Add or remove list properties attributes depending on the list type.\n listEditing.on('postFixer', (evt, { listNodes, writer }) => {\n for (const { node } of listNodes) {\n for (const strategy of strategies) {\n // Check if attribute is valid.\n if (strategy.hasValidAttribute(node)) {\n continue;\n }\n // Add missing default property attributes...\n if (strategy.appliesToListItem(node)) {\n writer.setAttribute(strategy.attributeName, strategy.defaultValue, node);\n }\n // ...or remove invalid property attributes.\n else {\n writer.removeAttribute(strategy.attributeName, node);\n }\n evt.return = true;\n }\n }\n });\n // Make sure that all items in a single list (items at the same level & listType) have the same properties.\n listEditing.on('postFixer', (evt, { listNodes, writer }) => {\n for (const { node, previousNodeInList } of listNodes) {\n // This is a first item of a nested list.\n if (!previousNodeInList) {\n continue;\n }\n // This is a first block of a list of a different type.\n if (previousNodeInList.getAttribute('listType') != node.getAttribute('listType')) {\n continue;\n }\n // Copy properties from the previous one.\n for (const strategy of strategies) {\n const { attributeName } = strategy;\n if (!strategy.appliesToListItem(node)) {\n continue;\n }\n const value = previousNodeInList.getAttribute(attributeName);\n if (node.getAttribute(attributeName) != value) {\n writer.setAttribute(attributeName, value, node);\n evt.return = true;\n }\n }\n }\n });\n }\n}\n/**\n * Creates an array of strategies for dealing with enabled listItem attributes.\n */\nfunction createAttributeStrategies(enabledProperties) {\n const strategies = [];\n const normalizedConfig = getNormalizedConfig(enabledProperties);\n if (enabledProperties.styles) {\n const useAttribute = normalizedConfig.styles.useAttribute;\n strategies.push({\n attributeName: 'listStyle',\n defaultValue: DEFAULT_LIST_TYPE,\n viewConsumables: { styles: 'list-style-type' },\n addCommand(editor) {\n let supportedTypes = getAllSupportedStyleTypes();\n if (useAttribute) {\n supportedTypes = supportedTypes.filter(styleType => !!getTypeAttributeFromListStyleType(styleType));\n }\n editor.commands.add('listStyle', new ListStyleCommand(editor, DEFAULT_LIST_TYPE, supportedTypes));\n },\n appliesToListItem(item) {\n return item.getAttribute('listType') == 'numbered' || item.getAttribute('listType') == 'bulleted';\n },\n hasValidAttribute(item) {\n if (!this.appliesToListItem(item)) {\n return !item.hasAttribute('listStyle');\n }\n if (!item.hasAttribute('listStyle')) {\n return false;\n }\n const value = item.getAttribute('listStyle');\n if (value == DEFAULT_LIST_TYPE) {\n return true;\n }\n return getListTypeFromListStyleType(value) == item.getAttribute('listType');\n },\n setAttributeOnDowncast(writer, listStyle, element) {\n if (listStyle && listStyle !== DEFAULT_LIST_TYPE) {\n if (useAttribute) {\n const value = getTypeAttributeFromListStyleType(listStyle);\n if (value) {\n writer.setAttribute('type', value, element);\n return;\n }\n }\n else {\n writer.setStyle('list-style-type', listStyle, element);\n return;\n }\n }\n writer.removeStyle('list-style-type', element);\n writer.removeAttribute('type', element);\n },\n getAttributeOnUpcast(listParent) {\n const style = listParent.getStyle('list-style-type');\n if (style) {\n return normalizeListStyle(style);\n }\n const attribute = listParent.getAttribute('type');\n if (attribute) {\n return getListStyleTypeFromTypeAttribute(attribute);\n }\n return DEFAULT_LIST_TYPE;\n }\n });\n }\n if (enabledProperties.reversed) {\n strategies.push({\n attributeName: 'listReversed',\n defaultValue: false,\n viewConsumables: { attributes: 'reversed' },\n addCommand(editor) {\n editor.commands.add('listReversed', new ListReversedCommand(editor));\n },\n appliesToListItem(item) {\n return item.getAttribute('listType') == 'numbered';\n },\n hasValidAttribute(item) {\n return this.appliesToListItem(item) == item.hasAttribute('listReversed');\n },\n setAttributeOnDowncast(writer, listReversed, element) {\n if (listReversed) {\n writer.setAttribute('reversed', 'reversed', element);\n }\n else {\n writer.removeAttribute('reversed', element);\n }\n },\n getAttributeOnUpcast(listParent) {\n return listParent.hasAttribute('reversed');\n }\n });\n }\n if (enabledProperties.startIndex) {\n strategies.push({\n attributeName: 'listStart',\n defaultValue: 1,\n viewConsumables: { attributes: 'start' },\n addCommand(editor) {\n editor.commands.add('listStart', new ListStartCommand(editor));\n },\n appliesToListItem(item) {\n return isNumberedListType(item.getAttribute('listType'));\n },\n hasValidAttribute(item) {\n return this.appliesToListItem(item) == item.hasAttribute('listStart');\n },\n setAttributeOnDowncast(writer, listStart, element) {\n if (listStart == 0 || listStart > 1) {\n writer.setAttribute('start', listStart, element);\n }\n else {\n writer.removeAttribute('start', element);\n }\n },\n getAttributeOnUpcast(listParent) {\n const startAttributeValue = listParent.getAttribute('start');\n return startAttributeValue >= 0 ? startAttributeValue : 1;\n }\n });\n }\n return strategies;\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module list/listproperties/ui/listpropertiesview\n */\nimport { ButtonView, View, ViewCollection, FocusCycler, SwitchButtonView, LabeledFieldView, createLabeledInputNumber, addKeyboardHandlingForGrid, CollapsibleView } from 'ckeditor5/src/ui.js';\nimport { FocusTracker, KeystrokeHandler, global } from 'ckeditor5/src/utils.js';\nimport '../../../theme/listproperties.css';\n/**\n * The list properties view to be displayed in the list dropdown.\n *\n * Contains a grid of available list styles and, for numbered list, also the list start index and reversed fields.\n *\n * @internal\n */\nexport class ListPropertiesView extends View {\n /**\n * A collection of the child views.\n */\n children;\n /**\n * A view that renders the grid of list styles.\n */\n stylesView = null;\n /**\n * A collapsible view that hosts additional list property fields ({@link #startIndexFieldView} and\n * {@link #reversedSwitchButtonView}) to visually separate them from the {@link #stylesView grid of styles}.\n *\n * **Note**: Only present when:\n * * the view represents **numbered** list properties,\n * * and the {@link #stylesView} is rendered,\n * * and either {@link #startIndexFieldView} or {@link #reversedSwitchButtonView} is rendered.\n *\n * @readonly\n */\n additionalPropertiesCollapsibleView = null;\n /**\n * A labeled number field allowing the user to set the start index of the list.\n *\n * **Note**: Only present when the view represents **numbered** list properties.\n *\n * @readonly\n */\n startIndexFieldView = null;\n /**\n * A switch button allowing the user to make the edited list reversed.\n *\n * **Note**: Only present when the view represents **numbered** list properties.\n *\n * @readonly\n */\n reversedSwitchButtonView = null;\n /**\n * Tracks information about the DOM focus in the view.\n */\n focusTracker = new FocusTracker();\n /**\n * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.\n */\n keystrokes = new KeystrokeHandler();\n /**\n * A collection of views that can be focused in the properties view.\n */\n focusables = new ViewCollection();\n /**\n * Helps cycling over {@link #focusables} in the view.\n */\n focusCycler;\n /**\n * Creates an instance of the list properties view.\n *\n * @param locale The {@link module:core/editor/editor~Editor#locale} instance.\n * @param options Options of the view.\n * @param options.enabledProperties An object containing the configuration of enabled list property names.\n * Allows conditional rendering the sub-components of the properties view.\n * @param options.styleButtonViews A list of style buttons to be rendered\n * inside the styles grid. The grid will not be rendered when `enabledProperties` does not include the `'styles'` key.\n * @param options.styleGridAriaLabel An assistive technologies label set on the grid of styles (if the grid is rendered).\n */\n constructor(locale, { enabledProperties, styleButtonViews, styleGridAriaLabel }) {\n super(locale);\n const elementCssClasses = [\n 'ck',\n 'ck-list-properties'\n ];\n this.children = this.createCollection();\n this.focusCycler = new FocusCycler({\n focusables: this.focusables,\n focusTracker: this.focusTracker,\n keystrokeHandler: this.keystrokes,\n actions: {\n // Navigate #children backwards using the Shift + Tab keystroke.\n focusPrevious: 'shift + tab',\n // Navigate #children forwards using the Tab key.\n focusNext: 'tab'\n }\n });\n // The rendering of the styles grid is conditional. When there is no styles grid, the view will render without collapsible\n // for numbered list properties, hence simplifying the layout.\n if (styleButtonViews && styleButtonViews.length) {\n this.stylesView = this._createStylesView(styleButtonViews, styleGridAriaLabel);\n this.children.add(this.stylesView);\n }\n else {\n elementCssClasses.push('ck-list-properties_without-styles');\n }\n // The rendering of the numbered list property views is also conditional. It only makes sense for the numbered list\n // dropdown. The unordered list does not have such properties.\n if (enabledProperties.startIndex || enabledProperties.reversed) {\n this._addNumberedListPropertyViews(enabledProperties);\n elementCssClasses.push('ck-list-properties_with-numbered-properties');\n }\n this.setTemplate({\n tag: 'div',\n attributes: {\n class: elementCssClasses\n },\n children: this.children\n });\n }\n /**\n * @inheritDoc\n */\n render() {\n super.render();\n if (this.stylesView) {\n this.focusables.add(this.stylesView);\n this.focusTracker.add(this.stylesView.element);\n // Register the collapsible toggle button to the focus system.\n if (this.startIndexFieldView || this.reversedSwitchButtonView) {\n this.focusables.add(this.children.last.buttonView);\n this.focusTracker.add(this.children.last.buttonView.element);\n }\n for (const item of this.stylesView.children) {\n this.stylesView.focusTracker.add(item.element);\n }\n addKeyboardHandlingForGrid({\n keystrokeHandler: this.stylesView.keystrokes,\n focusTracker: this.stylesView.focusTracker,\n gridItems: this.stylesView.children,\n // Note: The styles view has a different number of columns depending on whether the other properties\n // are enabled in the dropdown or not (https://github.com/ckeditor/ckeditor5/issues/12340)\n numberOfColumns: () => global.window\n .getComputedStyle(this.stylesView.element)\n .getPropertyValue('grid-template-columns')\n .split(' ')\n .length,\n uiLanguageDirection: this.locale && this.locale.uiLanguageDirection\n });\n }\n if (this.startIndexFieldView) {\n this.focusables.add(this.startIndexFieldView);\n this.focusTracker.add(this.startIndexFieldView.element);\n const stopPropagation = (data) => data.stopPropagation();\n // Since the form is in the dropdown panel which is a child of the toolbar, the toolbar's\n // keystroke handler would take over the key management in the input. We need to prevent\n // this ASAP. Otherwise, the basic caret movement using the arrow keys will be impossible.\n this.keystrokes.set('arrowright', stopPropagation);\n this.keystrokes.set('arrowleft', stopPropagation);\n this.keystrokes.set('arrowup', stopPropagation);\n this.keystrokes.set('arrowdown', stopPropagation);\n }\n if (this.reversedSwitchButtonView) {\n this.focusables.add(this.reversedSwitchButtonView);\n this.focusTracker.add(this.reversedSwitchButtonView.element);\n }\n // Start listening for the keystrokes coming from #element.\n this.keystrokes.listenTo(this.element);\n }\n /**\n * @inheritDoc\n */\n focus() {\n this.focusCycler.focusFirst();\n }\n /**\n * @inheritDoc\n */\n focusLast() {\n this.focusCycler.focusLast();\n }\n /**\n * @inheritDoc\n */\n destroy() {\n super.destroy();\n this.focusTracker.destroy();\n this.keystrokes.destroy();\n }\n /**\n * Creates the list styles grid.\n *\n * @param styleButtons Buttons to be placed in the grid.\n * @param styleGridAriaLabel The assistive technology label of the grid.\n */\n _createStylesView(styleButtons, styleGridAriaLabel) {\n const stylesView = new View(this.locale);\n stylesView.children = stylesView.createCollection();\n stylesView.children.addMany(styleButtons);\n stylesView.setTemplate({\n tag: 'div',\n attributes: {\n 'aria-label': styleGridAriaLabel,\n class: [\n 'ck',\n 'ck-list-styles-list'\n ]\n },\n children: stylesView.children\n });\n stylesView.children.delegate('execute').to(this);\n stylesView.focus = function () {\n // If there is a button that is already on, focus it.\n // It's counterintuitive to focus the first button when there is already a button on.\n for (const child of this.children) {\n if (child instanceof ButtonView && child.isOn) {\n child.focus();\n return;\n }\n }\n // ... otherwise focus the first button.\n this.children.first.focus();\n };\n stylesView.focusTracker = new FocusTracker();\n stylesView.keystrokes = new KeystrokeHandler();\n stylesView.render();\n stylesView.keystrokes.listenTo(stylesView.element);\n return stylesView;\n }\n /**\n * Renders {@link #startIndexFieldView} and/or {@link #reversedSwitchButtonView} depending on the configuration of the properties view.\n *\n * @param enabledProperties An object containing the configuration of enabled list property names\n * (see {@link #constructor}).\n */\n _addNumberedListPropertyViews(enabledProperties) {\n const t = this.locale.t;\n const numberedPropertyViews = [];\n if (enabledProperties.startIndex) {\n this.startIndexFieldView = this._createStartIndexField();\n numberedPropertyViews.push(this.startIndexFieldView);\n }\n if (enabledProperties.reversed) {\n this.reversedSwitchButtonView = this._createReversedSwitchButton();\n numberedPropertyViews.push(this.reversedSwitchButtonView);\n }\n // When there are some style buttons, pack the numbered list properties into a collapsible to separate them.\n if (this.stylesView) {\n this.additionalPropertiesCollapsibleView = new CollapsibleView(this.locale, numberedPropertyViews);\n this.additionalPropertiesCollapsibleView.set({\n label: t('List properties'),\n isCollapsed: true\n });\n // Don't enable the collapsible view unless either start index or reversed field is enabled (e.g. when no list is selected).\n this.additionalPropertiesCollapsibleView.buttonView.bind('isEnabled').toMany(numberedPropertyViews, 'isEnabled', (...areEnabled) => areEnabled.some(isEnabled => isEnabled));\n // Automatically collapse the additional properties collapsible when either start index or reversed field gets disabled.\n this.additionalPropertiesCollapsibleView.buttonView.on('change:isEnabled', (evt, data, isEnabled) => {\n if (!isEnabled) {\n this.additionalPropertiesCollapsibleView.isCollapsed = true;\n }\n });\n this.children.add(this.additionalPropertiesCollapsibleView);\n }\n else {\n this.children.addMany(numberedPropertyViews);\n }\n }\n /**\n * Creates the list start index labeled field.\n */\n _createStartIndexField() {\n const t = this.locale.t;\n const startIndexFieldView = new LabeledFieldView(this.locale, createLabeledInputNumber);\n startIndexFieldView.set({\n label: t('Start at'),\n class: 'ck-numbered-list-properties__start-index'\n });\n startIndexFieldView.fieldView.set({\n min: 0,\n step: 1,\n value: 1,\n inputMode: 'numeric'\n });\n startIndexFieldView.fieldView.on('input', () => {\n const inputElement = startIndexFieldView.fieldView.element;\n const startIndex = inputElement.valueAsNumber;\n if (Number.isNaN(startIndex)) {\n // Number inputs allow for the entry of characters that may result in NaN,\n // such as 'e', '+', '123e', '2-'.\n startIndexFieldView.errorText = t('Invalid start index value.');\n return;\n }\n if (!inputElement.checkValidity()) {\n startIndexFieldView.errorText = t('Start index must be greater than 0.');\n }\n else {\n this.fire('listStart', { startIndex });\n }\n });\n return startIndexFieldView;\n }\n /**\n * Creates the reversed list switch button.\n */\n _createReversedSwitchButton() {\n const t = this.locale.t;\n const reversedButtonView = new SwitchButtonView(this.locale);\n reversedButtonView.set({\n withText: true,\n label: t('Reversed order'),\n class: 'ck-numbered-list-properties__reversed-order'\n });\n reversedButtonView.delegate('execute').to(this, 'listReversed');\n return reversedButtonView;\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module list/listproperties/listpropertiesui\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { IconBulletedList, IconNumberedList, IconListStyleCircle, IconListStyleDecimal, IconListStyleDecimalLeadingZero, IconListStyleDisc, IconListStyleLowerLatin, IconListStyleLowerRoman, IconListStyleSquare, IconListStyleUpperLatin, IconListStyleUpperRoman } from 'ckeditor5/src/icons.js';\nimport { ButtonView, SplitButtonView, createDropdown, focusChildOnDropdownOpen, MenuBarMenuView } from 'ckeditor5/src/ui.js';\nimport { ListPropertiesView } from './ui/listpropertiesview.js';\nimport { getNormalizedConfig } from './utils/config.js';\nimport '../../theme/liststyles.css';\n/**\n * The list properties UI plugin. It introduces the extended `'bulletedList'` and `'numberedList'` toolbar\n * buttons that allow users to control such aspects of list as the marker, start index or order.\n *\n * **Note**: Buttons introduced by this plugin override implementations from the {@link module:list/list/listui~ListUI}\n * (because they share the same names).\n */\nexport class ListPropertiesUI extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'ListPropertiesUI';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n init() {\n const editor = this.editor;\n const t = editor.locale.t;\n const propertiesConfig = editor.config.get('list.properties');\n const normalizedConfig = getNormalizedConfig(propertiesConfig);\n const stylesListTypes = normalizedConfig.styles.listTypes;\n // Note: When this plugin does not register the \"bulletedList\" dropdown due to properties configuration,\n // a simple button will be still registered under the same name by ListUI as a fallback. This should happen\n // in most editor configuration because the List plugin automatically requires ListUI.\n if (stylesListTypes.includes('bulleted')) {\n const styleDefinitions = [\n {\n label: t('Toggle the disc list style'),\n tooltip: t('Disc'),\n type: 'disc',\n icon: IconListStyleDisc\n },\n {\n label: t('Toggle the circle list style'),\n tooltip: t('Circle'),\n type: 'circle',\n icon: IconListStyleCircle\n },\n {\n label: t('Toggle the square list style'),\n tooltip: t('Square'),\n type: 'square',\n icon: IconListStyleSquare\n }\n ];\n const buttonLabel = t('Bulleted List');\n const styleGridAriaLabel = t('Bulleted list styles toolbar');\n const commandName = 'bulletedList';\n editor.ui.componentFactory.add(commandName, getDropdownViewCreator({\n editor,\n normalizedConfig,\n parentCommandName: commandName,\n buttonLabel,\n buttonIcon: IconBulletedList,\n styleGridAriaLabel,\n styleDefinitions\n }));\n // Add the menu bar item for bulleted list.\n editor.ui.componentFactory.add(`menuBar:${commandName}`, getMenuBarStylesMenuCreator({\n editor,\n normalizedConfig,\n parentCommandName: commandName,\n buttonLabel,\n styleGridAriaLabel,\n styleDefinitions\n }));\n }\n // Note: When this plugin does not register the \"numberedList\" dropdown due to properties configuration,\n // a simple button will be still registered under the same name by ListUI as a fallback. This should happen\n // in most editor configuration because the List plugin automatically requires ListUI.\n if (stylesListTypes.includes('numbered') || propertiesConfig.startIndex || propertiesConfig.reversed) {\n const styleDefinitions = [\n {\n label: t('Toggle the decimal list style'),\n tooltip: t('Decimal'),\n type: 'decimal',\n icon: IconListStyleDecimal\n },\n {\n label: t('Toggle the decimal with leading zero list style'),\n tooltip: t('Decimal with leading zero'),\n type: 'decimal-leading-zero',\n icon: IconListStyleDecimalLeadingZero\n },\n {\n label: t('Toggle the lower–roman list style'),\n tooltip: t('Lower–roman'),\n type: 'lower-roman',\n icon: IconListStyleLowerRoman\n },\n {\n label: t('Toggle the upper–roman list style'),\n tooltip: t('Upper-roman'),\n type: 'upper-roman',\n icon: IconListStyleUpperRoman\n },\n {\n label: t('Toggle the lower–latin list style'),\n tooltip: t('Lower-latin'),\n type: 'lower-latin',\n icon: IconListStyleLowerLatin\n },\n {\n label: t('Toggle the upper–latin list style'),\n tooltip: t('Upper-latin'),\n type: 'upper-latin',\n icon: IconListStyleUpperLatin\n }\n ];\n const buttonLabel = t('Numbered List');\n const styleGridAriaLabel = t('Numbered list styles toolbar');\n const commandName = 'numberedList';\n editor.ui.componentFactory.add(commandName, getDropdownViewCreator({\n editor,\n normalizedConfig,\n parentCommandName: commandName,\n buttonLabel,\n buttonIcon: IconNumberedList,\n styleGridAriaLabel,\n styleDefinitions\n }));\n // Menu bar menu does not display list start index or reverse UI. If there are no styles enabled,\n // the menu makes no sense and should be omitted.\n if (stylesListTypes.includes('numbered')) {\n editor.ui.componentFactory.add(`menuBar:${commandName}`, getMenuBarStylesMenuCreator({\n editor,\n normalizedConfig,\n parentCommandName: commandName,\n buttonLabel,\n styleGridAriaLabel,\n styleDefinitions\n }));\n }\n }\n }\n}\n/**\n * A helper that returns a function that creates a split button with a toolbar in the dropdown,\n * which in turn contains buttons allowing users to change list styles in the context of the current selection.\n *\n * @param options.editor\n * @param options.normalizedConfig List properties configuration.\n * @param options.parentCommandName The name of the higher-order editor command associated with\n * the set of particular list styles (e.g. \"bulletedList\" for \"disc\", \"circle\", and \"square\" styles).\n * @param options.buttonLabel Label of the main part of the split button.\n * @param options.buttonIcon The SVG string of an icon for the main part of the split button.\n * @param options.styleGridAriaLabel The ARIA label for the styles grid in the split button dropdown.\n * @param options.styleDefinitions Definitions of the style buttons.\n * @returns A function that can be passed straight into {@link module:ui/componentfactory~ComponentFactory#add}.\n */\nfunction getDropdownViewCreator({ editor, normalizedConfig, parentCommandName, buttonLabel, buttonIcon, styleGridAriaLabel, styleDefinitions }) {\n const parentCommand = editor.commands.get(parentCommandName);\n return (locale) => {\n const dropdownView = createDropdown(locale, SplitButtonView);\n const mainButtonView = dropdownView.buttonView;\n dropdownView.bind('isEnabled').to(parentCommand);\n dropdownView.class = 'ck-list-styles-dropdown';\n // Main button was clicked.\n mainButtonView.on('execute', () => {\n editor.execute(parentCommandName);\n editor.editing.view.focus();\n });\n mainButtonView.set({\n label: buttonLabel,\n icon: buttonIcon,\n tooltip: true,\n isToggleable: true\n });\n mainButtonView.bind('isOn').to(parentCommand, 'value', value => !!value);\n dropdownView.once('change:isOpen', () => {\n const listPropertiesView = createListPropertiesView({\n editor,\n normalizedConfig,\n dropdownView,\n parentCommandName,\n styleGridAriaLabel,\n styleDefinitions\n });\n dropdownView.panelView.children.add(listPropertiesView);\n });\n // Focus the editable after executing the command.\n // Overrides a default behaviour where the focus is moved to the dropdown button (#12125).\n dropdownView.on('execute', () => {\n editor.editing.view.focus();\n });\n return dropdownView;\n };\n}\n/**\n * A helper that returns a function (factory) that creates individual buttons used by users to change styles\n * of lists.\n *\n * @param options.editor\n * @param options.listStyleCommand The instance of the `ListStylesCommand` class.\n * @param options.parentCommandName The name of the higher-order command associated with a\n * particular list style (e.g. \"bulletedList\" is associated with \"square\" and \"numberedList\" is associated with \"roman\").\n * @returns A function that can be passed straight into {@link module:ui/componentfactory~ComponentFactory#add}.\n */\nfunction getStyleButtonCreator({ editor, listStyleCommand, parentCommandName }) {\n const locale = editor.locale;\n const parentCommand = editor.commands.get(parentCommandName);\n return ({ label, type, icon, tooltip }) => {\n const button = new ButtonView(locale);\n button.set({ label, icon, tooltip });\n button.bind('isOn').to(listStyleCommand, 'value', value => value === type);\n button.on('execute', () => {\n // If the content the selection is anchored to is a list, let's change its style.\n if (parentCommand.value) {\n // Remove the list when the current list style is the same as the one that would normally be applied.\n if (listStyleCommand.value === type) {\n editor.execute(parentCommandName);\n }\n // If the current list style is not set in the model or the style is different than the\n // one to be applied, simply apply the new style.\n else if (listStyleCommand.value !== type) {\n editor.execute('listStyle', { type });\n }\n }\n // Otherwise, leave the creation of the styled list to the `ListStyleCommand`.\n else {\n editor.model.change(() => {\n editor.execute('listStyle', { type });\n });\n }\n });\n return button;\n };\n}\n/**\n * A helper that creates the properties view for the individual style dropdown.\n *\n * @param options.editor Editor instance.\n * @param options.normalizedConfig List properties configuration.\n * @param options.dropdownView Styles dropdown view that hosts the properties view.\n * @param options.parentCommandName The name of the higher-order editor command associated with\n * the set of particular list styles (e.g. \"bulletedList\" for \"disc\", \"circle\", and \"square\" styles).\n * @param options.styleDefinitions Definitions of the style buttons.\n * @param options.styleGridAriaLabel An assistive technologies label set on the grid of styles (if the grid is rendered).\n */\nfunction createListPropertiesView({ editor, normalizedConfig, dropdownView, parentCommandName, styleDefinitions, styleGridAriaLabel }) {\n const locale = editor.locale;\n const enabledProperties = {\n ...normalizedConfig,\n ...(parentCommandName != 'numberedList' ? {\n startIndex: false,\n reversed: false\n } : null)\n };\n const listType = parentCommandName.replace('List', '');\n let styleButtonViews = null;\n if (normalizedConfig.styles.listTypes.includes(listType)) {\n const listStyleCommand = editor.commands.get('listStyle');\n const styleButtonCreator = getStyleButtonCreator({\n editor,\n parentCommandName,\n listStyleCommand\n });\n const configuredListStylesTypes = normalizedConfig.styles.listStyleTypes;\n let filteredDefinitions = styleDefinitions;\n if (configuredListStylesTypes) {\n const allowedTypes = configuredListStylesTypes[listType];\n if (allowedTypes) {\n filteredDefinitions = styleDefinitions.filter(def => allowedTypes.includes(def.type));\n }\n }\n const isStyleTypeSupported = getStyleTypeSupportChecker(listStyleCommand);\n styleButtonViews = filteredDefinitions\n .filter(isStyleTypeSupported)\n .map(styleButtonCreator);\n }\n const listPropertiesView = new ListPropertiesView(locale, {\n styleGridAriaLabel,\n enabledProperties,\n styleButtonViews\n });\n if (normalizedConfig.styles.listTypes.includes(listType)) {\n // Accessibility: focus the first active style when opening the dropdown.\n focusChildOnDropdownOpen(dropdownView, () => {\n return listPropertiesView.stylesView.children.find((child) => child.isOn);\n });\n }\n if (enabledProperties.startIndex) {\n const listStartCommand = editor.commands.get('listStart');\n listPropertiesView.startIndexFieldView.bind('isEnabled').to(listStartCommand);\n listPropertiesView.startIndexFieldView.fieldView.bind('value').to(listStartCommand);\n listPropertiesView.on('listStart', (evt, data) => editor.execute('listStart', data));\n }\n if (enabledProperties.reversed) {\n const listReversedCommand = editor.commands.get('listReversed');\n listPropertiesView.reversedSwitchButtonView.bind('isEnabled').to(listReversedCommand);\n listPropertiesView.reversedSwitchButtonView.bind('isOn').to(listReversedCommand, 'value', value => !!value);\n listPropertiesView.on('listReversed', () => {\n const isReversed = listReversedCommand.value;\n editor.execute('listReversed', { reversed: !isReversed });\n });\n }\n // Make sure applying styles closes the dropdown.\n listPropertiesView.delegate('execute').to(dropdownView);\n return listPropertiesView;\n}\n/**\n * A helper that creates the list style submenu for menu bar.\n *\n * @param editor Editor instance.\n * @param normalizedConfig List properties configuration.\n * @param parentCommandName Name of the list command.\n * @param buttonLabel Label of the menu button.\n * @param styleGridAriaLabel ARIA label of the styles grid.\n */\nfunction getMenuBarStylesMenuCreator({ editor, normalizedConfig, parentCommandName, buttonLabel, styleGridAriaLabel, styleDefinitions }) {\n return (locale) => {\n const menuView = new MenuBarMenuView(locale);\n const listCommand = editor.commands.get(parentCommandName);\n const listStyleCommand = editor.commands.get('listStyle');\n const isStyleTypeSupported = getStyleTypeSupportChecker(listStyleCommand);\n const styleButtonCreator = getStyleButtonCreator({\n editor,\n parentCommandName,\n listStyleCommand\n });\n const configuredListStylesTypes = normalizedConfig.styles.listStyleTypes;\n let filteredDefinitions = styleDefinitions;\n if (configuredListStylesTypes) {\n const listType = listCommand.type;\n const allowedTypes = configuredListStylesTypes[listType];\n if (allowedTypes) {\n filteredDefinitions = styleDefinitions.filter(def => allowedTypes.includes(def.type));\n }\n }\n const styleButtonViews = filteredDefinitions.filter(isStyleTypeSupported).map(styleButtonCreator);\n const listPropertiesView = new ListPropertiesView(locale, {\n styleGridAriaLabel,\n enabledProperties: {\n ...normalizedConfig,\n // Disable list start index and reversed in the menu bar.\n startIndex: false,\n reversed: false\n },\n styleButtonViews\n });\n listPropertiesView.delegate('execute').to(menuView);\n menuView.buttonView.set({\n label: buttonLabel,\n icon: parentCommandName === 'bulletedList' ? IconBulletedList : IconNumberedList\n });\n menuView.panelView.children.add(listPropertiesView);\n menuView.bind('isEnabled').to(listCommand, 'isEnabled');\n menuView.on('execute', () => {\n editor.editing.view.focus();\n });\n return menuView;\n };\n}\nfunction getStyleTypeSupportChecker(listStyleCommand) {\n if (typeof listStyleCommand.isStyleTypeSupported == 'function') {\n return (styleDefinition) => listStyleCommand.isStyleTypeSupported(styleDefinition.type);\n }\n else {\n return () => true;\n }\n}\n","export default \"\";","export default \"\";","export default \"\";","export default \"\";","export default \"\";","export default \"\";","export default \"\";","export default \"\";","export default \"\";","export default \"\";","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module source-editing/sourceediting\n */\nimport { Plugin, PendingActions } from 'ckeditor5/src/core.js';\nimport { IconSource } from 'ckeditor5/src/icons.js';\nimport { ButtonView, MenuBarMenuListItemButtonView } from 'ckeditor5/src/ui.js';\nimport { CKEditorError, createElement, ElementReplacer, formatHtml } from 'ckeditor5/src/utils.js';\nimport '../theme/sourceediting.css';\nconst COMMAND_FORCE_DISABLE_ID = 'SourceEditingMode';\n/**\n * The source editing feature.\n *\n * It provides the possibility to view and edit the source of the document.\n *\n * For a detailed overview, check the {@glink features/source-editing/source-editing source editing feature documentation} and the\n * {@glink api/source-editing package page}.\n */\nexport class SourceEditing extends Plugin {\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'SourceEditing';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get requires() {\n return [PendingActions];\n }\n /**\n * The element replacer instance used to replace the editing roots with the wrapper elements containing the document source.\n */\n _elementReplacer;\n /**\n * Maps all root names to wrapper elements containing the document source.\n */\n _replacedRoots;\n /**\n * Maps all root names to their document data.\n */\n _dataFromRoots;\n /**\n * @inheritDoc\n */\n constructor(editor) {\n super(editor);\n this.set('isSourceEditingMode', false);\n this._elementReplacer = new ElementReplacer();\n this._replacedRoots = new Map();\n this._dataFromRoots = new Map();\n editor.config.define('sourceEditing.allowCollaborationFeatures', false);\n }\n /**\n * @inheritDoc\n */\n init() {\n this._checkCompatibility();\n const editor = this.editor;\n const t = editor.locale.t;\n editor.ui.componentFactory.add('sourceEditing', () => {\n const buttonView = this._createButton(ButtonView);\n buttonView.set({\n label: t('Source'),\n icon: IconSource,\n tooltip: true,\n class: 'ck-source-editing-button'\n });\n return buttonView;\n });\n editor.ui.componentFactory.add('menuBar:sourceEditing', () => {\n const buttonView = this._createButton(MenuBarMenuListItemButtonView);\n buttonView.set({\n label: t('Show source'),\n role: 'menuitemcheckbox'\n });\n return buttonView;\n });\n // Currently, the plugin handles the source editing mode by itself only for the classic editor. To use this plugin with other\n // integrations, listen to the `change:isSourceEditingMode` event and act accordingly.\n if (this._isAllowedToHandleSourceEditingMode()) {\n this.on('change:isSourceEditingMode', (evt, name, isSourceEditingMode) => {\n if (isSourceEditingMode) {\n this._hideVisibleDialog();\n this._showSourceEditing();\n this._disableCommands();\n }\n else {\n this._hideSourceEditing();\n this._enableCommands();\n }\n });\n this.on('change:isEnabled', (evt, name, isEnabled) => this._handleReadOnlyMode(!isEnabled));\n this.listenTo(editor, 'change:isReadOnly', (evt, name, isReadOnly) => this._handleReadOnlyMode(isReadOnly));\n }\n // Update the editor data while calling editor.getData() in the source editing mode.\n editor.data.on('get', () => {\n if (this.isSourceEditingMode) {\n this.updateEditorData();\n }\n }, { priority: 'high' });\n }\n /**\n * Updates the source data in all hidden editing roots.\n */\n updateEditorData() {\n const editor = this.editor;\n const data = {};\n for (const [rootName, domSourceEditingElementWrapper] of this._replacedRoots) {\n const oldData = this._dataFromRoots.get(rootName);\n const newData = domSourceEditingElementWrapper.dataset.value;\n // Do not set the data unless some changes have been made in the meantime.\n // This prevents empty undo steps after switching to the normal editor.\n if (oldData !== newData) {\n data[rootName] = newData;\n this._dataFromRoots.set(rootName, newData);\n }\n }\n if (Object.keys(data).length) {\n editor.data.set(data, { batchType: { isUndoable: true }, suppressErrorInCollaboration: true });\n }\n }\n _checkCompatibility() {\n const editor = this.editor;\n const allowCollaboration = editor.config.get('sourceEditing.allowCollaborationFeatures');\n if (!allowCollaboration && editor.plugins.has('RealTimeCollaborativeEditing')) {\n /**\n * Source editing feature is not fully compatible with real-time collaboration,\n * and using it may lead to data loss. Please read\n * {@glink features/source-editing/source-editing#limitations-and-incompatibilities source editing feature guide} to learn more.\n *\n * If you understand the possible risk of data loss, you can enable the source editing\n * by setting the\n * {@link module:source-editing/sourceeditingconfig~SourceEditingConfig#allowCollaborationFeatures}\n * configuration flag to `true`.\n *\n * @error source-editing-incompatible-with-real-time-collaboration\n */\n throw new CKEditorError('source-editing-incompatible-with-real-time-collaboration', null);\n }\n const collaborationPluginNamesToWarn = [\n 'CommentsEditing',\n 'TrackChangesEditing',\n 'RevisionHistory'\n ];\n // Currently, the basic integration with Collaboration Features is to display a warning in the console.\n //\n // If `allowCollaboration` flag is set, do not show these warnings. If the flag is set, we assume that the integrator read\n // appropriate section of the guide so there's no use to spam the console with warnings.\n //\n if (!allowCollaboration && collaborationPluginNamesToWarn.some(pluginName => editor.plugins.has(pluginName))) {\n console.warn('You initialized the editor with the source editing feature and at least one of the collaboration features. ' +\n 'Please be advised that the source editing feature may not work, and be careful when editing document source ' +\n 'that contains markers created by the collaboration features.');\n }\n // Restricted Editing integration can also lead to problems. Warn the user accordingly.\n if (editor.plugins.has('RestrictedEditingModeEditing')) {\n console.warn('You initialized the editor with the source editing feature and restricted editing feature. ' +\n 'Please be advised that the source editing feature may not work, and be careful when editing document source ' +\n 'that contains markers created by the restricted editing feature.');\n }\n }\n /**\n * Creates source editing wrappers that replace each editing root. Each wrapper contains the document source from the corresponding\n * root.\n *\n * The wrapper element contains a textarea and it solves the problem, that the textarea element cannot auto expand its height based on\n * the content it contains. The solution is to make the textarea more like a plain div element, which expands in height as much as it\n * needs to, in order to display the whole document source without scrolling. The wrapper element is a parent for the textarea and for\n * the pseudo-element `::after`, that replicates the look, content, and position of the textarea. The pseudo-element replica is hidden,\n * but it is styled to be an identical visual copy of the textarea with the same content. Then, the wrapper is a grid container and both\n * of its children (the textarea and the `::after` pseudo-element) are positioned within a CSS grid to occupy the same grid cell. The\n * content in the pseudo-element `::after` is set in CSS and it stretches the grid to the appropriate size based on the textarea value.\n * Since both children occupy the same grid cell, both have always the same height.\n */\n _showSourceEditing() {\n const editor = this.editor;\n const editingView = editor.editing.view;\n const model = editor.model;\n model.change(writer => {\n writer.setSelection(null);\n writer.removeSelectionAttribute(model.document.selection.getAttributeKeys());\n });\n // It is not needed to iterate through all editing roots, as currently the plugin supports only the Classic Editor with a single\n // main root, but this code may help understand and use this feature in external integrations.\n for (const [rootName, domRootElement] of editingView.domRoots) {\n const data = formatSource(editor.data.get({ rootName }));\n const domSourceEditingElementTextarea = createElement(domRootElement.ownerDocument, 'textarea', {\n rows: '1',\n 'aria-label': 'Source code editing area'\n });\n const domSourceEditingElementWrapper = createElement(domRootElement.ownerDocument, 'div', {\n class: 'ck-source-editing-area',\n 'data-value': data\n }, [domSourceEditingElementTextarea]);\n domSourceEditingElementTextarea.value = data;\n // Setting a value to textarea moves the input cursor to the end. We want the selection at the beginning.\n domSourceEditingElementTextarea.setSelectionRange(0, 0);\n // Bind the textarea's value to the wrapper's `data-value` property. Each change of the textarea's value updates the\n // wrapper's `data-value` property.\n domSourceEditingElementTextarea.addEventListener('input', () => {\n domSourceEditingElementWrapper.dataset.value = domSourceEditingElementTextarea.value;\n editor.ui.update();\n });\n editingView.change(writer => {\n const viewRoot = editingView.document.getRoot(rootName);\n writer.addClass('ck-hidden', viewRoot);\n });\n // Register the element so it becomes available for Alt+F10 and Esc navigation.\n editor.ui.setEditableElement('sourceEditing:' + rootName, domSourceEditingElementTextarea);\n this._replacedRoots.set(rootName, domSourceEditingElementWrapper);\n this._elementReplacer.replace(domRootElement, domSourceEditingElementWrapper);\n this._dataFromRoots.set(rootName, data);\n }\n this._hideDocumentOutline();\n this._refreshAnnotationsVisibility();\n this._focusSourceEditing();\n }\n /**\n * Restores all hidden editing roots and sets the source data in them.\n */\n _hideSourceEditing() {\n const editor = this.editor;\n const editingView = editor.editing.view;\n this.updateEditorData();\n editingView.change(writer => {\n for (const [rootName] of this._replacedRoots) {\n writer.removeClass('ck-hidden', editingView.document.getRoot(rootName));\n }\n });\n this._elementReplacer.restore();\n this._replacedRoots.clear();\n this._dataFromRoots.clear();\n this._showDocumentOutline();\n this._refreshAnnotationsVisibility();\n editingView.focus();\n }\n /**\n * Hides the document outline if it is configured.\n */\n _hideDocumentOutline() {\n if (this.editor.plugins.has('DocumentOutlineUI')) {\n this.editor.plugins.get('DocumentOutlineUI').view.element.style.display = 'none';\n }\n }\n /**\n * Shows the document outline if it was hidden when entering the source editing.\n */\n _showDocumentOutline() {\n if (this.editor.plugins.has('DocumentOutlineUI')) {\n this.editor.plugins.get('DocumentOutlineUI').view.element.style.display = '';\n }\n }\n /**\n * Hides the annotations when entering the source editing mode and shows back them after leaving it.\n */\n _refreshAnnotationsVisibility() {\n if (this.editor.plugins.has('Annotations')) {\n this.editor.plugins.get('Annotations').refreshVisibility();\n }\n }\n /**\n * Focuses the textarea containing document source from the first editing root.\n */\n _focusSourceEditing() {\n const editor = this.editor;\n const [domSourceEditingElementWrapper] = this._replacedRoots.values();\n const textarea = domSourceEditingElementWrapper.querySelector('textarea');\n // The FocusObserver was disabled by View.render() while the DOM root was getting hidden and the replacer\n // revealed the textarea. So it couldn't notice that the DOM root got blurred in the process.\n // Let's sync this state manually here because otherwise Renderer will attempt to render selection\n // in an invisible DOM root.\n editor.editing.view.document.isFocused = false;\n textarea.focus();\n }\n /**\n * Disables all commands.\n */\n _disableCommands() {\n const editor = this.editor;\n for (const command of editor.commands.commands()) {\n command.forceDisabled(COMMAND_FORCE_DISABLE_ID);\n }\n // Comments archive UI plugin will be disabled manually too.\n if (editor.plugins.has('CommentsArchiveUI')) {\n editor.plugins.get('CommentsArchiveUI').forceDisabled(COMMAND_FORCE_DISABLE_ID);\n }\n }\n /**\n * Clears forced disable for all commands, that was previously set through {@link #_disableCommands}.\n */\n _enableCommands() {\n const editor = this.editor;\n for (const command of editor.commands.commands()) {\n command.clearForceDisabled(COMMAND_FORCE_DISABLE_ID);\n }\n // Comments archive UI plugin will be enabled manually too.\n if (editor.plugins.has('CommentsArchiveUI')) {\n editor.plugins.get('CommentsArchiveUI').clearForceDisabled(COMMAND_FORCE_DISABLE_ID);\n }\n }\n /**\n * Adds or removes the `readonly` attribute from the textarea from all roots, if document source mode is active.\n *\n * @param isReadOnly Indicates whether all textarea elements should be read-only.\n */\n _handleReadOnlyMode(isReadOnly) {\n if (!this.isSourceEditingMode) {\n return;\n }\n for (const [, domSourceEditingElementWrapper] of this._replacedRoots) {\n domSourceEditingElementWrapper.querySelector('textarea').readOnly = isReadOnly;\n }\n }\n /**\n * Checks, if the plugin is allowed to handle the source editing mode by itself. Currently, the source editing mode is supported only\n * for the {@link module:editor-classic/classiceditor~ClassicEditor classic editor}.\n */\n _isAllowedToHandleSourceEditingMode() {\n const editor = this.editor;\n const editable = editor.ui.view.editable;\n // Checks, if the editor's editable belongs to the editor's DOM tree.\n return editable && !editable.hasExternalElement;\n }\n /**\n * If any {@link module:ui/dialog/dialogview~DialogView editor dialog} is currently visible, hide it.\n */\n _hideVisibleDialog() {\n if (this.editor.plugins.has('Dialog')) {\n const dialogPlugin = this.editor.plugins.get('Dialog');\n if (dialogPlugin.isOpen) {\n dialogPlugin.hide();\n }\n }\n }\n _createButton(ButtonClass) {\n const editor = this.editor;\n const buttonView = new ButtonClass(editor.locale);\n buttonView.set({\n withText: true,\n isToggleable: true\n });\n buttonView.bind('isOn').to(this, 'isSourceEditingMode');\n // The button should be disabled if one of the following conditions is met:\n buttonView.bind('isEnabled').to(this, 'isEnabled', editor, 'isReadOnly', editor.plugins.get(PendingActions), 'hasAny', (isEnabled, isEditorReadOnly, hasAnyPendingActions) => {\n // (1) The plugin itself is disabled.\n if (!isEnabled) {\n return false;\n }\n // (2) The editor is in read-only mode.\n if (isEditorReadOnly) {\n return false;\n }\n // (3) Any pending action is scheduled. It may change the model, so modifying the document source should be prevented\n // until the model is finally set.\n if (hasAnyPendingActions) {\n return false;\n }\n return true;\n });\n this.listenTo(buttonView, 'execute', () => {\n this.isSourceEditingMode = !this.isSourceEditingMode;\n });\n return buttonView;\n }\n}\n/**\n * Formats the content for a better readability.\n *\n * For a non-HTML source the unchanged input string is returned.\n *\n * @param input Input string to check.\n */\nfunction formatSource(input) {\n if (!isHtml(input)) {\n return input;\n }\n return formatHtml(input);\n}\n/**\n * Checks, if the document source is HTML. It is sufficient to just check the first character from the document data.\n *\n * @param input Input string to check.\n */\nfunction isHtml(input) {\n return input.startsWith('<');\n}\n","const CASE_SPLIT_PATTERN = /\\p{Lu}?\\p{Ll}+|[0-9]+|\\p{Lu}+(?!\\p{Ll})|\\p{Emoji_Presentation}|\\p{Extended_Pictographic}|\\p{L}+/gu;\nfunction words(str) {\n return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);\n}\n\nexport { CASE_SPLIT_PATTERN, words };\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { startCase, cloneDeep } from 'es-toolkit/compat';\n/**\n* Helper function for the downcast converter. Updates attributes on the given view element.\n*\n* @param writer The view writer.\n* @param oldViewAttributes The previous GHS attribute value.\n* @param newViewAttributes The current GHS attribute value.\n* @param viewElement The view element to update.\n* @internal\n*/\nexport function updateViewAttributes(writer, oldViewAttributes, newViewAttributes, viewElement) {\n if (oldViewAttributes) {\n removeViewAttributes(writer, oldViewAttributes, viewElement);\n }\n if (newViewAttributes) {\n setViewAttributes(writer, newViewAttributes, viewElement);\n }\n}\n/**\n * Helper function for the downcast converter. Sets attributes on the given view element.\n *\n * @param writer The view writer.\n * @param viewAttributes The GHS attribute value.\n * @param viewElement The view element to update.\n * @internal\n */\nexport function setViewAttributes(writer, viewAttributes, viewElement) {\n if (viewAttributes.attributes) {\n for (const [key, value] of Object.entries(viewAttributes.attributes)) {\n writer.setAttribute(key, value, viewElement);\n }\n }\n if (viewAttributes.styles) {\n writer.setStyle(viewAttributes.styles, viewElement);\n }\n if (viewAttributes.classes) {\n writer.addClass(viewAttributes.classes, viewElement);\n }\n}\n/**\n * Helper function for the downcast converter. Removes attributes on the given view element.\n *\n * @param writer The view writer.\n * @param viewAttributes The GHS attribute value.\n * @param viewElement The view element to update.\n * @internal\n */\nexport function removeViewAttributes(writer, viewAttributes, viewElement) {\n if (viewAttributes.attributes) {\n for (const [key] of Object.entries(viewAttributes.attributes)) {\n writer.removeAttribute(key, viewElement);\n }\n }\n if (viewAttributes.styles) {\n for (const style of Object.keys(viewAttributes.styles)) {\n writer.removeStyle(style, viewElement);\n }\n }\n if (viewAttributes.classes) {\n writer.removeClass(viewAttributes.classes, viewElement);\n }\n}\n/**\n* Merges view element attribute objects.\n*\n* @internal\n*/\nexport function mergeViewElementAttributes(target, source) {\n const result = cloneDeep(target);\n let key = 'attributes';\n for (key in source) {\n // Merge classes.\n if (key == 'classes') {\n result[key] = Array.from(new Set([...(target[key] || []), ...source[key]]));\n }\n // Merge attributes or styles.\n else {\n result[key] = { ...target[key], ...source[key] };\n }\n }\n return result;\n}\nexport function modifyGhsAttribute(writer, item, ghsAttributeName, subject, callback) {\n const oldValue = item.getAttribute(ghsAttributeName);\n const newValue = {};\n for (const kind of ['attributes', 'styles', 'classes']) {\n // Properties other than `subject` should be assigned from `oldValue`.\n if (kind != subject) {\n if (oldValue && oldValue[kind]) {\n newValue[kind] = oldValue[kind];\n }\n continue;\n }\n // `callback` should be applied on property [`subject`].\n if (subject == 'classes') {\n const values = new Set(oldValue && oldValue.classes || []);\n callback(values);\n if (values.size) {\n newValue[kind] = Array.from(values);\n }\n continue;\n }\n const values = new Map(Object.entries(oldValue && oldValue[kind] || {}));\n callback(values);\n if (values.size) {\n newValue[kind] = Object.fromEntries(values);\n }\n }\n if (Object.keys(newValue).length) {\n if (item.is('documentSelection')) {\n writer.setSelectionAttribute(ghsAttributeName, newValue);\n }\n else {\n writer.setAttribute(ghsAttributeName, newValue, item);\n }\n }\n else if (oldValue) {\n if (item.is('documentSelection')) {\n writer.removeSelectionAttribute(ghsAttributeName);\n }\n else {\n writer.removeAttribute(ghsAttributeName, item);\n }\n }\n}\n/**\n * Strips the `styles`, and `classes` keys from the GHS attribute value on the given item.\n *\n * @internal\n */\nexport function removeFormatting(ghsAttributeName, itemRange, writer) {\n for (const item of itemRange.getItems({ shallow: true })) {\n const value = item.getAttribute(ghsAttributeName);\n // Copy only attributes to the new attribute value.\n if (value && value.attributes && Object.keys(value.attributes).length) {\n // But reset the GHS attribute only when there is anything more than just attributes.\n if (Object.keys(value).length > 1) {\n writer.setAttribute(ghsAttributeName, { attributes: value.attributes }, item);\n }\n }\n else {\n // There are no attributes, so remove the GHS attribute completely.\n writer.removeAttribute(ghsAttributeName, item);\n }\n }\n}\n/**\n * Transforms passed string to PascalCase format. Examples:\n * * `div` => `Div`\n * * `h1` => `H1`\n * * `table` => `Table`\n *\n * @internal\n */\nexport function toPascalCase(data) {\n return startCase(data).replace(/ /g, '');\n}\n/**\n * Returns the attribute name of the model element that holds raw HTML attributes.\n *\n * @internal\n */\nexport function getHtmlAttributeName(viewElementName) {\n return `html${toPascalCase(viewElementName)}Attributes`;\n}\n","import { words } from '../../string/words.mjs';\nimport { normalizeForCase } from '../_internal/normalizeForCase.mjs';\n\nfunction startCase(str) {\n const words$1 = words(normalizeForCase(str).trim());\n let result = '';\n for (let i = 0; i < words$1.length; i++) {\n const word = words$1[i];\n if (result) {\n result += ' ';\n }\n if (word === word.toUpperCase()) {\n result += word;\n }\n else {\n result += word[0].toUpperCase() + word.slice(1).toLowerCase();\n }\n }\n return result;\n}\n\nexport { startCase };\n","import { toString } from '../util/toString.mjs';\n\nfunction normalizeForCase(str) {\n if (typeof str !== 'string') {\n str = toString(str);\n }\n return str.replace(/['\\u2019]/g, '');\n}\n\nexport { normalizeForCase };\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { toWidget } from 'ckeditor5/src/widget.js';\nimport { setViewAttributes, mergeViewElementAttributes, updateViewAttributes, getHtmlAttributeName } from './utils.js';\n/**\n * View-to-model conversion helper for object elements.\n *\n * Preserves object element content in `htmlContent` attribute.\n *\n * @returns Returns a conversion callback.\n * @internal\n*/\nexport function viewToModelObjectConverter({ model: modelName }) {\n return (viewElement, conversionApi) => {\n // Let's keep element HTML and its attributes, so we can rebuild element in downcast conversions.\n return conversionApi.writer.createElement(modelName, {\n htmlContent: viewElement.getCustomProperty('$rawContent')\n });\n };\n}\n/**\n * Conversion helper converting an object element to an HTML object widget.\n *\n * @returns Returns a conversion callback.\n * @internal\n*/\nexport function toObjectWidgetConverter(editor, { view: viewName, isInline }) {\n const t = editor.t;\n return (modelElement, { writer }) => {\n const widgetLabel = t('HTML object');\n const viewElement = createObjectView(viewName, modelElement, writer);\n const viewAttributes = modelElement.getAttribute(getHtmlAttributeName(viewName));\n writer.addClass('html-object-embed__content', viewElement);\n if (viewAttributes) {\n setViewAttributes(writer, viewAttributes, viewElement);\n }\n // Widget cannot be a raw element because the widget system would not be able\n // to add its UI to it. Thus, we need separate view container.\n const viewContainer = writer.createContainerElement(isInline ? 'span' : 'div', {\n class: 'html-object-embed',\n 'data-html-object-embed-label': widgetLabel\n }, viewElement);\n return toWidget(viewContainer, writer, { label: widgetLabel });\n };\n}\n/**\n* Creates object view element from the given model element.\n*\n* @internal\n*/\nexport function createObjectView(viewName, modelElement, writer) {\n return writer.createRawElement(viewName, null, (domElement, domConverter) => {\n domConverter.setContentOf(domElement, modelElement.getAttribute('htmlContent'));\n });\n}\n/**\n * View-to-attribute conversion helper preserving inline element attributes on `$text`.\n *\n * @returns Returns a conversion callback.\n * @internal\n*/\nexport function viewToAttributeInlineConverter({ view: viewName, model: attributeKey, allowEmpty }, dataFilter) {\n return dispatcher => {\n dispatcher.on(`element:${viewName}`, (evt, data, conversionApi) => {\n let viewAttributes = dataFilter.processViewAttributes(data.viewItem, conversionApi);\n // Do not apply the attribute if the element itself is already consumed and there are no view attributes to store.\n if (!viewAttributes && !conversionApi.consumable.test(data.viewItem, { name: true })) {\n return;\n }\n // Otherwise, we might need to convert it to an empty object just to preserve element itself,\n // for example `` => <$text htmlCite=\"{}\">.\n viewAttributes = viewAttributes || {};\n // Consume the element itself if it wasn't consumed by any other converter.\n conversionApi.consumable.consume(data.viewItem, { name: true });\n // Since we are converting to attribute we need a range on which we will set the attribute.\n // If the range is not created yet, we will create it.\n if (!data.modelRange) {\n data = Object.assign(data, conversionApi.convertChildren(data.viewItem, data.modelCursor));\n }\n // Convert empty inline element if allowed and has any attributes.\n if (allowEmpty && data.modelRange.isCollapsed && Object.keys(viewAttributes).length) {\n const modelElement = conversionApi.writer.createElement('htmlEmptyElement');\n if (!conversionApi.safeInsert(modelElement, data.modelCursor)) {\n return;\n }\n const parts = conversionApi.getSplitParts(modelElement);\n data.modelRange = conversionApi.writer.createRange(data.modelRange.start, conversionApi.writer.createPositionAfter(parts[parts.length - 1]));\n conversionApi.updateConversionResult(modelElement, data);\n setAttributeOnItem(modelElement, viewAttributes, conversionApi);\n return;\n }\n // Set attribute on each item in range according to the schema.\n for (const node of data.modelRange.getItems()) {\n setAttributeOnItem(node, viewAttributes, conversionApi);\n }\n }, { priority: 'low' });\n };\n function setAttributeOnItem(node, viewAttributes, conversionApi) {\n if (conversionApi.schema.checkAttribute(node, attributeKey)) {\n // Node's children are converted recursively, so node can already include model attribute.\n // We want to extend it, not replace.\n const nodeAttributes = node.getAttribute(attributeKey);\n const attributesToAdd = mergeViewElementAttributes(viewAttributes, nodeAttributes || {});\n conversionApi.writer.setAttribute(attributeKey, attributesToAdd, node);\n }\n }\n}\n/**\n * Conversion helper converting an empty inline model element to an HTML element or widget.\n *\n * @internal\n */\nexport function emptyInlineModelElementToViewConverter({ model: attributeKey, view: viewName }, asWidget) {\n return (item, { writer, consumable }) => {\n if (!item.hasAttribute(attributeKey)) {\n return null;\n }\n const viewElement = writer.createContainerElement(viewName);\n const attributeValue = item.getAttribute(attributeKey);\n consumable.consume(item, `attribute:${attributeKey}`);\n setViewAttributes(writer, attributeValue, viewElement);\n viewElement.getFillerOffset = () => null;\n return asWidget ? toWidget(viewElement, writer) : viewElement;\n };\n}\n/**\n * Attribute-to-view conversion helper applying attributes to view element preserved on `$text`.\n *\n * @returns Returns a conversion callback.\n * @internal\n*/\nexport function attributeToViewInlineConverter({ priority, view: viewName }) {\n return (attributeValue, conversionApi) => {\n if (!attributeValue) {\n return;\n }\n const { writer } = conversionApi;\n const viewElement = writer.createAttributeElement(viewName, null, { priority });\n setViewAttributes(writer, attributeValue, viewElement);\n return viewElement;\n };\n}\n/**\n * View-to-model conversion helper preserving allowed attributes on block element.\n *\n * All matched attributes will be preserved on `html*Attributes` attribute.\n *\n * @returns Returns a conversion callback.\n * @internal\n*/\nexport function viewToModelBlockAttributeConverter({ view: viewName }, dataFilter) {\n return (dispatcher) => {\n dispatcher.on(`element:${viewName}`, (evt, data, conversionApi) => {\n // Converting an attribute of an element that has not been converted to anything does not make sense\n // because there will be nowhere to set that attribute on. At this stage, the element should've already\n // been converted. A collapsed range can show up in to-do lists () or complex widgets (e.g. table).\n // (https://github.com/ckeditor/ckeditor5/issues/11000).\n if (!data.modelRange || data.modelRange.isCollapsed) {\n return;\n }\n const viewAttributes = dataFilter.processViewAttributes(data.viewItem, conversionApi);\n if (!viewAttributes) {\n return;\n }\n conversionApi.writer.setAttribute(getHtmlAttributeName(data.viewItem.name), viewAttributes, data.modelRange);\n }, { priority: 'low' });\n };\n}\n/**\n * Model-to-view conversion helper applying attributes preserved in `html*Attributes` attribute\n * for block elements.\n *\n * @returns Returns a conversion callback.\n * @internal\n*/\nexport function modelToViewBlockAttributeConverter({ view: viewName, model: modelName }) {\n return (dispatcher) => {\n dispatcher.on(`attribute:${getHtmlAttributeName(viewName)}:${modelName}`, (evt, data, conversionApi) => {\n if (!conversionApi.consumable.consume(data.item, evt.name)) {\n return;\n }\n const { attributeOldValue, attributeNewValue } = data;\n const viewWriter = conversionApi.writer;\n const viewElement = conversionApi.mapper.toViewElement(data.item);\n updateViewAttributes(viewWriter, attributeOldValue, attributeNewValue, viewElement);\n });\n };\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module html-support/schemadefinitions\n */\n/**\n * Skipped elements due to HTML deprecation:\n * * noframes (not sure if we should provide support for this element. CKE4 is not supporting frameset and frame,\n * but it will unpack foobar to foobar, so there\n * may be some content loss. Although using noframes as a standalone element seems invalid)\n * * keygen (this one is also empty)\n * * applet (support is limited mostly to old IE)\n * * basefont (this one is also empty)\n * * isindex (basically no support for modern browsers at all)\n *\n * Skipped elements due to lack empty element support:\n * * hr\n * * area\n * * br\n * * command\n * * map\n * * wbr\n * * colgroup -> col\n *\n * Skipped elements due to complexity:\n * * datalist with option elements used as a data source for input[list] element\n *\n * Skipped elements as they are handled as an object content:\n * * track\n * * source\n * * option\n * * param\n * * optgroup\n *\n * Skipped full page HTML elements:\n * * body\n * * html\n * * title\n * * head\n * * meta\n * * link\n * * etc...\n *\n * Skipped hidden elements:\n * noscript\n *\n * When adding elements to this list, update the feature guide listing, too.\n *\n * @internal\n */\nexport const defaultConfig = {\n block: [\n // Existing features.\n {\n model: 'codeBlock',\n view: 'pre'\n },\n {\n model: 'paragraph',\n view: 'p'\n },\n {\n model: 'blockQuote',\n view: 'blockquote'\n },\n {\n model: 'listItem',\n view: 'li'\n },\n {\n model: 'pageBreak',\n view: 'div'\n },\n {\n model: 'rawHtml',\n view: 'div'\n },\n {\n model: 'table',\n view: 'table'\n },\n {\n model: 'tableRow',\n view: 'tr'\n },\n {\n model: 'tableCell',\n view: 'td'\n },\n {\n model: 'tableCell',\n view: 'th'\n },\n {\n model: 'tableColumnGroup',\n view: 'colgroup'\n },\n {\n model: 'tableColumn',\n view: 'col'\n },\n {\n model: 'caption',\n view: 'caption'\n },\n {\n model: 'caption',\n view: 'figcaption'\n },\n {\n model: 'imageBlock',\n view: 'img'\n },\n {\n model: 'imageInline',\n view: 'img'\n },\n {\n model: 'horizontalLine',\n view: 'hr'\n },\n // Compatibility features.\n {\n model: 'htmlP',\n view: 'p',\n modelSchema: {\n inheritAllFrom: '$block'\n }\n },\n {\n model: 'htmlBlockquote',\n view: 'blockquote',\n modelSchema: {\n inheritAllFrom: '$container'\n }\n },\n {\n model: 'htmlTable',\n view: 'table',\n modelSchema: {\n allowWhere: '$block',\n isBlock: true\n }\n },\n {\n model: 'htmlTbody',\n view: 'tbody',\n modelSchema: {\n allowIn: 'htmlTable',\n isBlock: false\n }\n },\n {\n model: 'htmlThead',\n view: 'thead',\n modelSchema: {\n allowIn: 'htmlTable',\n isBlock: false\n }\n },\n {\n model: 'htmlTfoot',\n view: 'tfoot',\n modelSchema: {\n allowIn: 'htmlTable',\n isBlock: false\n }\n },\n {\n model: 'htmlCaption',\n view: 'caption',\n modelSchema: {\n allowIn: 'htmlTable',\n allowChildren: '$text',\n isBlock: false\n }\n },\n {\n model: 'htmlColgroup',\n view: 'colgroup',\n modelSchema: {\n allowIn: 'htmlTable',\n allowChildren: 'col',\n isBlock: false\n }\n },\n {\n model: 'htmlCol',\n view: 'col',\n modelSchema: {\n allowIn: 'htmlColgroup',\n isBlock: false\n }\n },\n {\n model: 'htmlTr',\n view: 'tr',\n modelSchema: {\n allowIn: ['htmlTable', 'htmlThead', 'htmlTbody'],\n isLimit: true\n }\n },\n // TODO can also include text.\n {\n model: 'htmlTd',\n view: 'td',\n modelSchema: {\n allowIn: 'htmlTr',\n allowContentOf: '$container',\n isLimit: true,\n isBlock: false\n }\n },\n // TODO can also include text.\n {\n model: 'htmlTh',\n view: 'th',\n modelSchema: {\n allowIn: 'htmlTr',\n allowContentOf: '$container',\n isLimit: true,\n isBlock: false\n }\n },\n // TODO can also include text.\n {\n model: 'htmlFigure',\n view: 'figure',\n modelSchema: {\n inheritAllFrom: '$container',\n isBlock: false\n }\n },\n // TODO can also include other block elements.\n {\n model: 'htmlFigcaption',\n view: 'figcaption',\n modelSchema: {\n allowIn: 'htmlFigure',\n allowChildren: '$text',\n isBlock: false\n }\n },\n // TODO can also include text.\n {\n model: 'htmlAddress',\n view: 'address',\n modelSchema: {\n inheritAllFrom: '$container',\n isBlock: false\n }\n },\n // TODO can also include text.\n {\n model: 'htmlAside',\n view: 'aside',\n modelSchema: {\n inheritAllFrom: '$container',\n isBlock: false\n }\n },\n // TODO can also include text.\n {\n model: 'htmlMain',\n view: 'main',\n modelSchema: {\n inheritAllFrom: '$container',\n isBlock: false\n }\n },\n // TODO can also include text.\n {\n model: 'htmlDetails',\n view: 'details',\n modelSchema: {\n inheritAllFrom: '$container',\n isBlock: false\n }\n },\n {\n model: 'htmlSummary',\n view: 'summary',\n modelSchema: {\n allowChildren: [\n 'htmlH1',\n 'htmlH2',\n 'htmlH3',\n 'htmlH4',\n 'htmlH5',\n 'htmlH6',\n '$text'\n ],\n allowIn: 'htmlDetails',\n isBlock: false\n }\n },\n {\n model: 'htmlDiv',\n view: 'div',\n paragraphLikeModel: 'htmlDivParagraph',\n modelSchema: {\n inheritAllFrom: '$container'\n }\n },\n // TODO can also include text.\n {\n model: 'htmlFieldset',\n view: 'fieldset',\n modelSchema: {\n inheritAllFrom: '$container',\n isBlock: false\n }\n },\n // TODO can also include h1-h6.\n {\n model: 'htmlLegend',\n view: 'legend',\n modelSchema: {\n allowIn: 'htmlFieldset',\n allowChildren: '$text'\n }\n },\n // TODO can also include text.\n {\n model: 'htmlHeader',\n view: 'header',\n modelSchema: {\n inheritAllFrom: '$container',\n isBlock: false\n }\n },\n // TODO can also include text.\n {\n model: 'htmlFooter',\n view: 'footer',\n modelSchema: {\n inheritAllFrom: '$container',\n isBlock: false\n }\n },\n // TODO can also include text.\n {\n model: 'htmlForm',\n view: 'form',\n modelSchema: {\n inheritAllFrom: '$container',\n isBlock: true\n }\n },\n {\n model: 'htmlHgroup',\n view: 'hgroup',\n modelSchema: {\n allowIn: ['$root', '$container'],\n allowChildren: [\n 'paragraph',\n 'htmlP',\n 'htmlH1',\n 'htmlH2',\n 'htmlH3',\n 'htmlH4',\n 'htmlH5',\n 'htmlH6'\n ],\n isBlock: false\n }\n },\n {\n model: 'htmlH1',\n view: 'h1',\n modelSchema: {\n inheritAllFrom: '$block'\n }\n },\n {\n model: 'htmlH2',\n view: 'h2',\n modelSchema: {\n inheritAllFrom: '$block'\n }\n },\n {\n model: 'htmlH3',\n view: 'h3',\n modelSchema: {\n inheritAllFrom: '$block'\n }\n },\n {\n model: 'htmlH4',\n view: 'h4',\n modelSchema: {\n inheritAllFrom: '$block'\n }\n },\n {\n model: 'htmlH5',\n view: 'h5',\n modelSchema: {\n inheritAllFrom: '$block'\n }\n },\n {\n model: 'htmlH6',\n view: 'h6',\n modelSchema: {\n inheritAllFrom: '$block'\n }\n },\n {\n model: '$htmlList',\n modelSchema: {\n allowWhere: '$container',\n allowChildren: ['$htmlList', 'htmlLi'],\n isBlock: false\n }\n },\n {\n model: 'htmlDir',\n view: 'dir',\n modelSchema: {\n inheritAllFrom: '$htmlList'\n }\n },\n {\n model: 'htmlMenu',\n view: 'menu',\n modelSchema: {\n inheritAllFrom: '$htmlList'\n }\n },\n {\n model: 'htmlUl',\n view: 'ul',\n modelSchema: {\n inheritAllFrom: '$htmlList'\n }\n },\n {\n model: 'htmlOl',\n view: 'ol',\n modelSchema: {\n inheritAllFrom: '$htmlList'\n }\n },\n // TODO can also include other block elements.\n {\n model: 'htmlLi',\n view: 'li',\n modelSchema: {\n allowIn: '$htmlList',\n allowChildren: '$text',\n isBlock: false\n }\n },\n {\n model: 'htmlPre',\n view: 'pre',\n modelSchema: {\n inheritAllFrom: '$block'\n }\n },\n {\n model: 'htmlArticle',\n view: 'article',\n modelSchema: {\n inheritAllFrom: '$container',\n isBlock: false\n }\n },\n {\n model: 'htmlSection',\n view: 'section',\n modelSchema: {\n inheritAllFrom: '$container',\n isBlock: false\n }\n },\n // TODO can also include text.\n {\n model: 'htmlNav',\n view: 'nav',\n modelSchema: {\n inheritAllFrom: '$container',\n isBlock: false\n }\n },\n {\n model: 'htmlDl',\n view: 'dl',\n modelSchema: {\n allowWhere: '$container',\n allowChildren: ['htmlDt', 'htmlDd', 'htmlDiv'],\n isBlock: false\n }\n },\n {\n model: 'htmlDt',\n view: 'dt',\n modelSchema: {\n allowChildren: '$block',\n allowIn: 'htmlDiv',\n isBlock: false\n }\n },\n {\n model: 'htmlDd',\n view: 'dd',\n modelSchema: {\n allowChildren: '$block',\n allowIn: 'htmlDiv',\n isBlock: false\n }\n },\n {\n model: 'htmlCenter',\n view: 'center',\n modelSchema: {\n inheritAllFrom: '$container',\n isBlock: false\n }\n },\n {\n model: 'htmlHr',\n view: 'hr',\n isEmpty: true,\n modelSchema: {\n inheritAllFrom: '$blockObject'\n }\n }\n ],\n inline: [\n // Existing features (attribute set on an existing model element).\n {\n model: 'htmlLiAttributes',\n view: 'li',\n appliesToBlock: true,\n coupledAttribute: 'listItemId'\n },\n {\n model: 'htmlOlAttributes',\n view: 'ol',\n appliesToBlock: true,\n coupledAttribute: 'listItemId'\n },\n {\n model: 'htmlUlAttributes',\n view: 'ul',\n appliesToBlock: true,\n coupledAttribute: 'listItemId'\n },\n {\n model: 'htmlFigureAttributes',\n view: 'figure',\n appliesToBlock: 'table'\n },\n {\n model: 'htmlTheadAttributes',\n view: 'thead',\n appliesToBlock: 'table'\n },\n {\n model: 'htmlTbodyAttributes',\n view: 'tbody',\n appliesToBlock: 'table'\n },\n {\n model: 'htmlFigureAttributes',\n view: 'figure',\n appliesToBlock: 'imageBlock'\n },\n // Compatibility features.\n {\n model: 'htmlAcronym',\n view: 'acronym',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlTt',\n view: 'tt',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlFont',\n view: 'font',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlTime',\n view: 'time',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlVar',\n view: 'var',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlBig',\n view: 'big',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlSmall',\n view: 'small',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlSamp',\n view: 'samp',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlQ',\n view: 'q',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlOutput',\n view: 'output',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlKbd',\n view: 'kbd',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlBdi',\n view: 'bdi',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlBdo',\n view: 'bdo',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlAbbr',\n view: 'abbr',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlA',\n view: 'a',\n priority: 5,\n coupledAttribute: 'linkHref',\n attributeProperties: {\n isFormatting: true\n }\n },\n {\n model: 'htmlStrong',\n view: 'strong',\n coupledAttribute: 'bold',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlB',\n view: 'b',\n coupledAttribute: 'bold',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlI',\n view: 'i',\n coupledAttribute: 'italic',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlEm',\n view: 'em',\n coupledAttribute: 'italic',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlS',\n view: 's',\n coupledAttribute: 'strikethrough',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n // TODO According to HTML-spec can behave as div-like element, although CKE4 only handles it as an inline element.\n {\n model: 'htmlDel',\n view: 'del',\n coupledAttribute: 'strikethrough',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n // TODO According to HTML-spec can behave as div-like element, although CKE4 only handles it as an inline element.\n {\n model: 'htmlIns',\n view: 'ins',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlU',\n view: 'u',\n coupledAttribute: 'underline',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlSub',\n view: 'sub',\n coupledAttribute: 'subscript',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlSup',\n view: 'sup',\n coupledAttribute: 'superscript',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlCode',\n view: 'code',\n coupledAttribute: 'code',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlMark',\n view: 'mark',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlSpan',\n view: 'span',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlCite',\n view: 'cite',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlLabel',\n view: 'label',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n {\n model: 'htmlDfn',\n view: 'dfn',\n attributeProperties: {\n copyOnEnter: true,\n isFormatting: true\n }\n },\n // Objects.\n {\n model: 'htmlObject',\n view: 'object',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n {\n model: 'htmlIframe',\n view: 'iframe',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n {\n model: 'htmlInput',\n view: 'input',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n {\n model: 'htmlButton',\n view: 'button',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n {\n model: 'htmlTextarea',\n view: 'textarea',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n {\n model: 'htmlSelect',\n view: 'select',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n {\n model: 'htmlVideo',\n view: 'video',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n {\n model: 'htmlEmbed',\n view: 'embed',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n {\n model: 'htmlOembed',\n view: 'oembed',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n {\n model: 'htmlAudio',\n view: 'audio',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n {\n model: 'htmlImg',\n view: 'img',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n {\n model: 'htmlCanvas',\n view: 'canvas',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n // TODO it could be probably represented as non-object element, although it has graphical representation,\n // so probably makes more sense to keep it as an object.\n {\n model: 'htmlMeter',\n view: 'meter',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n // TODO it could be probably represented as non-object element, although it has graphical representation,\n // so probably makes more sense to keep it as an object.\n {\n model: 'htmlProgress',\n view: 'progress',\n isObject: true,\n modelSchema: {\n inheritAllFrom: '$inlineObject'\n }\n },\n {\n model: 'htmlScript',\n view: 'script',\n modelSchema: {\n allowWhere: ['$text', '$block'],\n isInline: true\n }\n },\n {\n model: 'htmlStyle',\n view: 'style',\n modelSchema: {\n allowWhere: ['$text', '$block'],\n isInline: true\n }\n },\n {\n model: 'htmlCustomElement',\n view: '$customElement',\n modelSchema: {\n allowWhere: ['$text', '$block'],\n allowAttributesOf: '$inlineObject',\n isInline: true\n }\n }\n ]\n};\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module html-support/dataschema\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { toArray } from 'ckeditor5/src/utils.js';\nimport { defaultConfig } from './schemadefinitions.js';\nimport { mergeWith } from 'es-toolkit/compat';\n/**\n * Holds representation of the extended HTML document type definitions to be used by the\n * editor in HTML support.\n *\n * Data schema is represented by data schema definitions.\n *\n * To add new definition for block element,\n * use {@link module:html-support/dataschema~DataSchema#registerBlockElement} method:\n *\n * ```ts\n * dataSchema.registerBlockElement( {\n * \tview: 'section',\n * \tmodel: 'my-section',\n * \tmodelSchema: {\n * \t\tinheritAllFrom: '$block'\n * \t}\n * } );\n * ```\n *\n * To add new definition for inline element,\n * use {@link module:html-support/dataschema~DataSchema#registerInlineElement} method:\n *\n * ```\n * dataSchema.registerInlineElement( {\n * \tview: 'span',\n * \tmodel: 'my-span',\n * \tattributeProperties: {\n * \t\tcopyOnEnter: true\n * \t}\n * } );\n * ```\n */\nexport class DataSchema extends Plugin {\n /**\n * A map of registered data schema definitions.\n */\n _definitions = [];\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'DataSchema';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n for (const definition of defaultConfig.block) {\n this.registerBlockElement(definition);\n }\n for (const definition of defaultConfig.inline) {\n this.registerInlineElement(definition);\n }\n }\n /**\n * Add new data schema definition describing block element.\n */\n registerBlockElement(definition) {\n this._definitions.push({ ...definition, isBlock: true });\n }\n /**\n * Add new data schema definition describing inline element.\n */\n registerInlineElement(definition) {\n this._definitions.push({ ...definition, isInline: true });\n }\n /**\n * Updates schema definition describing block element with new properties.\n *\n * Creates new scheme if it doesn't exist.\n * Array properties are concatenated with original values.\n *\n * @param definition Definition update.\n */\n extendBlockElement(definition) {\n this._extendDefinition({ ...definition, isBlock: true });\n }\n /**\n * Updates schema definition describing inline element with new properties.\n *\n * Creates new scheme if it doesn't exist.\n * Array properties are concatenated with original values.\n *\n * @param definition Definition update.\n */\n extendInlineElement(definition) {\n this._extendDefinition({ ...definition, isInline: true });\n }\n /**\n * Returns all definitions matching the given view name.\n *\n * @param includeReferences Indicates if this method should also include definitions of referenced models.\n */\n getDefinitionsForView(viewName, includeReferences = false) {\n const definitions = new Set();\n for (const definition of this._getMatchingViewDefinitions(viewName)) {\n if (includeReferences) {\n for (const reference of this._getReferences(definition.model)) {\n definitions.add(reference);\n }\n }\n definitions.add(definition);\n }\n return definitions;\n }\n /**\n * Returns definitions matching the given model name.\n */\n getDefinitionsForModel(modelName) {\n return this._definitions.filter(definition => definition.model == modelName);\n }\n /**\n * Returns definitions matching the given view name.\n */\n _getMatchingViewDefinitions(viewName) {\n return this._definitions.filter(def => def.view && testViewName(viewName, def.view));\n }\n /**\n * Resolves all definition references registered for the given data schema definition.\n *\n * @param modelName Data schema model name.\n */\n *_getReferences(modelName) {\n const inheritProperties = [\n 'inheritAllFrom',\n 'inheritTypesFrom',\n 'allowWhere',\n 'allowContentOf',\n 'allowAttributesOf'\n ];\n const definitions = this._definitions.filter(definition => definition.model == modelName);\n for (const { modelSchema } of definitions) {\n if (!modelSchema) {\n continue;\n }\n for (const property of inheritProperties) {\n for (const referenceName of toArray(modelSchema[property] || [])) {\n const definitions = this._definitions.filter(definition => definition.model == referenceName);\n for (const definition of definitions) {\n if (referenceName !== modelName) {\n yield* this._getReferences(definition.model);\n yield definition;\n }\n }\n }\n }\n }\n }\n /**\n * Updates schema definition with new properties.\n *\n * Creates new scheme if it doesn't exist.\n * Array properties are concatenated with original values.\n *\n * @param definition Definition update.\n */\n _extendDefinition(definition) {\n const currentDefinitions = Array.from(this._definitions.entries())\n .filter(([, currentDefinition]) => currentDefinition.model == definition.model);\n if (currentDefinitions.length == 0) {\n this._definitions.push(definition);\n return;\n }\n for (const [idx, currentDefinition] of currentDefinitions) {\n this._definitions[idx] = mergeWith({}, currentDefinition, definition, (target, source) => {\n return Array.isArray(target) ? target.concat(source) : undefined;\n });\n }\n }\n}\n/**\n * Test view name against the given pattern.\n */\nfunction testViewName(pattern, viewName) {\n if (typeof pattern === 'string') {\n return pattern === viewName;\n }\n if (pattern instanceof RegExp) {\n return pattern.test(viewName);\n }\n return false;\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module html-support/datafilter\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { Matcher, StylesMap } from 'ckeditor5/src/engine.js';\nimport { CKEditorError, priorities, isValidAttributeName } from 'ckeditor5/src/utils.js';\nimport { Widget } from 'ckeditor5/src/widget.js';\nimport { viewToModelObjectConverter, toObjectWidgetConverter, createObjectView, viewToAttributeInlineConverter, attributeToViewInlineConverter, emptyInlineModelElementToViewConverter, viewToModelBlockAttributeConverter, modelToViewBlockAttributeConverter } from './converters.js';\nimport { DataSchema } from './dataschema.js';\nimport { getHtmlAttributeName } from './utils.js';\nimport { isPlainObject } from 'es-toolkit/compat';\nimport '../theme/datafilter.css';\n/**\n * Allows to validate elements and element attributes registered by {@link module:html-support/dataschema~DataSchema}.\n *\n * To enable registered element in the editor, use {@link module:html-support/datafilter~DataFilter#allowElement} method:\n *\n * ```ts\n * dataFilter.allowElement( 'section' );\n * ```\n *\n * You can also allow or disallow specific element attributes:\n *\n * ```ts\n * // Allow `data-foo` attribute on `section` element.\n * dataFilter.allowAttributes( {\n * \tname: 'section',\n * \tattributes: {\n * \t\t'data-foo': true\n * \t}\n * } );\n *\n * // Disallow `color` style attribute on 'section' element.\n * dataFilter.disallowAttributes( {\n * \tname: 'section',\n * \tstyles: {\n * \t\tcolor: /[\\s\\S]+/\n * \t}\n * } );\n * ```\n *\n * To apply the information about allowed and disallowed attributes in custom integration plugin,\n * use the {@link module:html-support/datafilter~DataFilter#processViewAttributes `processViewAttributes()`} method.\n */\nexport class DataFilter extends Plugin {\n /**\n * An instance of the {@link module:html-support/dataschema~DataSchema}.\n */\n _dataSchema;\n /**\n * {@link module:engine/view/matcher~Matcher Matcher} instance describing rules upon which\n * content attributes should be allowed.\n */\n _allowedAttributes;\n /**\n * {@link module:engine/view/matcher~Matcher Matcher} instance describing rules upon which\n * content attributes should be disallowed.\n */\n _disallowedAttributes;\n /**\n * Allowed element definitions by {@link module:html-support/datafilter~DataFilter#allowElement} method.\n */\n _allowedElements;\n /**\n * Disallowed element names by {@link module:html-support/datafilter~DataFilter#disallowElement} method.\n */\n _disallowedElements;\n /**\n * Indicates if {@link module:engine/controller/datacontroller~DataController editor's data controller}\n * data has been already initialized.\n */\n _dataInitialized;\n /**\n * Cached map of coupled attributes. Keys are the feature attributes names\n * and values are arrays with coupled GHS attributes names.\n */\n _coupledAttributes;\n constructor(editor) {\n super(editor);\n this._dataSchema = editor.plugins.get('DataSchema');\n this._allowedAttributes = new Matcher();\n this._disallowedAttributes = new Matcher();\n this._allowedElements = new Set();\n this._disallowedElements = new Set();\n this._dataInitialized = false;\n this._coupledAttributes = null;\n this._registerElementsAfterInit();\n this._registerElementHandlers();\n this._registerCoupledAttributesPostFixer();\n this._registerAssociatedHtmlAttributesPostFixer();\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'DataFilter';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n static get requires() {\n return [DataSchema, Widget];\n }\n /**\n * Load a configuration of one or many elements, where their attributes should be allowed.\n *\n * **Note**: Rules will be applied just before next data pipeline data init or set.\n *\n * @param config Configuration of elements that should have their attributes accepted in the editor.\n */\n loadAllowedConfig(config) {\n for (const pattern of config) {\n // MatcherPattern allows omitting `name` to widen the search of elements.\n // Let's keep it consistent and match every element if a `name` has not been provided.\n const elementName = pattern.name || /[\\s\\S]+/;\n const rules = splitRules(pattern);\n this.allowElement(elementName);\n rules.forEach(pattern => this.allowAttributes(pattern));\n }\n }\n /**\n * Load a configuration of one or many elements, where their attributes should be disallowed.\n *\n * **Note**: Rules will be applied just before next data pipeline data init or set.\n *\n * @param config Configuration of elements that should have their attributes rejected from the editor.\n */\n loadDisallowedConfig(config) {\n for (const pattern of config) {\n // MatcherPattern allows omitting `name` to widen the search of elements.\n // Let's keep it consistent and match every element if a `name` has not been provided.\n const elementName = pattern.name || /[\\s\\S]+/;\n const rules = splitRules(pattern);\n // Disallow element itself if there is no other rules.\n if (rules.length == 0) {\n this.disallowElement(elementName);\n }\n else {\n rules.forEach(pattern => this.disallowAttributes(pattern));\n }\n }\n }\n /**\n * Load a configuration of one or many elements, where when empty should be allowed.\n *\n * **Note**: It modifies DataSchema so must be loaded before registering filtering rules.\n *\n * @param config Configuration of elements that should be preserved even if empty.\n */\n loadAllowedEmptyElementsConfig(config) {\n for (const elementName of config) {\n this.allowEmptyElement(elementName);\n }\n }\n /**\n * Allow the given element in the editor context.\n *\n * This method will only allow elements described by the {@link module:html-support/dataschema~DataSchema} used\n * to create data filter.\n *\n * **Note**: Rules will be applied just before next data pipeline data init or set.\n *\n * @param viewName String or regular expression matching view name.\n */\n allowElement(viewName) {\n for (const definition of this._dataSchema.getDefinitionsForView(viewName, true)) {\n this._addAllowedElement(definition);\n // Reset cached map to recalculate it on the next usage.\n this._coupledAttributes = null;\n }\n }\n /**\n * Disallow the given element in the editor context.\n *\n * This method will only disallow elements described by the {@link module:html-support/dataschema~DataSchema} used\n * to create data filter.\n *\n * @param viewName String or regular expression matching view name.\n */\n disallowElement(viewName) {\n for (const definition of this._dataSchema.getDefinitionsForView(viewName, false)) {\n this._disallowedElements.add(definition.view);\n }\n }\n /**\n * Allow the given empty element in the editor context.\n *\n * This method will only allow elements described by the {@link module:html-support/dataschema~DataSchema} used\n * to create data filter.\n *\n * **Note**: It modifies DataSchema so must be called before registering filtering rules.\n *\n * @param viewName String or regular expression matching view name.\n */\n allowEmptyElement(viewName) {\n for (const definition of this._dataSchema.getDefinitionsForView(viewName, true)) {\n if (definition.isInline) {\n this._dataSchema.extendInlineElement({ ...definition, allowEmpty: true });\n }\n }\n }\n /**\n * Allow the given attributes for view element allowed by {@link #allowElement} method.\n *\n * @param config Pattern matching all attributes which should be allowed.\n */\n allowAttributes(config) {\n this._allowedAttributes.add(config);\n }\n /**\n * Disallow the given attributes for view element allowed by {@link #allowElement} method.\n *\n * @param config Pattern matching all attributes which should be disallowed.\n */\n disallowAttributes(config) {\n this._disallowedAttributes.add(config);\n }\n /**\n * Processes all allowed and disallowed attributes on the view element by consuming them and returning the allowed ones.\n *\n * This method applies the configuration set up by {@link #allowAttributes `allowAttributes()`}\n * and {@link #disallowAttributes `disallowAttributes()`} over the given view element by consuming relevant attributes.\n * It returns the allowed attributes that were found on the given view element for further processing by integration code.\n *\n * ```ts\n * dispatcher.on( 'element:myElement', ( evt, data, conversionApi ) => {\n * \t// Get rid of disallowed and extract all allowed attributes from a viewElement.\n * \tconst viewAttributes = dataFilter.processViewAttributes( data.viewItem, conversionApi );\n * \t// Do something with them, i.e. store inside a model as a dictionary.\n * \tif ( viewAttributes ) {\n * \t\tconversionApi.writer.setAttribute( 'htmlAttributesOfMyElement', viewAttributes, data.modelRange );\n * \t}\n * } );\n * ```\n *\n * @see module:engine/conversion/viewconsumable~ViewConsumable#consume\n *\n * @returns Object with following properties:\n * - attributes Set with matched attribute names.\n * - styles Set with matched style names.\n * - classes Set with matched class names.\n */\n processViewAttributes(viewElement, conversionApi) {\n const { consumable } = conversionApi;\n // Make sure that the disabled attributes are handled before the allowed attributes are called.\n // For example, for block images the
                    converter triggers conversion for first and then for other elements, i.e. .\n matchAndConsumeAttributes(viewElement, this._disallowedAttributes, consumable);\n return prepareGHSAttribute(viewElement, matchAndConsumeAttributes(viewElement, this._allowedAttributes, consumable));\n }\n /**\n * Adds allowed element definition and fires registration event.\n */\n _addAllowedElement(definition) {\n if (this._allowedElements.has(definition)) {\n return;\n }\n this._allowedElements.add(definition);\n // For attribute based integrations (table figure, document lists, etc.) register related element definitions.\n if ('appliesToBlock' in definition && typeof definition.appliesToBlock == 'string') {\n for (const relatedDefinition of this._dataSchema.getDefinitionsForModel(definition.appliesToBlock)) {\n if (relatedDefinition.isBlock) {\n this._addAllowedElement(relatedDefinition);\n }\n }\n }\n // We need to wait for all features to be initialized before we can register\n // element, so we can access existing features model schemas.\n // If the data has not been initialized yet, _registerElementsAfterInit() method will take care of\n // registering elements.\n if (this._dataInitialized) {\n // Defer registration to the next data pipeline data set so any disallow rules could be applied\n // even if added after allow rule (disallowElement).\n this.editor.data.once('set', () => {\n this._fireRegisterEvent(definition);\n }, {\n // With the highest priority listener we are able to register elements right before\n // running data conversion.\n priority: priorities.highest + 1\n });\n }\n }\n /**\n * Registers elements allowed by {@link module:html-support/datafilter~DataFilter#allowElement} method\n * once {@link module:engine/controller/datacontroller~DataController editor's data controller} is initialized.\n */\n _registerElementsAfterInit() {\n this.editor.data.on('init', () => {\n this._dataInitialized = true;\n for (const definition of this._allowedElements) {\n this._fireRegisterEvent(definition);\n }\n }, {\n // With highest priority listener we are able to register elements right before\n // running data conversion. Also:\n // * Make sure that priority is higher than the one used by `RealTimeCollaborationClient`,\n // as RTC is stopping event propagation.\n // * Make sure no other features hook into this event before GHS because otherwise the\n // downcast conversion (for these features) could run before GHS registered its converters\n // (https://github.com/ckeditor/ckeditor5/issues/11356).\n priority: priorities.highest + 1\n });\n }\n /**\n * Registers default element handlers.\n */\n _registerElementHandlers() {\n this.on('register', (evt, definition) => {\n const schema = this.editor.model.schema;\n // Object element should be only registered for new features.\n // If the model schema is already registered, it should be handled by\n // #_registerBlockElement() or #_registerObjectElement() attribute handlers.\n if (definition.isObject && !schema.isRegistered(definition.model)) {\n this._registerObjectElement(definition);\n }\n else if (definition.isBlock) {\n this._registerBlockElement(definition);\n }\n else if (definition.isInline) {\n this._registerInlineElement(definition);\n }\n else {\n /**\n * The definition cannot be handled by the data filter.\n *\n * Make sure that the registered definition is correct.\n *\n * @error data-filter-invalid-definition\n */\n throw new CKEditorError('data-filter-invalid-definition', null, definition);\n }\n evt.stop();\n }, { priority: 'lowest' });\n }\n /**\n * Registers a model post-fixer that is removing coupled GHS attributes of inline elements. Those attributes\n * are removed if a coupled feature attribute is removed.\n *\n * For example, consider following HTML:\n *\n * ```html\n * bar\n * ```\n *\n * Which would be upcasted to following text node in the model:\n *\n * ```html\n * <$text linkHref=\"foo.html\" htmlA=\"{ attributes: { id: 'myId' } }\">bar\n * ```\n *\n * When the user removes the link from that text (using UI), only `linkHref` attribute would be removed:\n *\n * ```html\n * <$text htmlA=\"{ attributes: { id: 'myId' } }\">bar\n * ```\n *\n * The `htmlA` attribute would stay in the model and would cause GHS to generate an `` element.\n * This is incorrect from UX point of view, as the user wanted to remove the whole link (not only `href`).\n */\n _registerCoupledAttributesPostFixer() {\n const model = this.editor.model;\n const selection = model.document.selection;\n model.document.registerPostFixer(writer => {\n const changes = model.document.differ.getChanges();\n let changed = false;\n const coupledAttributes = this._getCoupledAttributesMap();\n for (const change of changes) {\n // Handle only attribute removals.\n if (change.type != 'attribute' || change.attributeNewValue !== null) {\n continue;\n }\n // Find a list of coupled GHS attributes.\n const attributeKeys = coupledAttributes.get(change.attributeKey);\n if (!attributeKeys) {\n continue;\n }\n // Remove the coupled GHS attributes on the same range as the feature attribute was removed.\n for (const { item } of change.range.getWalker()) {\n for (const attributeKey of attributeKeys) {\n if (item.hasAttribute(attributeKey)) {\n writer.removeAttribute(attributeKey, item);\n changed = true;\n }\n }\n }\n }\n return changed;\n });\n this.listenTo(selection, 'change:attribute', (evt, { attributeKeys }) => {\n const removeAttributes = new Set();\n const coupledAttributes = this._getCoupledAttributesMap();\n for (const attributeKey of attributeKeys) {\n // Handle only attribute removals.\n if (selection.hasAttribute(attributeKey)) {\n continue;\n }\n // Find a list of coupled GHS attributes.\n const coupledAttributeKeys = coupledAttributes.get(attributeKey);\n if (!coupledAttributeKeys) {\n continue;\n }\n for (const coupledAttributeKey of coupledAttributeKeys) {\n if (selection.hasAttribute(coupledAttributeKey)) {\n removeAttributes.add(coupledAttributeKey);\n }\n }\n }\n if (removeAttributes.size == 0) {\n return;\n }\n model.change(writer => {\n for (const attributeKey of removeAttributes) {\n writer.removeSelectionAttribute(attributeKey);\n }\n });\n });\n }\n /**\n * Removes `html*Attributes` attributes from incompatible elements.\n *\n * For example, consider the following HTML:\n *\n * ```html\n * foobar[]\n * ```\n *\n * Pressing `enter` creates a new `paragraph` element that inherits\n * the `htmlH2Attributes` attribute from `heading2`.\n *\n * ```html\n * foobar\n * []\n * ```\n *\n * This postfixer ensures that this doesn't happen, and that elements can\n * only have `html*Attributes` associated with them,\n * e.g.: `htmlPAttributes` for `

                    `, `htmlDivAttributes` for `

                    `, etc.\n *\n * With it enabled, pressing `enter` at the end of `` will create\n * a new paragraph without the `htmlH2Attributes` attribute.\n *\n * ```html\n * foobar\n * []\n * ```\n */\n _registerAssociatedHtmlAttributesPostFixer() {\n const model = this.editor.model;\n model.document.registerPostFixer(writer => {\n const changes = model.document.differ.getChanges();\n let changed = false;\n for (const change of changes) {\n if (change.type !== 'insert' || change.name === '$text') {\n continue;\n }\n for (const attr of change.attributes.keys()) {\n if (!attr.startsWith('html') || !attr.endsWith('Attributes')) {\n continue;\n }\n if (!model.schema.checkAttribute(change.name, attr)) {\n writer.removeAttribute(attr, change.position.nodeAfter);\n changed = true;\n }\n }\n }\n return changed;\n });\n }\n /**\n * Collects the map of coupled attributes. The returned map is keyed by the feature attribute name\n * and coupled GHS attribute names are stored in the value array.\n */\n _getCoupledAttributesMap() {\n if (this._coupledAttributes) {\n return this._coupledAttributes;\n }\n this._coupledAttributes = new Map();\n for (const definition of this._allowedElements) {\n if (definition.coupledAttribute && definition.model) {\n const attributeNames = this._coupledAttributes.get(definition.coupledAttribute);\n if (attributeNames) {\n attributeNames.push(definition.model);\n }\n else {\n this._coupledAttributes.set(definition.coupledAttribute, [definition.model]);\n }\n }\n }\n return this._coupledAttributes;\n }\n /**\n * Fires `register` event for the given element definition.\n */\n _fireRegisterEvent(definition) {\n if (definition.view && this._disallowedElements.has(definition.view)) {\n return;\n }\n this.fire(definition.view ? `register:${definition.view}` : 'register', definition);\n }\n /**\n * Registers object element and attribute converters for the given data schema definition.\n */\n _registerObjectElement(definition) {\n const editor = this.editor;\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n const { view: viewName, model: modelName } = definition;\n schema.register(modelName, definition.modelSchema);\n /* istanbul ignore next: paranoid check -- @preserve */\n if (!viewName) {\n return;\n }\n schema.extend(definition.model, {\n allowAttributes: [getHtmlAttributeName(viewName), 'htmlContent']\n });\n // Store element content in special `$rawContent` custom property to\n // avoid editor's data filtering mechanism.\n editor.data.registerRawContentMatcher({\n name: viewName\n });\n conversion.for('upcast').elementToElement({\n view: viewName,\n model: viewToModelObjectConverter(definition),\n // With a `low` priority, `paragraph` plugin auto-paragraphing mechanism is executed. Make sure\n // this listener is called before it. If not, some elements will be transformed into a paragraph.\n // `+ 2` is used to take priority over `_addDefaultH1Conversion` in the Heading plugin.\n converterPriority: priorities.low + 2\n });\n conversion.for('upcast')\n .add(viewToModelBlockAttributeConverter(definition, this));\n conversion.for('editingDowncast').elementToStructure({\n model: {\n name: modelName,\n attributes: [getHtmlAttributeName(viewName)]\n },\n view: toObjectWidgetConverter(editor, definition)\n });\n conversion.for('dataDowncast').elementToElement({\n model: modelName,\n view: (modelElement, { writer }) => {\n return createObjectView(viewName, modelElement, writer);\n }\n });\n conversion.for('dataDowncast')\n .add(modelToViewBlockAttributeConverter(definition));\n }\n /**\n * Registers block element and attribute converters for the given data schema definition.\n */\n _registerBlockElement(definition) {\n const editor = this.editor;\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n const { view: viewName, model: modelName } = definition;\n if (!schema.isRegistered(definition.model)) {\n // Do not register converters and empty schema for editor existing feature\n // as empty schema won't allow element anywhere in the model.\n if (!definition.modelSchema) {\n return;\n }\n schema.register(definition.model, definition.modelSchema);\n if (!viewName) {\n return;\n }\n conversion.for('upcast').elementToElement({\n model: modelName,\n view: viewName,\n // With a `low` priority, `paragraph` plugin auto-paragraphing mechanism is executed. Make sure\n // this listener is called before it. If not, some elements will be transformed into a paragraph.\n // `+ 2` is used to take priority over `_addDefaultH1Conversion` in the Heading plugin.\n converterPriority: priorities.low + 2\n });\n conversion.for('downcast').elementToElement({\n model: modelName,\n view: (modelElement, { writer }) => definition.isEmpty ?\n writer.createEmptyElement(viewName) :\n writer.createContainerElement(viewName)\n });\n }\n if (!viewName) {\n return;\n }\n schema.extend(definition.model, {\n allowAttributes: getHtmlAttributeName(viewName)\n });\n conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, this));\n conversion.for('downcast').add(modelToViewBlockAttributeConverter(definition));\n }\n /**\n * Registers inline element and attribute converters for the given data schema definition.\n *\n * Extends `$text` model schema to allow the given definition model attribute and its properties.\n */\n _registerInlineElement(definition) {\n const editor = this.editor;\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n const attributeKey = definition.model;\n // This element is stored in the model as an attribute on a block element, for example Lists.\n if (definition.appliesToBlock) {\n return;\n }\n schema.extend('$text', {\n allowAttributes: attributeKey\n });\n if (definition.attributeProperties) {\n schema.setAttributeProperties(attributeKey, definition.attributeProperties);\n }\n conversion.for('upcast').add(viewToAttributeInlineConverter(definition, this));\n conversion.for('downcast').attributeToElement({\n model: attributeKey,\n view: attributeToViewInlineConverter(definition)\n });\n if (!definition.allowEmpty) {\n return;\n }\n schema.setAttributeProperties(attributeKey, { copyFromObject: false });\n if (!schema.isRegistered('htmlEmptyElement')) {\n schema.register('htmlEmptyElement', {\n inheritAllFrom: '$inlineObject'\n });\n // Helper function to check if an element has any HTML attributes.\n const hasHtmlAttributes = (element) => Array\n .from(element.getAttributeKeys())\n .some(key => key.startsWith('html'));\n // Register a post-fixer that removes htmlEmptyElement when its htmlXX attribute is removed.\n // See: https://github.com/ckeditor/ckeditor5/issues/18089\n editor.model.document.registerPostFixer(writer => {\n const changes = editor.model.document.differ.getChanges();\n const elementsToRemove = new Set();\n for (const change of changes) {\n if (change.type === 'remove') {\n continue;\n }\n // Look for removal of html* attributes.\n if (change.type === 'attribute' && change.attributeNewValue === null) {\n // Find htmlEmptyElement instances in the range that lost their html attribute.\n for (const { item } of change.range) {\n if (item.is('element', 'htmlEmptyElement') && !hasHtmlAttributes(item)) {\n elementsToRemove.add(item);\n }\n }\n }\n // Look for insertion of htmlEmptyElement.\n if (change.type === 'insert' && change.position.nodeAfter) {\n const insertedElement = change.position.nodeAfter;\n for (const { item } of writer.createRangeOn(insertedElement)) {\n if (item.is('element', 'htmlEmptyElement') && !hasHtmlAttributes(item)) {\n elementsToRemove.add(item);\n }\n }\n }\n }\n for (const element of elementsToRemove) {\n writer.remove(element);\n }\n return elementsToRemove.size > 0;\n });\n }\n editor.data.htmlProcessor.domConverter.registerInlineObjectMatcher(element => {\n // Element must be empty and have any attribute.\n if (element.name == definition.view &&\n element.isEmpty &&\n Array.from(element.getAttributeKeys()).length) {\n return {\n name: true\n };\n }\n return null;\n });\n conversion.for('editingDowncast')\n .elementToElement({\n model: 'htmlEmptyElement',\n view: emptyInlineModelElementToViewConverter(definition, true)\n });\n conversion.for('dataDowncast')\n .elementToElement({\n model: 'htmlEmptyElement',\n view: emptyInlineModelElementToViewConverter(definition)\n });\n }\n}\n/**\n * Matches and consumes matched attributes.\n *\n * @returns Object with following properties:\n * - attributes Array with matched attribute names.\n * - classes Array with matched class names.\n * - styles Array with matched style names.\n */\nfunction matchAndConsumeAttributes(viewElement, matcher, consumable) {\n const matches = matcher.matchAll(viewElement) || [];\n const stylesProcessor = viewElement.document.stylesProcessor;\n return matches.reduce((result, { match }) => {\n for (const [key, token] of match.attributes || []) {\n // Verify and consume styles.\n if (key == 'style') {\n const style = token;\n // Check longer forms of the same style as those could be matched\n // but not present in the element directly.\n // Consider only longhand (or longer than current notation) so that\n // we do not include all sides of the box if only one side is allowed.\n const sortedRelatedStyles = stylesProcessor.getRelatedStyles(style)\n .filter(relatedStyle => relatedStyle.split('-').length > style.split('-').length)\n .sort((a, b) => b.split('-').length - a.split('-').length);\n for (const relatedStyle of sortedRelatedStyles) {\n if (consumable.consume(viewElement, { styles: [relatedStyle] })) {\n result.styles.push(relatedStyle);\n }\n }\n // Verify and consume style as specified in the matcher.\n if (consumable.consume(viewElement, { styles: [style] })) {\n result.styles.push(style);\n }\n }\n // Verify and consume class names.\n else if (key == 'class') {\n const className = token;\n if (consumable.consume(viewElement, { classes: [className] })) {\n result.classes.push(className);\n }\n }\n else {\n // Verify and consume other attributes.\n if (consumable.consume(viewElement, { attributes: [key] })) {\n result.attributes.push(key);\n }\n }\n }\n return result;\n }, {\n attributes: [],\n classes: [],\n styles: []\n });\n}\n/**\n * Prepares the GHS attribute value as an object with element attributes' values.\n */\nfunction prepareGHSAttribute(viewElement, { attributes, classes, styles }) {\n if (!attributes.length && !classes.length && !styles.length) {\n return null;\n }\n return {\n ...(attributes.length && {\n attributes: getAttributes(viewElement, attributes)\n }),\n ...(styles.length && {\n styles: getReducedStyles(viewElement, styles)\n }),\n ...(classes.length && {\n classes\n })\n };\n}\n/**\n * Returns attributes as an object with names and values.\n */\nfunction getAttributes(viewElement, attributes) {\n const attributesObject = {};\n for (const key of attributes) {\n const value = viewElement.getAttribute(key);\n if (value !== undefined && isValidAttributeName(key)) {\n attributesObject[key] = value;\n }\n }\n return attributesObject;\n}\n/**\n * Returns styles as an object reduced to shorthand notation without redundant entries.\n */\nfunction getReducedStyles(viewElement, styles) {\n // Use StyleMap to reduce style value to the minimal form (without shorthand and long-hand notation and duplication).\n const stylesMap = new StylesMap(viewElement.document.stylesProcessor);\n for (const key of styles) {\n const styleValue = viewElement.getStyle(key);\n if (styleValue !== undefined) {\n stylesMap.set(key, styleValue);\n }\n }\n return Object.fromEntries(stylesMap.getStylesEntries());\n}\n/**\n * Matcher by default has to match **all** patterns to count it as an actual match. Splitting the pattern\n * into separate patterns means that any matched pattern will be count as a match.\n *\n * @param pattern Pattern to split.\n * @param attributeName Name of the attribute to split (e.g. 'attributes', 'classes', 'styles').\n */\nfunction splitPattern(pattern, attributeName) {\n const { name } = pattern;\n const attributeValue = pattern[attributeName];\n if (isPlainObject(attributeValue)) {\n return Object.entries(attributeValue)\n .map(([key, value]) => ({\n name,\n [attributeName]: {\n [key]: value\n }\n }));\n }\n if (Array.isArray(attributeValue)) {\n return attributeValue\n .map(value => ({\n name,\n [attributeName]: [value]\n }));\n }\n return [pattern];\n}\n/**\n * Rules are matched in conjunction (AND operation), but we want to have a match if *any* of the rules is matched (OR operation).\n * By splitting the rules we force the latter effect.\n */\nfunction splitRules(rules) {\n const { name, attributes, classes, styles } = rules;\n const splitRules = [];\n if (attributes) {\n splitRules.push(...splitPattern({ name, attributes }, 'attributes'));\n }\n if (classes) {\n splitRules.push(...splitPattern({ name, classes }, 'classes'));\n }\n if (styles) {\n splitRules.push(...splitPattern({ name, styles }, 'styles'));\n }\n return splitRules;\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { updateViewAttributes } from '../utils.js';\nimport { DataFilter } from '../datafilter.js';\n/**\n * Provides the General HTML Support integration with {@link module:code-block/codeblock~CodeBlock Code Block} feature.\n */\nexport class CodeBlockElementSupport extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [DataFilter];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'CodeBlockElementSupport';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n if (!this.editor.plugins.has('CodeBlockEditing')) {\n return;\n }\n const dataFilter = this.editor.plugins.get(DataFilter);\n dataFilter.on('register:pre', (evt, definition) => {\n if (definition.model !== 'codeBlock') {\n return;\n }\n const editor = this.editor;\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n // Extend codeBlock to allow attributes required by attribute filtration.\n schema.extend('codeBlock', {\n allowAttributes: ['htmlPreAttributes', 'htmlContentAttributes']\n });\n conversion.for('upcast').add(viewToModelCodeBlockAttributeConverter(dataFilter));\n conversion.for('downcast').add(modelToViewCodeBlockAttributeConverter());\n evt.stop();\n });\n }\n}\n/**\n * View-to-model conversion helper preserving allowed attributes on {@link module:code-block/codeblock~CodeBlock Code Block}\n * feature model element.\n *\n * Attributes are preserved as a value of `html*Attributes` model attribute.\n * @param dataFilter\n * @returns Returns a conversion callback.\n */\nfunction viewToModelCodeBlockAttributeConverter(dataFilter) {\n return (dispatcher) => {\n dispatcher.on('element:code', (evt, data, conversionApi) => {\n const viewCodeElement = data.viewItem;\n const viewPreElement = viewCodeElement.parent;\n if (!viewPreElement || !viewPreElement.is('element', 'pre')) {\n return;\n }\n preserveElementAttributes(viewPreElement, 'htmlPreAttributes');\n preserveElementAttributes(viewCodeElement, 'htmlContentAttributes');\n function preserveElementAttributes(viewElement, attributeName) {\n const viewAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);\n if (viewAttributes) {\n conversionApi.writer.setAttribute(attributeName, viewAttributes, data.modelRange);\n }\n }\n }, { priority: 'low' });\n };\n}\n/**\n * Model-to-view conversion helper applying attributes from {@link module:code-block/codeblock~CodeBlock Code Block}\n * feature model element.\n * @returns Returns a conversion callback.\n */\nfunction modelToViewCodeBlockAttributeConverter() {\n return (dispatcher) => {\n dispatcher.on('attribute:htmlPreAttributes:codeBlock', (evt, data, conversionApi) => {\n if (!conversionApi.consumable.consume(data.item, evt.name)) {\n return;\n }\n const { attributeOldValue, attributeNewValue } = data;\n const viewCodeElement = conversionApi.mapper.toViewElement(data.item);\n const viewPreElement = viewCodeElement.parent;\n updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewPreElement);\n });\n dispatcher.on('attribute:htmlContentAttributes:codeBlock', (evt, data, conversionApi) => {\n if (!conversionApi.consumable.consume(data.item, evt.name)) {\n return;\n }\n const { attributeOldValue, attributeNewValue } = data;\n const viewCodeElement = conversionApi.mapper.toViewElement(data.item);\n updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewCodeElement);\n });\n };\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { priorities } from 'ckeditor5/src/utils.js';\nimport { modelToViewBlockAttributeConverter, viewToModelBlockAttributeConverter } from '../converters.js';\nimport { DataFilter } from '../datafilter.js';\nimport { getHtmlAttributeName } from '../utils.js';\n/**\n * Provides the General HTML Support integration for elements which can behave like sectioning element (e.g. article) or\n * element accepting only inline content (e.g. paragraph).\n *\n * The distinction between this two content models is important for choosing correct schema model and proper content conversion.\n * As an example, it ensures that:\n *\n * * children elements paragraphing is enabled for sectioning elements only,\n * * element and its content can be correctly handled by editing view (splitting and merging elements),\n * * model element HTML is semantically correct and easier to work with.\n *\n * If element contains any block element, it will be treated as a sectioning element and registered using\n * {@link module:html-support/dataschema~HtmlSupportDataSchemaDefinition#model} and\n * {@link module:html-support/dataschema~HtmlSupportDataSchemaDefinition#modelSchema} in editor schema.\n * Otherwise, it will be registered under\n * {@link module:html-support/dataschema~HtmlSupportDataSchemaBlockElementDefinition#paragraphLikeModel} model\n * name with model schema accepting only inline content (inheriting from `$block`).\n */\nexport class DualContentModelElementSupport extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [DataFilter];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'DualContentModelElementSupport';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const dataFilter = this.editor.plugins.get(DataFilter);\n dataFilter.on('register', (evt, definition) => {\n const blockDefinition = definition;\n const editor = this.editor;\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n if (!blockDefinition.paragraphLikeModel) {\n return;\n }\n // Can only apply to newly registered features.\n if (schema.isRegistered(blockDefinition.model) || schema.isRegistered(blockDefinition.paragraphLikeModel)) {\n return;\n }\n const paragraphLikeModelDefinition = {\n model: blockDefinition.paragraphLikeModel,\n view: blockDefinition.view\n };\n schema.register(blockDefinition.model, blockDefinition.modelSchema);\n schema.register(paragraphLikeModelDefinition.model, {\n inheritAllFrom: '$block'\n });\n conversion.for('upcast').elementToElement({\n view: blockDefinition.view,\n model: (viewElement, { writer }) => {\n if (this._hasBlockContent(viewElement)) {\n return writer.createElement(blockDefinition.model);\n }\n return writer.createElement(paragraphLikeModelDefinition.model);\n },\n // With a `low` priority, `paragraph` plugin auto-paragraphing mechanism is executed. Make sure\n // this listener is called before it. If not, some elements will be transformed into a paragraph.\n converterPriority: priorities.low + 0.5\n });\n conversion.for('downcast').elementToElement({\n view: blockDefinition.view,\n model: blockDefinition.model\n });\n this._addAttributeConversion(blockDefinition);\n conversion.for('downcast').elementToElement({\n view: paragraphLikeModelDefinition.view,\n model: paragraphLikeModelDefinition.model\n });\n this._addAttributeConversion(paragraphLikeModelDefinition);\n evt.stop();\n });\n }\n /**\n * Checks whether the given view element includes any other block element.\n */\n _hasBlockContent(viewElement) {\n const view = this.editor.editing.view;\n const blockElements = view.domConverter.blockElements;\n // Traversing the viewElement subtree looking for block elements.\n // Especially for the cases like .\n // https://github.com/ckeditor/ckeditor5/issues/11513\n for (const viewItem of view.createRangeIn(viewElement).getItems()) {\n if (viewItem.is('element') && blockElements.includes(viewItem.name)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Adds attribute filtering conversion for the given data schema.\n */\n _addAttributeConversion(definition) {\n const editor = this.editor;\n const conversion = editor.conversion;\n const dataFilter = editor.plugins.get(DataFilter);\n editor.model.schema.extend(definition.model, {\n allowAttributes: getHtmlAttributeName(definition.view)\n });\n conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, dataFilter));\n conversion.for('downcast').add(modelToViewBlockAttributeConverter(definition));\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module html-support/integrations/heading\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { Enter } from 'ckeditor5/src/enter.js';\nimport { DataSchema } from '../dataschema.js';\n/**\n * Provides the General HTML Support integration with {@link module:heading/heading~Heading Heading} feature.\n */\nexport class HeadingElementSupport extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [DataSchema, Enter];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'HeadingElementSupport';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n if (!editor.plugins.has('HeadingEditing')) {\n return;\n }\n const options = editor.config.get('heading.options');\n this.registerHeadingElements(editor, options);\n }\n /**\n * Registers all elements supported by HeadingEditing to enable custom attributes for those elements.\n */\n registerHeadingElements(editor, options) {\n const dataSchema = editor.plugins.get(DataSchema);\n const headerModels = [];\n for (const option of options) {\n if ('model' in option && 'view' in option) {\n dataSchema.registerBlockElement({\n view: option.view,\n model: option.model\n });\n headerModels.push(option.model);\n }\n }\n dataSchema.extendBlockElement({\n model: 'htmlHgroup',\n modelSchema: {\n allowChildren: headerModels\n }\n });\n dataSchema.extendBlockElement({\n model: 'htmlSummary',\n modelSchema: {\n allowChildren: headerModels\n }\n });\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module html-support/integrations/integrationutils\n */\n/**\n * Returns the first view element descendant matching the given view name.\n * Includes view element itself.\n *\n * @internal\n */\nexport function getDescendantElement(writer, containerElement, elementName) {\n const range = writer.createRangeOn(containerElement);\n for (const { item } of range.getWalker()) {\n if (item.is('element', elementName)) {\n return item;\n }\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module html-support/integrations/image\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { DataFilter } from '../datafilter.js';\nimport { setViewAttributes, updateViewAttributes } from '../utils.js';\nimport { getDescendantElement } from './integrationutils.js';\n/**\n * Provides the General HTML Support integration with the {@link module:image/image~Image Image} feature.\n */\nexport class ImageElementSupport extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [DataFilter];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'ImageElementSupport';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n // At least one image plugin should be loaded for the integration to work properly.\n if (!editor.plugins.has('ImageInlineEditing') && !editor.plugins.has('ImageBlockEditing')) {\n return;\n }\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n const dataFilter = editor.plugins.get(DataFilter);\n dataFilter.on('register:figure', () => {\n conversion.for('upcast').add(viewToModelFigureAttributeConverter(dataFilter));\n });\n dataFilter.on('register:img', (evt, definition) => {\n if (definition.model !== 'imageBlock' && definition.model !== 'imageInline') {\n return;\n }\n if (schema.isRegistered('imageBlock')) {\n schema.extend('imageBlock', {\n allowAttributes: [\n 'htmlImgAttributes',\n // Figure and Link don't have model counterpart.\n // We will preserve attributes on image model element using these attribute keys.\n 'htmlFigureAttributes',\n 'htmlLinkAttributes'\n ]\n });\n }\n if (schema.isRegistered('imageInline')) {\n schema.extend('imageInline', {\n allowAttributes: [\n // `htmlA` is needed for standard GHS link integration.\n 'htmlA',\n 'htmlImgAttributes'\n ]\n });\n }\n conversion.for('upcast').add(viewToModelImageAttributeConverter(dataFilter));\n conversion.for('downcast').add(modelToViewImageAttributeConverter());\n if (editor.plugins.has('LinkImage')) {\n conversion.for('upcast').add(viewToModelLinkImageAttributeConverter(dataFilter, editor));\n }\n evt.stop();\n });\n }\n}\n/**\n * View-to-model conversion helper preserving allowed attributes on the {@link module:image/image~Image Image}\n * feature model element.\n *\n * @returns Returns a conversion callback.\n */\nfunction viewToModelImageAttributeConverter(dataFilter) {\n return (dispatcher) => {\n dispatcher.on('element:img', (evt, data, conversionApi) => {\n if (!data.modelRange) {\n return;\n }\n const viewImageElement = data.viewItem;\n const viewAttributes = dataFilter.processViewAttributes(viewImageElement, conversionApi);\n if (viewAttributes) {\n conversionApi.writer.setAttribute('htmlImgAttributes', viewAttributes, data.modelRange);\n }\n }, { priority: 'low' });\n };\n}\n/**\n * View-to-model conversion helper preserving allowed attributes on {@link module:image/image~Image Image}\n * feature model element from link view element.\n *\n * @returns Returns a conversion callback.\n */\nfunction viewToModelLinkImageAttributeConverter(dataFilter, editor) {\n const imageUtils = editor.plugins.get('ImageUtils');\n return (dispatcher) => {\n dispatcher.on('element:a', (evt, data, conversionApi) => {\n const viewLink = data.viewItem;\n const viewImage = imageUtils.findViewImgElement(viewLink);\n if (!viewImage) {\n return;\n }\n const modelImage = data.modelCursor.parent;\n if (!modelImage.is('element', 'imageBlock')) {\n return;\n }\n const viewAttributes = dataFilter.processViewAttributes(viewLink, conversionApi);\n if (viewAttributes) {\n conversionApi.writer.setAttribute('htmlLinkAttributes', viewAttributes, modelImage);\n }\n }, { priority: 'low' });\n };\n}\n/**\n * View-to-model conversion helper preserving allowed attributes on {@link module:image/image~Image Image}\n * feature model element from figure view element.\n *\n * @returns Returns a conversion callback.\n */\nfunction viewToModelFigureAttributeConverter(dataFilter) {\n return (dispatcher) => {\n dispatcher.on('element:figure', (evt, data, conversionApi) => {\n const viewFigureElement = data.viewItem;\n if (!data.modelRange || !viewFigureElement.hasClass('image')) {\n return;\n }\n const viewAttributes = dataFilter.processViewAttributes(viewFigureElement, conversionApi);\n if (viewAttributes) {\n conversionApi.writer.setAttribute('htmlFigureAttributes', viewAttributes, data.modelRange);\n }\n }, { priority: 'low' });\n };\n}\n/**\n * A model-to-view conversion helper applying attributes from the {@link module:image/image~Image Image}\n * feature.\n * @returns Returns a conversion callback.\n */\nfunction modelToViewImageAttributeConverter() {\n return (dispatcher) => {\n addInlineAttributeConversion('htmlImgAttributes');\n addBlockAttributeConversion('img', 'htmlImgAttributes');\n addBlockAttributeConversion('figure', 'htmlFigureAttributes');\n addBlockAttributeConversion('a', 'htmlLinkAttributes');\n function addInlineAttributeConversion(attributeName) {\n dispatcher.on(`attribute:${attributeName}:imageInline`, (evt, data, conversionApi) => {\n if (!conversionApi.consumable.consume(data.item, evt.name)) {\n return;\n }\n const { attributeOldValue, attributeNewValue } = data;\n const viewElement = conversionApi.mapper.toViewElement(data.item);\n updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);\n }, { priority: 'low' });\n }\n function addBlockAttributeConversion(elementName, attributeName) {\n dispatcher.on(`attribute:${attributeName}:imageBlock`, (evt, data, conversionApi) => {\n if (!conversionApi.consumable.test(data.item, evt.name)) {\n return;\n }\n const { attributeOldValue, attributeNewValue } = data;\n const containerElement = conversionApi.mapper.toViewElement(data.item);\n const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);\n if (viewElement) {\n updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);\n conversionApi.consumable.consume(data.item, evt.name);\n }\n }, { priority: 'low' });\n if (elementName === 'a') {\n // To have a link element in the view, we need to attach a converter to the `linkHref` attribute as well.\n dispatcher.on('attribute:linkHref:imageBlock', (evt, data, conversionApi) => {\n if (!conversionApi.consumable.consume(data.item, 'attribute:htmlLinkAttributes:imageBlock')) {\n return;\n }\n const containerElement = conversionApi.mapper.toViewElement(data.item);\n const viewElement = getDescendantElement(conversionApi.writer, containerElement, 'a');\n setViewAttributes(conversionApi.writer, data.item.getAttribute('htmlLinkAttributes'), viewElement);\n }, { priority: 'low' });\n }\n }\n };\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module html-support/integrations/mediaembed\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { DataFilter } from '../datafilter.js';\nimport { DataSchema } from '../dataschema.js';\nimport { updateViewAttributes, getHtmlAttributeName } from '../utils.js';\nimport { getDescendantElement } from './integrationutils.js';\n/**\n * Provides the General HTML Support integration with {@link module:media-embed/mediaembed~MediaEmbed Media Embed} feature.\n */\nexport class MediaEmbedElementSupport extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [DataFilter];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'MediaEmbedElementSupport';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n // Stop here if MediaEmbed plugin is not provided or the integrator wants to output markup with previews as\n // we do not support filtering previews.\n if (!editor.plugins.has('MediaEmbed') || editor.config.get('mediaEmbed.previewsInData')) {\n return;\n }\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n const dataFilter = this.editor.plugins.get(DataFilter);\n const dataSchema = this.editor.plugins.get(DataSchema);\n const mediaElementName = editor.config.get('mediaEmbed.elementName');\n // Overwrite GHS schema definition for a given elementName.\n dataSchema.registerBlockElement({\n model: 'media',\n view: mediaElementName\n });\n dataFilter.on('register:figure', () => {\n conversion.for('upcast').add(viewToModelFigureAttributesConverter(dataFilter));\n });\n dataFilter.on(`register:${mediaElementName}`, (evt, definition) => {\n if (definition.model !== 'media') {\n return;\n }\n schema.extend('media', {\n allowAttributes: [\n getHtmlAttributeName(mediaElementName),\n 'htmlFigureAttributes'\n ]\n });\n conversion.for('upcast').add(viewToModelMediaAttributesConverter(dataFilter, mediaElementName));\n conversion.for('dataDowncast').add(modelToViewMediaAttributeConverter(mediaElementName));\n evt.stop();\n });\n }\n}\nfunction viewToModelMediaAttributesConverter(dataFilter, mediaElementName) {\n const upcastMedia = (evt, data, conversionApi) => {\n const viewMediaElement = data.viewItem;\n preserveElementAttributes(viewMediaElement, getHtmlAttributeName(mediaElementName));\n function preserveElementAttributes(viewElement, attributeName) {\n const viewAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);\n if (viewAttributes) {\n conversionApi.writer.setAttribute(attributeName, viewAttributes, data.modelRange);\n }\n }\n };\n return (dispatcher) => {\n dispatcher.on(`element:${mediaElementName}`, upcastMedia, { priority: 'low' });\n };\n}\n/**\n * View-to-model conversion helper preserving allowed attributes on {@link module:media-embed/mediaembed~MediaEmbed MediaEmbed}\n * feature model element from figure view element.\n *\n * @returns Returns a conversion callback.\n */\nfunction viewToModelFigureAttributesConverter(dataFilter) {\n return (dispatcher) => {\n dispatcher.on('element:figure', (evt, data, conversionApi) => {\n const viewFigureElement = data.viewItem;\n if (!data.modelRange || !viewFigureElement.hasClass('media')) {\n return;\n }\n const viewAttributes = dataFilter.processViewAttributes(viewFigureElement, conversionApi);\n if (viewAttributes) {\n conversionApi.writer.setAttribute('htmlFigureAttributes', viewAttributes, data.modelRange);\n }\n }, { priority: 'low' });\n };\n}\nfunction modelToViewMediaAttributeConverter(mediaElementName) {\n return (dispatcher) => {\n addAttributeConversionDispatcherHandler(mediaElementName, getHtmlAttributeName(mediaElementName));\n addAttributeConversionDispatcherHandler('figure', 'htmlFigureAttributes');\n function addAttributeConversionDispatcherHandler(elementName, attributeName) {\n dispatcher.on(`attribute:${attributeName}:media`, (evt, data, conversionApi) => {\n if (!conversionApi.consumable.consume(data.item, evt.name)) {\n return;\n }\n const { attributeOldValue, attributeNewValue } = data;\n const containerElement = conversionApi.mapper.toViewElement(data.item);\n const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);\n updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);\n });\n }\n };\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module html-support/integrations/script\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { createObjectView, modelToViewBlockAttributeConverter, viewToModelBlockAttributeConverter, viewToModelObjectConverter } from '../converters.js';\nimport { DataFilter } from '../datafilter.js';\n/**\n * Provides the General HTML Support for `script` elements.\n */\nexport class ScriptElementSupport extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [DataFilter];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'ScriptElementSupport';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const dataFilter = this.editor.plugins.get(DataFilter);\n dataFilter.on('register:script', (evt, definition) => {\n const editor = this.editor;\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n schema.register('htmlScript', definition.modelSchema);\n schema.extend('htmlScript', {\n allowAttributes: ['htmlScriptAttributes', 'htmlContent'],\n isContent: true\n });\n editor.data.registerRawContentMatcher({\n name: 'script'\n });\n conversion.for('upcast').elementToElement({\n view: 'script',\n model: viewToModelObjectConverter(definition)\n });\n conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, dataFilter));\n conversion.for('downcast').elementToElement({\n model: 'htmlScript',\n view: (modelElement, { writer }) => {\n return createObjectView('script', modelElement, writer);\n }\n });\n conversion.for('downcast')\n .add(modelToViewBlockAttributeConverter(definition));\n evt.stop();\n });\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { updateViewAttributes } from '../utils.js';\nimport { DataFilter } from '../datafilter.js';\nimport { getDescendantElement } from './integrationutils.js';\nconst STYLE_ATTRIBUTES_TO_PROPAGATE = [\n 'width',\n 'max-width',\n 'min-width',\n 'height',\n 'min-height',\n 'max-height'\n];\n/**\n * Provides the General HTML Support integration with {@link module:table/table~Table Table} feature.\n */\nexport class TableElementSupport extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [DataFilter];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'TableElementSupport';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n if (!editor.plugins.has('TableEditing')) {\n return;\n }\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n const dataFilter = editor.plugins.get(DataFilter);\n const tableUtils = editor.plugins.get('TableUtils');\n dataFilter.on('register:figure', () => {\n conversion.for('upcast').add(viewToModelFigureAttributeConverter(dataFilter));\n });\n dataFilter.on('register:table', (evt, definition) => {\n if (definition.model !== 'table') {\n return;\n }\n schema.extend('table', {\n allowAttributes: [\n 'htmlTableAttributes',\n // Figure, thead and tbody elements don't have model counterparts.\n // We will be preserving attributes on table element using these attribute keys.\n 'htmlFigureAttributes', 'htmlTheadAttributes', 'htmlTbodyAttributes'\n ]\n });\n conversion.for('upcast').add(viewToModelTableAttributeConverter(dataFilter));\n conversion.for('downcast').add(modelToViewTableAttributeConverter());\n editor.model.document.registerPostFixer(createHeadingRowsPostFixer(editor.model, tableUtils));\n evt.stop();\n });\n }\n}\n/**\n * Creates a model post-fixer for thead and tbody GHS related attributes.\n */\nfunction createHeadingRowsPostFixer(model, tableUtils) {\n return writer => {\n const changes = model.document.differ.getChanges();\n let wasFixed = false;\n for (const change of changes) {\n if (change.type != 'attribute' || change.attributeKey != 'headingRows') {\n continue;\n }\n const table = change.range.start.nodeAfter;\n const hasTHeadAttributes = table.getAttribute('htmlTheadAttributes');\n const hasTBodyAttributes = table.getAttribute('htmlTbodyAttributes');\n if (hasTHeadAttributes && !change.attributeNewValue) {\n writer.removeAttribute('htmlTheadAttributes', table);\n wasFixed = true;\n }\n else if (hasTBodyAttributes && change.attributeNewValue == tableUtils.getRows(table)) {\n writer.removeAttribute('htmlTbodyAttributes', table);\n wasFixed = true;\n }\n }\n return wasFixed;\n };\n}\n/**\n * View-to-model conversion helper preserving allowed attributes on {@link module:table/table~Table Table}\n * feature model element.\n *\n * @returns Returns a conversion callback.\n */\nfunction viewToModelTableAttributeConverter(dataFilter) {\n return (dispatcher) => {\n dispatcher.on('element:table', (evt, data, conversionApi) => {\n if (!data.modelRange) {\n return;\n }\n const viewTableElement = data.viewItem;\n // Prevent `table` class on both and
                    elements simultaneously.\n conversionApi.consumable.consume(viewTableElement, { classes: 'table' });\n preserveElementAttributes(viewTableElement, 'htmlTableAttributes');\n for (const childNode of viewTableElement.getChildren()) {\n if (childNode.is('element', 'thead')) {\n preserveElementAttributes(childNode, 'htmlTheadAttributes');\n }\n if (childNode.is('element', 'tbody')) {\n preserveElementAttributes(childNode, 'htmlTbodyAttributes');\n }\n }\n function preserveElementAttributes(viewElement, attributeName) {\n const viewAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);\n if (viewAttributes) {\n conversionApi.writer.setAttribute(attributeName, viewAttributes, data.modelRange);\n }\n }\n }, { priority: 'low' });\n };\n}\n/**\n * View-to-model conversion helper preserving allowed attributes on {@link module:table/table~Table Table}\n * feature model element from figure view element.\n *\n * @returns Returns a conversion callback.\n */\nfunction viewToModelFigureAttributeConverter(dataFilter) {\n return (dispatcher) => {\n dispatcher.on('element:figure', (evt, data, conversionApi) => {\n const viewFigureElement = data.viewItem;\n if (!data.modelRange || !viewFigureElement.hasClass('table')) {\n return;\n }\n const viewAttributes = dataFilter.processViewAttributes(viewFigureElement, conversionApi);\n if (viewAttributes) {\n conversionApi.writer.setAttribute('htmlFigureAttributes', viewAttributes, data.modelRange);\n }\n }, { priority: 'low' });\n };\n}\n/**\n * Model-to-view conversion helper applying attributes from {@link module:table/table~Table Table}\n * feature.\n *\n * @returns Returns a conversion callback.\n */\nfunction modelToViewTableAttributeConverter() {\n return (dispatcher) => {\n addAttributeConversionDispatcherHandler('table', 'htmlTableAttributes');\n addAttributeConversionDispatcherHandler('figure', 'htmlFigureAttributes');\n addAttributeConversionDispatcherHandler('thead', 'htmlTheadAttributes');\n addAttributeConversionDispatcherHandler('tbody', 'htmlTbodyAttributes');\n function addAttributeConversionDispatcherHandler(elementName, attributeName) {\n dispatcher.on(`attribute:${attributeName}:table`, (evt, data, conversionApi) => {\n if (!conversionApi.consumable.test(data.item, evt.name)) {\n return;\n }\n const containerElement = conversionApi.mapper.toViewElement(data.item);\n const viewElement = getDescendantElement(conversionApi.writer, containerElement, elementName);\n if (!viewElement) {\n return;\n }\n conversionApi.consumable.consume(data.item, evt.name);\n // Downcast selected styles to a figure element instead of a table element.\n if (attributeName === 'htmlTableAttributes' && containerElement !== viewElement) {\n const oldAttributes = splitAttributesForFigureAndTable(data.attributeOldValue);\n const newAttributes = splitAttributesForFigureAndTable(data.attributeNewValue);\n updateViewAttributes(conversionApi.writer, oldAttributes.tableAttributes, newAttributes.tableAttributes, viewElement);\n updateViewAttributes(conversionApi.writer, oldAttributes.figureAttributes, newAttributes.figureAttributes, containerElement);\n }\n else {\n updateViewAttributes(conversionApi.writer, data.attributeOldValue, data.attributeNewValue, viewElement);\n }\n });\n }\n };\n}\n/**\n * Splits styles based on the `STYLE_ATTRIBUTES_TO_PROPAGATE` pattern that should be moved to the parent element\n * and those that should remain on element.\n */\nfunction splitAttributesForFigureAndTable(data) {\n const figureAttributes = {};\n const tableAttributes = { ...data };\n if (!data || !('styles' in data)) {\n return { figureAttributes, tableAttributes };\n }\n tableAttributes.styles = {};\n for (const [key, value] of Object.entries(data.styles)) {\n if (STYLE_ATTRIBUTES_TO_PROPAGATE.includes(key)) {\n figureAttributes.styles = { ...figureAttributes.styles, [key]: value };\n }\n else {\n tableAttributes.styles = { ...tableAttributes.styles, [key]: value };\n }\n }\n return { figureAttributes, tableAttributes };\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module html-support/integrations/style\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { createObjectView, modelToViewBlockAttributeConverter, viewToModelBlockAttributeConverter, viewToModelObjectConverter } from '../converters.js';\nimport { DataFilter } from '../datafilter.js';\n/**\n * Provides the General HTML Support for `style` elements.\n */\nexport class StyleElementSupport extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [DataFilter];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'StyleElementSupport';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const dataFilter = this.editor.plugins.get(DataFilter);\n dataFilter.on('register:style', (evt, definition) => {\n const editor = this.editor;\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n schema.register('htmlStyle', definition.modelSchema);\n schema.extend('htmlStyle', {\n allowAttributes: ['htmlStyleAttributes', 'htmlContent'],\n isContent: true\n });\n editor.data.registerRawContentMatcher({\n name: 'style'\n });\n conversion.for('upcast').elementToElement({\n view: 'style',\n model: viewToModelObjectConverter(definition)\n });\n conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, dataFilter));\n conversion.for('downcast').elementToElement({\n model: 'htmlStyle',\n view: (modelElement, { writer }) => {\n return createObjectView('style', modelElement, writer);\n }\n });\n conversion.for('downcast')\n .add(modelToViewBlockAttributeConverter(definition));\n evt.stop();\n });\n }\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module html-support/integrations/list\n */\nimport { isEqual } from 'es-toolkit/compat';\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { getHtmlAttributeName, setViewAttributes } from '../utils.js';\nimport { DataFilter } from '../datafilter.js';\n/**\n * Provides the General HTML Support integration with the {@link module:list/list~List List} feature.\n */\nexport class ListElementSupport extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [DataFilter];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'ListElementSupport';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n if (!editor.plugins.has('ListEditing')) {\n return;\n }\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n const dataFilter = editor.plugins.get(DataFilter);\n const listEditing = editor.plugins.get('ListEditing');\n const listUtils = editor.plugins.get('ListUtils');\n const viewElements = ['ul', 'ol', 'li'];\n // Register downcast strategy.\n // Note that this must be done before document list editing registers conversion in afterInit.\n listEditing.registerDowncastStrategy({\n scope: 'item',\n attributeName: 'htmlLiAttributes',\n setAttributeOnDowncast: setViewAttributes\n });\n listEditing.registerDowncastStrategy({\n scope: 'list',\n attributeName: 'htmlUlAttributes',\n setAttributeOnDowncast: setViewAttributes\n });\n listEditing.registerDowncastStrategy({\n scope: 'list',\n attributeName: 'htmlOlAttributes',\n setAttributeOnDowncast: setViewAttributes\n });\n dataFilter.on('register', (evt, definition) => {\n if (!viewElements.includes(definition.view)) {\n return;\n }\n evt.stop();\n // Do not register same converters twice.\n if (schema.checkAttribute('$block', 'htmlLiAttributes')) {\n return;\n }\n const allowAttributes = viewElements.map(element => getHtmlAttributeName(element));\n schema.extend('$listItem', { allowAttributes });\n conversion.for('upcast').add(dispatcher => {\n dispatcher.on('element:ul', viewToModelListAttributeConverter('htmlUlAttributes', dataFilter), { priority: 'low' });\n dispatcher.on('element:ol', viewToModelListAttributeConverter('htmlOlAttributes', dataFilter), { priority: 'low' });\n dispatcher.on('element:li', viewToModelListAttributeConverter('htmlLiAttributes', dataFilter), { priority: 'low' });\n });\n });\n // Make sure that all items in a single list (items at the same level & listType) have the same properties.\n listEditing.on('postFixer', (evt, { listNodes, writer }) => {\n for (const { node, previousNodeInList } of listNodes) {\n // This is a first item of a nested list.\n if (!previousNodeInList) {\n continue;\n }\n if (previousNodeInList.getAttribute('listType') == node.getAttribute('listType')) {\n const attribute = getAttributeFromListType(previousNodeInList.getAttribute('listType'));\n const value = previousNodeInList.getAttribute(attribute);\n if (!isEqual(node.getAttribute(attribute), value) &&\n writer.model.schema.checkAttribute(node, attribute)) {\n writer.setAttribute(attribute, value, node);\n evt.return = true;\n }\n }\n if (previousNodeInList.getAttribute('listItemId') == node.getAttribute('listItemId')) {\n const value = previousNodeInList.getAttribute('htmlLiAttributes');\n if (!isEqual(node.getAttribute('htmlLiAttributes'), value) &&\n writer.model.schema.checkAttribute(node, 'htmlLiAttributes')) {\n writer.setAttribute('htmlLiAttributes', value, node);\n evt.return = true;\n }\n }\n }\n });\n // Remove `ol` attributes from `ul` elements and vice versa.\n listEditing.on('postFixer', (evt, { listNodes, writer }) => {\n for (const { node } of listNodes) {\n const listType = node.getAttribute('listType');\n if (!listUtils.isNumberedListType(listType) && node.getAttribute('htmlOlAttributes')) {\n writer.removeAttribute('htmlOlAttributes', node);\n evt.return = true;\n }\n if (listUtils.isNumberedListType(listType) && node.getAttribute('htmlUlAttributes')) {\n writer.removeAttribute('htmlUlAttributes', node);\n evt.return = true;\n }\n }\n });\n }\n /**\n * @inheritDoc\n */\n afterInit() {\n const editor = this.editor;\n if (!editor.commands.get('indentList')) {\n return;\n }\n // Reset list attributes after indenting list items.\n const indentList = editor.commands.get('indentList');\n this.listenTo(indentList, 'afterExecute', (evt, changedBlocks) => {\n editor.model.change(writer => {\n for (const node of changedBlocks) {\n const attribute = getAttributeFromListType(node.getAttribute('listType'));\n if (!editor.model.schema.checkAttribute(node, attribute)) {\n continue;\n }\n // Just reset the attribute.\n // If there is a previous indented list that this node should be merged into,\n // the postfixer will unify all the attributes of both sub-lists.\n writer.setAttribute(attribute, {}, node);\n }\n });\n });\n }\n}\n/**\n * View-to-model conversion helper preserving allowed attributes on {@link TODO}\n * feature model element.\n *\n * @returns Returns a conversion callback.\n */\nfunction viewToModelListAttributeConverter(attributeName, dataFilter) {\n return (evt, data, conversionApi) => {\n const viewElement = data.viewItem;\n if (!data.modelRange) {\n Object.assign(data, conversionApi.convertChildren(data.viewItem, data.modelCursor));\n }\n const viewAttributes = dataFilter.processViewAttributes(viewElement, conversionApi);\n for (const item of data.modelRange.getItems({ shallow: true })) {\n // Apply only to list item blocks.\n if (!item.hasAttribute('listItemId')) {\n continue;\n }\n // Set list attributes only on same level items, those nested deeper are already handled\n // by the recursive conversion.\n if (item.hasAttribute('htmlUlAttributes') || item.hasAttribute('htmlOlAttributes')) {\n continue;\n }\n if (conversionApi.writer.model.schema.checkAttribute(item, attributeName)) {\n conversionApi.writer.setAttribute(attributeName, viewAttributes || {}, item);\n }\n }\n };\n}\n/**\n * Returns HTML attribute name based on provided list type.\n */\nfunction getAttributeFromListType(listType) {\n return listType === 'numbered' || listType == 'customNumbered' ?\n 'htmlOlAttributes' :\n 'htmlUlAttributes';\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module html-support/integrations/horizontalline\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { DataFilter } from '../datafilter.js';\nimport { updateViewAttributes } from '../utils.js';\nimport { getDescendantElement } from './integrationutils.js';\nimport { viewToModelBlockAttributeConverter } from '../converters.js';\n/**\n * Provides the General HTML Support integration with the {@link module:horizontal-line/horizontalline~HorizontalLine} feature.\n */\nexport class HorizontalLineElementSupport extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [DataFilter];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'HorizontalLineElementSupport';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const editor = this.editor;\n if (!editor.plugins.has('HorizontalLineEditing')) {\n return;\n }\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n const dataFilter = editor.plugins.get(DataFilter);\n dataFilter.on('register:hr', (evt, definition) => {\n if (definition.model !== 'horizontalLine') {\n return;\n }\n schema.extend('horizontalLine', {\n allowAttributes: ['htmlHrAttributes']\n });\n conversion.for('upcast').add(viewToModelBlockAttributeConverter(definition, dataFilter));\n conversion.for('downcast').add(modelToViewHorizontalLineAttributeConverter());\n evt.stop();\n });\n }\n}\n/**\n * A model-to-view conversion helper applying attributes from the\n * {@link module:horizontal-line/horizontalline~HorizontalLine HorizontalLine} feature.\n *\n * @returns Returns a conversion callback.\n */\nfunction modelToViewHorizontalLineAttributeConverter() {\n return (dispatcher) => {\n dispatcher.on('attribute:htmlHrAttributes:horizontalLine', (evt, data, conversionApi) => {\n if (!conversionApi.consumable.test(data.item, evt.name)) {\n return;\n }\n const { attributeOldValue, attributeNewValue } = data;\n const containerElement = conversionApi.mapper.toViewElement(data.item);\n const viewElement = getDescendantElement(conversionApi.writer, containerElement, 'hr');\n if (viewElement) {\n updateViewAttributes(conversionApi.writer, attributeOldValue, attributeNewValue, viewElement);\n conversionApi.consumable.consume(data.item, evt.name);\n }\n }, { priority: 'low' });\n };\n}\n","/**\n * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options\n */\n/**\n * @module html-support/integrations/customelement\n */\nimport { Plugin } from 'ckeditor5/src/core.js';\nimport { ViewUpcastWriter } from 'ckeditor5/src/engine.js';\nimport { DataSchema } from '../dataschema.js';\nimport { DataFilter } from '../datafilter.js';\nimport { setViewAttributes } from '../utils.js';\n/**\n * Provides the General HTML Support for custom elements (not registered in the {@link module:html-support/dataschema~DataSchema}).\n */\nexport class CustomElementSupport extends Plugin {\n /**\n * @inheritDoc\n */\n static get requires() {\n return [DataFilter, DataSchema];\n }\n /**\n * @inheritDoc\n */\n static get pluginName() {\n return 'CustomElementSupport';\n }\n /**\n * @inheritDoc\n */\n static get isOfficialPlugin() {\n return true;\n }\n /**\n * @inheritDoc\n */\n init() {\n const dataFilter = this.editor.plugins.get(DataFilter);\n const dataSchema = this.editor.plugins.get(DataSchema);\n dataFilter.on('register:$customElement', (evt, definition) => {\n evt.stop();\n const editor = this.editor;\n const schema = editor.model.schema;\n const conversion = editor.conversion;\n const unsafeElements = editor.editing.view.domConverter.unsafeElements;\n const preLikeElements = editor.data.htmlProcessor.domConverter.preElements;\n schema.register(definition.model, definition.modelSchema);\n schema.extend(definition.model, {\n allowAttributes: ['htmlElementName', 'htmlCustomElementAttributes', 'htmlContent'],\n isContent: true\n });\n // For the `