diff --git a/dist/js/field.js b/dist/js/field.js index 3357491..dccf181 100644 --- a/dist/js/field.js +++ b/dist/js/field.js @@ -1,2 +1,2 @@ /*! For license information please see field.js.LICENSE.txt */ -!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"%0 of %1",Accept:"Accept",Activity:"Activity","Align center":"Align center","Align left":"Align left","Align right":"Align right","Animals & Nature":"Animals & Nature",Aquamarine:"Aquamarine",Big:"Big",Black:"Black","Block quote":"Block quote",Blue:"Blue",Bold:"Bold","Break text":"Break text","Bulleted List":"Bulleted List",Cancel:"Cancel","Caption for image: %0":"Caption for image: %0","Caption for the image":"Caption for the image","Centered image":"Centered image","Change image text alternative":"Change image text alternative","Choose heading":"Choose heading","Choose language":"Choose language",Clear:"Clear","Click to edit block":"Click to edit block",Code:"Code","Color picker":"Color picker",Column:"Column","Decrease indent":"Decrease indent",Default:"Default","Delete column":"Delete column","Delete row":"Delete row","Dim grey":"Dim grey","Document colors":"Document colors",Downloadable:"Downloadable","Drag to move":"Drag to move","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 editing area: %0":"Editor editing area: %0","Editor toolbar":"Editor toolbar",Emoji:"","Emoji categories":"Emoji categories","Empty snippet content":"Empty snippet content","Enter image caption":"Enter image caption",Flags:"Flags","Font Background Color":"Font Background Color","Font Color":"Font Color","Font Family":"Font Family","Font Size":"Font Size","Food & Drink":"Food & Drink","Full size image":"Full size image",Green:"Green",Grey:"Grey","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",HEX:"HEX","Horizontal line":"Horizontal line","HTML object":"HTML object","HTML snippet":"HTML snippet",Huge:"Huge","Image resize list":"Image resize list","Image toolbar":"Image toolbar","image widget":"image widget","In line":"In line","Increase indent":"Increase indent",Insert:"Insert","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",Italic:"Italic",Justify:"Justify",Language:"Language","Left aligned image":"Left aligned image","Light blue":"Light blue","Light green":"Light green","Light grey":"Light grey",Link:"Link","Link image":"Link image","Link URL":"Link URL","Media URL":"Media URL","media widget":"media widget","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",Next:"Next","No preview available":"No preview available","No results found":"No results found","No searchable items":"No searchable items","Numbered List":"Numbered List",Objects:"Objects","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",Orange:"Orange",Original:"Original",Paragraph:"Paragraph","Paste raw HTML here...":"Paste raw HTML here...","Paste the media URL in the input.":"Paste the media URL in the input.","Plain text":"Plain text","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",Purple:"Purple",Red:"Red",Redo:"Redo","Remove color":"Remove color","Remove Format":"Remove Format","Remove language":"Remove language","Replace from computer":"Replace from computer","Replace image":"Replace image","Replace image from computer":"Replace image from computer","Resize image":"Resize image","Resize image to %0":"Resize image to %0","Resize image to the original size":"Resize image to the original size","Rich Text Editor":"Rich Text Editor","Right aligned image":"Right aligned image",Row:"Row",Save:"Save","Save changes":"Save changes","Select all":"Select all","Select column":"Select column","Select row":"Select row","Show blocks":"Show blocks","Show more items":"Show more items","Side image":"Side image",Small:"Small","Smileys & People":"Smileys & People",Source:"Source","Split cell horizontally":"Split cell horizontally","Split cell vertically":"Split cell vertically",Strikethrough:"Strikethrough",Subscript:"Subscript",Superscript:"Superscript",Symbols:"Symbols","Table toolbar":"Table toolbar","Text alignment":"Text alignment","Text alignment toolbar":"Text alignment toolbar","Text alternative":"Text alternative","The URL must not be empty.":"The URL must not be empty.","This link has no URL":"This link has no URL","This media URL is not supported.":"This media URL is not supported.",Tiny:"Tiny","Tip: Paste the URL into the content to embed faster.":"Tip: Paste the URL into the content to embed faster.","Toggle caption off":"Toggle caption off","Toggle caption on":"Toggle caption on","Travel & Places":"Travel & Places",Turquoise:"Turquoise",Underline:"Underline",Undo:"Undo",Unlink:"Unlink",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",White:"White","Widget toolbar":"Widget toolbar","Wrap text":"Wrap text",Yellow:"Yellow"}),t.getPluralForm=function(e){return e%1==0&&1==e?0:e%1==0&&e>=2&&e<=4?1:e%1!=0?2:3}}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),(()=>{var __webpack_modules__={3093:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{A:()=>__WEBPACK_DEFAULT_EXPORT__});var _ckeditor_ckeditor__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(3860),_components_snippet_browser_SnippetBrowser_vue__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(7516),_components_media_browser_MediaBrowser_vue__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(6083),_components_mixins_hasUUID__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(7319),laravel_nova__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(6610),laravel_nova__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(laravel_nova__WEBPACK_IMPORTED_MODULE_4__),lodash_debounce__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(8221),lodash_debounce__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(lodash_debounce__WEBPACK_IMPORTED_MODULE_5__),regex_parser__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(1924),regex_parser__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(regex_parser__WEBPACK_IMPORTED_MODULE_6__);function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function ownKeys(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function _objectSpread(e){for(var t=1;t1&&i.setStyle("height","".concat(t.currentField.height,"px"),e.editing.view.document.getRoot()),t.editorResizeFix(e,i)})),t.syncDataOnSourceEditing(),t.currentField.readonly&&e.enableReadOnlyMode(t.$options[t.editorUUID]),t.currentField.forcePasteAsPlainText&&e.editing.view.document.on("clipboardInput",(function(t,i){t.stop(),e.model.change((function(t){t.insertText(i.dataTransfer.getData("text/plain"),e.model.document.selection.getFirstPosition())}))}))})).catch((function(e){console.log(e),Nova.error(e.toString())}))},destroyCkEditor:function(){var e=this;this.$options[this.editorName]&&this.$options[this.editorName].destroy().then((function(){return e.$options[e.editorName]=null})).catch((function(e){return Nova.error(e.toString())}))},setInitialValue:function(){this.value=this.currentField.value||""},initToolbarOptions:function(e){return e.mediaEmbed&&(e.mediaEmbed.providers&&(e.mediaEmbed.providers=this.normalizeMediaEmbedToolbarOptions(e.mediaEmbed.providers)),e.mediaEmbed.extraProviders&&(e.mediaEmbed.extraProviders=this.normalizeMediaEmbedToolbarOptions(e.mediaEmbed.extraProviders))),e},normalizeMediaEmbedToolbarOptions:function normalizeMediaEmbedToolbarOptions(providers){if(providers&&Array.isArray(providers))for(var _loop=function _loop(){var _providers$i$url,_providers$i,_providers$i$html,_providers$i2,url=null!==(_providers$i$url=null===(_providers$i=providers[i])||void 0===_providers$i?void 0:_providers$i.url)&&void 0!==_providers$i$url?_providers$i$url:null,html=null!==(_providers$i$html=null===(_providers$i2=providers[i])||void 0===_providers$i2?void 0:_providers$i2.html)&&void 0!==_providers$i$html?_providers$i$html:null;if(Array.isArray(url)){for(var urls=url,j=0;j10&&t.setStyle("height","".concat(r,"px"),e.editing.view.document.getRoot())}),100)),r=e.ui.view.element.getElementsByClassName("ck-editor__editable");null!=r&&r.length&&i.observe(r[0])}},created:function(){this.$options[this.editorUUID]=this.uuid(),this.setInitialValue()},mounted:function(){this.currentlyIsVisible&&this.createCkEditor(),this.mounted=!0},beforeUnmount:function(){this.destroyCkEditor()}}},3860:(e,t,i)=>{"use strict";function r({emitter:e,activator:t,callback:i,contextElements:r}){e.listenTo(document,"mousedown",((e,n)=>{if(!t())return;const o="function"==typeof n.composedPath?n.composedPath():[],s="function"==typeof r?r():r;for(const e of s)if(e.contains(n.target)||o.includes(e))return;i()}))}function n(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.extendTemplate({attributes:{class:[this.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}}}function o({view:e}){e.listenTo(e.element,"submit",((t,i)=>{i.preventDefault(),e.fire("submit")}),{useCapture:!0})}function s({keystrokeHandler:e,focusTracker:t,gridItems:i,numberOfColumns:r,uiLanguageDirection:n}){const o="number"==typeof r?()=>r:r;function s(e){return r=>{const n=i.find((e=>e.element===t.focusedElement)),o=i.getIndex(n),s=e(o,i);i.get(s).focus(),r.stopPropagation(),r.preventDefault()}}function a(e,t){return e===t-1?0:e+1}function c(e,t){return 0===e?t-1:e-1}e.set("arrowright",s(((e,t)=>"rtl"===n?c(e,t.length):a(e,t.length)))),e.set("arrowleft",s(((e,t)=>"rtl"===n?a(e,t.length):c(e,t.length)))),e.set("arrowup",s(((e,t)=>{let i=e-o();return i<0&&(i=e+o()*Math.floor(t.length/o()),i>t.length-1&&(i-=o())),i}))),e.set("arrowdown",s(((e,t)=>{let i=e+o();return i>t.length-1&&(i=e%o()),i})))}i.d(t,{A:()=>UV});const a=function(){try{return navigator.userAgent.toLowerCase()}catch(e){return""}}(),c={isMac:d(a),isWindows:function(e){return e.indexOf("windows")>-1}(a),isGecko:function(e){return!!e.match(/gecko\/\d+/)}(a),isSafari:function(e){return e.indexOf(" applewebkit/")>-1&&-1===e.indexOf("chrome")}(a),isiOS:function(e){return!!e.match(/iphone|ipad/i)||d(e)&&navigator.maxTouchPoints>0}(a),isAndroid:function(e){return e.indexOf("android")>-1}(a),isBlink:function(e){return e.indexOf("chrome/")>-1&&e.indexOf("edge/")<0}(a),features:{isRegExpUnicodePropertySupported:function(){let e=!1;try{e=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch(e){}return e}()}},l=c;function d(e){return e.indexOf("macintosh")>-1}function u(e,t,i,r){i=i||function(e,t){return e===t};const n=Array.isArray(e)?e:Array.prototype.slice.call(e),o=Array.isArray(t)?t:Array.prototype.slice.call(t),s=function(e,t,i){const r=h(e,t,i);if(-1===r)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const n=m(e,r),o=m(t,r),s=h(n,o,i),a=e.length-s,c=t.length-s;return{firstIndex:r,lastIndexOld:a,lastIndexNew:c}}(n,o,i),a=r?function(e,t){const{firstIndex:i,lastIndexOld:r,lastIndexNew:n}=e;if(-1===i)return Array(t).fill("equal");let o=[];i>0&&(o=o.concat(Array(i).fill("equal")));n-i>0&&(o=o.concat(Array(n-i).fill("insert")));r-i>0&&(o=o.concat(Array(r-i).fill("delete")));n0&&i.push({index:r,type:"insert",values:e.slice(r,o)});n-r>0&&i.push({index:r+(o-r),type:"delete",howMany:n-r});return i}(o,s);return a}function h(e,t,i){for(let r=0;r200||n>200||r+n>300)return g.fastDiff(e,t,i,!0);let o,s;if(nl?-1:1;d[r+h]&&(d[r]=d[r+h].slice(0)),d[r]||(d[r]=[]),d[r].push(n>l?o:s);let m=Math.max(n,l),g=m-r;for(;gl;m--)u[m]=h(m);u[l]=h(l),p++}while(u[l]!==c);return d[l].slice(1)}g.fastDiff=u;const p=function(){return function e(){e.called=!0}};class f{constructor(e,t){this.source=e,this.name=t,this.path=[],this.stop=p(),this.off=p()}}const b=new Array(256).fill("").map(((e,t)=>("0"+t.toString(16)).slice(-2)));function w(){const e=4294967296*Math.random()>>>0,t=4294967296*Math.random()>>>0,i=4294967296*Math.random()>>>0,r=4294967296*Math.random()>>>0;return"e"+b[255&e]+b[e>>8&255]+b[e>>16&255]+b[e>>24&255]+b[255&t]+b[t>>8&255]+b[t>>16&255]+b[t>>24&255]+b[255&i]+b[i>>8&255]+b[i>>16&255]+b[i>>24&255]+b[255&r]+b[r>>8&255]+b[r>>16&255]+b[r>>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 v(e,t){const i=k.get(t.priority);for(let r=0;r{if("object"==typeof t&&null!==t){if(i.has(t))return`[object ${t.constructor.name}]`;i.add(t)}return t},n=t?` ${JSON.stringify(t,r)}`:"",o=x(e);return e+n+o}(e,i)),this.name="CKEditorError",this.context=t,this.data=i}is(e){return"CKEditorError"===e}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;const i=new _(e.message,t);throw i.stack=e.stack,i}}function y(e,t){console.warn(...A(e,t))}function x(e){return`\nRead more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-${e}`}function A(e,t){const i=x(e);return t?[e,t,i]:[e,i]}const C="40.2.0",E=new Date(2023,11,12);if(globalThis.CKEDITOR_VERSION)throw new _("ckeditor-duplicated-modules",null);globalThis.CKEDITOR_VERSION=C;const S=Symbol("listeningTo"),T=Symbol("emitterId"),P=Symbol("delegations"),I=M(Object);function M(e){if(!e)return I;return class extends e{on(e,t,i){this.listenTo(this,e,t,i)}once(e,t,i){let r=!1;this.listenTo(this,e,((e,...i)=>{r||(r=!0,e.off(),t.call(this,e,...i))}),i)}off(e,t){this.stopListening(this,e,t)}listenTo(e,t,i,r={}){let n,o;this[S]||(this[S]={});const s=this[S];N(e)||O(e);const a=N(e);(n=s[a])||(n=s[a]={emitter:e,callbacks:{}}),(o=n.callbacks[t])||(o=n.callbacks[t]=[]),o.push(i),function(e,t,i,r,n){t._addEventListener?t._addEventListener(i,r,n):e._addEventListener.call(t,i,r,n)}(this,e,t,i,r)}stopListening(e,t,i){const r=this[S];let n=e&&N(e);const o=r&&n?r[n]:void 0,s=o&&t?o.callbacks[t]:void 0;if(!(!r||e&&!o||t&&!s))if(i){D(this,e,t,i);-1!==s.indexOf(i)&&(1===s.length?delete o.callbacks[t]:D(this,e,t,i))}else if(s){for(;i=s.pop();)D(this,e,t,i);delete o.callbacks[t]}else if(o){for(t in o.callbacks)this.stopListening(e,t);delete r[n]}else{for(n in r)this.stopListening(r[n].emitter);delete this[S]}}fire(e,...t){try{const i=e instanceof f?e:new f(this,e),r=i.name;let n=R(this,r);if(i.path.push(this),n){const e=[i,...t];n=Array.from(n);for(let t=0;t{this[P]||(this[P]=new Map),e.forEach((e=>{const r=this[P].get(e);r?r.set(t,i):this[P].set(e,new Map([[t,i]]))}))}}}stopDelegating(e,t){if(this[P])if(e)if(t){const i=this[P].get(e);i&&i.delete(t)}else this[P].delete(e);else this[P].clear()}_addEventListener(e,t,i){!function(e,t){const i=V(e);if(i[t])return;let r=t,n=null;const o=[];for(;""!==r&&!i[r];)i[r]={callbacks:[],childEvents:[]},o.push(i[r]),n&&i[r].childEvents.push(n),n=r,r=r.substr(0,r.lastIndexOf(":"));if(""!==r){for(const e of o)e.callbacks=i[r].callbacks.slice();i[r].childEvents.push(n)}}(this,e);const r=B(this,e),n={callback:t,priority:k.get(i.priority)};for(const e of r)v(e,n)}_removeEventListener(e,t){const i=B(this,e);for(const e of i)for(let i=0;i-1?R(e,t.substr(0,t.lastIndexOf(":"))):null}function L(e,t,i){for(let[r,n]of e){n?"function"==typeof n&&(n=n(t.name)):n=t.name;const e=new f(t.source,n);e.path=[...t.path],r.fire(e,...i)}}function D(e,t,i,r){t._removeEventListener?t._removeEventListener(i,r):e._removeEventListener.call(t,i,r)}["on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach((e=>{M[e]=I.prototype[e]}));const F=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},j=Symbol("observableProperties"),z=Symbol("boundObservables"),H=Symbol("boundProperties"),U=Symbol("decoratedMethods"),W=Symbol("decoratedOriginal"),$=q(M());function q(e){if(!e)return $;return class extends e{set(e,t){if(F(e))return void Object.keys(e).forEach((t=>{this.set(t,e[t])}),this);G(this);const i=this[j];if(e in this&&!i.has(e))throw new _("observable-set-cannot-override",this);Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>i.get(e),set(t){const r=i.get(e);let n=this.fire(`set:${e}`,e,t,r);void 0===n&&(n=t),r===n&&i.has(e)||(i.set(e,n),this.fire(`change:${e}`,e,n,r))}}),this[e]=t}bind(...e){if(!e.length||!J(e))throw new _("observable-bind-wrong-properties",this);if(new Set(e).size!==e.length)throw new _("observable-bind-duplicate-properties",this);G(this);const t=this[H];e.forEach((e=>{if(t.has(e))throw new _("observable-bind-rebind",this)}));const i=new Map;return e.forEach((e=>{const r={property:e,to:[]};t.set(e,r),i.set(e,r)})),{to:K,toMany:Y,_observable:this,_bindProperties:e,_to:[],_bindings:i}}unbind(...e){if(!this[j])return;const t=this[H],i=this[z];if(e.length){if(!J(e))throw new _("observable-unbind-wrong-properties",this);e.forEach((e=>{const r=t.get(e);r&&(r.to.forEach((([e,t])=>{const n=i.get(e),o=n[t];o.delete(r),o.size||delete n[t],Object.keys(n).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){G(this);const t=this[e];if(!t)throw new _("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][W]=t,this[U]||(this[U]=[]),this[U].push(e)}stopListening(e,t,i){if(!e&&this[U]){for(const e of this[U])this[e]=this[e][W];delete this[U]}super.stopListening(e,t,i)}}}function G(e){e[j]||(Object.defineProperty(e,j,{value:new Map}),Object.defineProperty(e,z,{value:new Map}),Object.defineProperty(e,H,{value:new Map}))}function K(...e){const t=function(...e){if(!e.length)throw new _("observable-bind-to-parse-error",null);const t={to:[]};let i;"function"==typeof e[e.length-1]&&(t.callback=e.pop());return e.forEach((e=>{if("string"==typeof e)i.properties.push(e);else{if("object"!=typeof e)throw new _("observable-bind-to-parse-error",null);i={observable:e,properties:[]},t.to.push(i)}})),t}(...e),i=Array.from(this._bindings.keys()),r=i.length;if(!t.callback&&t.to.length>1)throw new _("observable-bind-to-no-callback",this);if(r>1&&t.callback)throw new _("observable-bind-to-extra-callback",this);var n;t.to.forEach((e=>{if(e.properties.length&&e.properties.length!==r)throw new _("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),n=this._observable,this._to.forEach((e=>{const t=n[z];let i;t.get(e.observable)||n.listenTo(e.observable,"change",((r,o)=>{i=t.get(e.observable)[o],i&&i.forEach((e=>{Z(n,e.property)}))}))})),function(e){let t;e._bindings.forEach(((i,r)=>{e._to.forEach((n=>{t=n.properties[i.callback?0:e._bindProperties.indexOf(r)],i.to.push([n.observable,t]),function(e,t,i,r){const n=e[z],o=n.get(i),s=o||{};s[r]||(s[r]=new Set);s[r].add(t),o||n.set(i,s)}(e._observable,i,n.observable,t)}))}))}(this),this._bindProperties.forEach((e=>{Z(this._observable,e)}))}function Y(e,t,i){if(this._bindings.size>1)throw new _("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 J(e){return e.every((e=>"string"==typeof e))}function Z(e,t){const i=e[H].get(t);let r;i.callback?r=i.callback.apply(e,i.to.map((e=>e[0][e[1]]))):(r=i.to[0],r=r[0][r[1]]),Object.prototype.hasOwnProperty.call(e,t)?e[t]=r:e.set(t,r)}["set","bind","unbind","decorate","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach((e=>{q[e]=$.prototype[e]}));class Q{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 X(e){let t=0;for(const i of e)t++;return t}function ee(e,t){const i=Math.min(e.length,t.length);for(let r=0;r-1};const Ve=function(e,t){var i=this.__data__,r=Pe(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this};function Be(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991};var $t={};$t["[object Float32Array]"]=$t["[object Float64Array]"]=$t["[object Int8Array]"]=$t["[object Int16Array]"]=$t["[object Int32Array]"]=$t["[object Uint8Array]"]=$t["[object Uint8ClampedArray]"]=$t["[object Uint16Array]"]=$t["[object Uint32Array]"]=!0,$t["[object Arguments]"]=$t["[object Array]"]=$t["[object ArrayBuffer]"]=$t["[object Boolean]"]=$t["[object DataView]"]=$t["[object Date]"]=$t["[object Error]"]=$t["[object Function]"]=$t["[object Map]"]=$t["[object Number]"]=$t["[object Object]"]=$t["[object RegExp]"]=$t["[object Set]"]=$t["[object String]"]=$t["[object WeakMap]"]=!1;const qt=function(e){return fe(e)&&Wt(e.length)&&!!$t[ge(e)]};const Gt=function(e){return function(t){return e(t)}};var Kt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Yt=Kt&&"object"==typeof module&&module&&!module.nodeType&&module,Jt=Yt&&Yt.exports===Kt&&ie.process;const Zt=function(){try{var e=Yt&&Yt.require&&Yt.require("util").types;return e||Jt&&Jt.binding&&Jt.binding("util")}catch(e){}}();var Qt=Zt&&Zt.isTypedArray;const Xt=Qt?Gt(Qt):qt;var ei=Object.prototype.hasOwnProperty;const ti=function(e,t){var i=pe(e),r=!i&&Rt(e),n=!i&&!r&&zt(e),o=!i&&!r&&!n&&Xt(e),s=i||r||n||o,a=s?Mt(e.length,String):[],c=a.length;for(var l in e)!t&&!ei.call(e,l)||s&&("length"==l||n&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Ut(l,c))||a.push(l);return a};var ii=Object.prototype;const ri=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||ii)};const ni=ke(Object.keys,Object);var oi=Object.prototype.hasOwnProperty;const si=function(e){if(!ri(e))return ni(e);var t=[];for(var i in Object(e))oi.call(e,i)&&"constructor"!=i&&t.push(i);return t};const ai=function(e){return null!=e&&Wt(e.length)&&!ze(e)};const ci=function(e){return ai(e)?ti(e):si(e)};const li=function(e,t){return e&&It(t,ci(t),e)};const di=function(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t};var ui=Object.prototype.hasOwnProperty;const hi=function(e){if(!F(e))return di(e);var t=ri(e),i=[];for(var r in e)("constructor"!=r||!t&&ui.call(e,r))&&i.push(r);return i};const mi=function(e){return ai(e)?ti(e,!0):hi(e)};const gi=function(e,t){return e&&It(t,mi(t),e)};var pi="object"==typeof exports&&exports&&!exports.nodeType&&exports,fi=pi&&"object"==typeof module&&module&&!module.nodeType&&module,bi=fi&&fi.exports===pi?ne.Buffer:void 0,wi=bi?bi.allocUnsafe:void 0;const ki=function(e,t){if(t)return e.slice();var i=e.length,r=wi?wi(i):new e.constructor(i);return e.copy(r),r};const vi=function(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i{this._setToTarget(e,r,t[r],i)}))}}function Ar(e){return _r(e,Cr)}function Cr(e){return yr(e)||"function"==typeof e?e:void 0}function Er(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 Sr(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}const Tr=Pr(M());function Pr(e){if(!e)return Tr;return class extends e{listenTo(e,t,i,r={}){if(Er(e)||Sr(e)){const n={capture:!!r.useCapture,passive:!!r.usePassive},o=this._getProxyEmitter(e,n)||new Ir(e,n);this.listenTo(o,t,i,r)}else super.listenTo(e,t,i,r)}stopListening(e,t,i){if(Er(e)||Sr(e)){const r=this._getAllProxyEmitters(e);for(const e of r)this.stopListening(e,t,i)}else super.stopListening(e,t,i)}_getProxyEmitter(e,t){return function(e,t){const i=e[S];return i&&i[t]?i[t].emitter:null}(this,Mr(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))}}}["_getProxyEmitter","_getAllProxyEmitters","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach((e=>{Pr[e]=Tr.prototype[e]}));class Ir extends(M()){constructor(e,t){super(),O(this,Mr(e,t)),this._domNode=e,this._options=t}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),M().prototype._addEventListener.call(this,e,t,i)}_removeEventListener(e,t){M().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 Mr(e,t){let i=function(e){return e["data-ck-expando"]||(e["data-ck-expando"]=w())}(e);for(const e of Object.keys(t).sort())t[e]&&(i+="-"+e);return i}let Or;try{Or={window,document}}catch(e){Or={window:{},document:{}}}const Nr=Or;function Vr(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)}}function Br(e){return"[object Text]"==Object.prototype.toString.call(e)}function Rr(e){return"[object Range]"==Object.prototype.toString.apply(e)}function Lr(e){return e&&e.parentNode?e.offsetParent===Nr.document.body?null:e.offsetParent:null}const Dr=["top","right","bottom","left","width","height"];class Fr{constructor(e){const t=Rr(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),Hr(e)||t)if(t){const t=Fr.getDomRangeRects(e);jr(this,Fr.getBoundingRect(t))}else jr(this,e.getBoundingClientRect());else if(Sr(e)){const{innerWidth:t,innerHeight:i}=e;jr(this,{top:0,right:t,bottom:i,left:0,width:t,height:i})}else jr(this,e)}clone(){return new Fr(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 Fr(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(zr(e))return t;let i,r=e,n=e.parentNode||e.commonAncestorContainer;for(;n&&!zr(n);){const e="visible"===((o=n)instanceof HTMLElement?o.ownerDocument.defaultView.getComputedStyle(o).overflow:"visible");r instanceof HTMLElement&&"absolute"===Ur(r)&&(i=r);const s=Ur(n);if(e||i&&("relative"===s&&e||"relative"!==s)){r=n,n=n.parentNode;continue}const a=new Fr(n),c=t.getIntersection(a);if(!c)return null;c.getArea(){for(const t of e){const e=Wr._getElementCallbacks(t.target);if(e)for(const i of e)i(t)}}))}}function $r(e,t){e instanceof HTMLTextAreaElement&&(e.value=t),e.innerHTML=t}function qr(e){return t=>t+e}function Gr(e){let t=0;for(;e.previousSibling;)e=e.previousSibling,t++;return t}function Kr(e,t,i){e.insertBefore(i,e.childNodes[t]||null)}function Yr(e){return e&&e.nodeType===Node.COMMENT_NODE}function Jr(e){try{Nr.document.createAttribute(e)}catch(e){return!1}return!0}function Zr(e){return!!(e&&e.getClientRects&&e.getClientRects().length)}function Qr({element:e,target:t,positions:i,limiter:r,fitInViewport:n,viewportOffsetConfig:o}){ze(t)&&(t=t()),ze(r)&&(r=r());const s=Lr(e),a=function(e){e=Object.assign({top:0,bottom:0,left:0,right:0},e);const t=new Fr(Nr.window);return t.top+=e.top,t.height-=e.top,t.bottom-=e.bottom,t.height-=e.bottom,t}(o),c=new Fr(e),l=Xr(t,a);let d;if(!l||!a.getIntersection(l))return null;const u={targetRect:l,elementRect:c,positionedElementAncestor:s,viewportRect:a};if(r||n){if(r){const e=Xr(r,a);e&&(u.limiterRect=e)}d=function(e,t){const{elementRect:i}=t,r=i.getArea(),n=e.map((e=>new en(e,t))).filter((e=>!!e.name));let o=0,s=null;for(const e of n){const{limiterIntersectionArea:t,viewportIntersectionArea:i}=e;if(t===r)return e;const n=i**2+t**2;n>o&&(o=n,s=e)}return s}(i,u)}else d=new en(i[0],u);return d}function Xr(e,t){const i=new Fr(e).getVisible();return i?i.getIntersection(t):null}Wr._observerInstance=null,Wr._elementCallbacks=null;class en{constructor(e,t){const i=e(t.targetRect,t.elementRect,t.viewportRect,t.limiterRect);if(!i)return;const{left:r,top:n,name:o,config:s}=i;this.name=o,this.config=s,this._positioningFunctionCoordinates={left:r,top:n},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 tn(e){const t=e.parentNode;t&&t.removeChild(e)}function rn({window:e,rect:t,alignToTop:i,forceScroll:r,viewportOffset:n}){const o=t.clone().moveBy(0,n.bottom),s=t.clone().moveBy(0,-n.top),a=new Fr(e).excludeScrollbarsAndBorders(),c=i&&r,l=[s,o].every((e=>a.contains(e)));let{scrollX:d,scrollY:u}=e;const h=d,m=u;c?u-=a.top-t.top+n.top:l||(sn(s,a)?u-=a.top-t.top+n.top:on(o,a)&&(u+=i?t.top-a.top-n.top:t.bottom-a.bottom+n.bottom)),l||(an(t,a)?d-=a.left-t.left+n.left:cn(t,a)&&(d+=t.right-a.right+n.right)),d==h&&u===m||e.scrollTo(d,u)}function nn({parent:e,getRect:t,alignToTop:i,forceScroll:r,ancestorOffset:n=0,limiterElement:o}){const s=ln(e),a=i&&r;let c,l,d;const u=o||s.document.body;for(;e!=u;)l=t(),c=new Fr(e).excludeScrollbarsAndBorders(),d=c.contains(l),a?e.scrollTop-=c.top-l.top+n:d||(sn(l,c)?e.scrollTop-=c.top-l.top+n:on(l,c)&&(e.scrollTop+=i?l.top-c.top-n:l.bottom-c.bottom+n)),d||(an(l,c)?e.scrollLeft-=c.left-l.left+n:cn(l,c)&&(e.scrollLeft+=l.right-c.right+n)),e=e.parentNode}function on(e,t){return e.bottom>t.bottom}function sn(e,t){return e.topt.right}function ln(e){return Rr(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function dn(e){if(Rr(e)){let t=e.commonAncestorContainer;return Br(t)&&(t=t.parentNode),t}return e.parentNode}function un(e,t){const i=ln(e),r=new Fr(e);if(i===t)return r;{let e=i;for(;e!=t;){const t=e.frameElement,i=new Fr(t).excludeScrollbarsAndBorders();r.moveBy(i.left,i.top),e=e.parent}}return r}const hn={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},mn={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},gn=function(){const e={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;for(const t of"`-=[];',./\\")e[t]=t.charCodeAt(0);return e}(),pn=Object.fromEntries(Object.entries(gn).map((([e,t])=>[t,e.charAt(0).toUpperCase()+e.slice(1)])));function fn(e){let t;if("string"==typeof e){if(t=gn[e.toLowerCase()],!t)throw new _("keyboard-unknown-key",null,{key:e})}else t=e.keyCode+(e.altKey?gn.alt:0)+(e.ctrlKey?gn.ctrl:0)+(e.shiftKey?gn.shift:0)+(e.metaKey?gn.cmd:0);return t}function bn(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 fn(e.slice(0,-1));const t=fn(e);return(l.isMac||l.isiOS)&&t==gn.ctrl?gn.cmd:t}(e):e)).reduce(((e,t)=>t+e),0)}function wn(e){let t=bn(e);return Object.entries(l.isMac||l.isiOS?hn:mn).reduce(((e,[i,r])=>(t&gn[i]&&(t&=~gn[i],e+=r),e)),"")+(t?pn[t]:"")}function kn(e,t){const i="ltr"===t;switch(e){case gn.arrowleft:return i?"left":"right";case gn.arrowright:return i?"right":"left";case gn.arrowup:return"up";case gn.arrowdown:return"down"}}const vn=["ar","ara","fa","per","fas","he","heb","ku","kur","ug","uig"];function _n(e){return vn.includes(e)?"rtl":"ltr"}function yn(e){return Array.isArray(e)?e:[e]}function xn(e,t,i=1){if("number"!=typeof i)throw new _("translation-service-quantity-not-a-number",null,{quantity:i});const r=Object.keys(Nr.window.CKEDITOR_TRANSLATIONS).length;1===r&&(e=Object.keys(Nr.window.CKEDITOR_TRANSLATIONS)[0]);const n=t.id||t.string;if(0===r||!function(e,t){return!!Nr.window.CKEDITOR_TRANSLATIONS[e]&&!!Nr.window.CKEDITOR_TRANSLATIONS[e].dictionary[t]}(e,n))return 1!==i?t.plural:t.string;const o=Nr.window.CKEDITOR_TRANSLATIONS[e].dictionary,s=Nr.window.CKEDITOR_TRANSLATIONS[e].getPluralForm||(e=>1===e?0:1),a=o[n];if("string"==typeof a)return a;return a[Number(s(i))]}Nr.window.CKEDITOR_TRANSLATIONS||(Nr.window.CKEDITOR_TRANSLATIONS={});class An{constructor({uiLanguage:e="en",contentLanguage:t}={}){this.uiLanguage=e,this.contentLanguage=t||this.uiLanguage,this.uiLanguageDirection=_n(this.uiLanguage),this.contentLanguageDirection=_n(this.contentLanguage),this.t=(e,t)=>this._t(e,t)}get language(){return console.warn("locale-deprecated-language-property: The Locale#language property has been deprecated and will be removed in the near future. Please use #uiLanguage and #contentLanguage properties instead."),this.uiLanguage}_t(e,t=[]){t=yn(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)=>ithis._items.length||t<0)throw new _("collection-add-item-invalid-index",this);let i=0;for(const r of e){const e=this._getItemIdBeforeAdding(r),n=t+i;this._items.splice(n,0,r),this._itemMap.set(e,r),this.fire("add",r,n),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 _("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 _("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,r,n)=>{const o=t._bindToCollection==this,s=t._bindToInternalToExternalMap.get(r);if(o&&s)this._bindToExternalToInternalMap.set(r,s),this._bindToInternalToExternalMap.set(s,r);else{const i=e(r);if(!i)return void this._skippedIndexesFromExternal.push(n);let o=n;for(const e of this._skippedIndexesFromExternal)n>e&&o--;for(const e of t._skippedIndexesFromExternal)o>=e&&o++;this._bindToExternalToInternalMap.set(r,i),this._bindToInternalToExternalMap.set(i,r),this.add(i,o);for(let e=0;e{const r=this._bindToExternalToInternalMap.get(t);r&&this.remove(r),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 _("collection-add-invalid-id",this);if(this.get(i))throw new _("collection-add-item-already-exists",this)}else e[t]=i=w();return i}_remove(e){let t,i,r,n=!1;const o=this._idProperty;if("string"==typeof e?(i=e,r=this._itemMap.get(i),n=!r,r&&(t=this._items.indexOf(r))):"number"==typeof e?(t=e,r=this._items[t],n=!r,r&&(i=r[o])):(r=e,i=r[o],t=this._items.indexOf(r),n=-1==t||!this._itemMap.get(i)),n)throw new _("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(i);const s=this._bindToInternalToExternalMap.get(r);return this._bindToInternalToExternalMap.delete(r),this._bindToExternalToInternalMap.delete(s),this.fire("remove",r,t),[r,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}function En(e){const t=e.next();return t.done?null:t.value}class Sn extends(Pr(q())){constructor(){super(),this._elements=new Set,this._nextEventLoopTimeout=null,this.set("isFocused",!1),this.set("focusedElement",null)}add(e){if(this._elements.has(e))throw new _("focustracker-add-element-already-exist",this);this.listenTo(e,"focus",(()=>this._focus(e)),{useCapture:!0}),this.listenTo(e,"blur",(()=>this._blur()),{useCapture:!0}),this._elements.add(e)}remove(e){e===this.focusedElement&&this._blur(),this._elements.has(e)&&(this.stopListening(e),this._elements.delete(e))}destroy(){this.stopListening()}_focus(e){clearTimeout(this._nextEventLoopTimeout),this.focusedElement=e,this.isFocused=!0}_blur(){clearTimeout(this._nextEventLoopTimeout),this._nextEventLoopTimeout=setTimeout((()=>{this.focusedElement=null,this.isFocused=!1}),0)}}class Tn{constructor(){this._listener=new(Pr())}listenTo(e){this._listener.listenTo(e,"keydown",((e,t)=>{this._listener.fire("_keydown:"+fn(t),t)}))}set(e,t,i={}){const r=bn(e),n=i.priority;this._listener.listenTo(this._listener,"_keydown:"+r,((e,i)=>{t(i,(()=>{i.preventDefault(),i.stopPropagation(),e.stop()})),e.return=!0}),{priority:n})}press(e){return!!this._listener.fire("_keydown:"+fn(e),e)}stopListening(e){this._listener.stopListening(e)}destroy(){this.stopListening()}}function Pn(e){return te(e)?new Map(e):function(e){const t=new Map;for(const i in e)t.set(i,e[i]);return t}(e)}function In(e,t){let i;function r(...n){r.cancel(),i=setTimeout((()=>e(...n)),t)}return r.cancel=()=>{clearTimeout(i)},r}function Mn(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 On(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 Nn=function(){const e=/\p{Regional_Indicator}{2}/u.source,t="(?:"+[/\p{Emoji}[\u{E0020}-\u{E007E}]+\u{E007F}/u,/\p{Emoji}\u{FE0F}?\u{20E3}/u,/\p{Emoji}\u{FE0F}/u,/(?=\p{General_Category=Other_Symbol})\p{Emoji}\p{Emoji_Modifier}*/u].map((e=>e.source)).join("|")+")";return new RegExp(`${e}|${t}(?:‍${t})*`,"ug")}();function Vn(e,t){const i=String(e).matchAll(Nn);return Array.from(i).some((e=>e.index{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 _("ui-viewcollection-delegate-wrong-events",this);return{to:t=>{for(const i of this)for(const r of e)i.delegate(r).to(t);this.on("add",((i,r)=>{for(const i of e)r.delegate(i).to(t)})),this.on("remove",((i,r)=>{for(const i of e)r.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)}}var Rn=i(5072),Ln=i.n(Rn),Dn=i(4284),Fn=i.n(Dn),jn=i(7659),zn=i.n(jn),Hn=i(4868),Un=i.n(Hn),Wn=i(540),$n=i.n(Wn),qn=i(3851),Gn={attributes:{"data-cke":!0}};Gn.setAttributes=Un(),Gn.insert=zn().bind(null,"head"),Gn.domAPI=Fn(),Gn.insertStyleElement=$n();Ln()(qn.A,Gn);qn.A&&qn.A.locals&&qn.A.locals;class Kn extends(Pr(q())){constructor(e){super(),this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new Cn,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=Yn.bind(this,this)}createCollection(e){const t=new Bn(e);return this._viewCollections.add(t),t}registerChild(e){te(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){te(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new Yn(e)}extendTemplate(e){Yn.extend(this.template,e)}render(){if(this.isRendered)throw new _("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)}}class Yn extends(M()){constructor(e){super(),Object.assign(this,oo(no(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 _("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)ho(i)?yield i:mo(i)&&(yield*e(i))}(this)}static bind(e,t){return{to:(i,r)=>new Zn({eventNameOrFunction:i,attribute:i,observable:e,emitter:t,callback:r}),if:(i,r,n)=>new Qn({observable:e,emitter:t,attribute:i,valueIfTrue:r,callback:n})}}static extend(e,t){if(e._isRendered)throw new _("template-extend-render",[this,e]);lo(e,oo(no(t)))}_renderNode(e){let t;if(t=e.node?this.tag&&this.text:this.tag?this.text:!this.text,t)throw new _("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(""),Xn(this.text)?this._bindToObservable({schema:this.text,updater:to(t),data:e}):t.textContent=this.text.join(""),t}_renderAttributes(e){if(!this.attributes)return;const t=e.node,i=e.revertData;for(const r in this.attributes){const n=t.getAttribute(r),o=this.attributes[r];i&&(i.attributes[r]=n);const s=po(o)?o[0].ns:null;if(Xn(o)){const a=po(o)?o[0].value:o;i&&fo(r)&&a.unshift(n),this._bindToObservable({schema:a,updater:io(t,r,s),data:e})}else if("style"==r&&"string"!=typeof o[0])this._renderStyleAttribute(o[0],e);else{i&&n&&fo(r)&&o.unshift(n);const e=o.map((e=>e&&e.value||e)).reduce(((e,t)=>e.concat(t)),[]).reduce(ao,"");uo(e)||t.setAttributeNS(s,r,e)}}}_renderStyleAttribute(e,t){const i=t.node;for(const r in e){const n=e[r];Xn(n)?this._bindToObservable({schema:[n],updater:ro(i,r),data:t}):i.style[r]=n}}_renderElementChildren(e){const t=e.node,i=e.intoFragment?document.createDocumentFragment():t,r=e.isApplying;let n=0;for(const o of this.children)if(go(o)){if(!r){o.setParent(t);for(const e of o)i.appendChild(e.element)}}else if(ho(o))r||(o.isRendered||o.render(),i.appendChild(o.element));else if(Er(o))i.appendChild(o);else if(r){const t={children:[],bindings:[],attributes:{}};e.revertData.children.push(t),o._renderNode({intoFragment:!1,node:i.childNodes[n++],isApplying:!0,revertData:t})}else i.appendChild(o.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[r,n]=t.split("@");return i.activateDomEventListener(r,n,e)}));e.revertData&&e.revertData.bindings.push(i)}}_bindToObservable({schema:e,updater:t,data:i}){const r=i.revertData;eo(e,t,i);const n=e.filter((e=>!uo(e))).filter((e=>e.observable)).map((r=>r.activateAttributeListener(e,t,i)));r&&r.bindings.push(n)}_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 r=t.attributes[e];null===r?i.removeAttribute(e):i.setAttribute(e,r)}for(let e=0;eeo(e,t,i);return this.emitter.listenTo(this.observable,`change:${this.attribute}`,r),()=>{this.emitter.stopListening(this.observable,`change:${this.attribute}`,r)}}}class Zn extends Jn{constructor(e){super(e),this.eventNameOrFunction=e.eventNameOrFunction}activateDomEventListener(e,t,i){const r=(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,r),()=>{this.emitter.stopListening(i.node,e,r)}}}class Qn extends Jn{constructor(e){super(e),this.valueIfTrue=e.valueIfTrue}getValue(e){return!uo(super.getValue(e))&&(this.valueIfTrue||!0)}}function Xn(e){return!!e&&(e.value&&(e=e.value),Array.isArray(e)?e.some(Xn):e instanceof Jn)}function eo(e,t,{node:i}){const r=function(e,t){return e.map((e=>e instanceof Jn?e.getValue(t):e))}(e,i);let n;n=1==e.length&&e[0]instanceof Qn?r[0]:r.reduce(ao,""),uo(n)?t.remove():t.set(n)}function to(e){return{set(t){e.textContent=t},remove(){e.textContent=""}}}function io(e,t,i){return{set(r){e.setAttributeNS(i,t,r)},remove(){e.removeAttributeNS(i,t)}}}function ro(e,t){return{set(i){e.style[t]=i},remove(){e.style[t]=null}}}function no(e){return _r(e,(e=>{if(e&&(e instanceof Jn||mo(e)||ho(e)||go(e)))return e}))}function oo(e){if("string"==typeof e?e=function(e){return{text:[e]}}(e):e.text&&function(e){e.text=yn(e.text)}(e),e.on&&(e.eventListeners=function(e){for(const t in e)so(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=yn(e[t].value)),so(e,t)}(e.attributes);const t=[];if(e.children)if(go(e.children))t.push(e.children);else for(const i of e.children)mo(i)||ho(i)||Er(i)?t.push(i):t.push(new Yn(i));e.children=t}return e}function so(e,t){e[t]=yn(e[t])}function ao(e,t){return uo(t)?e:uo(e)?t:`${e} ${t}`}function co(e,t){for(const i in t)e[i]?e[i].push(...t[i]):e[i]=t[i]}function lo(e,t){if(t.attributes&&(e.attributes||(e.attributes={}),co(e.attributes,t.attributes)),t.eventListeners&&(e.eventListeners||(e.eventListeners={}),co(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 _("ui-template-extend-children-mismatch",e);let i=0;for(const r of t.children)lo(e.children[i++],r)}}function uo(e){return!e&&0!==e}function ho(e){return e instanceof Kn}function mo(e){return e instanceof Yn}function go(e){return e instanceof Bn}function po(e){return F(e[0])&&e[0].ns}function fo(e){return"class"==e||"style"==e}class bo extends Bn{constructor(e,t=[]){super(t),this.locale=e}get bodyCollectionContainer(){return this._bodyCollectionContainer}attachToDom(){this._bodyCollectionContainer=new Yn({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:this.locale.uiLanguageDirection},children:this}).render();let e=document.querySelector(".ck-body-wrapper");e||(e=we(document,"div",{class:"ck-body-wrapper"}),document.body.appendChild(e)),e.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove();const e=document.querySelector(".ck-body-wrapper");e&&0==e.childElementCount&&e.remove()}}var wo=i(1668),ko={attributes:{"data-cke":!0}};ko.setAttributes=Un(),ko.insert=zn().bind(null,"head"),ko.domAPI=Fn(),ko.insertStyleElement=$n();Ln()(wo.A,ko);wo.A&&wo.A.locals&&wo.A.locals;class vo extends Kn{constructor(){super();const e=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.set("isColorInherited",!0),this.set("isVisible",!0),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon",e.if("isVisible","ck-hidden",(e=>!e)),"ck-reset_all-excluded",e.if("isColorInherited","ck-icon_inherit-color")],viewBox:e.to("viewBox")}})}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"),t=e.getAttribute("viewBox");t&&(this.viewBox=t);for(const{name:t,value:i}of Array.from(e.attributes))vo.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}))}}vo.presentationalAttributeNames=["alignment-baseline","baseline-shift","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-rendering","cursor","direction","display","dominant-baseline","fill","fill-opacity","fill-rule","filter","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","mask","opacity","overflow","paint-order","pointer-events","shape-rendering","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-overflow","text-rendering","transform","unicode-bidi","vector-effect","visibility","white-space","word-spacing","writing-mode"];class _o extends Kn{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")}]})}}var yo=i(8742),xo={attributes:{"data-cke":!0}};xo.setAttributes=Un(),xo.insert=zn().bind(null,"head"),xo.domAPI=Fn(),xo.insertStyleElement=$n();Ln()(yo.A,xo);yo.A&&yo.A.locals&&yo.A.locals;class Ao extends Kn{constructor(e,t=new _o){super(e),this._focusDelayed=null;const i=this.bindTemplate,r=w();this.set("ariaLabel",void 0),this.set("ariaLabelledBy",`ck-editor__aria-label_${r}`),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 vo,this.iconView.extendTemplate({attributes:{class:"ck-button__icon"}}),this.keystrokeView=this._createKeystrokeView(),this.bind("_tooltipString").to(this,"tooltip",this,"label",this,"keystroke",this._getTooltipString.bind(this));const n={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-label":i.to("ariaLabel"),"aria-labelledby":i.to("ariaLabelledBy"),"aria-disabled":i.if("isEnabled",!0,(e=>!e)),"aria-pressed":i.to("isOn",(e=>!!this.isToggleable&&String(!!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()}))}};l.isSafari&&(this._focusDelayed||(this._focusDelayed=In((()=>this.focus()),0)),n.on.mousedown=i.to((()=>{this._focusDelayed()})),n.on.mouseup=i.to((()=>{this._focusDelayed.cancel()}))),this.setTemplate(n)}render(){super.render(),this.icon&&(this.iconView.bind("content").to(this,"icon"),this.children.add(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 Kn;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",(e=>wn(e)))}]}),e}_getTooltipString(e,t,i){return e?"string"==typeof e?e:(i&&(i=wn(i)),e instanceof Function?e(t,i):`${t}${i?` (${i})`:""}`):""}}var Co=i(422),Eo={attributes:{"data-cke":!0}};Eo.setAttributes=Un(),Eo.insert=zn().bind(null,"head"),Eo.domAPI=Fn(),Eo.insertStyleElement=$n();Ln()(Co.A,Eo);Co.A&&Co.A.locals&&Co.A.locals;class So extends Ao{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 Kn;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}}function To(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 Po extends Ao{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")},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%)"}}var Io=i(8108),Mo={attributes:{"data-cke":!0}};Mo.setAttributes=Un(),Mo.insert=zn().bind(null,"head"),Mo.domAPI=Fn(),Mo.insertStyleElement=$n();Ln()(Io.A,Mo);Io.A&&Io.A.locals&&Io.A.locals;class Oo extends Kn{constructor(e,t){super(e);const i=t&&t.colorDefinitions?t.colorDefinitions:[];this.columns=t&&t.columns?t.columns:5;const r={gridTemplateColumns:`repeat( ${this.columns}, 1fr)`};this.set("selectedColor",void 0),this.items=this.createCollection(),this.focusTracker=new Sn,this.keystrokes=new Tn,this.items.on("add",((e,t)=>{t.isOn=t.color===this.selectedColor})),i.forEach((e=>{const t=new Po;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:r}}),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),s({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:this.columns,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}var No=i(8156);const Vo=function(e){var t,i,r=[],n=1;if("string"==typeof e)if(No[e])r=No[e].slice(),i="rgb";else if("transparent"===e)n=0,i="rgb",r=[0,0,0];else if(/^#[A-Fa-f0-9]+$/.test(e)){var o=e.slice(1);n=1,(c=o.length)<=4?(r=[parseInt(o[0]+o[0],16),parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16)],4===c&&(n=parseInt(o[3]+o[3],16)/255)):(r=[parseInt(o[0]+o[1],16),parseInt(o[2]+o[3],16),parseInt(o[4]+o[5],16)],8===c&&(n=parseInt(o[6]+o[7],16)/255)),r[0]||(r[0]=0),r[1]||(r[1]=0),r[2]||(r[2]=0),i="rgb"}else if(t=/^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(e)){var s=t[1],a="rgb"===s;i=o=s.replace(/a$/,"");var c="cmyk"===o?4:"gray"===o?1:3;r=t[2].trim().split(/\s*[,\/]\s*|\s+/).map((function(e,t){if(/%$/.test(e))return t===c?parseFloat(e)/100:"rgb"===o?255*parseFloat(e)/100:parseFloat(e);if("h"===o[t]){if(/deg$/.test(e))return parseFloat(e);if(void 0!==Bo[e])return Bo[e]}return parseFloat(e)})),s===o&&r.push(1),n=a||void 0===r[c]?1:r[c],r=r.slice(0,c)}else e.length>10&&/[0-9](?:\s|\/)/.test(e)&&(r=e.match(/([0-9]+)/g).map((function(e){return parseFloat(e)})),i=e.match(/([a-z])/gi).join("").toLowerCase());else isNaN(e)?Array.isArray(e)||e.length?(r=[e[0],e[1],e[2]],i="rgb",n=4===e.length?e[3]:1):e instanceof Object&&(null!=e.r||null!=e.red||null!=e.R?(i="rgb",r=[e.r||e.red||e.R||0,e.g||e.green||e.G||0,e.b||e.blue||e.B||0]):(i="hsl",r=[e.h||e.hue||e.H||0,e.s||e.saturation||e.S||0,e.l||e.lightness||e.L||e.b||e.brightness]),n=e.a||e.alpha||e.opacity||1,null!=e.opacity&&(n/=100)):(i="rgb",r=[e>>>16,(65280&e)>>>8,255&e]);return{space:i,values:r,alpha:n}};var Bo={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};var Ro=i(734);function Lo(e,t){if(!e)return"";const i=Do(e);if(!i)return"";if(i.space===t)return e;if(r=i,!Object.keys(Ro).includes(r.space))return"";var r;const n=Ro[i.space][t];if(!n)return"";return function(e,t){switch(t){case"hex":return`#${e}`;case"rgb":return`rgb( ${e[0]}, ${e[1]}, ${e[2]} )`;case"hsl":return`hsl( ${e[0]}, ${e[1]}%, ${e[2]}% )`;case"hwb":return`hwb( ${e[0]}, ${e[1]}, ${e[2]} )`;case"lab":return`lab( ${e[0]}% ${e[1]} ${e[2]} )`;case"lch":return`lch( ${e[0]}% ${e[1]} ${e[2]} )`;default:return""}}(n("hex"===i.space?i.hexValue:i.values),t)}function Do(e){if(e.startsWith("#")){const t=Vo(e);return{space:"hex",values:t.values,hexValue:e,alpha:t.alpha}}const t=Vo(e);return t.space?t:null}const Fo=function(){return ne.Date.now()};var jo=/\s/;const zo=function(e){for(var t=e.length;t--&&jo.test(e.charAt(t)););return t};var Ho=/^\s+/;const Uo=function(e){return e?e.slice(0,zo(e)+1).replace(Ho,""):e};const Wo=function(e){return"symbol"==typeof e||fe(e)&&"[object Symbol]"==ge(e)};var $o=/^[-+]0x[0-9a-f]+$/i,qo=/^0b[01]+$/i,Go=/^0o[0-7]+$/i,Ko=parseInt;const Yo=function(e){if("number"==typeof e)return e;if(Wo(e))return NaN;if(F(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=F(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Uo(e);var i=qo.test(e);return i||Go.test(e)?Ko(e.slice(2),i?2:8):$o.test(e)?NaN:+e};var Jo=Math.max,Zo=Math.min;const Qo=function(e,t,i){var r,n,o,s,a,c,l=0,d=!1,u=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function m(t){var i=r,o=n;return r=n=void 0,l=t,s=e.apply(o,i)}function g(e){var i=e-c;return void 0===c||i>=t||i<0||u&&e-l>=o}function p(){var e=Fo();if(g(e))return f(e);a=setTimeout(p,function(e){var i=t-(e-c);return u?Zo(i,o-(e-l)):i}(e))}function f(e){return a=void 0,h&&r?m(e):(r=n=void 0,s)}function b(){var e=Fo(),i=g(e);if(r=arguments,n=this,c=e,i){if(void 0===a)return function(e){return l=e,a=setTimeout(p,t),d?m(e):s}(c);if(u)return clearTimeout(a),a=setTimeout(p,t),m(c)}return void 0===a&&(a=setTimeout(p,t)),s}return t=Yo(t)||0,F(i)&&(d=!!i.leading,o=(u="maxWait"in i)?Jo(Yo(i.maxWait)||0,t):o,h="trailing"in i?!!i.trailing:h),b.cancel=function(){void 0!==a&&clearTimeout(a),l=0,r=c=n=a=void 0},b.flush=function(){return void 0===a?s:f(Fo())},b};var Xo=i(192),es={attributes:{"data-cke":!0}};es.setAttributes=Un(),es.insert=zn().bind(null,"head"),es.domAPI=Fn(),es.insertStyleElement=$n();Ln()(Xo.A,es);Xo.A&&Xo.A.locals&&Xo.A.locals;class ts extends Kn{constructor(e){super(e),this.set("text",void 0),this.set("for",void 0),this.id=`ck-editor__label_${w()}`;const t=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],id:this.id,for:t.to("for")},children:[{text:t.to("text")}]})}}var is=i(9015),rs={attributes:{"data-cke":!0}};rs.setAttributes=Un(),rs.insert=zn().bind(null,"head"),rs.domAPI=Fn(),rs.insertStyleElement=$n();Ln()(is.A,rs);is.A&&is.A.locals&&is.A.locals;class ns extends Kn{constructor(e,t){super(e);const i=`ck-labeled-field-view-${w()}`,r=`ck-labeled-field-view-status-${w()}`;this.fieldView=t(this,i,r),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(r),this.fieldWrapperChildren=this.createCollection([this.fieldView,this.labelView]),this.bind("_statusText").to(this,"errorText",this,"infoText",((e,t)=>e||t));const n=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",n.to("class"),n.if("isEnabled","ck-disabled",(e=>!e)),n.if("isEmpty","ck-labeled-field-view_empty"),n.if("isFocused","ck-labeled-field-view_focused"),n.if("placeholder","ck-labeled-field-view_placeholder"),n.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 ts(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new Kn(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 os extends Kn{constructor(e){super(e),this.set("value",void 0),this.set("id",void 0),this.set("placeholder",void 0),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById",void 0),this.focusTracker=new Sn,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"),readonly:t.to("isReadOnly"),"aria-invalid":t.if("hasError",!0),"aria-describedby":t.to("ariaDescribedById")},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:""}}var ss=i(7564),as={attributes:{"data-cke":!0}};as.setAttributes=Un(),as.insert=zn().bind(null,"head"),as.domAPI=Fn(),as.insertStyleElement=$n();Ln()(ss.A,as);ss.A&&ss.A.locals&&ss.A.locals;class cs extends os{constructor(e){super(e),this.set("inputMode","text");const t=this.bindTemplate;this.extendTemplate({attributes:{inputmode:t.to("inputMode")}})}}class ls extends cs{constructor(e){super(e),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}var ds=i(1978),us={attributes:{"data-cke":!0}};us.setAttributes=Un(),us.insert=zn().bind(null,"head"),us.domAPI=Fn(),us.insertStyleElement=$n();Ln()(ds.A,us);ds.A&&ds.A.locals&&ds.A.locals;class hs extends Kn{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-dropdown__panel",t.to("position",(e=>`ck-dropdown__panel_${e}`)),t.if("isVisible","ck-dropdown__panel-visible")],tabindex:"-1"},children:this.children,on:{selectstart:t.to((e=>{"input"!==e.target.tagName.toLocaleLowerCase()&&e.preventDefault()}))}})}focus(){if(this.children.length){const e=this.children.first;"function"==typeof e.focus?e.focus():y("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()}}}var ms=i(8500),gs={attributes:{"data-cke":!0}};gs.setAttributes=Un(),gs.insert=zn().bind(null,"head"),gs.domAPI=Fn(),gs.insertStyleElement=$n();Ln()(ms.A,gs);ms.A&&ms.A.locals&&ms.A.locals;class ps extends Kn{constructor(e,t,i){super(e);const r=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 Tn,this.focusTracker=new Sn,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",r.to("class"),r.if("isEnabled","ck-disabled",(e=>!e))],id:r.to("id"),"aria-describedby":r.to("ariaDescribedById")},children:[t,i]}),t.extendTemplate({attributes:{class:["ck-dropdown__button"],"data-cke-tooltip-disabled":r.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=ps._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions});this.panelView.position=e?e.name:this._panelPositions[0].name}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:r,northEast:n,northWest:o,southMiddleEast:s,southMiddleWest:a,northMiddleEast:c,northMiddleWest:l}=ps.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[i,r,s,a,e,n,o,c,l,t]:[r,i,a,s,e,o,n,l,c,t]}}ps.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"})},ps._getOptimalPosition=Qr;const fs='';class bs extends Ao{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 vo;return e.content=fs,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}}class ws extends(M()){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 r of i)e.keystrokeHandler.set(r,((e,i)=>{this[t](),i()}))}this.on("forwardCycle",(()=>this.focusFirst()),{priority:"low"}),this.on("backwardCycle",(()=>this.focusLast()),{priority:"low"})}get first(){return this.focusables.find(ks)||null}get last(){return this.focusables.filter(ks).slice(-1)[0]||null}get next(){return this._getFocusableItem(1)}get previous(){return this._getFocusableItem(-1)}get current(){let e=null;return null===this.focusTracker.focusedElement?null:(this.focusables.find(((t,i)=>{const r=t.element===this.focusTracker.focusedElement;return r&&(e=i),r})),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))}_focus(e,t){e&&e.focus(t)}_getFocusableItem(e){const t=this.current,i=this.focusables.length;if(!i)return null;if(null===t)return this[1===e?"first":"last"];let r=(t+i+e)%i;do{const t=this.focusables.get(r);if(ks(t))return t;r=(r+i+e)%i}while(r!==t);return null}}function ks(e){return!(!("focus"in e)||!Zr(e.element))}class vs extends Kn{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}class _s extends Kn{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}function ys(e){if(Array.isArray(e))return{items:e,removeItems:[]};const t={items:[],removeItems:[]};return e?{...t,...e}:t}class xs extends(q()){constructor(e){super(),this._disableStack=new Set,this.editor=e,this.set("isEnabled",!0)}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",As,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",As),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}}function As(e){e.return=!1,e.stop()}class Cs extends(q()){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,r=!("$graveyard"==i.getFirstPosition().root.rootName)&&e.model.canEditAt(i);(e.isReadOnly||this._isEnabledBasedOnSelection&&!r)&&(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",Es,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",Es),this.refresh())}execute(...e){}destroy(){this.stopListening()}}function Es(e){e.return=!1,e.stop()}class Ss extends Cs{constructor(){super(...arguments),this._childCommandsDefinitions=[]}refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){v(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 Ts extends(M()){constructor(e,t=[],i=[]){super(),this._plugins=new Map,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 _("plugincollection-plugin-not-loaded",this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}init(e,t=[],i=[]){const r=this,n=this._context;!function e(t,i=new Set){t.forEach((t=>{a(t)&&(i.has(t)||(i.add(t),t.pluginName&&!r._availablePlugins.has(t.pluginName)&&r._availablePlugins.set(t.pluginName,t),t.requires&&e(t.requires,i)))}))}(e),u(e);const o=[...function e(t,i=new Set){return t.map((e=>a(e)?e:r._availablePlugins.get(e))).reduce(((t,r)=>i.has(r)?t:(i.add(r),r.requires&&(u(r.requires,r),e(r.requires,i).forEach((e=>t.add(e)))),t.add(r))),new Set)}(e.filter((e=>!l(e,t))))];!function(e,t){for(const i of t){if("function"!=typeof i)throw new _("plugincollection-replace-plugin-invalid-type",null,{pluginItem:i});const t=i.pluginName;if(!t)throw new _("plugincollection-replace-plugin-missing-name",null,{pluginItem:i});if(i.requires&&i.requires.length)throw new _("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const n=r._availablePlugins.get(t);if(!n)throw new _("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:t});const o=e.indexOf(n);if(-1===o){if(r._contextPlugins.has(n))return;throw new _("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:t})}if(n.requires&&n.requires.length)throw new _("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:t});e.splice(o,1,i),r._availablePlugins.set(t,i)}}(o,i);const s=function(e){return e.map((e=>{let t=r._contextPlugins.get(e);return t=t||new e(n),r._add(e,t),t}))}(o);return h(s,"init").then((()=>h(s,"afterInit"))).then((()=>s));function a(e){return"function"==typeof e}function c(e){return a(e)&&!!e.isContextPlugin}function l(e,t){return t.some((t=>t===e||(d(e)===t||d(t)===e)))}function d(e){return a(e)?e.pluginName||e.name:e}function u(e,i=null){e.map((e=>a(e)?e:r._availablePlugins.get(e)||e)).forEach((e=>{!function(e,t){if(a(e))return;if(t)throw new _("plugincollection-soft-required",n,{missingPlugin:e,requiredBy:d(t)});throw new _("plugincollection-plugin-not-found",n,{plugin:e})}(e,i),function(e,t){if(!c(t))return;if(c(e))return;throw new _("plugincollection-context-required",n,{plugin:d(e),requiredBy:d(t)})}(e,i),function(e,i){if(!i)return;if(!l(e,t))return;throw new _("plugincollection-required",n,{plugin:d(e),requiredBy:d(i)})}(e,i)}))}function h(e,t){return e.reduce(((e,i)=>i[t]?r._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 _("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}}class Ps{constructor(e){this._contextOwner=null,this.config=new xr(e,this.constructor.defaultConfig);const t=this.constructor.builtinPlugins;this.config.define("plugins",t),this.plugins=new Ts(this,t);const i=this.config.get("language")||{};this.locale=new An({uiLanguage:"string"==typeof i?i:i.ui,contentLanguage:this.config.get("language.content")}),this.t=this.locale.t,this.editors=new Cn}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 _("context-initplugins-constructor-only",null,{Plugin:i});if(!0!==i.isContextPlugin)throw new _("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 _("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)))}))}}class Is extends(q()){constructor(e){super(),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}var Ms=i(8045),Os={attributes:{"data-cke":!0}};Os.setAttributes=Un(),Os.insert=zn().bind(null,"head"),Os.domAPI=Fn(),Os.insertStyleElement=$n();Ln()(Ms.A,Os);Ms.A&&Ms.A.locals&&Ms.A.locals;const Ns=new WeakMap;let Vs=!1;function Bs({view:e,element:t,text:i,isDirectHost:r=!0,keepOnFocus:n=!1}){const o=e.document;function s(i){Ns.get(o).set(t,{text:i,isDirectHost:r,keepOnFocus:n,hostElement:r?t:null}),e.change((e=>Ls(o,e)))}Ns.has(o)||(Ns.set(o,new Map),o.registerPostFixer((e=>Ls(o,e))),o.on("change:isComposing",(()=>{e.change((e=>Ls(o,e)))}),{priority:"high"})),t.is("editableElement")&&t.on("change:placeholder",((e,t,i)=>{s(i)})),t.placeholder?s(t.placeholder):i&&s(i),i&&function(){Vs||y("enableplaceholder-deprecated-text-option");Vs=!0}()}function Rs(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function Ls(e,t){const i=Ns.get(e),r=[];let n=!1;for(const[e,o]of i)o.isDirectHost&&(r.push(e),Ds(t,e,o)&&(n=!0));for(const[e,o]of i){if(o.isDirectHost)continue;const i=Fs(e);i&&(r.includes(i)||(o.hostElement=i,Ds(t,e,o)&&(n=!0)))}return n}function Ds(e,t,i){const{text:r,isDirectHost:n,hostElement:o}=i;let s=!1;o.getAttribute("data-placeholder")!==r&&(e.setAttribute("data-placeholder",r,o),s=!0);return(n||1==t.childCount)&&function(e,t){if(!e.isAttached())return!1;const i=Array.from(e.getChildren()).some((e=>!e.is("uiElement")));if(i)return!1;const r=e.document,n=r.selection.anchor;return!(r.isComposing&&n&&n.parent===e||!t&&r.isFocused&&(!n||n.parent===e))}(o,i.keepOnFocus)?function(e,t){return!t.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",t),!0)}(e,o)&&(s=!0):Rs(e,o)&&(s=!0),s}function Fs(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}class js{is(){throw new Error("is() method is abstract")}}const zs=function(e){return vr(e,4)};class Hs extends(M(js)){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 _("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),r=e.getAncestors(t);let n=0;for(;i[n]==r[n]&&i[n];)n++;return 0===n?null:i[n-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),r=ee(t,i);switch(r){case"prefix":return!0;case"extension":return!1;default:return t[r]e.data.length)throw new _("view-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.data.length)throw new _("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}}Ws.prototype.is=function(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e};class $s{constructor(...e){this._patterns=[],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=qs(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 r=qs(i,e);r&&t.push({element:i,pattern:e,match:r})}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}}function qs(e,t){if("function"==typeof t)return t(e);const i={};return t.name&&(i.name=function(e,t){if(e instanceof RegExp)return!!t.match(e);return e===t}(t.name,e.name),!i.name)||t.attributes&&(i.attributes=function(e,t){const i=new Set(t.getAttributeKeys());Ee(e)?(void 0!==e.style&&y("matcher-pattern-deprecated-attributes-style-key",e),void 0!==e.class&&y("matcher-pattern-deprecated-attributes-class-key",e)):(i.delete("style"),i.delete("class"));return Gs(e,i,(e=>t.getAttribute(e)))}(t.attributes,e),!i.attributes)||t.classes&&(i.classes=function(e,t){return Gs(e,t.getClassNames(),(()=>{}))}(t.classes,e),!i.classes)||t.styles&&(i.styles=function(e,t){return Gs(e,t.getStyleNames(!0),(e=>t.getStyle(e)))}(t.styles,e),!i.styles)?null:i}function Gs(e,t,i){const r=function(e){if(Array.isArray(e))return e.map((e=>Ee(e)?(void 0!==e.key&&void 0!==e.value||y("matcher-pattern-missing-key-or-value",e),[e.key,e.value]):[e,!0]));if(Ee(e))return Object.entries(e);return[[e,!0]]}(e),n=Array.from(t),o=[];if(r.forEach((([e,t])=>{n.forEach((r=>{(function(e,t){return!0===e||e===t||e instanceof RegExp&&t.match(e)})(e,r)&&function(e,t,i){if(!0===e)return!0;const r=i(t);return e===r||e instanceof RegExp&&!!String(r).match(e)}(t,r,i)&&o.push(r)}))})),r.length&&!(o.lengthn?0:n+t),(i=i>n?n:i)<0&&(i+=n),n=t>i?0:i-t>>>0,t>>>=0;for(var o=Array(n);++r0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}};const Na=Oa(Ia);const Va=function(e,t){return Na(Ta(e,t,Ca),e+"")};const Ba=function(e,t,i){if(!F(i))return!1;var r=typeof t;return!!("number"==r?ai(i)&&Ut(t,i.length):"string"==r&&t in i)&&Te(i[t],e)};const Ra=function(e){return Va((function(t,i){var r=-1,n=i.length,o=n>1?i[n-1]:void 0,s=n>2?i[2]:void 0;for(o=e.length>3&&"function"==typeof o?(n--,o):void 0,s&&Ba(i[0],i[1],s)&&(o=n<3?void 0:o,n=1),t=Object(t);++rt===e));return Array.isArray(t)}set(e,t){if(F(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=Ha(e);fa(this._styles,t),delete this._styles[e],this._cleanEmptyObjectsOnPath(t)}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]&&!F(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){if(this.isEmpty)return[];if(e)return this._styleProcessor.getStyleNames(this._styles);return this._getStylesEntries().map((([e])=>e))}clear(){this._styles={}}_getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const i of t)e.push(...this._styleProcessor.getReducedForm(i,this._styles));return e}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const i=t.splice(0,t.length-1).join("."),r=ba(this._styles,i);if(!r)return;!Object.keys(r).length&&this.remove(i)}}class za{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,i){if(F(t))Ua(i,Ha(e),t);else if(this._normalizers.has(e)){const r=this._normalizers.get(e),{path:n,value:o}=r(t);Ua(i,n,o)}else Ua(i,e,t)}getNormalized(e,t){if(!e)return La({},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 ba(t,i);const r=i(e,t);if(r)return r}return ba(t,Ha(e))}getReducedForm(e,t){const i=this.getNormalized(e,t);if(void 0===i)return[];if(this._reducers.has(e)){return this._reducers.get(e)(i)}return[[e,i]]}getStyleNames(e){const t=Array.from(this._consumables.keys()).filter((t=>{const i=this.getNormalized(t,e);return i&&"object"==typeof i?Object.keys(i).length:i})),i=new Set([...t,...Object.keys(e)]);return Array.from(i)}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 Ha(e){return e.replace("-",".")}function Ua(e,t,i){let r=i;F(i)&&(r=La({},ba(e,t),i)),Fa(e,t,r)}class Wa extends Hs{constructor(e,t,i,r){if(super(e),this._unsafeAttributesToRender=[],this._customProperties=new Map,this.name=t,this._attrs=function(e){const t=Pn(e);for(const[e,i]of t)null===i?t.delete(e):"string"!=typeof i&&t.set(e,String(i));return t}(i),this._children=[],r&&this._insertChild(0,r),this._classes=new Set,this._attrs.has("class")){const e=this._attrs.get("class");$a(this._classes,e),this._attrs.delete("class")}this._styles=new ja(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style"))}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.size>0&&(yield"class"),this._styles.isEmpty||(yield"style"),yield*this._attrs.keys()}*getAttributes(){yield*this._attrs.entries(),this._classes.size>0&&(yield["class",this.getAttribute("class")]),this._styles.isEmpty||(yield["style",this.getAttribute("style")])}getAttribute(e){if("class"==e)return this._classes.size>0?[...this._classes].join(" "):void 0;if("style"==e){const e=this._styles.toString();return""==e?void 0:e}return this._attrs.get(e)}hasAttribute(e){return"class"==e?this._classes.size>0:"style"==e?!this._styles.isEmpty:this._attrs.has(e)}isSimilar(e){if(!(e instanceof Wa))return!1;if(this===e)return!0;if(this.name!=e.name)return!1;if(this._attrs.size!==e._attrs.size||this._classes.size!==e._classes.size||this._styles.size!==e._styles.size)return!1;for(const[t,i]of this._attrs)if(!e._attrs.has(t)||e._attrs.get(t)!==i)return!1;for(const t of this._classes)if(!e._classes.has(t))return!1;for(const t of this._styles.getStyleNames())if(!e._styles.has(t)||e._styles.getAsString(t)!==this._styles.getAsString(t))return!1;return!0}hasClass(...e){for(const t of e)if(!this._classes.has(t))return!1;return!0}getClassNames(){return this._classes.keys()}getStyle(e){return this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles.getNormalized(e)}getStyleNames(e){return this._styles.getStyleNames(e)}hasStyle(...e){for(const t of e)if(!this._styles.has(t))return!1;return!0}findAncestor(...e){const t=new $s(...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=Array.from(this._classes).sort().join(","),t=this._styles.toString(),i=Array.from(this._attrs).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)}_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._classes=new Set(this._classes),i._styles.set(this._styles.getNormalized()),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);let i=0;const r=function(e,t){if("string"==typeof t)return[new Us(e,t)];te(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new Us(e,t):t instanceof Ws?new Us(e,t.data):t))}(this.document,t);for(const t of r)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);for(let i=e;i0&&(this._classes.clear(),!0):"style"==e?!this._styles.isEmpty&&(this._styles.clear(),!0):this._attrs.delete(e)}_addClass(e){this._fireChange("attributes",this);for(const t of yn(e))this._classes.add(t)}_removeClass(e){this._fireChange("attributes",this);for(const t of yn(e))this._classes.delete(t)}_setStyle(e,t){this._fireChange("attributes",this),"string"!=typeof e?this._styles.set(e):this._styles.set(e,t)}_removeStyle(e){this._fireChange("attributes",this);for(const t of yn(e))this._styles.remove(t)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}}function $a(e,t){const i=t.split(/\s+/);e.clear(),i.forEach((t=>e.add(t)))}Wa.prototype.is=function(e,t){return t?t===this.name&&("element"===e||"view:element"===e):"element"===e||"view:element"===e||"node"===e||"view:node"===e};class qa extends Wa{constructor(e,t,i,r){super(e,t,i,r),this.getFillerOffset=Ga}}function Ga(){const e=[...this.getChildren()],t=e[this.childCount-1];if(t&&t.is("element","br"))return this.childCount;for(const t of e)if(!t.is("uiElement"))return null;return this.childCount}qa.prototype.is=function(e,t){return t?t===this.name&&("containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class Ka extends(q(qa)){constructor(e,t,i,r){super(e,t,i,r),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("placeholder",void 0),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",(t=>t&&e.selection.editableElement==this)),this.listenTo(e.selection,"change",(()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this}))}destroy(){this.stopListening()}}Ka.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 Ya=Symbol("rootName");class Ja extends Ka{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(Ya)}set rootName(e){this._setCustomProperty(Ya,e)}set _name(e){this.name=e}}Ja.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 Za{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new _("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new _("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=Qa._createAt(e.startPosition):this._position=Qa._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)}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 r;if(i instanceof Us){if(e.isAtEnd)return this._position=Qa._createAfter(i),this._next();r=i.data[e.offset]}else r=i.getChild(e.offset);if(r instanceof Wa){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}else e=new Qa(r,0);return this._position=e,this._formatReturnValue("elementStart",r,t,e,1)}if(r instanceof Us){if(this.singleCharacters)return e=new Qa(r,0),this._position=e,this._next();let i,n=r.data.length;return r==this._boundaryEndParent?(n=this.boundaries.end.offset,i=new Ws(r,0,n),e=Qa._createAfter(i)):(i=new Ws(r,0,r.data.length),e.offset++),this._position=e,this._formatReturnValue("text",i,t,e,n)}if("string"==typeof r){let r;if(this.singleCharacters)r=1;else{r=(i===this._boundaryEndParent?this.boundaries.end.offset:i.data.length)-e.offset}const n=new Ws(i,e.offset,r);return e.offset+=r,this._position=e,this._formatReturnValue("text",n,t,e,r)}return e=Qa._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 r;if(i instanceof Us){if(e.isAtStart)return this._position=Qa._createBefore(i),this._previous();r=i.data[e.offset-1]}else r=i.getChild(e.offset-1);if(r instanceof Wa)return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",r,t,e,1)):(e=new Qa(r,r.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",r,t,e));if(r instanceof Us){if(this.singleCharacters)return e=new Qa(r,r.data.length),this._position=e,this._previous();let i,n=r.data.length;if(r==this._boundaryStartParent){const t=this.boundaries.start.offset;i=new Ws(r,t,r.data.length-t),n=i.data.length,e=Qa._createBefore(i)}else i=new Ws(r,0,r.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",i,t,e,n)}if("string"==typeof r){let r;if(this.singleCharacters)r=1;else{const t=i===this._boundaryStartParent?this.boundaries.start.offset:0;r=e.offset-t}e.offset-=r;const n=new Ws(i,e.offset,r);return this._position=e,this._formatReturnValue("text",n,t,e,r)}return e=Qa._createBefore(i),this._position=e,this._formatReturnValue("elementStart",i,t,e,1)}_formatReturnValue(e,t,i,r,n){return t instanceof Ws&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?i=Qa._createAfter(t.textNode):(r=Qa._createAfter(t.textNode),this._position=r)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?i=Qa._createBefore(t.textNode):(r=Qa._createBefore(t.textNode),this._position=r))),{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:r,length:n}}}}class Qa extends js{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 Ka);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(e){const t=Qa._createAt(this),i=t.offset+e;return t.offset=i<0?0:i,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new Za(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 r=0;for(;t[r]==i[r]&&t[r];)r++;return 0===r?null:t[r-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 r=ee(t,i);switch(r){case"prefix":return"before";case"extension":return"after";default:return t[r]0?new this(i,r):new this(r,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(Qa._createBefore(e),t)}}function ec(e){return!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))}Xa.prototype.is=function(e){return"range"===e||"view:range"===e};class tc extends(M(js)){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 r of e._ranges)if(t.isEqual(r)){i=!0;break}if(!i)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=X(this.getRanges());if(t!=X(e.getRanges()))return!1;if(0==t)return!0;for(let t of this.getRanges()){t=t.getTrimmed();let i=!1;for(let r of e.getRanges())if(r=r.getTrimmed(),t.start.isEqual(r.start)&&t.end.isEqual(r.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,i,r]=e;if("object"==typeof i&&(r=i,i=void 0),null===t)this._setRanges([]),this._setFakeOptions(r);else if(t instanceof tc||t instanceof ic)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof Xa)this._setRanges([t],r&&r.backward),this._setFakeOptions(r);else if(t instanceof Qa)this._setRanges([new Xa(t)]),this._setFakeOptions(r);else if(t instanceof Hs){const e=!!r&&!!r.backward;let n;if(void 0===i)throw new _("view-selection-setto-required-second-parameter",this);n="in"==i?Xa._createIn(t):"on"==i?Xa._createOn(t):new Xa(Qa._createAt(t,i)),this._setRanges([n],e),this._setFakeOptions(r)}else{if(!te(t))throw new _("view-selection-setto-not-selectable",this);this._setRanges(t,r&&r.backward),this._setFakeOptions(r)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new _("view-selection-setfocus-no-ranges",this);const i=Qa._createAt(e,t);if("same"==i.compareWith(this.focus))return;const r=this.anchor;this._ranges.pop(),"before"==i.compareWith(r)?this._addRange(new Xa(i,r),!0):this._addRange(new Xa(r,i)),this.fire("change")}_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 Xa))throw new _("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 _("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new Xa(e.start,e.end))}}tc.prototype.is=function(e){return"selection"===e||"view:selection"===e};class ic extends(M(js)){constructor(...e){super(),this._selection=new tc,this._selection.delegate("change").to(this),e.length&&this._selection.setTo(...e)}get isFake(){return this._selection.isFake}get fakeSelectionLabel(){return this._selection.fakeSelectionLabel}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get isCollapsed(){return this._selection.isCollapsed}get rangeCount(){return this._selection.rangeCount}get isBackward(){return this._selection.isBackward}get editableElement(){return this._selection.editableElement}get _ranges(){return this._selection._ranges}*getRanges(){yield*this._selection.getRanges()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getSelectedElement(){return this._selection.getSelectedElement()}isEqual(e){return this._selection.isEqual(e)}isSimilar(e){return this._selection.isSimilar(e)}_setTo(...e){this._selection.setTo(...e)}_setFocus(e,t){this._selection.setFocus(e,t)}}ic.prototype.is=function(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e};class rc extends f{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 nc=Symbol("bubbling contexts");function oc(e){return class extends e{fire(e,...t){try{const i=e instanceof f?e:new f(this,e),r=lc(this);if(!r.size)return;if(sc(i,"capturing",this),ac(r,"$capture",i,...t))return i.return;const n=i.startRange||this.selection.getFirstRange(),o=n?n.getContainedElement():null,s=!!o&&Boolean(cc(r,o));let a=o||function(e){if(!e)return null;const t=e.start.parent,i=e.end.parent,r=t.getPath(),n=i.getPath();return r.length>n.length?t:i}(n);if(sc(i,"atTarget",a),!s){if(ac(r,"$text",i,...t))return i.return;sc(i,"bubbling",a)}for(;a;){if(a.is("rootElement")){if(ac(r,"$root",i,...t))return i.return}else if(a.is("element")&&ac(r,a.name,i,...t))return i.return;if(ac(r,a,i,...t))return i.return;a=a.parent,sc(i,"bubbling",a)}return sc(i,"bubbling",this),ac(r,"$document",i,...t),i.return}catch(e){_.rethrowUnexpectedError(e,this)}}_addEventListener(e,t,i){const r=yn(i.context||"$document"),n=lc(this);for(const o of r){let r=n.get(o);r||(r=new(M()),n.set(o,r)),this.listenTo(r,e,t,i)}}_removeEventListener(e,t){const i=lc(this);for(const r of i.values())this.stopListening(r,e,t)}}}{const e=oc(Object);["fire","_addEventListener","_removeEventListener"].forEach((t=>{oc[t]=e.prototype[t]}))}function sc(e,t,i){e instanceof rc&&(e._eventPhase=t,e._currentTarget=i)}function ac(e,t,i,...r){const n="string"==typeof t?e.get(t):cc(e,t);return!!n&&(n.fire(i,...r),i.stop.called)}function cc(e,t){for(const[i,r]of e)if("function"==typeof i&&i(t))return r;return null}function lc(e){return e[nc]||(e[nc]=new Map),e[nc]}class dc extends(oc(q())){constructor(e){super(),this._postFixers=new Set,this.selection=new ic,this.roots=new Cn({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 uc extends Wa{constructor(e,t,i,r){super(e,t,i,r),this._priority=10,this._id=null,this._clonesGroup=null,this.getFillerOffset=hc}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new _("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}_clone(e=!1){const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}}function hc(){if(mc(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(mc(e)>1)return null;e=e.parent}return!e||mc(e)>1?null:this.childCount}function mc(e){return Array.from(e.getChildren()).filter((e=>!e.is("uiElement"))).length}uc.DEFAULT_PRIORITY=10,uc.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 gc extends Wa{constructor(e,t,i,r){super(e,t,i,r),this.getFillerOffset=pc}_insertChild(e,t){if(t&&(t instanceof Hs||Array.from(t).length>0))throw new _("view-emptyelement-cannot-add",[this,t]);return 0}}function pc(){return null}gc.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 fc extends Wa{constructor(e,t,i,r){super(e,t,i,r),this.getFillerOffset=wc}_insertChild(e,t){if(t&&(t instanceof Hs||Array.from(t).length>0))throw new _("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}}function bc(e){e.document.on("arrowKey",((t,i)=>function(e,t,i){if(t.keyCode==gn.arrowright){const e=t.domTarget.ownerDocument.defaultView.getSelection(),r=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(r||t.shiftKey){const t=e.focusNode,n=e.focusOffset,o=i.domPositionToView(t,n);if(null===o)return;let s=!1;const a=o.getLastMatchingPosition((e=>(e.item.is("uiElement")&&(s=!0),!(!e.item.is("uiElement")&&!e.item.is("attributeElement")))));if(s){const t=i.viewPositionToDom(a);r?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}}(0,i,e.domConverter)),{priority:"low"})}function wc(){return null}fc.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 kc extends Wa{constructor(e,t,i,r){super(e,t,i,r),this.getFillerOffset=vc}_insertChild(e,t){if(t&&(t instanceof Hs||Array.from(t).length>0))throw new _("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}function vc(){return null}kc.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 _c extends(M(js)){constructor(e,t){super(),this._children=[],this._customProperties=new Map,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()}_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);let i=0;const r=function(e,t){if("string"==typeof t)return[new Us(e,t)];te(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new Us(e,t):t instanceof Ws?new Us(e,t.data):t))}(this.document,t);for(const t of r)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);for(let i=e;i{const i=e[e.length-1],r=!t.is("uiElement");return i&&i.breakAttributes==r?i.nodes.push(t):e.push({breakAttributes:r,nodes:[t]}),e}),[]);let r=null,n=e;for(const{nodes:e,breakAttributes:t}of i){const i=this._insertNodes(n,e,t);r||(r=i.start),n=i.end}return r?new Xa(r,n):new Xa(e)}remove(e){const t=e instanceof Xa?e:Xa._createOn(e);if(Mc(t,this.document),t.isCollapsed)return new _c(this.document);const{start:i,end:r}=this._breakAttributesRange(t,!0),n=i.parent,o=r.offset-i.offset,s=n._removeChildren(i.offset,o);for(const e of s)this._removeFromClonedElementsGroup(e);const a=this.mergeAttributes(i);return t.start=a,t.end=a.clone(),new _c(this.document,s)}clear(e,t){Mc(e,this.document);const i=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const r of i){const i=r.item;let n;if(i.is("element")&&t.isSimilar(i))n=Xa._createOn(i);else if(!r.nextPosition.isAfter(e.start)&&i.is("$textProxy")){const e=i.getAncestors().find((e=>e.is("element")&&t.isSimilar(e)));e&&(n=Xa._createIn(e))}n&&(n.end.isAfter(e.end)&&(n.end=e.end),n.start.isBefore(e.start)&&(n.start=e.start),this.remove(n))}}move(e,t){let i;if(t.isAfter(e.end)){const r=(t=this._breakAttributes(t,!0)).parent,n=r.childCount;e=this._breakAttributesRange(e,!0),i=this.remove(e),t.offset+=r.childCount-n}else i=this.remove(e);return this.insert(t,i)}wrap(e,t){if(!(t instanceof uc))throw new _("view-writer-wrap-invalid-attribute",this.document);if(Mc(e,this.document),e.isCollapsed){let r=e.start;r.parent.is("element")&&(i=r.parent,!Array.from(i.getChildren()).some((e=>!e.is("uiElement"))))&&(r=r.getLastMatchingPosition((e=>e.item.is("uiElement")))),r=this._wrapPosition(r,t);const n=this.document.selection;return n.isCollapsed&&n.getFirstPosition().isEqual(e.start)&&this.setSelection(r),new Xa(r)}return this._wrapRange(e,t);var i}unwrap(e,t){if(!(t instanceof uc))throw new _("view-writer-unwrap-invalid-attribute",this.document);if(Mc(e,this.document),e.isCollapsed)return e;const{start:i,end:r}=this._breakAttributesRange(e,!0),n=i.parent,o=this._unwrapChildren(n,i.offset,r.offset,t),s=this.mergeAttributes(o.start);s.isEqual(o.start)||o.end.offset--;const a=this.mergeAttributes(o.end);return new Xa(s,a)}rename(e,t){const i=new qa(this.document,e,t.getAttributes());return this.insert(Qa._createAfter(t),i),this.move(Xa._createIn(t),Qa._createAt(i,0)),this.remove(Xa._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return Qa._createAt(e,t)}createPositionAfter(e){return Qa._createAfter(e)}createPositionBefore(e){return Qa._createBefore(e)}createRange(e,t){return new Xa(e,t)}createRangeOn(e){return Xa._createOn(e)}createRangeIn(e){return Xa._createIn(e)}createSelection(...e){return new tc(...e)}createSlot(e="children"){if(!this._slotFactory)throw new _("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 r,n;if(r=i?xc(e):e.parent.is("$text")?e.parent.parent:e.parent,!r)throw new _("view-writer-invalid-position-container",this.document);n=i?this._breakAttributes(e,!0):e.parent.is("$text")?Ec(e):e;const o=r._insertChild(n.offset,t);for(const e of t)this._addToClonedElementsGroup(e);const s=n.getShiftedBy(o),a=this.mergeAttributes(n);a.isEqual(n)||s.offset--;const c=this.mergeAttributes(s);return new Xa(a,c)}_wrapChildren(e,t,i,r){let n=t;const o=[];for(;n!1,e.parent._insertChild(e.offset,i);const r=new Xa(e,e.getShiftedBy(1));this.wrap(r,t);const n=new Qa(i.parent,i.index);i._remove();const o=n.nodeBefore,s=n.nodeAfter;return o instanceof Us&&s instanceof Us?Sc(o,s):Cc(n)}_wrapAttributeElement(e,t){if(!Oc(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&t.hasAttribute(i)&&t.getAttribute(i)!==e.getAttribute(i))return!1;for(const i of e.getStyleNames())if(t.hasStyle(i)&&t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&(t.hasAttribute(i)||this.setAttribute(i,e.getAttribute(i),t));for(const i of e.getStyleNames())t.hasStyle(i)||this.setStyle(i,e.getStyle(i),t);for(const i of e.getClassNames())t.hasClass(i)||this.addClass(i,t);return!0}_unwrapAttributeElement(e,t){if(!Oc(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&(!t.hasAttribute(i)||t.getAttribute(i)!==e.getAttribute(i)))return!1;if(!t.hasClass(...e.getClassNames()))return!1;for(const i of e.getStyleNames())if(!t.hasStyle(i)||t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&this.removeAttribute(i,t);return this.removeClass(Array.from(e.getClassNames()),t),this.removeStyle(Array.from(e.getStyleNames()),t),!0}_breakAttributesRange(e,t=!1){const i=e.start,r=e.end;if(Mc(e,this.document),e.isCollapsed){const i=this._breakAttributes(e.start,t);return new Xa(i,i)}const n=this._breakAttributes(r,t),o=n.parent.childCount,s=this._breakAttributes(i,t);return n.offset+=n.parent.childCount-o,new Xa(s,n)}_breakAttributes(e,t=!1){const i=e.offset,r=e.parent;if(e.parent.is("emptyElement"))throw new _("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new _("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new _("view-writer-cannot-break-raw-element",this.document);if(!t&&r.is("$text")&&Ic(r.parent))return e.clone();if(Ic(r))return e.clone();if(r.is("$text"))return this._breakAttributes(Ec(e),t);if(i==r.childCount){const e=new Qa(r.parent,r.index+1);return this._breakAttributes(e,t)}if(0===i){const e=new Qa(r.parent,r.index);return this._breakAttributes(e,t)}{const e=r.index+1,n=r._clone();r.parent._insertChild(e,n),this._addToClonedElementsGroup(n);const o=r.childCount-i,s=r._removeChildren(i,o);n._appendChild(s);const a=new Qa(r.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 xc(e){let t=e.parent;for(;!Ic(t);){if(!t)return;t=t.parent}return t}function Ac(e,t){return e.priorityt.priority)&&e.getIdentity()i instanceof e)))throw new _("view-writer-insert-invalid-node-type",t);i.is("$text")||Pc(i.getChildren(),t)}}function Ic(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function Mc(e,t){const i=xc(e.start),r=xc(e.end);if(!i||!r||i!==r)throw new _("view-writer-invalid-range-container",t)}function Oc(e,t){return null===e.id&&null===t.id}const Nc=e=>e.createTextNode(" "),Vc=e=>{const t=e.createElement("span");return t.dataset.ckeFiller="true",t.innerText=" ",t},Bc=e=>{const t=e.createElement("br");return t.dataset.ckeFiller="true",t},Rc="⁠".repeat(7);function Lc(e){return"string"==typeof e?e.substr(0,7)===Rc:Br(e)&&e.data.substr(0,7)===Rc}function Dc(e){return 7==e.data.length&&Lc(e)}function Fc(e){const t="string"==typeof e?e:e.data;return Lc(e)?t.slice(7):t}function jc(e,t){if(t.keyCode==gn.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;Lc(t)&&i<=7&&e.collapse(t,0)}}}var zc=i(5793),Hc={attributes:{"data-cke":!0}};Hc.setAttributes=Un(),Hc.insert=zn().bind(null,"head"),Hc.domAPI=Fn(),Hc.insertStyleElement=$n();Ln()(zc.A,Hc);zc.A&&zc.A.locals&&zc.A.locals;class Uc extends(q()){constructor(e,t){super(),this.domDocuments=new Set,this.markedAttributes=new Set,this.markedChildren=new Set,this.markedTexts=new Set,this._inlineFiller=null,this._fakeSelectionContainer=null,this.domConverter=e,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),l.isBlink&&!l.isAndroid&&this.on("change:isSelecting",(()=>{this.isSelecting||this.render()})),this.set("isComposing",!1),this.on("change:isComposing",(()=>{this.isComposing||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 _("view-renderer-unknown-type",this)}this.markedChildren.add(t)}}}render(){if(this.isComposing&&!l.isAndroid)return;let e=null;const t=!(l.isBlink&&!l.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=Qa._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;Lc(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=Wc(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),r=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),n=this._diffNodeLists(i,r),o=this._findUpdateActions(n,i,r,$c);if(-1!==o.indexOf("update")){const t={equal:0,insert:0,delete:0};for(const n of o)if("update"===n){const n=t.equal+t.insert,o=t.equal+t.delete,s=e.getChild(n);!s||s.is("uiElement")||s.is("rawElement")||this._updateElementMappings(s,i[o]),tn(r[n]),t.equal++}else t[n]++}}_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")?Qa._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&&Br(t.parent)&&Lc(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!Lc(e))throw new _("view-renderer-filler-was-lost",this);Dc(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;if(i===t.getFillerOffset())return!1;const r=e.nodeBefore,n=e.nodeAfter;return!(r instanceof Us||n instanceof Us)&&(!l.isAndroid||!r&&!n)}_updateText(e,t){const i=this.domConverter.findCorrespondingDomText(e);let r=this.domConverter.viewToDom(e).data;const n=t.inlineFillerPosition;n&&n.parent==e.parent&&n.offset==e.index&&(r=Rc+r),Kc(i,r)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(t.attributes).map((e=>e.name)),r=e.getAttributeKeys();for(const i of r)this.domConverter.setDomElementAttribute(t,i,e.getAttribute(i),e);for(const r of i)e.hasAttribute(r)||this.domConverter.removeDomElementAttribute(t,r)}_updateChildren(e,t){const i=this.domConverter.mapViewToDom(e);if(!i)return;if(l.isAndroid){let e=null;for(const t of Array.from(i.childNodes)){if(e&&Br(e)&&Br(t)){i.normalize();break}e=t}}const r=t.inlineFillerPosition,n=i.childNodes,o=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));r&&r.parent===e&&Wc(i.ownerDocument,o,r.offset);const s=this._diffNodeLists(n,o),a=this._findUpdateActions(s,n,o,qc);let c=0;const d=new Set;for(const e of a)"delete"===e?(d.add(n[c]),tn(n[c])):"equal"!==e&&"update"!==e||c++;c=0;for(const e of a)"insert"===e?(Kr(i,c,o[c]),c++):"update"===e?(Kc(n[c],o[c].data),c++):"equal"===e&&(this._markDescendantTextToSync(this.domConverter.domToView(o[c])),c++);for(const e of d)e.parentNode||this.domConverter.unbindDomElement(e)}_diffNodeLists(e,t){return e=function(e,t){const i=Array.from(e);if(0==i.length||!t)return i;const r=i[i.length-1];r==t&&i.pop();return i}(e,this._fakeSelectionContainer),g(e,t,Gc.bind(null,this.domConverter))}_findUpdateActions(e,t,i,r){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let n=[],o=[],s=[];const a={equal:0,insert:0,delete:0};for(const c of e)"insert"===c?s.push(i[a.equal+a.insert]):"delete"===c?o.push(t[a.equal+a.delete]):(n=n.concat(g(o,s,r).map((e=>"equal"===e?"update":e))),n.push("equal"),o=[],s=[]),a[c]++;return n.concat(g(o,s,r).map((e=>"equal"===e?"update":e)))}_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(l.isBlink&&!l.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&&l.isAndroid||this._updateDomSelection(e))}_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 r=t.getSelection(),n=t.createRange();r.removeAllRanges(),n.selectNodeContents(i),r.addRange(n)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const i=this.domConverter.viewPositionToDom(this.selection.anchor),r=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(i.parent,i.offset,r.parent,r.offset),l.isGecko&&function(e,t){const i=e.parent;if(i.nodeType!=Node.ELEMENT_NODE||e.offset!=i.childNodes.length-1)return;const r=i.childNodes[e.offset];r&&"BR"==r.tagName&&t.addRange(t.getRangeAt(0))}(r,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return(!t||!this.selection.isEqual(t))&&!(!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,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,r=this.domConverter.mapDomToView(i);i&&r&&t.removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function Wc(e,t,i){const r=t instanceof Array?t:t.childNodes,n=r[i];if(Br(n))return n.data=Rc+n.data,n;{const n=e.createTextNode(Rc);return Array.isArray(t)?r.splice(i,0,n):Kr(t,i,n),n}}function $c(e,t){return Er(e)&&Er(t)&&!Br(e)&&!Br(t)&&!Yr(e)&&!Yr(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function qc(e,t){return Er(e)&&Er(t)&&Br(e)&&Br(t)}function Gc(e,t,i){return t===i||(Br(t)&&Br(i)?t.data===i.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(i)))}function Kc(e,t){const i=e.data;if(i==t)return;const r=u(i,t);for(const t of r)"insert"===t.type?e.insertData(t.index,t.values.join("")):e.deleteData(t.index,t.howMany)}const Yc=Bc(Nr.document),Jc=Nc(Nr.document),Zc=Vc(Nr.document),Qc="data-ck-unsafe-attribute-",Xc="data-ck-unsafe-element";class el{constructor(e,{blockFillerMode:t,renderingMode:i="editing"}={}){this._domToViewMapping=new WeakMap,this._viewToDomMapping=new WeakMap,this._fakeSelectionMapping=new WeakMap,this._rawContentElementMatcher=new $s,this._inlineObjectElementMatcher=new $s,this._elementsWithTemporaryCustomProperties=new Set,this.document=e,this.renderingMode=i,this.blockFillerMode=t||("editing"===i?"br":"nbsp"),this.preElements=["pre"],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?Nr.document:Nr.document.implementation.createHTMLDocument("")}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new tc(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 Array.from(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"),r=i.createDocumentFragment(),n=i.body.childNodes;for(;n.length>0;)r.appendChild(n[0]);const o=i.createTreeWalker(r,NodeFilter.SHOW_ELEMENT),s=[];let a;for(;a=o.nextNode();)s.push(a);for(const e of s){for(const t of e.getAttributeNames())this.setDomElementAttribute(e,t,e.getAttribute(t));const t=e.tagName.toLowerCase();this._shouldRenameElement(t)&&(nl(t),e.replaceWith(this._createReplacementDomElement(t,e)))}for(;e.firstChild;)e.firstChild.remove();e.append(r)}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 r;if(i.is("documentFragment"))r=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(r,i);else{if(i.is("uiElement"))return r="$comment"===i.name?this._domDocument.createComment(i.getCustomProperty("$rawContent")):i.render(this._domDocument,this),t.bind&&this.bindElements(r,i),r;this._shouldRenameElement(i.name)?(nl(i.name),r=this._createReplacementDomElement(i.name)):r=i.hasAttribute("xmlns")?this._domDocument.createElementNS(i.getAttribute("xmlns"),i.name):this._domDocument.createElement(i.name),i.is("rawElement")&&i.render(r,this),t.bind&&this.bindElements(r,i);for(const e of i.getAttributeKeys())this.setDomElementAttribute(r,e,i.getAttribute(e),i)}if(!1!==t.withChildren)for(const e of this.viewChildrenToDom(i,t))r.appendChild(e);return r}}setDomElementAttribute(e,t,i,r){const n=this.shouldRenderAttribute(t,i,e.tagName.toLowerCase())||r&&r.shouldRenderUnsafeAttribute(t);n||y("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:i}),Jr(t)?(e.hasAttribute(t)&&!n?e.removeAttribute(t):e.hasAttribute(Qc+t)&&n&&e.removeAttribute(Qc+t),e.setAttribute(n?t:Qc+t,i)):y("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:i})}removeDomElementAttribute(e,t){t!=Xc&&(e.removeAttribute(t),e.removeAttribute(Qc+t))}*viewChildrenToDom(e,t={}){const i=e.getFillerOffset&&e.getFillerOffset();let r=0;for(const n of e.getChildren()){i===r&&(yield this._getBlockFiller());const e=n.is("element")&&!!n.getCustomProperty("dataPipeline:transparentRendering")&&!En(n.getAttributes());e&&"data"==this.renderingMode?yield*this.viewChildrenToDom(n,t):(e&&y("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:n}),yield this.viewToDom(n,t)),r++}i===r&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),i=this.viewPositionToDom(e.end),r=this._domDocument.createRange();return r.setStart(t.parent,t.offset),r.setEnd(i.parent,i.offset),r}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const i=this.findCorrespondingDomText(t);if(!i)return null;let r=e.offset;return Lc(i)&&(r+=7),{parent:i,offset:r}}{let i,r,n;if(0===e.offset){if(i=this.mapViewToDom(t),!i)return null;n=i.childNodes[0]}else{const t=e.nodeBefore;if(r=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(t),!r)return null;i=r.parentNode,n=r.nextSibling}if(Br(n)&&Lc(n))return{parent:n,offset:7};return{parent:i,offset:r?Gr(r)+1:0}}}domToView(e,t={}){const i=[],r=this._domToView(e,t,i),n=r.next().value;return n?(r.next(),this._processDomInlineNodes(null,i,t),n.is("$text")&&0==n.data.length?null:n):null}*domChildrenToView(e,t={},i=[]){for(let r=0;r{const{scrollLeft:t,scrollTop:i}=e;r.push([t,i])})),t.focus(),il(t,(e=>{const[t,i]=r.shift();e.scrollLeft=t,e.scrollTop=i})),Nr.window.scrollTo(e,i)}}_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(Yc):!("BR"!==e.tagName||!rl(e,this.blockElements)||1!==e.parentNode.childNodes.length)||(e.isEqualNode(Zc)||function(e,t){const i=e.isEqualNode(Jc);return i&&rl(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(e){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 Nc(this._domDocument);case"markedNbsp":return Vc(this._domDocument);case"br":return Bc(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(Br(e)&&Lc(e)&&t<7)return!1;if(this.isElement(e)&&Lc(e.childNodes[t]))return!1;const i=this.mapDomToView(e);return!i||!i.is("uiElement")&&!i.is("rawElement")}*_domToView(e,t,i){if(this.isBlockFiller(e))return null;const r=this.getHostViewElement(e);if(r)return r;if(Yr(e)&&t.skipComments)return null;if(Br(e)){if(Dc(e))return null;{const t=e.data;if(""===t)return null;const r=new Us(this.document,t);return i.push(r),r}}{let r=this.mapDomToView(e);if(r)return this._isInlineObjectElement(r)&&i.push(r),r;if(this.isDocumentFragment(e))r=new _c(this.document),t.bind&&this.bindDocumentFragments(e,r);else{r=this._createViewElement(e,t),t.bind&&this.bindElements(e,r);const n=e.attributes;if(n)for(let e=n.length,t=0;t0?t[e-1]:null,c=e+1this.preElements.includes(e.name))))return t;if(" "==t.charAt(0)){const i=this._getTouchingInlineViewNode(e,!1);!(i&&i.is("$textProxy")&&this._nodeEndsWithSpace(i))&&i||(t=" "+t.substr(1))}if(" "==t.charAt(t.length-1)){const i=this._getTouchingInlineViewNode(e,!0),r=i&&i.is("$textProxy")&&" "==i.data.charAt(0);" "!=t.charAt(t.length-2)&&i&&!r||(t=t.substr(0,t.length-1)+" ")}return t.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(e){if(e.getAncestors().some((e=>this.preElements.includes(e.name))))return!1;const t=this._processDataFromViewText(e);return" "==t.charAt(t.length-1)}_getTouchingInlineViewNode(e,t){const i=new Za({startPosition:t?Qa._createAfter(e):Qa._createBefore(e),direction:t?"forward":"backward"});for(const e of i){if(e.item.is("element","br"))return null;if(this._isInlineObjectElement(e.item))return e.item;if(e.item.is("containerElement"))return null;if(e.item.is("$textProxy"))return e.item}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(Yr(e))return new fc(this.document,"$comment");const i=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new Wa(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(Xc,e),t){for(;t.firstChild;)i.appendChild(t.firstChild);for(const e of t.getAttributeNames())i.setAttribute(e,t.getAttribute(e))}return i}}function tl(e,t){return e.getAncestors().some((e=>e.is("element")&&t.includes(e.name)))}function il(e,t){let i=e;for(;i;)t(i),i=i.parentElement}function rl(e,t){const i=e.parentNode;return!!i&&!!i.tagName&&t.includes(i.tagName.toLowerCase())}function nl(e){"script"===e&&y("domconverter-unsafe-script-element-detected"),"style"===e&&y("domconverter-unsafe-style-element-detected")}class ol extends(Pr()){constructor(e){super(),this._isEnabled=!1,this.view=e,this.document=e.document}get isEnabled(){return this._isEnabled}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(e){return e&&3===e.nodeType&&(e=e.parentNode),!(!e||1!==e.nodeType)&&e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}const sl=Ra((function(e,t){It(t,mi(t),e)}));class al{constructor(e,t,i){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,sl(this,i)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class cl extends ol{constructor(){super(...arguments),this.useCapture=!1}observe(e){("string"==typeof this.domEventType?[this.domEventType]:this.domEventType).forEach((t=>{this.listenTo(e,t,((e,t)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(t.target)&&this.onDomEvent(t)}),{useCapture:this.useCapture})}))}stopObserving(e){this.stopListening(e)}fire(e,t,i){this.isEnabled&&this.document.fire(e,new al(this.view,t,i))}}class ll extends cl{constructor(){super(...arguments),this.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 fn(this)}};this.fire(e.type,e,t)}}class dl extends ol{constructor(e){super(e),this._fireSelectionChangeDoneDebounced=Qo((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 tc(t.getRanges(),{backward:t.isBackward,fake:!1});e!=gn.arrowleft&&e!=gn.arrowup||i.setTo(i.getFirstPosition()),e!=gn.arrowright&&e!=gn.arrowdown||i.setTo(i.getLastPosition());const r={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",r),this._fireSelectionChangeDoneDebounced(r)}}const ul=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this};const hl=function(e){return this.__data__.has(e)};function ml(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new _t;++ta))return!1;var l=o.get(e),d=o.get(t);if(l&&d)return l==t&&d==e;var u=-1,h=!0,m=2&i?new gl:void 0;for(o.set(e,t),o.set(t,e);++u{this._isFocusChanging=!0,this._renderTimeoutId=setTimeout((()=>{this.flush(),e.change((()=>{}))}),50)})),t.on("blur",((i,r)=>{const n=t.selection.editableElement;null!==n&&n!==r.target||(t.isFocused=!1,this._isFocusChanging=!1,e.change((()=>{})))}))}flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),super.destroy()}}class Bl extends ol{constructor(e){super(e),this.mutationObserver=e.getObserver(Ol),this.focusObserver=e.getObserver(Vl),this.selection=this.document.selection,this.domConverter=e.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=Qo((e=>{this.document.fire("selectionChangeDone",e)}),200),this._clearInfiniteLoopInterval=setInterval((()=>this._clearInfiniteLoop()),1e3),this._documentIsSelectingInactivityTimeoutDebounced=Qo((()=>this.document.isSelecting=!1),5e3),this._loopbackCounter=0}observe(e){const t=e.ownerDocument,i=()=>{this.document.isSelecting&&(this._handleSelectionChange(null,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",((e,i)=>{this.document.isComposing&&!l.isAndroid||(this._handleSelectionChange(i,t),this._documentIsSelectingInactivityTimeoutDebounced())})),this._documents.add(t))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e,t){if(!this.isEnabled)return;const i=t.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(i.anchorNode))return;this.mutationObserver.flush();const r=this.domConverter.domSelectionToView(i);if(0!=r.rangeCount){if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.selection.isEqual(r)||!this.domConverter.isDomSelectionCorrect(i))if(++this._loopbackCounter>60)this._reportInfiniteLoop();else if(this.selection.isSimilar(r))this.view.forceRender();else{const e={oldSelection:this.selection,newSelection:r,domSelection:i};this.document.fire("selectionChange",e),this._fireSelectionChangeDoneDebounced(e)}}else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}}class Rl extends cl{constructor(e){super(e),this.domEventType=["compositionstart","compositionupdate","compositionend"];const t=this.document;t.on("compositionstart",(()=>{t.isComposing=!0}),{priority:"low"}),t.on("compositionend",(()=>{t.isComposing=!1}),{priority:"low"})}onDomEvent(e){this.fire(e.type,e,{data:e.data})}}class Ll{constructor(e,t={}){this._files=t.cacheFiles?Dl(e):null,this._native=e}get files(){return this._files||(this._files=Dl(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 Dl(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 Fl extends cl{constructor(){super(...arguments),this.domEventType="beforeinput"}onDomEvent(e){const t=e.getTargetRanges(),i=this.view,r=i.document;let n=null,o=null,s=[];if(e.dataTransfer&&(n=new Ll(e.dataTransfer)),null!==e.data?o=e.data:n&&(o=n.getData("text/plain")),r.selection.isFake)s=Array.from(r.selection.getRanges());else if(t.length)s=t.map((e=>{const t=i.domConverter.domPositionToView(e.startContainer,e.startOffset),r=i.domConverter.domPositionToView(e.endContainer,e.endOffset);return t?i.createRange(t,r):r?i.createRange(r):void 0})).filter((e=>!!e));else if(l.isAndroid){const t=e.target.ownerDocument.defaultView.getSelection();s=Array.from(i.domConverter.domSelectionToView(t).getRanges())}if(l.isAndroid&&"insertCompositionText"==e.inputType&&o&&o.endsWith("\n"))this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[i.createRange(s[0].end)]});else if("insertText"==e.inputType&&o&&o.includes("\n")){const t=o.split(/\n{1,2}/g);let i=s;for(let o=0;o{if(this.isEnabled&&((i=t.keyCode)==gn.arrowright||i==gn.arrowleft||i==gn.arrowup||i==gn.arrowdown)){const i=new rc(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(i,t),i.stop.called&&e.stop()}var i}))}observe(){}stopObserving(){}}class zl extends ol{constructor(e){super(e);const t=this.document;t.on("keydown",((e,i)=>{if(!this.isEnabled||i.keyCode!=gn.tab||i.ctrlKey)return;const r=new rc(t,"tab",t.selection.getFirstRange());t.fire(r,i),r.stop.called&&e.stop()}))}observe(){}stopObserving(){}}const Hl=function(e){return vr(e,5)};class Ul extends(q()){constructor(e){super(),this.domRoots=new Map,this._initialDomRootAttributes=new WeakMap,this._observers=new Map,this._ongoingChange=!1,this._postFixersInProgress=!1,this._renderingDisabled=!1,this._hasChangedSinceTheLastRendering=!1,this.document=new dc(e),this.domConverter=new el(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new Uc(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new yc(this.document),this.addObserver(Ol),this.addObserver(Vl),this.addObserver(Bl),this.addObserver(ll),this.addObserver(dl),this.addObserver(Rl),this.addObserver(jl),this.addObserver(Fl),this.addObserver(zl),this.document.on("arrowKey",jc,{priority:"low"}),bc(this),this.on("render",(()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1})),this.listenTo(this.document.selection,"change",(()=>{this._hasChangedSinceTheLastRendering=!0})),this.listenTo(this.document,"change:isFocused",(()=>{this._hasChangedSinceTheLastRendering=!0})),l.isiOS&&this.listenTo(this.document,"blur",((e,t)=>{this.domConverter.mapDomToView(t.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}))}attachDomRoot(e,t="main"){const i=this.document.getRoot(t);i._name=e.tagName.toLowerCase();const r={};for(const{name:t,value:n}of Array.from(e.attributes))r[t]=n,"class"===t?this._writer.addClass(n.split(" "),i):this._writer.setAttribute(t,n,i);this._initialDomRootAttributes.set(e,r);const n=()=>{this._writer.setAttribute("contenteditable",(!i.isReadOnly).toString(),i),i.isReadOnly?this._writer.addClass("ck-read-only",i):this._writer.removeClass("ck-read-only",i)};n(),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(n))),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:r=20}={}){const n=this.document.selection.getFirstRange();if(!n)return;const o=Hl({alignToTop:e,forceScroll:t,viewportOffset:i,ancestorOffset:r});"number"==typeof i&&(i={top:i,bottom:i,left:i,right:i});const s={target:this.domConverter.viewRangeToDom(n),viewportOffset:i,ancestorOffset:r,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",s,o),function({target:e,viewportOffset:t=0,ancestorOffset:i=0,alignToTop:r,forceScroll:n}){const o=ln(e);let s=o,a=null;for(t=function(e){return"number"==typeof e?{top:e,bottom:e,left:e,right:e}:e}(t);s;){let c;c=dn(s==o?e:a),nn({parent:c,getRect:()=>un(e,s),alignToTop:r,ancestorOffset:i,forceScroll:n});const l=un(e,s);if(rn({window:s,rect:l,viewportOffset:t,alignToTop:r,forceScroll:n}),s.parent!=s){if(a=s.frameElement,s=s.parent,!a)return}else s=null}}(s)}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 _("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){_.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Vl).flush(),this.change((()=>{}))}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return Qa._createAt(e,t)}createPositionAfter(e){return Qa._createAfter(e)}createPositionBefore(e){return Qa._createBefore(e)}createRange(e,t){return new Xa(e,t)}createRangeOn(e){return Xa._createOn(e)}createRangeIn(e){return Xa._createIn(e)}createSelection(...e){return new tc(...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 Wl{is(){throw new Error("is() method is abstract")}}class $l extends Wl{constructor(e){super(),this.parent=null,this._attrs=Pn(e)}get document(){return null}get index(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildIndex(this)))throw new _("model-node-not-found-in-parent",this);return e}get startOffset(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildStartOffset(this)))throw new _("model-node-not-found-in-parent",this);return e}get offsetSize(){return 1}get endOffset(){return this.parent?this.startOffset+this.offsetSize:null}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),r=e.getAncestors(t);let n=0;for(;i[n]==r[n]&&i[n];)n++;return 0===n?null:i[n-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),r=ee(t,i);switch(r){case"prefix":return!0;case"extension":return!1;default:return t[r](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=Pn(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}$l.prototype.is=function(e){return"node"===e||"model:node"===e};class ql{constructor(e){this._nodes=[],e&&this._insertNodes(0,e)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._nodes.reduce(((e,t)=>e+t.offsetSize),0)}getNode(e){return this._nodes[e]||null}getNodeIndex(e){const t=this._nodes.indexOf(e);return-1==t?null:t}getNodeStartOffset(e){const t=this.getNodeIndex(e);return null===t?null:this._nodes.slice(0,t).reduce(((e,t)=>e+t.offsetSize),0)}indexToOffset(e){if(e==this._nodes.length)return this.maxOffset;const t=this._nodes[e];if(!t)throw new _("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){let t=0;for(const i of this._nodes){if(e>=t&&e1e4)return e.slice(0,i).concat(t).concat(e.slice(i+r,e.length));{const n=Array.from(e);return n.splice(i,r,...t),n}}(this._nodes,Array.from(t),e,0)}_removeNodes(e,t=1){return this._nodes.splice(e,t)}toJSON(){return this._nodes.map((e=>e.toJSON()))}}class Gl extends $l{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 Gl(this.data,this.getAttributes())}static fromJSON(e){return new Gl(e.data,e.attributes)}}Gl.prototype.is=function(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e};class Kl extends Wl{constructor(e,t,i){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new _("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new _("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()}}Kl.prototype.is=function(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e};class Yl extends $l{constructor(e,t,i){super(t),this._children=new ql,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)}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.getChild(t.offsetToIndex(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?Array.from(this._children).map((e=>e._clone(!0))):void 0;return new Yl(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 Gl(e)];te(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Gl(e):e instanceof Kl?new Gl(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}static fromJSON(e){let t;if(e.children){t=[];for(const i of e.children)i.name?t.push(Yl.fromJSON(i)):t.push(Gl.fromJSON(i))}return new Yl(e.name,e.attributes,t)}}Yl.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 Jl{constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new _("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new _("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=Ql._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,r,n;do{r=this.position,n=this._visitedParent,({done:t,value:i}=this.next())}while(!t&&e(i));t||(this._position=r,this._visitedParent=n)}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 r=Xl(t,i),n=r||ed(t,i,r);if(n instanceof Yl){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=n;return this._position=t,Zl("elementStart",n,e,t,1)}if(n instanceof Gl){let r;if(this.singleCharacters)r=1;else{let e=n.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offsete&&(e=this.boundaries.start.offset),r=t.offset-e}const n=t.offset-o.startOffset,s=new Kl(o,n-r,r);return t.offset-=r,this._position=t,Zl("text",s,e,t,r)}return t.path.pop(),this._position=t,this._visitedParent=i.parent,Zl("elementStart",i,e,t,1)}}function Zl(e,t,i,r,n){return{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:r,length:n}}}class Ql extends Wl{constructor(e,t,i="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new _("model-position-root-invalid",e);if(!(t instanceof Array)||0===t.length)throw new _("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 id(e,this,i);if(-1===t)return id(this,e,i)}return this.path.length===e.path.length||(this.path.length>e.path.length?rd(this.path,t):rd(e.path,t))}hasSameParentAs(e){if(this.root!==e.root)return!1;return"same"==ee(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=Ql._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)?Ql._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),i}_getTransformedByDeletion(e,t){const i=Ql._createAt(this);if(this.root!=e.root)return i;if("same"==ee(e.getParentPath(),this.getParentPath())){if(e.offsetthis.offset)return null;i.offset-=t}}else if("prefix"==ee(e.getParentPath(),this.getParentPath())){const r=e.path.length-1;if(e.offset<=this.path[r]){if(e.offset+t>this.path[r])return null;i.path[r]-=t}}return i}_getTransformedByInsertion(e,t){const i=Ql._createAt(this);if(this.root!=e.root)return i;if("same"==ee(e.getParentPath(),this.getParentPath()))(e.offset=t;){if(e.path[r]+n!==i.maxOffset)return!1;n=1,r--,i=i.parent}return!0}(e,i+1))}function rd(e,t){for(;tt+1;){const t=r.maxOffset-i.offset;0!==t&&e.push(new nd(i,i.getShiftedBy(t))),i.path=i.path.slice(0,-1),i.offset++,r=r.parent}for(;i.path.length<=this.end.path.length;){const t=this.end.path[i.path.length-1],r=t-i.offset;0!==r&&e.push(new nd(i,i.getShiftedBy(r))),i.offset=t,i.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new Jl(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new Jl(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new Jl(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 nd(this.start,this.end)]}getTransformedByOperations(e){const t=[new nd(this.start,this.end)];for(const i of e)for(let e=0;e0?new this(i,r):new this(r,i)}static _createIn(e){return new this(Ql._createAt(e,0),Ql._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(Ql._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new _("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),r=new this(t.start,t.end);if(i>0)for(let t=i-1;e[t].end.isEqual(r.start);t++)r.start=Ql._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 _("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),r=this._viewToModelMapping.get(i),n=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,i);t.modelPosition=Ql._createAt(r,n)}),{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._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)}bindElementToMarker(e,t){const i=this._markerNameToElements.get(t)||new Set;i.add(e);const r=this._elementToMarkerNames.get(e)||new Set;r.add(t),this._markerNameToElements.set(t,i),this._elementToMarkerNames.set(e,r)}unbindElementFromMarkerName(e,t){const i=this._markerNameToElements.get(t);i&&(i.delete(e),0==i.size&&this._markerNameToElements.delete(t));const r=this._elementToMarkerNames.get(e);r&&(r.delete(t),0==r.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 nd(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new Xa(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 r=0;for(let i=0;i1?t[0]+":"+t[1]:t[0]}class cd extends(M()){constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,i){const r=this._createConversionApi(i,e.getRefreshedItems());for(const t of e.getMarkersToRemove())this._convertMarkerRemove(t.name,t.range,r);const n=this._reduceChanges(e.getChanges());for(const e of n)"insert"===e.type?this._convertInsert(nd._createFromPositionAndShift(e.position,e.length),r):"reinsert"===e.type?this._convertReinsert(nd._createFromPositionAndShift(e.position,e.length),r):"remove"===e.type?this._convertRemove(e.position,e.length,e.name,r):this._convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,r);r.mapper.flushDeferredBindings();for(const e of r.mapper.flushUnboundMarkerNames()){const i=t.get(e).getRange();this._convertMarkerRemove(e,i,r),this._convertMarkerAdd(e,i,r)}for(const t of e.getMarkersToAdd())this._convertMarkerAdd(t.name,t.range,r);r.consumable.verifyAllConsumed("insert")}convert(e,t,i,r={}){const n=this._createConversionApi(i,void 0,r);this._convertInsert(e,n);for(const[e,i]of t)this._convertMarkerAdd(e,i,n);n.consumable.verifyAllConsumed("insert")}convertSelection(e,t,i){const r=this._createConversionApi(i);this.fire("cleanSelection",{selection:e},r);const n=e.getFirstPosition().root;if(!r.mapper.toViewElement(n))return;const o=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(r.consumable,e,o),this.fire("selection",{selection:e},r),e.isCollapsed){for(const t of o)if(r.consumable.test(e,"addMarker:"+t.name)){const i=t.getRange();if(!ld(e.getFirstPosition(),t,r.mapper))continue;const n={item:e,markerName:t.name,markerRange:i};this.fire(`addMarker:${t.name}`,n,r)}for(const t of e.getAttributeKeys())if(r.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,r)}}}_convertInsert(e,t,i={}){i.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,e);for(const i of Array.from(e.getWalker({shallow:!0})).map(dd))this._testAndFire("insert",i,t)}_convertRemove(e,t,i,r){this.fire(`remove:${i}`,{position:e,length:t},r)}_convertAttribute(e,t,i,r,n){this._addConsumablesForRange(n.consumable,e,`attribute:${t}`);for(const o of e){const e={item:o.item,range:nd._createFromPositionAndShift(o.previousPosition,o.length),attributeKey:t,attributeOldValue:i,attributeNewValue:r};this._testAndFire(`attribute:${t}`,e,n)}}_convertReinsert(e,t){const i=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,i);for(const e of i.map(dd))this._testAndFire("insert",{...e,reconversion:!0},t)}_convertMarkerAdd(e,t,i){if("$graveyard"==t.root.rootName)return;const r=`addMarker:${e}`;if(i.consumable.add(t,r),this.fire(r,{markerName:e,markerRange:t},i),i.consumable.consume(t,r)){this._addConsumablesForRange(i.consumable,t,r);for(const n of t.getItems()){if(!i.consumable.test(n,r))continue;const o={item:n,range:nd._createOn(n),markerName:e,markerRange:t};this.fire(r,o,i)}}}_convertMarkerRemove(e,t,i){"$graveyard"!=t.root.rootName&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},i)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.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 r of t.getItems())e.add(r,i);return e}_addConsumablesForSelection(e,t,i){e.add(t,"selection");for(const r of i)e.add(t,"addMarker:"+r.name);for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i);return e}_testAndFire(e,t,i){const r=function(e,t){const i=t.item.is("element")?t.item.name:"$text";return`${e}:${i}`}(e,t),n=t.item.is("$textProxy")?i.consumable._getSymbolForTextProxy(t.item):t.item,o=this._firedEventsMap.get(i),s=o.get(n);if(s){if(s.has(r))return;s.add(r)}else o.set(n,new Set([r]));this.fire(r,t,i)}_testAndFireAddAttributes(e,t){const i={item:e,range:nd._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 r={...this._conversionApi,consumable:new sd,writer:e,options:i,convertItem:e=>this._convertInsert(nd._createOn(e),r),convertChildren:e=>this._convertInsert(nd._createIn(e),r,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,r),canReuseView:e=>!t.has(r.mapper.toModelElement(e))};return this._firedEventsMap.set(r,new Map),r}}function ld(e,t,i){const r=t.getRange(),n=Array.from(e.getAncestors());n.shift(),n.reverse();return!n.some((e=>{if(r.containsItem(e)){return!!i.toViewElement(e).getCustomProperty("addHighlight")}}))}function dd(e){return{item:e.item,range:nd._createFromPositionAndShift(e.previousPosition,e.length)}}class ud extends(M(Wl)){constructor(...e){super(),this._lastRangeBackward=!1,this._attrs=new Map,this._ranges=[],e.length&&this.setTo(...e)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return 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 r of e._ranges)if(t.isEqual(r)){i=!0;break}if(!i)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new nd(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 nd(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 nd(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,r]=e;if("object"==typeof i&&(r=i,i=void 0),null===t)this._setRanges([]);else if(t instanceof ud)this._setRanges(t.getRanges(),t.isBackward);else if(t&&"function"==typeof t.getRanges)this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof nd)this._setRanges([t],!!r&&!!r.backward);else if(t instanceof Ql)this._setRanges([new nd(t)]);else if(t instanceof $l){const e=!!r&&!!r.backward;let n;if("in"==i)n=nd._createIn(t);else if("on"==i)n=nd._createOn(t);else{if(void 0===i)throw new _("model-selection-setto-required-second-parameter",[this,t]);n=new nd(Ql._createAt(t,i))}this._setRanges([n],e)}else{if(!te(t))throw new _("model-selection-setto-not-selectable",[this,t]);this._setRanges(t,r&&!!r.backward)}}_setRanges(e,t=!1){const i=Array.from(e),r=i.some((t=>{if(!(t instanceof nd))throw new _("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every((e=>!e.isEqual(t)))}));(i.length!==this._ranges.length||r)&&(this._replaceAllRanges(i),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(null===this.anchor)throw new _("model-selection-setfocus-no-ranges",[this,e]);const i=Ql._createAt(e,t);if("same"==i.compareWith(this.focus))return;const r=this.anchor;this._ranges.length&&this._popRange(),"before"==i.compareWith(r)?(this._pushRange(new nd(i,r)),this._lastRangeBackward=!0):(this._pushRange(new nd(r,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=gd(t.start,e);fd(i,t)&&(yield i);for(const i of t.getWalker()){const r=i.item;"elementEnd"==i.type&&md(r,e,t)&&(yield r)}const r=gd(t.end,e);bd(r,t)&&(yield r)}}containsEntireContent(e=this.anchor.root){const t=Ql._createAt(e,0),i=Ql._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new nd(e.start,e.end))}_checkRange(e){for(let t=0;t0;)this._popRange()}_popRange(){this._ranges.pop()}}function hd(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&!!e.parent)}function md(e,t,i){return hd(e,t)&&pd(e,i)}function gd(e,t){const i=e.parent.root.document.model.schema,r=e.parent.getAncestors({parentFirst:!0,includeSelf:!0});let n=!1;const o=r.find((e=>!n&&(n=i.isLimit(e),!n&&hd(e,t))));return r.forEach((e=>t.add(e))),o}function pd(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);if(!i)return!0;return!t.containsRange(nd._createOn(i),!0)}function fd(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.start.isTouching(Ql._createAt(e,e.maxOffset))&&pd(e,t))}function bd(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.end.isTouching(Ql._createAt(e,0))&&pd(e,t))}ud.prototype.is=function(e){return"selection"===e||"model:selection"===e};class wd extends(M(nd)){constructor(e,t){super(e,t),kd.call(this)}detach(){this.stopListening()}toRange(){return new nd(this.start,this.end)}static fromRange(e){return new wd(e.start,e.end)}}function kd(){this.listenTo(this.root.document.model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&vd.call(this,i)}),{priority:"low"})}function vd(e){const t=this.getTransformedByOperation(e),i=nd._createFromRanges(t),r=!i.isEqual(this),n=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 o=null;if(r){"$graveyard"==i.root.rootName&&(o="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:o})}else n&&this.fire("change:content",this.toRange(),{deletionPosition:o})}wd.prototype.is=function(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e};const _d="selection:";class yd extends(M(Wl)){constructor(e){super(),this._selection=new xd(e),this._selection.delegate("change:range").to(this),this._selection.delegate("change:attribute").to(this),this._selection.delegate("change:marker").to(this)}get isCollapsed(){return this._selection.isCollapsed}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get rangeCount(){return this._selection.rangeCount}get hasOwnRange(){return this._selection.hasOwnRange}get isBackward(){return this._selection.isBackward}get isGravityOverridden(){return this._selection.isGravityOverridden}get markers(){return this._selection.markers}get _ranges(){return this._selection._ranges}getRanges(){return this._selection.getRanges()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getSelectedBlocks(){return this._selection.getSelectedBlocks()}getSelectedElement(){return this._selection.getSelectedElement()}containsEntireContent(e){return this._selection.containsEntireContent(e)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(e){return this._selection.getAttribute(e)}hasAttribute(e){return this._selection.hasAttribute(e)}refresh(){this._selection.updateMarkers(),this._selection._updateAttributes(!1)}observeMarkers(e){this._selection.observeMarkers(e)}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(...e){this._selection.setTo(...e)}_setAttribute(e,t){this._selection.setAttribute(e,t)}_removeAttribute(e){this._selection.removeAttribute(e)}_getStoredAttributes(){return this._selection.getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(e){this._selection.restoreGravity(e)}static _getStoreAttributeKey(e){return _d+e}static _isStoreAttributeKey(e){return e.startsWith(_d)}}yd.prototype.is=function(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e};class xd extends ud{constructor(e){super(),this.markers=new Cn({idProperty:"name"}),this._attributePriority=new Map,this._selectionRestorePosition=null,this._hasChangedRange=!1,this._overriddenGravityRegister=new Set,this._observedMarkers=new Set,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,r)=>{this._updateMarker(t,r)})),this.listenTo(this._document,"change",((e,t)=>{!function(e,t){const i=e.document.differ;for(const r of i.getChanges()){if("insert"!=r.type)continue;const i=r.position.parent;r.length===i.maxOffset&&e.enqueueChange(t,(e=>{const t=Array.from(i.getAttributeKeys()).filter((e=>e.startsWith(_d)));for(const r of t)e.removeAttribute(r,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;e{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=r.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 r=t.getRange();for(const i of this.getRanges())r.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 r=!1;const n=Array.from(this.markers),o=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&&!o?(this.markers.add(e),r=!0):!i&&o&&(this.markers.remove(e),r=!0)}else o&&(this.markers.remove(e),r=!0);r&&this.fire("change:marker",{oldMarkers:n,directChange:!1})}_updateAttributes(e){const t=Pn(this._getSurroundingAttributes()),i=Pn(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 r=[];for(const[e,t]of this.getAttributes())i.has(e)&&i.get(e)===t||r.push(e);for(const[e]of i)this.hasAttribute(e)||r.push(e);r.length>0&&this.fire("change:attribute",{attributeKeys:r,directChange:!1})}_setAttribute(e,t,i=!0){const r=i?"normal":"low";if("low"==r&&"normal"==this._attributePriority.get(e))return!1;return super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,r),!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,r]of e){this._setAttribute(i,r,!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(_d)){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 r=e.textNode?e.textNode:e.nodeBefore,n=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(i=Ad(r,t)),i||(i=Ad(n,t)),!this.isGravityOverridden&&!i){let e=r;for(;e&&!i;)e=e.previousSibling,i=Ad(e,t)}if(!i){let e=n;for(;e&&!i;)e=e.nextSibling,i=Ad(e,t)}i||(i=this.getStoredAttributes())}else{const e=this.getFirstRange();for(const r of e){if(r.item.is("element")&&t.isObject(r.item)){i=Ad(r.item,t);break}if("text"==r.type){i=r.item.getAttributes();break}}}return i}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function Ad(e,t){if(!e)return null;if(e instanceof Kl||e instanceof Gl)return e.getAttributes();if(!t.isInline(e))return null;if(!t.isObject(e))return[];const i=[];for(const[r,n]of e.getAttributes())t.checkAttribute("$text",r)&&!1!==t.getAttributeProperties(r).copyFromObject&&i.push([r,n]);return i}class Cd{constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}class Ed extends Cd{elementToElement(e){return this.add(function(e){const t=Pd(e.model),i=Id(e.view,"container");t.attributes.length&&(t.children=!0);return r=>{r.on(`insert:${t.name}`,function(e,t=Dd){return(i,r,n)=>{if(!t(r.item,n.consumable,{preflight:!0}))return;const o=e(r.item,n,r);if(!o)return;t(r.item,n.consumable);const s=n.mapper.toViewPosition(r.range.start);n.mapper.bindElements(r.item,o),n.writer.insert(s,o),n.convertAttributes(r.item),Rd(o,r.item.getChildren(),n,{reconversion:r.reconversion})}}(i,Bd(t)),{priority:e.converterPriority||"normal"}),(t.children||t.attributes.length)&&r.on("reduceChanges",Vd(t),{priority:"low"})}}(e))}elementToStructure(e){return this.add(function(e){const t=Pd(e.model),i=Id(e.view,"container");return t.children=!0,r=>{if(r._conversionApi.schema.checkChild(t.name,"$text"))throw new _("conversion-element-to-structure-disallowed-text",r,{elementName:t.name});var n,o;r.on(`insert:${t.name}`,(n=i,o=Bd(t),(e,t,i)=>{if(!o(t.item,i.consumable,{preflight:!0}))return;const r=new Map;i.writer._registerSlotFactory(function(e,t,i){return(r,n)=>{const o=r.createContainerElement("$slot");let s=null;if("children"===n)s=Array.from(e.getChildren());else{if("function"!=typeof n)throw new _("conversion-slot-mode-unknown",i.dispatcher,{modeOrFilter:n});s=Array.from(e.getChildren()).filter((e=>n(e)))}return t.set(o,s),o}}(t.item,r,i));const s=n(t.item,i,t);if(i.writer._clearSlotFactory(),!s)return;!function(e,t,i){const r=Array.from(t.values()).flat(),n=new Set(r);if(n.size!=r.length)throw new _("conversion-slot-filter-overlap",i.dispatcher,{element:e});if(n.size!=e.childCount)throw new _("conversion-slot-filter-incomplete",i.dispatcher,{element:e})}(t.item,r,i),o(t.item,i.consumable);const a=i.mapper.toViewPosition(t.range.start);i.mapper.bindElements(t.item,s),i.writer.insert(a,s),i.convertAttributes(t.item),function(e,t,i,r){i.mapper.on("modelToViewPosition",s,{priority:"highest"});let n=null,o=null;for([n,o]of t)Rd(e,o,i,r),i.writer.move(i.writer.createRangeIn(n),i.writer.createPositionBefore(n)),i.writer.remove(n);function s(e,t){const i=t.modelPosition.nodeAfter,r=o.indexOf(i);r<0||(t.viewPosition=t.mapper.findPositionIn(n,r))}i.mapper.off("modelToViewPosition",s)}(s,r,i,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),r.on("reduceChanges",Vd(t),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){e=Hl(e);let t=e.model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;t.name&&(i+=":"+t.name);if(t.values)for(const i of t.values)e.view[i]=Id(e.view[i],"attribute");else e.view=Id(e.view,"attribute");const r=Md(e);return t=>{t.on(i,function(e){return(t,i,r)=>{if(!r.consumable.test(i.item,t.name))return;const n=e(i.attributeOldValue,r,i),o=e(i.attributeNewValue,r,i);if(!n&&!o)return;r.consumable.consume(i.item,t.name);const s=r.writer,a=s.document.selection;if(i.item instanceof ud||i.item instanceof yd)s.wrap(a.getFirstRange(),o);else{let e=r.mapper.toViewRange(i.range);null!==i.attributeOldValue&&n&&(e=s.unwrap(e,n)),null!==i.attributeNewValue&&o&&s.wrap(e,o)}}}(r),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=Hl(e);let t=e.model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;t.name&&(i+=":"+t.name);if(t.values)for(const i of t.values)e.view[i]=Od(e.view[i]);else e.view=Od(e.view);const r=Md(e);return t=>{var n;t.on(i,(n=r,(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const r=n(t.attributeOldValue,i,t),o=n(t.attributeNewValue,i,t);if(!r&&!o)return;i.consumable.consume(t.item,e.name);const s=i.mapper.toViewElement(t.item),a=i.writer;if(!s)throw new _("conversion-attribute-to-attribute-on-text",i.dispatcher,t);if(null!==t.attributeOldValue&&r)if("class"==r.key){const e=yn(r.value);for(const t of e)a.removeClass(t,s)}else if("style"==r.key){const e=Object.keys(r.value);for(const t of e)a.removeStyle(t,s)}else a.removeAttribute(r.key,s);if(null!==t.attributeNewValue&&o)if("class"==o.key){const e=yn(o.value);for(const t of e)a.addClass(t,s)}else if("style"==o.key){const e=Object.keys(o.value);for(const t of e)a.setStyle(t,o.value[t],s)}else a.setAttribute(o.key,o.value,s)}),{priority:e.converterPriority||"normal"})}}(e))}markerToElement(e){return this.add(function(e){const t=Id(e.view,"ui");return i=>{var r;i.on(`addMarker:${e.model}`,(r=t,(e,t,i)=>{t.isOpening=!0;const n=r(t,i);t.isOpening=!1;const o=r(t,i);if(!n||!o)return;const s=t.markerRange;if(s.isCollapsed&&!i.consumable.consume(s,e.name))return;for(const t of s)if(!i.consumable.consume(t.item,e.name))return;const a=i.mapper,c=i.writer;c.insert(a.toViewPosition(s.start),n),i.mapper.bindElementToMarker(n,t.markerName),s.isCollapsed||(c.insert(a.toViewPosition(s.end),o),i.mapper.bindElementToMarker(o,t.markerName)),e.stop()}),{priority:e.converterPriority||"normal"}),i.on(`removeMarker:${e.model}`,((e,t,i)=>{const r=i.mapper.markerNameToElements(t.markerName);if(r){for(const e of r)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,r)=>{if(!t.item)return;if(!(t.item instanceof ud||t.item instanceof yd||t.item.is("$textProxy")))return;const n=Nd(i,t,r);if(!n)return;if(!r.consumable.consume(t.item,e.name))return;const o=r.writer,s=Sd(o,n),a=o.document.selection;if(t.item instanceof ud||t.item instanceof yd)o.wrap(a.getFirstRange(),s);else{const e=r.mapper.toViewRange(t.range),i=o.wrap(e,s);for(const e of i.getItems())if(e.is("attributeElement")&&e.isSimilar(s)){r.mapper.bindElementToMarker(e,t.markerName);break}}}),{priority:e.converterPriority||"normal"}),t.on(`addMarker:${e.model}`,function(e){return(t,i,r)=>{if(!i.item)return;if(!(i.item instanceof Yl))return;const n=Nd(e,i,r);if(!n)return;if(!r.consumable.test(i.item,t.name))return;const o=r.mapper.toViewElement(i.item);if(o&&o.getCustomProperty("addHighlight")){r.consumable.consume(i.item,t.name);for(const e of nd._createIn(i.item))r.consumable.consume(e.item,t.name);o.getCustomProperty("addHighlight")(o,n,r.writer),r.mapper.bindElementToMarker(o,i.markerName)}}}(e.view),{priority:e.converterPriority||"normal"}),t.on(`removeMarker:${e.model}`,function(e){return(t,i,r)=>{if(i.markerRange.isCollapsed)return;const n=Nd(e,i,r);if(!n)return;const o=Sd(r.writer,n),s=r.mapper.markerNameToElements(i.markerName);if(s){for(const e of s)if(r.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("attributeElement"))r.writer.unwrap(r.writer.createRangeOn(e),o);else{e.getCustomProperty("removeHighlight")(e,n.id,r.writer)}r.writer.clearClonedElementsGroup(i.markerName),t.stop()}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}markerToData(e){return this.add(function(e){e=Hl(e);const t=e.model;let i=e.view;i||(i=i=>({group:t,name:i.substr(e.model.length+1)}));return r=>{var n;r.on(`addMarker:${t}`,(n=i,(e,t,i)=>{const r=n(t.markerName,i);if(!r)return;const o=t.markerRange;i.consumable.consume(o,e.name)&&(Td(o,!1,i,t,r),Td(o,!0,i,t,r),e.stop())}),{priority:e.converterPriority||"normal"}),r.on(`removeMarker:${t}`,function(e){return(t,i,r)=>{const n=e(i.markerName,r);if(!n)return;const o=r.mapper.markerNameToElements(i.markerName);if(o){for(const e of o)r.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("containerElement")?(s(`data-${n.group}-start-before`,e),s(`data-${n.group}-start-after`,e),s(`data-${n.group}-end-before`,e),s(`data-${n.group}-end-after`,e)):r.writer.clear(r.writer.createRangeOn(e),e);r.writer.clearClonedElementsGroup(i.markerName),t.stop()}function s(e,t){if(t.hasAttribute(e)){const i=new Set(t.getAttribute(e).split(","));i.delete(n.name),0==i.size?r.writer.removeAttribute(e,t):r.writer.setAttribute(e,Array.from(i).join(","),t)}}}}(i),{priority:e.converterPriority||"normal"})}}(e))}}function Sd(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 Td(e,t,i,r,n){const o=t?e.start:e.end,s=o.nodeAfter&&o.nodeAfter.is("element")?o.nodeAfter:null,a=o.nodeBefore&&o.nodeBefore.is("element")?o.nodeBefore:null;if(s||a){let e,o;t&&s||!t&&!a?(e=s,o=!0):(e=a,o=!1);const c=i.mapper.toViewElement(e);if(c)return void function(e,t,i,r,n,o){const s=`data-${o.group}-${t?"start":"end"}-${i?"before":"after"}`,a=e.hasAttribute(s)?e.getAttribute(s).split(","):[];a.unshift(o.name),r.writer.setAttribute(s,a.join(","),e),r.mapper.bindElementToMarker(e,n.markerName)}(c,t,o,i,r,n)}!function(e,t,i,r,n){const o=`${n.group}-${t?"start":"end"}`,s=n.name?{name:n.name}:null,a=i.writer.createUIElement(o,s);i.writer.insert(e,a),i.mapper.bindElementToMarker(a,r.markerName)}(i.mapper.toViewPosition(o),t,i,r,n)}function Pd(e){return"string"==typeof e&&(e={name:e}),{name:e.name,attributes:e.attributes?yn(e.attributes):[],children:!!e.children}}function Id(e,t){return"function"==typeof e?e:(i,r)=>function(e,t,i){"string"==typeof e&&(e={name:e});let r;const n=t.writer,o=Object.assign({},e.attributes);if("container"==i)r=n.createContainerElement(e.name,o);else if("attribute"==i){const t={priority:e.priority||uc.DEFAULT_PRIORITY};r=n.createAttributeElement(e.name,o,t)}else r=n.createUIElement(e.name,o);if(e.styles){const t=Object.keys(e.styles);for(const i of t)n.setStyle(i,e.styles[i],r)}if(e.classes){const t=e.classes;if("string"==typeof t)n.addClass(t,r);else for(const e of t)n.addClass(e,r)}return r}(e,r,t)}function Md(e){return e.model.values?(t,i,r)=>{const n=e.view[t];return n?n(t,i,r):null}:e.view}function Od(e){return"string"==typeof e?t=>({key:e,value:t}):"object"==typeof e?e.value?()=>e:t=>({key:e.key,value:t}):e}function Nd(e,t,i){const r="function"==typeof e?e(t,i):e;return r?(r.priority||(r.priority=10),r.id||(r.id=t.markerName),r):null}function Vd(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 r=[];i.reconvertedElements||(i.reconvertedElements=new Set);for(const e of i.changes){const n="attribute"==e.type?e.range.start.nodeAfter:e.position.parent;if(n&&t(n,e)){if(!i.reconvertedElements.has(n)){i.reconvertedElements.add(n);const e=Ql._createBefore(n);let t=r.length;for(let i=r.length-1;i>=0;i--){const n=r[i],o=("attribute"==n.type?n.range.start:n.position).compareWith(e);if("before"==o||"remove"==n.type&&"same"==o)break;t=i}r.splice(t,0,{type:"remove",name:n.name,position:e,length:1},{type:"reinsert",name:n.name,position:e,length:1})}}else r.push(e)}i.changes=r}}function Bd(e){return(t,i,r={})=>{const n=["insert"];for(const i of e.attributes)t.hasAttribute(i)&&n.push(`attribute:${i}`);return!!n.every((e=>i.test(t,e)))&&(r.preflight||n.forEach((e=>i.consume(t,e))),!0)}}function Rd(e,t,i,r){for(const n of t)Ld(e.root,n,i,r)||i.convertItem(n)}function Ld(e,t,i,r){const{writer:n,mapper:o}=i;if(!r.reconversion)return!1;const s=o.toViewElement(t);return!(!s||s.root==e)&&(!!i.canReuseView(s)&&(n.move(n.createRangeOn(s),o.toViewPosition(Ql._createBefore(t))),!0))}function Dd(e,t,{preflight:i}={}){return i?t.test(e,"insert"):t.consume(e,"insert")}function Fd(e){const{schema:t,document:i}=e.model;for(const r of i.getRoots())if(r.isEmpty&&!t.checkChild(r,"$text")&&t.checkChild(r,"paragraph"))return e.insertElement("paragraph",r),!0;return!1}function jd(e,t,i){const r=i.createContext(e);return!!i.checkChild(r,"paragraph")&&!!i.checkChild(r.push("paragraph"),t)}function zd(e,t){const i=t.createElement("paragraph");return t.insert(i,e),t.createPositionAt(i,0)}class Hd extends Cd{elementToElement(e){return this.add(Ud(e))}elementToAttribute(e){return this.add(function(e){e=Hl(e),qd(e);const t=Gd(e,!1),i=Wd(e.view),r=i?`element:${i}`:"element";return i=>{i.on(r,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=Hl(e);let t=null;("string"==typeof e.view||e.view.key)&&(t=function(e){"string"==typeof e.view&&(e.view={key:e.view});const t=e.view.key;let i;if("class"==t||"style"==t){const r="class"==t?"classes":"styles";i={[r]:e.view.value}}else{const r=void 0===e.view.value?/[\s\S]*/:e.view.value;i={attributes:{[t]:r}}}e.view.name&&(i.name=e.view.name);return e.view=i,t}(e));qd(e,t);const i=Gd(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 r="string"==typeof e?e:e(t,i);return i.writer.createElement("$marker",{"data-name":r})}}(e.model);return Ud({...e,model:t})}(e))}dataToMarker(e){return this.add(function(e){e=Hl(e),e.model||(e.model=t=>t?e.view+":"+t:e.view);const t={view:e.view,model:e.model},i=$d(Kd(t,"start")),r=$d(Kd(t,"end"));return n=>{n.on(`element:${e.view}-start`,i,{priority:e.converterPriority||"normal"}),n.on(`element:${e.view}-end`,r,{priority:e.converterPriority||"normal"});const o=k.low,s=k.highest,a=k.get(e.converterPriority)/s;n.on("element",function(e){return(t,i,r)=>{const n=`data-${e.view}`;function o(t,n){for(const o of n){const n=e.model(o,r),s=r.writer.createElement("$marker",{"data-name":n});r.writer.insert(s,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]}}(r.consumable.test(i.viewItem,{attributes:n+"-end-after"})||r.consumable.test(i.viewItem,{attributes:n+"-start-after"})||r.consumable.test(i.viewItem,{attributes:n+"-end-before"})||r.consumable.test(i.viewItem,{attributes:n+"-start-before"}))&&(i.modelRange||Object.assign(i,r.convertChildren(i.viewItem,i.modelCursor)),r.consumable.consume(i.viewItem,{attributes:n+"-end-after"})&&o(i.modelRange.end,i.viewItem.getAttribute(n+"-end-after").split(",")),r.consumable.consume(i.viewItem,{attributes:n+"-start-after"})&&o(i.modelRange.end,i.viewItem.getAttribute(n+"-start-after").split(",")),r.consumable.consume(i.viewItem,{attributes:n+"-end-before"})&&o(i.modelRange.start,i.viewItem.getAttribute(n+"-end-before").split(",")),r.consumable.consume(i.viewItem,{attributes:n+"-start-before"})&&o(i.modelRange.start,i.viewItem.getAttribute(n+"-start-before").split(",")))}}(t),{priority:o+a})}}(e))}}function Ud(e){const t=$d(e=Hl(e)),i=Wd(e.view),r=i?`element:${i}`:"element";return i=>{i.on(r,t,{priority:e.converterPriority||"normal"})}}function Wd(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}function $d(e){const t=new $s(e.view);return(i,r,n)=>{const o=t.match(r.viewItem);if(!o)return;const s=o.match;if(s.name=!0,!n.consumable.test(r.viewItem,s))return;const a=function(e,t,i){return e instanceof Function?e(t,i):i.writer.createElement(e)}(e.model,r.viewItem,n);a&&n.safeInsert(a,r.modelCursor)&&(n.consumable.consume(r.viewItem,s),n.convertChildren(r.viewItem,a),n.updateConversionResult(a,r))}}function qd(e,t=null){const i=null===t||(e=>e.getAttribute(t)),r="object"!=typeof e.model?e.model:e.model.key,n="object"!=typeof e.model||void 0===e.model.value?i:e.model.value;e.model={key:r,value:n}}function Gd(e,t){const i=new $s(e.view);return(r,n,o)=>{if(!n.modelRange&&t)return;const s=i.match(n.viewItem);if(!s)return;if(!function(e,t){const i="function"==typeof e?e(t):e;if("object"==typeof i&&!Wd(i))return!1;return!i.classes&&!i.attributes&&!i.styles}(e.view,n.viewItem)?delete s.match.name:s.match.name=!0,!o.consumable.test(n.viewItem,s.match))return;const a=e.model.key,c="function"==typeof e.model.value?e.model.value(n.viewItem,o):e.model.value;if(null===c)return;n.modelRange||Object.assign(n,o.convertChildren(n.viewItem,n.modelCursor));const l=function(e,t,i,r){let n=!1;for(const o of Array.from(e.getItems({shallow:i})))r.schema.checkAttribute(o,t.key)&&(n=!0,o.hasAttribute(t.key)||r.writer.setAttribute(t.key,t.value,o));return n}(n.modelRange,{key:a,value:c},t,o);l&&(o.consumable.test(n.viewItem,{name:!0})&&(s.match.name=!0),o.consumable.consume(n.viewItem,s.match))}}function Kd(e,t){return{view:`${e.view}-${t}`,model:(t,i)=>{const r=t.getAttribute("name"),n=e.model(r,i);return i.writer.createElement("$marker",{"data-name":n})}}}function Yd(e){e.document.registerPostFixer((t=>function(e,t){const i=t.document.selection,r=t.schema,n=[];let o=!1;for(const e of i.getRanges()){const t=Jd(e,r);t&&!t.isEqual(e)?(n.push(t),o=!0):n.push(e)}o&&e.setSelection(function(e){const t=[...e],i=new Set;let r=1;for(;r!i.has(t)))}(n),{backward:i.isBackward});return!1}(t,e)))}function Jd(e,t){return e.isCollapsed?function(e,t){const i=e.start,r=t.getNearestSelectionRange(i);if(!r){const e=i.getAncestors().reverse().find((e=>t.isObject(e)));return e?nd._createOn(e):null}if(!r.isCollapsed)return r;const n=r.start;if(i.isEqual(n))return null;return new nd(n)}(e,t):function(e,t){const{start:i,end:r}=e,n=t.checkChild(i,"$text"),o=t.checkChild(r,"$text"),s=t.getLimitElement(i),a=t.getLimitElement(r);if(s===a){if(n&&o)return null;if(function(e,t,i){const r=e.nodeAfter&&!i.isLimit(e.nodeAfter)||i.checkChild(e,"$text"),n=t.nodeBefore&&!i.isLimit(t.nodeBefore)||i.checkChild(t,"$text");return r||n}(i,r,t)){const e=i.nodeAfter&&t.isSelectable(i.nodeAfter)?null:t.getNearestSelectionRange(i,"forward"),n=r.nodeBefore&&t.isSelectable(r.nodeBefore)?null:t.getNearestSelectionRange(r,"backward"),o=e?e.start:i,s=n?n.end:r;return new nd(o,s)}}const c=s&&!s.is("rootElement"),l=a&&!a.is("rootElement");if(c||l){const e=i.nodeAfter&&r.nodeBefore&&i.nodeAfter.parent===r.nodeBefore.parent,n=c&&(!e||!Qd(i.nodeAfter,t)),o=l&&(!e||!Qd(r.nodeBefore,t));let d=i,u=r;return n&&(d=Ql._createBefore(Zd(s,t))),o&&(u=Ql._createAfter(Zd(a,t))),new nd(d,u)}return null}(e,t)}function Zd(e,t){let i=e,r=i;for(;t.isLimit(r)&&r.parent;)i=r,r=r.parent;return i}function Qd(e,t){return e&&t.isSelectable(e)}class Xd extends(q()){constructor(e,t){super(),this.model=e,this.view=new Ul(t),this.mapper=new od,this.downcastDispatcher=new cd({mapper:this.mapper,schema:e.schema});const i=this.model.document,r=i.selection,n=this.model.markers;var o,s,a;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,n,e),this.downcastDispatcher.convertSelection(r,n,e)}))}),{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(i,r)=>{const n=r.newSelection,o=[];for(const e of n.getRanges())o.push(t.toModelRange(e));const s=e.createSelection(o,{backward:n.isBackward});s.isEqual(e.document.selection)||e.change((e=>{e.setSelection(s)}))}}(this.model,this.mapper)),this.listenTo(this.view.document,"beforeinput",(o=this.mapper,s=this.model.schema,a=this.view,(e,t)=>{if(!a.document.isComposing||l.isAndroid)for(let e=0;e{if(!i.consumable.consume(t.item,e.name))return;const r=i.writer,n=i.mapper.toViewPosition(t.range.start),o=r.createText(t.item.data);r.insert(n,o)}),{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)=>{const r=i.mapper.toViewPosition(t.position),n=t.position.getShiftedBy(t.length),o=i.mapper.toViewPosition(n,{isPhantom:!0}),s=i.writer.createRange(r,o),a=i.writer.remove(s.getTrimmed());for(const e of i.writer.createRangeIn(a).getItems())i.mapper.unbindViewElement(e,{defer:!0})}),{priority:"low"}),this.downcastDispatcher.on("cleanSelection",((e,t,i)=>{const r=i.writer,n=r.document.selection;for(const e of n.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&i.writer.mergeAttributes(e.start);r.setSelection(null)})),this.downcastDispatcher.on("selection",((e,t,i)=>{const r=t.selection;if(r.isCollapsed)return;if(!i.consumable.consume(r,"selection"))return;const n=[];for(const e of r.getRanges())n.push(i.mapper.toViewRange(e));i.writer.setSelection(n,{backward:r.isBackward})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,i)=>{const r=t.selection;if(!r.isCollapsed)return;if(!i.consumable.consume(r,"selection"))return;const n=i.writer,o=r.getFirstPosition(),s=i.mapper.toViewPosition(o),a=n.breakAttributes(s);n.setSelection(a)}),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using((e=>{if("$graveyard"==e.rootName)return null;const t=new Ja(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 _("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 eu{constructor(){this._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 iu(e),this._consumables.set(e,i)),i.add(t))}test(e,t){const i=this._consumables.get(e);return void 0===i?null:e.is("$text")||e.is("documentFragment")?i:i.test(t)}consume(e,t){return!!this.test(e,t)&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!1):this._consumables.get(e).consume(t),!0)}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(t))}static consumablesFromElement(e){const t={element:e,name:!0,attributes:[],classes:[],styles:[]},i=e.getAttributeKeys();for(const e of i)"style"!=e&&"class"!=e&&t.attributes.push(e);const r=e.getClassNames();for(const e of r)t.classes.push(e);const n=e.getStyleNames();for(const e of n)t.styles.push(e);return t}static createFrom(e,t){if(t||(t=new eu),e.is("$text"))return t.add(e),t;e.is("element")&&t.add(e,eu.consumablesFromElement(e)),e.is("documentFragment")&&t.add(e);for(const i of e.getChildren())t=eu.createFrom(i,t);return t}}const tu=["attributes","classes","styles"];class iu{constructor(e){this.element=e,this._canConsumeName=null,this._consumables={attributes:new Map,styles:new Map,classes:new Map}}add(e){e.name&&(this._canConsumeName=!0);for(const t of tu)t in e&&this._add(t,e[t])}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const t of tu)if(t in e){const i=this._test(t,e[t]);if(!0!==i)return i}return!0}consume(e){e.name&&(this._canConsumeName=!1);for(const t of tu)t in e&&this._consume(t,e[t])}revert(e){e.name&&(this._canConsumeName=!0);for(const t of tu)t in e&&this._revert(t,e[t])}_add(e,t){const i=pe(t)?t:[t],r=this._consumables[e];for(const t of i){if("attributes"===e&&("class"===t||"style"===t))throw new _("viewconsumable-invalid-attribute",this);if(r.set(t,!0),"styles"===e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))r.set(e,!0)}}_test(e,t){const i=pe(t)?t:[t],r=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){const e=r.get(t);if(void 0===e)return null;if(!e)return!1}else{const e="class"==t?"classes":"styles",i=this._test(e,[...this._consumables[e].keys()]);if(!0!==i)return i}return!0}_consume(e,t){const i=pe(t)?t:[t],r=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){if(r.set(t,!1),"styles"==e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))r.set(e,!1)}else{const e="class"==t?"classes":"styles";this._consume(e,[...this._consumables[e].keys()])}}_revert(e,t){const i=pe(t)?t:[t],r=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){!1===r.get(t)&&r.set(t,!0)}else{const e="class"==t?"classes":"styles";this._revert(e,[...this._consumables[e].keys()])}}}class ru extends(q()){constructor(){super(),this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",((e,t)=>{t[0]=new nu(t[0])}),{priority:"highest"}),this.on("checkChild",((e,t)=>{t[0]=new nu(t[0]),t[1]=this.getDefinition(t[1])}),{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new _("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 _("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(t,e)}checkAttribute(e,t){const i=this.getDefinition(e.last);return!!i&&i.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof Ql){const t=e.nodeBefore,i=e.nodeAfter;if(!(t instanceof Yl))throw new _("schema-check-merge-no-element-before",this);if(!(i instanceof Yl))throw new _("schema-check-merge-no-element-after",this);return this.checkMerge(t,i)}for(const i of t.getChildren())if(!this.checkChild(e,i))return!1;return!0}addChildCheck(e){this.on("checkChild",((t,[i,r])=>{if(!r)return;const n=e(i,r);"boolean"==typeof n&&(t.stop(),t.return=n)}),{priority:"high"})}addAttributeCheck(e){this.on("checkAttribute",((t,[i,r])=>{const n=e(i,r);"boolean"==typeof n&&(t.stop(),t.return=n)}),{priority:"high"})}setAttributeProperties(e,t){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),t)}getAttributeProperties(e){return this._attributeProperties[e]||{}}getLimitElement(e){let t;if(e instanceof Ql)t=e.parent;else{t=(e instanceof nd?[e]:Array.from(e.getRanges())).reduce(((e,t)=>{const i=t.getCommonAncestor();return e?e.getCommonAncestor(i,{includeSelf:!0}):i}),null)}for(;!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const i=[...e.getFirstPosition().getAncestors(),new Gl("",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){e=function*(e){for(const t of e)yield*t.getMinimalFlatRanges()}(e);for(const i of e)yield*this._getValidRangesForRange(i,t)}getNearestSelectionRange(e,t="both"){if("$graveyard"==e.root.rootName)return null;if(this.checkChild(e,"$text"))return new nd(e);let i,r;const n=e.getAncestors().reverse().find((e=>this.isLimit(e)))||e.root;"both"!=t&&"backward"!=t||(i=new Jl({boundaries:nd._createIn(n),startPosition:e,direction:"backward"})),"both"!=t&&"forward"!=t||(r=new Jl({boundaries:nd._createIn(n),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,r)){const t=e.walker==i?"elementEnd":"elementStart",r=e.value;if(r.type==t&&this.isObject(r.item))return nd._createOn(r.item);if(this.checkChild(r.nextPosition,"$text"))return new nd(r.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 r=i.model;for(const[n,o]of Object.entries(t))r.schema.checkAttribute(e,n)&&i.setAttribute(n,o,e)}removeDisallowedAttributes(e,t){for(const i of e)if(i.is("$text"))bu(this,i,t);else{const e=nd._createIn(i).getPositions();for(const i of e){bu(this,i.nodeBefore||i.parent,t)}}}getAttributesWithProperty(e,t,i){const r={};for(const[n,o]of e.getAttributes()){const e=this.getAttributeProperties(n);void 0!==e[t]&&(void 0!==i&&i!==e[t]||(r[n]=o))}return r}createContext(e){return new nu(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,i=Object.keys(t);for(const r of i)e[r]=ou(t[r],r);for(const t of i)su(e,t);for(const t of i)au(e,t);for(const t of i)cu(e,t);for(const t of i)lu(e,t),du(e,t);for(const t of i)uu(e,t),hu(e,t),mu(e,t);this._compiledDefinitions=e}_checkContextMatch(e,t,i=t.length-1){const r=t.getItem(i);if(e.allowIn.includes(r.name)){if(0==i)return!0;{const e=this.getDefinition(r);return this._checkContextMatch(e,t,i-1)}}return!1}*_getValidRangesForRange(e,t){let i=e.start,r=e.start;for(const n of e.getItems({shallow:!0}))n.is("element")&&(yield*this._getValidRangesForRange(nd._createIn(n),t)),this.checkAttribute(n,t)||(i.isEqual(r)||(yield new nd(i,r)),i=Ql._createAfter(n)),r=Ql._createAfter(n);i.isEqual(r)||(yield new nd(i,r))}}class nu{constructor(e){if(e instanceof nu)return e;let t;t="string"==typeof e?[e]:Array.isArray(e)?e:e.getAncestors({includeSelf:!0}),this._items=t.map(fu)}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 nu([e]);return t._items=[...this._items,...t._items],t}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 ou(e,t){const i={name:t,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],allowChildren:[],inheritTypesFrom:[]};return function(e,t){for(const i of e){const e=Object.keys(i).filter((e=>e.startsWith("is")));for(const r of e)t[r]=!!i[r]}}(e,i),gu(e,i,"allowIn"),gu(e,i,"allowContentOf"),gu(e,i,"allowWhere"),gu(e,i,"allowAttributes"),gu(e,i,"allowAttributesOf"),gu(e,i,"allowChildren"),gu(e,i,"inheritTypesFrom"),function(e,t){for(const i of e){const e=i.inheritAllFrom;e&&(t.allowContentOf.push(e),t.allowWhere.push(e),t.allowAttributesOf.push(e),t.inheritTypesFrom.push(e))}}(e,i),i}function su(e,t){const i=e[t];for(const r of i.allowChildren){const i=e[r];i&&i.allowIn.push(t)}i.allowChildren.length=0}function au(e,t){for(const i of e[t].allowContentOf)if(e[i]){pu(e,i).forEach((e=>{e.allowIn.push(t)}))}delete e[t].allowContentOf}function cu(e,t){for(const i of e[t].allowWhere){const r=e[i];if(r){const i=r.allowIn;e[t].allowIn.push(...i)}}delete e[t].allowWhere}function lu(e,t){for(const i of e[t].allowAttributesOf){const r=e[i];if(r){const i=r.allowAttributes;e[t].allowAttributes.push(...i)}}delete e[t].allowAttributesOf}function du(e,t){const i=e[t];for(const t of i.inheritTypesFrom){const r=e[t];if(r){const e=Object.keys(r).filter((e=>e.startsWith("is")));for(const t of e)t in i||(i[t]=r[t])}}delete i.inheritTypesFrom}function uu(e,t){const i=e[t],r=i.allowIn.filter((t=>e[t]));i.allowIn=Array.from(new Set(r))}function hu(e,t){const i=e[t];for(const r of i.allowIn){e[r].allowChildren.push(t)}}function mu(e,t){const i=e[t];i.allowAttributes=Array.from(new Set(i.allowAttributes))}function gu(e,t,i){for(const r of e){const e=r[i];"string"==typeof e?t[i].push(e):Array.isArray(e)&&t[i].push(...e)}}function pu(e,t){const i=e[t];return(r=e,Object.keys(r).map((e=>r[e]))).filter((e=>e.allowIn.includes(i.name)));var r}function fu(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 bu(e,t,i){for(const r of t.getAttributeKeys())e.checkAttribute(t,r)||i.removeAttribute(r,t)}class wu extends(M()){constructor(e){super(),this._splitParts=new Map,this._cursorParents=new Map,this._modelCursor=null,this._emptyElementsToKeep=new Set,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 r of new nu(e)){const e={};for(const t of r.getAttributeKeys())e[t]=r.getAttribute(t);const n=t.createElement(r.name,e);i&&t.insert(n,i),i=Ql._createAt(n,0)}return i}(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=eu.createFrom(e),this.conversionApi.store={};const{modelRange:r}=this._convertItem(e,this._modelCursor),n=t.createDocumentFragment();if(r){this._removeEmptyElements();for(const e of Array.from(this._modelCursor.parent.getChildren()))t.append(e,n);n.markers=function(e,t){const i=new Set,r=new Map,n=nd._createIn(e).getItems();for(const e of n)e.is("element","$marker")&&i.add(e);for(const e of i){const i=e.getAttribute("data-name"),n=t.createPositionBefore(e);r.has(i)?r.get(i).end=n.clone():r.set(i,new nd(n.clone())),t.remove(e)}return r}(n,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,n}_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 nd))throw new _("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:Ql._createAt(t,0);const r=new nd(i);for(const t of Array.from(e.getChildren())){const e=this._convertItem(t,i);e.modelRange instanceof nd&&(r.end=e.modelRange.end,i=e.modelCursor)}return{modelRange:r,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),r=this.conversionApi.writer;t.modelRange||(t.modelRange=r.createRange(r.createPositionBefore(e),r.createPositionAfter(i[i.length-1])));const n=this._cursorParents.get(e);t.modelCursor=n?r.createPositionAt(n,0):t.modelRange.end}_splitToAllowedParent(e,t){const{schema:i,writer:r}=this.conversionApi;let n=i.findAllowedParent(t,e);if(n){if(n===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(n)&&(n=null)}if(!n)return jd(t,e,i)?{position:zd(t,r)}:null;const o=this.conversionApi.writer.split(t,n),s=[];for(const e of o.range.getWalker())if("elementEnd"==e.type)s.push(e.item);else{const t=s.pop(),i=e.item;this._registerSplitPair(t,i)}const a=o.range.end.parent;return this._cursorParents.set(e,a),{position:o.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(){let e=!1;for(const t of this._splitParts.keys())t.isEmpty&&!this._emptyElementsToKeep.has(t)&&(this.conversionApi.writer.remove(t),this._splitParts.delete(t),e=!0);e&&this._removeEmptyElements()}}class ku{getHtml(e){const t=Nr.document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class vu{constructor(e){this.skipComments=!0,this.domParser=new DOMParser,this.domConverter=new el(e,{renderingMode:"data"}),this.htmlWriter=new ku}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){e.match(/<(?:html|body|head|meta)(?:\s[^>]*)?>/i)||(e=`${e}`);const t=this.domParser.parseFromString(e,"text/html"),i=t.createDocumentFragment(),r=t.body.childNodes;for(;r.length>0;)i.appendChild(r[0]);return i}}class _u extends(M()){constructor(e,t){super(),this.model=e,this.mapper=new od,this.downcastDispatcher=new cd({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const r=i.writer,n=i.mapper.toViewPosition(t.range.start),o=r.createText(t.item.data);r.insert(n,o)}),{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 wu({schema:e.schema}),this.viewDocument=new dc(t),this.stylesProcessor=t,this.htmlProcessor=new vu(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new yc(this.viewDocument),this.upcastDispatcher.on("text",((e,t,{schema:i,consumable:r,writer:n})=>{let o=t.modelCursor;if(!r.test(t.viewItem))return;if(!i.checkChild(o,"$text")){if(!jd(o,"$text",i))return;if(0==t.viewItem.data.trim().length)return;const e=o.nodeBefore;o=zd(o,n),e&&e.is("element","$marker")&&(n.move(n.createRangeOn(e),o),o=n.createPositionAfter(e))}r.consume(t.viewItem);const s=n.createText(t.viewItem.data);n.insert(s,o),t.modelRange=n.createRange(o,o.getShiftedBy(s.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:r}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=r}}),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",((e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:r}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=r}}),{priority:"lowest"}),q().prototype.decorate.call(this,"init"),q().prototype.decorate.call(this,"set"),q().prototype.decorate.call(this,"get"),q().prototype.decorate.call(this,"toView"),q().prototype.decorate.call(this,"toModel"),this.on("init",(()=>{this.fire("ready")}),{priority:"lowest"}),this.on("ready",(()=>{this.model.enqueueChange({isUndoable:!1},Fd)}),{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new _("datacontroller-get-non-existent-root",this);const r=this.model.document.getRoot(t);return r.isAttached()||y("datacontroller-get-detached-root",this),"empty"!==i||this.model.hasContent(r,{ignoreWhitespaces:!0})?this.stringify(r,e):""}stringify(e,t={}){const i=this.toView(e,t);return this.processor.toData(i)}toView(e,t={}){const i=this.viewDocument,r=this._viewWriter;this.mapper.clearBindings();const n=nd._createIn(e),o=new _c(i);this.mapper.bindElements(e,o);const s=e.is("documentFragment")?e.markers:function(e){const t=[],i=e.root.document;if(!i)return new Map;const r=nd._createIn(e);for(const e of i.model.markers){const i=e.getRange(),n=i.isCollapsed,o=i.start.isEqual(r.start)||i.end.isEqual(r.end);if(n&&o)t.push([e.name,i]);else{const n=r.getIntersection(i);n&&t.push([e.name,n])}}return t.sort((([e,t],[i,r])=>{if("after"!==t.end.compareWith(r.start))return 1;if("before"!==t.start.compareWith(r.end))return-1;switch(t.start.compareWith(r.start)){case"before":return 1;case"after":return-1;default:switch(t.end.compareWith(r.end)){case"before":return 1;case"after":return-1;default:return i.localeCompare(e)}}})),new Map(t)}(e);return this.downcastDispatcher.convert(n,s,r,t),o}init(e){if(this.model.document.version)throw new _("datacontroller-init-document-not-empty",this);let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new _("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},(e=>{for(const i of Object.keys(t)){const r=this.model.document.getRoot(i);e.insert(this.parse(t[i],r),r,0)}})),Promise.resolve()}set(e,t={}){let i={};if("string"==typeof e?i.main=e:i=e,!this._checkIfRootsExists(Object.keys(i)))throw new _("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 r=this.model.document.getRoot(t);e.remove(e.createRangeIn(r)),e.insert(this.parse(i[t],r),r,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 yu{constructor(e,t){this._helpers=new Map,this._downcast=yn(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=yn(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 _("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new _("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:i}of xu(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 xu(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 xu(e))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:i}){if(this._helpers.has(e))throw new _("conversion-group-exists",this);const r=i?new Ed(t):new Hd(t);this._helpers.set(e,r)}}function*xu(e){if(e.model.values)for(const t of e.model.values){const i={key:e.model.key,value:t},r=e.view[t],n=e.upcastAlso?e.upcastAlso[t]:void 0;yield*Au(i,r,n)}else yield*Au(e.model,e.view,e.upcastAlso)}function*Au(e,t,i){if(yield{model:e,view:t},i)for(const t of yn(i))yield{model:e,view:t}}class Cu{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 Eu(e,t){const i=Pu(t),r=i.reduce(((e,t)=>e+t.offsetSize),0),n=e.parent;Mu(e);const o=e.index;return n._insertChild(o,i),Iu(n,o+i.length),Iu(n,o),new nd(e,e.getShiftedBy(r))}function Su(e){if(!e.isFlat)throw new _("operation-utils-remove-range-not-flat",this);const t=e.start.parent;Mu(e.start),Mu(e.end);const i=t._removeChildren(e.start.index,e.end.index-e.start.index);return Iu(t,e.start.index),i}function Tu(e,t){if(!e.isFlat)throw new _("operation-utils-move-range-not-flat",this);const i=Su(e);return Eu(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),i)}function Pu(e){const t=[];!function e(i){if("string"==typeof i)t.push(new Gl(i));else if(i instanceof Kl)t.push(new Gl(i.data,i.getAttributes()));else if(i instanceof $l)t.push(i);else if(te(i))for(const t of i)e(t);else{}}(e);for(let e=1;ee.maxOffset)throw new _("move-operation-nodes-do-not-exist",this);if(e===t&&i=i&&this.targetPosition.path[e]e._clone(!0)))),t=new Vu(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new Ql(e,[0]);return new Nu(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffsete._clone(!0)))),Eu(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(Yl.fromJSON(t)):i.push(Gl.fromJSON(t));const r=new Vu(Ql.fromJSON(e.position,t),i,e.baseVersion);return r.shouldReceiveAttributes=e.shouldReceiveAttributes,r}}class Bu extends Cu{constructor(e,t,i,r,n){super(n),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=i,this.graveyardPosition=r?r.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new Ql(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new nd(this.splitPosition,e)}get affectedSelectable(){const e=[nd._createFromPositionAndShift(this.splitPosition,0),nd._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(nd._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new Bu(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new Ql(e,[0]);return new Ru(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset{if(e.key===t.key&&e.range.start.hasSameParentAs(t.range.start)){const r=e.range.getDifference(t.range).map((t=>new Fu(t,e.key,e.oldValue,e.newValue,0))),n=e.range.getIntersection(t.range);return n&&i.aIsStrong&&r.push(new Fu(n,t.key,t.newValue,e.newValue,0)),0==r.length?[new ju(0)]:r}return[e]})),Gu(Fu,Vu,((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 Fu(t,e.key,e.oldValue,e.newValue,e.baseVersion)));if(t.shouldReceiveAttributes){const r=eh(t,e.key,e.oldValue);r&&i.unshift(r)}return i}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]})),Gu(Fu,Ru,((e,t)=>{const i=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&i.push(nd._createFromPositionAndShift(t.graveyardPosition,1));const r=e.range._getTransformedByMergeOperation(t);return r.isCollapsed||i.push(r),i.map((t=>new Fu(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),Gu(Fu,Nu,((e,t)=>{const i=function(e,t){const i=nd._createFromPositionAndShift(t.sourcePosition,t.howMany);let r=null,n=[];i.containsRange(e,!0)?r=e:e.start.hasSameParentAs(i.start)?(n=e.getDifference(i),r=e.getIntersection(i)):n=[e];const o=[];for(let e of n){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const i=t.getMovedRangeStart(),r=e.start.hasSameParentAs(i),n=e._getTransformedByInsertion(i,t.howMany,r);o.push(...n)}r&&o.push(r._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]);return o}(e.range,t);return i.map((t=>new Fu(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),Gu(Fu,Bu,((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 nd(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]})),Gu(Vu,Fu,((e,t)=>{const i=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const r=eh(e,t.key,t.newValue);r&&i.push(r)}return i})),Gu(Vu,Vu,((e,t,i)=>(e.position.isEqual(t.position)&&i.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e]))),Gu(Vu,Nu,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Gu(Vu,Bu,((e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e]))),Gu(Vu,Ru,((e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e]))),Gu(Lu,Vu,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e]))),Gu(Lu,Lu,((e,t,i)=>{if(e.name==t.name){if(!i.aIsStrong)return[new ju(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]})),Gu(Lu,Ru,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e]))),Gu(Lu,Nu,((e,t,i)=>{if(e.oldRange&&(e.oldRange=nd._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){if(i.abRelation){const r=nd._createFromRanges(e.newRange._getTransformedByMoveOperation(t));if("left"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.start))return e.newRange.end=r.end,e.newRange.start.path=i.abRelation.path,[e];if("right"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.end))return e.newRange.start=r.start,e.newRange.end.path=i.abRelation.path,[e]}e.newRange=nd._createFromRanges(e.newRange._getTransformedByMoveOperation(t))}return[e]})),Gu(Lu,Bu,((e,t,i)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(i.abRelation){const r=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)&&i.abRelation.wasStartBeforeMergedElement?e.newRange.start=Ql._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!i.abRelation.wasInLeftElement&&(e.newRange.start=Ql._createAt(t.moveTargetPosition)),e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasInRightElement?e.newRange.end=Ql._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?e.newRange.end=Ql._createAt(t.insertionPosition):e.newRange.end=r.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]})),Gu(Ru,Vu,((e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e]))),Gu(Ru,Ru,((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 Ql(t.graveyardPosition.root,i),e.howMany=0,[e]}return[new ju(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!i.bWasUndone&&"splitAtSource"!=i.abRelation){const r="$graveyard"==e.targetPosition.root.rootName,n="$graveyard"==t.targetPosition.root.rootName;if(n&&!r||!(r&&!n)&&i.aIsStrong){const i=t.targetPosition._getTransformedByMergeOperation(t),r=e.targetPosition._getTransformedByMergeOperation(t);return[new Nu(i,e.howMany,r,0)]}return[new ju(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]})),Gu(Ru,Nu,((e,t,i)=>{const r=nd._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!i.bWasUndone&&!i.forceWeakRemove&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&r.containsPosition(e.sourcePosition)?[new ju(0)]:(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.graveyardPosition.isEqual(t.targetPosition)||(e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)),[e])})),Gu(Ru,Bu,((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)){const r=0!=t.howMany,n=t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition);if(r||n||"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]})),Gu(Nu,Vu,((e,t)=>{const i=nd._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]})),Gu(Nu,Nu,((e,t,i)=>{const r=nd._createFromPositionAndShift(e.sourcePosition,e.howMany),n=nd._createFromPositionAndShift(t.sourcePosition,t.howMany);let o,s=i.aIsStrong,a=!i.aIsStrong;if("insertBefore"==i.abRelation||"insertAfter"==i.baRelation?a=!0:"insertAfter"!=i.abRelation&&"insertBefore"!=i.baRelation||(a=!1),o=e.targetPosition.isEqual(t.targetPosition)&&a?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),th(e,t)&&th(t,e))return[t.getReversed()];if(r.containsPosition(t.targetPosition)&&r.containsRange(n,!0))return r.start=r.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),r.end=r.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),ih([r],o);if(n.containsPosition(e.targetPosition)&&n.containsRange(r,!0))return r.start=r.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),r.end=r.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),ih([r],o);const c=ee(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==c||"extension"==c)return r.start=r.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),r.end=r.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),ih([r],o);"remove"!=e.type||"remove"==t.type||i.aWasUndone||i.forceWeakRemove?"remove"==e.type||"remove"!=t.type||i.bWasUndone||i.forceWeakRemove||(s=!1):s=!0;const l=[],d=r.getDifference(n);for(const e of d){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const i="same"==ee(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),r=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,i);l.push(...r)}const u=r.getIntersection(n);return null!==u&&s&&(u.start=u.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),u.end=u.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===l.length?l.push(u):1==l.length?n.start.isBefore(r.start)||n.start.isEqual(r.start)?l.unshift(u):l.push(u):l.splice(1,0,u)),0===l.length?[new ju(e.baseVersion)]:ih(l,o)})),Gu(Nu,Bu,((e,t,i)=>{let r=e.targetPosition.clone();e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=i.abRelation||(r=e.targetPosition._getTransformedBySplitOperation(t));const n=nd._createFromPositionAndShift(e.sourcePosition,e.howMany);if(n.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.howMany++,e.targetPosition=r,[e];if(n.start.hasSameParentAs(t.splitPosition)&&n.containsPosition(t.splitPosition)){let e=new nd(t.splitPosition,n.end);e=e._getTransformedBySplitOperation(t);return ih([new nd(n.start,t.splitPosition),e],r)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==i.abRelation&&(r=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==i.abRelation&&(r=e.targetPosition);const o=[n._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const r=n.start.isEqual(t.graveyardPosition)||n.containsPosition(t.graveyardPosition);e.howMany>1&&r&&!i.aWasUndone&&o.push(nd._createFromPositionAndShift(t.insertionPosition,1))}return ih(o,r)})),Gu(Nu,Ru,((e,t,i)=>{const r=nd._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&r.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 ju(0)]}else if(!i.aWasUndone){const i=[];let r=t.graveyardPosition.clone(),n=t.targetPosition._getTransformedByMergeOperation(t);e.howMany>1&&(i.push(new Nu(e.sourcePosition,e.howMany-1,e.targetPosition,0)),r=r._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1),n=n._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1));const o=t.deletionPosition._getCombined(e.sourcePosition,e.targetPosition),s=new Nu(r,1,o,0),a=s.getMovedRangeStart().path.slice();a.push(0);const c=new Ql(s.targetPosition.root,a);n=n._getTransformedByMove(r,o,1);const l=new Nu(n,t.howMany,c,0);return i.push(s),i.push(l),i}const n=nd._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByMergeOperation(t);return e.sourcePosition=n.start,e.howMany=n.end.offset-n.start.offset,e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]})),Gu(zu,Vu,((e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e]))),Gu(zu,Ru,((e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e]))),Gu(zu,Nu,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Gu(zu,zu,((e,t,i)=>{if(e.position.isEqual(t.position)){if(!i.aIsStrong)return[new ju(0)];e.oldName=t.newName}return[e]})),Gu(zu,Bu,((e,t)=>{if("same"==ee(e.position.path,t.splitPosition.getParentPath())&&!t.graveyardPosition){const t=new zu(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]})),Gu(Hu,Hu,((e,t,i)=>{if(e.root===t.root&&e.key===t.key){if(!i.aIsStrong||e.newValue===t.newValue)return[new ju(0)];e.oldValue=t.newValue}return[e]})),Gu(Uu,Uu,((e,t)=>e.rootName===t.rootName&&e.isAdd===t.isAdd?[new ju(0)]:[e])),Gu(Bu,Vu,((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 r=new Ql(t.graveyardPosition.root,i),n=Bu.getInsertionPosition(new Ql(t.graveyardPosition.root,i)),o=new Bu(r,0,n,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Bu.getInsertionPosition(e.splitPosition),e.graveyardPosition=o.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[o,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=Bu.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),Gu(Bu,Nu,((e,t,i)=>{const r=nd._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const n=r.start.isEqual(e.graveyardPosition)||r.containsPosition(e.graveyardPosition);if(!i.bWasUndone&&n){const i=e.splitPosition._getTransformedByMoveOperation(t),r=e.graveyardPosition._getTransformedByMoveOperation(t),n=r.path.slice();n.push(0);const o=new Ql(r.root,n);return[new Nu(i,e.howMany,o,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const n=e.splitPosition.isEqual(t.targetPosition);if(n&&("insertAtSource"==i.baRelation||"splitBefore"==i.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=Bu.getInsertionPosition(e.splitPosition),[e];if(n&&i.abRelation&&i.abRelation.howMany){const{howMany:t,offset:r}=i.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(r),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&r.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 ju(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new ju(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 r="$graveyard"==e.splitPosition.root.rootName,n="$graveyard"==t.splitPosition.root.rootName;if(n&&!r||!(r&&!n)&&i.aIsStrong){const i=[];return t.howMany&&i.push(new Nu(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&i.push(new Nu(e.splitPosition,e.howMany,e.moveTargetPosition,0)),i}return[new ju(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 r=new Ql(t.insertionPosition.root,i);return[e,new Nu(e.insertionPosition,1,r,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset{const i=t[0];i.isDocumentOperation&&oh.call(this,i)}),{priority:"low"})}function oh(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)}}rh.prototype.is=function(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e};class sh{constructor(e={}){"string"==typeof e&&(e="transparent"===e?{isUndoable:!1}:{},y("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:i=!0,isUndo:r=!1,isTyping:n=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=i,this.isUndo=r,this.isTyping=n}get type(){return y("batch-type-deprecated"),"default"}get baseVersion(){for(const e of this.operations)if(null!==e.baseVersion)return e.baseVersion;return null}addOperation(e){return e.batch=this,this.operations.push(e),e}}class ah{constructor(e){this._changesInElement=new Map,this._elementSnapshots=new Map,this._changedMarkers=new Map,this._changedRoots=new Map,this._changeCount=0,this._cachedChanges=null,this._cachedChangesWithGraveyard=null,this._refreshedItems=new Set,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);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=nd._createFromPositionAndShift(t.position,1);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getData();this.bufferMarkerChange(t.name,e,e)}break}case"split":{const e=t.splitPosition.parent;this._isInInsertedElement(e)||this._markRemove(e,t.splitPosition.offset,t.howMany),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);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);const r=t.targetPosition.parent;this._isInInsertedElement(r)||this._markInsert(r,t.targetPosition.offset,e.maxOffset);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 r=this._changedMarkers.get(e);r?r.newMarkerData=i:(r={newMarkerData:i,oldMarkerData:t},this._changedMarkers.set(e,r)),null==r.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._changesInElement.size>0)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,r=!e.range&&t.range,n=e.range&&t.range&&!e.range.isEqual(t.range);if(i||r||n)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(dh),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._elementSnapshots.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems=new Set,this._cachedChanges=null}_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,r){const n=this._changedRoots.get(e)||{name:e},o=n.attributes||{};if(o[t]){const e=o[t];r===e.oldValue?delete o[t]:e.newValue=r}else o[t]={oldValue:i,newValue:r};0===Object.entries(o).length?(delete n.attributes,void 0===n.state&&this._changedRoots.delete(e)):(n.attributes=o,this._changedRoots.set(e,n))}_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);const t=nd._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)}}}_markInsert(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const r={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,r)}_markRemove(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const r={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,r),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._makeSnapshot(e);const i=this._getChangesForElement(e);this._handleChange(t,i),i.push(t);for(let e=0;ei.offset){if(r>n){const e={type:"attribute",offset:n,howMany:r-n,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.offsetn?(e.nodesToHandle=r-n,e.offset=n):e.nodesToHandle=0);if("remove"==i.type&&e.offseti.offset){const n={type:"attribute",offset:i.offset,howMany:r-i.offset,count:this._changeCount++};this._handleChange(n,t),t.push(n),e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==i.type&&(e.offset>=i.offset&&r<=n?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=i.offset&&r>=n&&(i.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,i){return{type:"insert",position:Ql._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++}}_getRemoveDiff(e,t,i){return{type:"remove",position:Ql._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,i){const r=[];i=new Map(i);for(const[n,o]of t){const t=i.has(n)?i.get(n):null;t!==o&&r.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:n,attributeOldValue:o,attributeNewValue:t,changeCount:this._changeCount++}),i.delete(n)}for(const[t,n]of i)r.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:n,changeCount:this._changeCount++});return r}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const i=this._changesInElement.get(t),r=e.startOffset;if(i)for(const e of i)if("insert"==e.type&&r>=e.offset&&rr){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 _("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 r=t-1;for(const[t,i]of this._gaps)e>t&&et&&rthis.lastOperation.baseVersion)return[];let n=this._baseVersionToOperationIndex.get(e);void 0===n&&(n=0);let o=this._baseVersionToOperationIndex.get(r);return void 0===o&&(o=this._operations.length-1),this._operations.slice(n,o+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 hh extends Yl{constructor(e,t,i="main"){super(t),this._isAttached=!0,this._isLoaded=!0,this._document=e,this.rootName=i}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}hh.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 mh="$graveyard";class gh extends(M()){constructor(e){super(),this.model=e,this.history=new uh,this.selection=new yd(this),this.roots=new Cn({idProperty:"rootName"}),this.differ=new ah(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",mh),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,r,n)=>{const o={...t.getData(),range:r};this.differ.bufferMarkerChange(t.name,n,o),null===i&&t.on("change",((e,i)=>{const r=t.getData();this.differ.bufferMarkerChange(t.name,{...r,range:i},r)}))})),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(mh)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new _("model-document-createroot-name-exists",this,{name:t});const i=new hh(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=zs(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){const e=this.getRoots();return e.length?e[0]:this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,i=t.schema,r=t.createPositionFromPath(e,[0]);return i.getNearestSelectionRange(r)||t.createRange(r)}_validateSelectionRange(e){return ph(e.start)&&ph(e.end)}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(this.selection.refresh(),t=i(e),t)break}while(t)}}function ph(e){const t=e.textNode;if(t){const i=t.data,r=e.offset-t.startOffset;return!Mn(i,r)&&!On(i,r)}return!0}class fh extends(M()){constructor(){super(...arguments),this._markers=new Map}[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof bh?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,i=!1,r=!1){const n=e instanceof bh?e.name:e;if(n.includes(","))throw new _("markercollection-incorrect-marker-name",this);const o=this._markers.get(n);if(o){const e=o.getData(),s=o.getRange();let a=!1;return s.isEqual(t)||(o._attachLiveRange(wd.fromRange(t)),a=!0),i!=o.managedUsingOperations&&(o._managedUsingOperations=i,a=!0),"boolean"==typeof r&&r!=o.affectsData&&(o._affectsData=r,a=!0),a&&this.fire(`update:${n}`,o,s,t,e),o}const s=wd.fromRange(t),a=new bh(n,s,i,r);return this._markers.set(n,a),this.fire(`update:${n}`,a,null,t,{...a.getData(),range:null}),a}_remove(e){const t=e instanceof bh?e.name:e,i=this._markers.get(t);return!!i&&(this._markers.delete(t),this.fire(`update:${t}`,i,i.getRange(),null,i.getData()),this._destroyMarker(i),!0)}_refresh(e){const t=e instanceof bh?e.name:e,i=this._markers.get(t);if(!i)throw new _("markercollection-refresh-marker-not-exists",this);const r=i.getRange();this.fire(`update:${t}`,i,r,r,i.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)null!==t.getRange().getIntersection(e)&&(yield t)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}class bh extends(M(Wl)){constructor(e,t,i,r){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=i,this._affectsData=r}get managedUsingOperations(){if(!this._liveRange)throw new _("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new _("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new _("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new _("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new _("marker-destroyed",this);return this._liveRange.toRange()}_attachLiveRange(e){return this._liveRange&&this._detachLiveRange(),e.delegate("change:range").to(this),e.delegate("change:content").to(this),this._liveRange=e,e}_detachLiveRange(){this._liveRange.stopDelegating("change:range",this),this._liveRange.stopDelegating("change:content",this),this._liveRange.detach(),this._liveRange=null}}bh.prototype.is=function(e){return"marker"===e||"model:marker"===e};class wh extends Cu{constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}get type(){return"detach"}get affectedSelectable(){return null}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new _("detach-operation-on-document-node",this)}_execute(){Su(nd._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class kh extends Wl{constructor(e){super(),this.markers=new Map,this._children=new ql,e&&this._insertChild(0,e)}[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}get nextSibling(){return null}get previousSibling(){return null}get root(){return this}get parent(){return null}get document(){return null}isAttached(){return!1}getAncestors(){return[]}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(const i of e)t=t.getChild(t.offsetToIndex(i));return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const i of e)i.name?t.push(Yl.fromJSON(i)):t.push(Gl.fromJSON(i));return new kh(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){if("string"==typeof e)return[new Gl(e)];te(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Gl(e):e instanceof Kl?new Gl(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}}kh.prototype.is=function(e){return"documentFragment"===e||"model:documentFragment"===e};class vh{constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new Gl(e,t)}createElement(e,t){return new Yl(e,t)}createDocumentFragment(){return new kh}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,i=0){if(this._assertWriterUsedCorrectly(),e instanceof Gl&&""==e.data)return;const r=Ql._createAt(t,i);if(e.parent){if(Ch(e.root,r.root))return void this.move(nd._createOn(e),r);if(e.root.document)throw new _("model-writer-insert-forbidden-move",this);this.remove(e)}const n=r.root.document?r.root.document.version:null,o=new Vu(r,e,n);if(e instanceof Gl&&(o.shouldReceiveAttributes=!0),this.batch.addOperation(o),this.model.applyOperation(o),e instanceof kh)for(const[t,i]of e.markers){const e=Ql._createAt(i.root,0),n={range:new nd(i.start._getCombined(e,r),i.end._getCombined(e,r)),usingOperation:!0,affectsData:!0};this.model.markers.has(t)?this.updateMarker(t,n):this.addMarker(t,n)}}insertText(e,t,i,r){t instanceof kh||t instanceof Yl||t instanceof Ql?this.insert(this.createText(e),t,i):this.insert(this.createText(e,t),i,r)}insertElement(e,t,i,r){t instanceof kh||t instanceof Yl||t instanceof Ql?this.insert(this.createElement(e),t,i):this.insert(this.createElement(e,t),i,r)}append(e,t){this.insert(e,t,"end")}appendText(e,t,i){t instanceof kh||t instanceof Yl?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),i,"end")}appendElement(e,t,i){t instanceof kh||t instanceof Yl?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),i,"end")}setAttribute(e,t,i){if(this._assertWriterUsedCorrectly(),i instanceof nd){const r=i.getMinimalFlatRanges();for(const i of r)_h(this,e,t,i)}else yh(this,e,t,i)}setAttributes(e,t){for(const[i,r]of Pn(e))this.setAttribute(i,r,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof nd){const i=t.getMinimalFlatRanges();for(const t of i)_h(this,e,null,t)}else yh(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=e=>{for(const t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof nd)for(const i of e.getItems())t(i);else t(e)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof nd))throw new _("writer-move-invalid-range",this);if(!e.isFlat)throw new _("writer-move-range-not-flat",this);const r=Ql._createAt(t,i);if(r.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!Ch(e.root,r.root))throw new _("writer-move-different-document",this);const n=e.root.document?e.root.document.version:null,o=new Nu(e.start,e.end.offset-e.start.offset,r,n);this.batch.addOperation(o),this.model.applyOperation(o)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof nd?e:nd._createOn(e)).getMinimalFlatRanges().reverse();for(const e of t)this._addOperationForAffectedMarkers("move",e),Ah(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 Yl))throw new _("writer-merge-no-element-before",this);if(!(i instanceof Yl))throw new _("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(nd._createIn(i),Ql._createAt(t,"end")),this.remove(i)}_merge(e){const t=Ql._createAt(e.nodeBefore,"end"),i=Ql._createAt(e.nodeAfter,0),r=e.root.document.graveyard,n=new Ql(r,[0]),o=e.root.document.version,s=new Ru(i,e.nodeAfter.maxOffset,t,n,o);this.batch.addOperation(s),this.model.applyOperation(s)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof Yl))throw new _("writer-rename-not-element-instance",this);const i=e.root.document?e.root.document.version:null,r=new zu(Ql._createBefore(e),e.name,t,i);this.batch.addOperation(r),this.model.applyOperation(r)}split(e,t){this._assertWriterUsedCorrectly();let i,r,n=e.parent;if(!n.parent)throw new _("writer-split-element-no-parent",this);if(t||(t=n.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new _("writer-split-invalid-limit-element",this);do{const t=n.root.document?n.root.document.version:null,o=n.maxOffset-e.offset,s=Bu.getInsertionPosition(e),a=new Bu(e,o,s,null,t);this.batch.addOperation(a),this.model.applyOperation(a),i||r||(i=n,r=e.parent.nextSibling),n=(e=this.createPositionAfter(e.parent)).parent}while(n!==t);return{position:e,range:new nd(Ql._createAt(i,"end"),Ql._createAt(r,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new _("writer-wrap-range-not-flat",this);const i=t instanceof Yl?t:new Yl(t);if(i.childCount>0)throw new _("writer-wrap-element-not-empty",this);if(null!==i.parent)throw new _("writer-wrap-element-attached",this);this.insert(i,e.start);const r=new nd(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(r,Ql._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new _("writer-unwrap-element-no-parent",this);this.move(nd._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new _("writer-addmarker-no-usingoperation",this);const i=t.usingOperation,r=t.range,n=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new _("writer-addmarker-marker-exists",this);if(!r)throw new _("writer-addmarker-no-range",this);return i?(xh(this,e,null,r,n),this.model.markers.get(e)):this.model.markers._set(e,r,i,n)}updateMarker(e,t){this._assertWriterUsedCorrectly();const i="string"==typeof e?e:e.name,r=this.model.markers.get(i);if(!r)throw new _("writer-updatemarker-marker-not-exists",this);if(!t)return y("writer-updatemarker-reconvert-using-editingcontroller",{markerName:i}),void this.model.markers._refresh(r);const n="boolean"==typeof t.usingOperation,o="boolean"==typeof t.affectsData,s=o?t.affectsData:r.affectsData;if(!n&&!t.range&&!o)throw new _("writer-updatemarker-wrong-options",this);const a=r.getRange(),c=t.range?t.range:a;n&&t.usingOperation!==r.managedUsingOperations?t.usingOperation?xh(this,i,null,c,s):(xh(this,i,a,null,s),this.model.markers._set(i,c,void 0,s)):r.managedUsingOperations?xh(this,i,a,c,s):this.model.markers._set(i,c,void 0,s)}removeMarker(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new _("writer-removemarker-no-marker",this);const i=this.model.markers.get(t);if(!i.managedUsingOperations)return void this.model.markers._remove(t);xh(this,t,i.getRange(),null,i.affectsData)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const i=this.model.document.getRoot(e);if(i&&i.isAttached())throw new _("writer-addroot-root-exists",this);const r=this.model.document,n=new Uu(e,t,!0,r,r.version);return this.batch.addOperation(n),this.model.applyOperation(n),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 _("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,r=new Uu(t.rootName,t.name,!1,i,i.version);this.batch.addOperation(r),this.model.applyOperation(r)}setSelection(...e){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...e)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._setSelectionAttribute(e,t);else for(const[t,i]of Pn(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 r=yd._getStoreAttributeKey(e);this.setAttribute(r,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=yd._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new _("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const i of this.model.markers){if(!i.managedUsingOperations)continue;const r=i.getRange();let n=!1;if("move"===e){const e=t;n=e.containsPosition(r.start)||e.start.isEqual(r.start)||e.containsPosition(r.end)||e.end.isEqual(r.end)}else{const e=t,i=e.nodeBefore,o=e.nodeAfter,s=r.start.parent==i&&r.start.isAtEnd,a=r.end.parent==o&&0==r.end.offset,c=r.end.nodeAfter==o,l=r.start.nodeAfter==o;n=s||a||c||l}n&&this.updateMarker(i.name,{range:r})}}}function _h(e,t,i,r){const n=e.model,o=n.document;let s,a,c,l=r.start;for(const e of r.getWalker({shallow:!0}))c=e.item.getAttribute(t),s&&a!=c&&(a!=i&&d(),l=s),s=e.nextPosition,a=c;function d(){const r=new nd(l,s),c=r.root.document?o.version:null,d=new Fu(r,t,a,i,c);e.batch.addOperation(d),n.applyOperation(d)}s instanceof Ql&&s!=l&&a!=i&&d()}function yh(e,t,i,r){const n=e.model,o=n.document,s=r.getAttribute(t);let a,c;if(s!=i){if(r.root===r){const e=r.document?o.version:null;c=new Hu(r,t,s,i,e)}else{a=new nd(Ql._createBefore(r),e.createPositionAfter(r));const n=a.root.document?o.version:null;c=new Fu(a,t,s,i,n)}e.batch.addOperation(c),n.applyOperation(c)}}function xh(e,t,i,r,n){const o=e.model,s=o.document,a=new Lu(t,i,r,o.markers,!!n,s.version);e.batch.addOperation(a),o.applyOperation(a)}function Ah(e,t,i,r){let n;if(e.root.document){const i=r.document,o=new Ql(i.graveyard,[0]);n=new Nu(e,t,o,i.version)}else n=new wh(e,t);i.addOperation(n),r.applyOperation(n)}function Ch(e,t){return e===t||e instanceof hh&&t instanceof hh}function Eh(e,t,i={}){if(t.isCollapsed)return;const r=t.getFirstRange();if("$graveyard"==r.root.rootName)return;const n=e.schema;e.change((e=>{if(!i.doNotResetEntireContent&&function(e,t){const i=e.getLimitElement(t);if(!t.containsEntireContent(i))return!1;const r=t.getFirstRange();if(r.start.parent==r.end.parent)return!1;return e.checkChild(i,"paragraph")}(n,t))return void function(e,t){const i=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(i)),Ih(e,e.createPositionAt(i,0),t)}(e,t);const o={};if(!i.doNotAutoparagraph){const e=t.getSelectedElement();e&&Object.assign(o,n.getAttributesWithProperty(e,"copyOnReplace",!0))}const[s,a]=function(e){const t=e.root.document.model,i=e.start;let r=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){const i=function(e){const t=e.parent,i=t.root.document.model.schema,r=t.getAncestors({parentFirst:!0,includeSelf:!0});for(const e of r){if(i.isLimit(e))return null;if(i.isBlock(e))return e}}(r);if(i&&r.isTouching(t.createPositionAt(i,0))){const i=t.createSelection(e);t.modifySelection(i,{direction:"backward"});const n=i.getLastPosition(),o=t.createRange(n,r);t.hasContent(o,{ignoreMarkers:!0})||(r=n)}}return[rh.fromPosition(i,"toPrevious"),rh.fromPosition(r,"toNext")]}(r);s.isTouching(a)||e.remove(e.createRange(s,a)),i.leaveUnmerged||(!function(e,t,i){const r=e.model;if(!Ph(e.model.schema,t,i))return;const[n,o]=function(e,t){const i=e.getAncestors(),r=t.getAncestors();let n=0;for(;i[n]&&i[n]==r[n];)n++;return[i[n],r[n]]}(t,i);if(!n||!o)return;!r.hasContent(n,{ignoreMarkers:!0})&&r.hasContent(o,{ignoreMarkers:!0})?Th(e,t,i,n.parent):Sh(e,t,i,n.parent)}(e,s,a),n.removeDisallowedAttributes(s.parent.getChildren(),e)),Mh(e,t,s),!i.doNotAutoparagraph&&function(e,t){const i=e.checkChild(t,"$text"),r=e.checkChild(t,"paragraph");return!i&&r}(n,s)&&Ih(e,s,t,o),s.detach(),a.detach()}))}function Sh(e,t,i,r){const n=t.parent,o=i.parent;if(n!=r&&o!=r){for(t=e.createPositionAfter(n),(i=e.createPositionBefore(o)).isEqual(t)||e.insert(o,t),e.merge(t);i.parent.isEmpty;){const t=i.parent;i=e.createPositionBefore(t),e.remove(t)}Ph(e.model.schema,t,i)&&Sh(e,t,i,r)}}function Th(e,t,i,r){const n=t.parent,o=i.parent;if(n!=r&&o!=r){for(t=e.createPositionAfter(n),(i=e.createPositionBefore(o)).isEqual(t)||e.insert(n,i);t.parent.isEmpty;){const i=t.parent;t=e.createPositionBefore(i),e.remove(i)}i=e.createPositionBefore(o),function(e,t){const i=t.nodeBefore,r=t.nodeAfter;i.name!=r.name&&e.rename(i,r.name);e.clearAttributes(i),e.setAttributes(Object.fromEntries(r.getAttributes()),i),e.merge(t)}(e,i),Ph(e.model.schema,t,i)&&Th(e,t,i,r)}}function Ph(e,t,i){const r=t.parent,n=i.parent;return r!=n&&(!e.isLimit(r)&&!e.isLimit(n)&&function(e,t,i){const r=new nd(e,t);for(const e of r.getWalker())if(i.isLimit(e.item))return!1;return!0}(t,i,e))}function Ih(e,t,i,r={}){const n=e.createElement("paragraph");e.model.schema.setAllowedAttributes(n,r,e),e.insert(n,t),Mh(e,i,e.createPositionAt(n,0))}function Mh(e,t,i){t instanceof yd?e.setSelection(i):t.setTo(i)}function Oh(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 Nh{constructor(e,t,i){this._firstNode=null,this._lastNode=null,this._lastAutoParagraph=null,this._filterAttributesOf=[],this._affectedStart=null,this._affectedEnd=null,this._nodeToSelect=null,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))this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),i=this.writer.createPositionAfter(e);if(i.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new _("insertcontent-invalid-insertion-position",this);this.position=i,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?nd._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new nd(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(e){if(this.schema.isObject(e))return void this._handleObject(e);let t=this._checkAndAutoParagraphToAllowedPosition(e);t||(t=this._checkAndSplitToAllowedPosition(e),t)?(this._appendToFragment(e),this._firstNode||(this._firstNode=e),this._lastNode=e):this._handleDisallowedNode(e)}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const e=rh.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()}_handleObject(e){this._checkAndSplitToAllowedPosition(e)?this._appendToFragment(e):this._tryAutoparagraphing(e)}_handleDisallowedNode(e){e.is("element")?this.handleNodes(e.getChildren()):this._tryAutoparagraphing(e)}_appendToFragment(e){if(!this.schema.checkChild(this.position,e))throw new _("insertcontent-wrong-position",this,{node:e,position:this.position});this.writer.insert(e,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(e.offsetSize),this.schema.isObject(e)&&!this.schema.checkChild(this.position,"$text")?this._nodeToSelect=e:this._nodeToSelect=null,this._filterAttributesOf.push(e)}_setAffectedBoundaries(e){this._affectedStart||(this._affectedStart=rh.fromPosition(e,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(e)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=rh.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof Yl))return;if(!this._canMergeLeft(e))return;const t=rh._createBefore(e);t.stickiness="toNext";const i=rh.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=rh._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=rh._createAt(t.nodeBefore,"end","toNext")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof Yl))return;if(!this._canMergeRight(e))return;const t=rh._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new _("insertcontent-invalid-insertion-position",this);this.position=Ql._createAt(t.nodeBefore,"end");const i=rh.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=rh._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=rh._createAt(t.nodeBefore,0,"toPrevious")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof Yl&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof Yl&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(e,t)}_tryAutoparagraphing(e){const t=this.writer.createElement("paragraph");this._getAllowedIn(this.position.parent,t)&&this.schema.checkChild(t,e)&&(t._appendChild(e),this._handleNode(t))}_checkAndAutoParagraphToAllowedPosition(e){if(this.schema.checkChild(this.position.parent,e))return!0;if(!this.schema.checkChild(this.position.parent,"paragraph")||!this.schema.checkChild("paragraph",e))return!1;this._insertPartialFragment();const t=this.writer.createElement("paragraph");return this.writer.insert(t,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=t,this.position=this.writer.createPositionAt(t,0),!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!0}_getAllowedIn(e,t){return this.schema.checkChild(e,t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}}function Vh(e,t,i="auto"){const r=e.getSelectedElement();if(r&&t.schema.isObject(r)&&!t.schema.isInline(r))return"before"==i||"after"==i?t.createRange(t.createPositionAt(r,i)):t.createRangeOn(r);const n=En(e.getSelectedBlocks());if(!n)return t.createRange(e.focus);if(n.isEmpty)return t.createRange(t.createPositionAt(n,0));const o=t.createPositionAfter(n);return e.focus.isTouching(o)?t.createRange(o):t.createRange(t.createPositionBefore(n))}function Bh(e,t,i,r={}){if(!e.schema.isObject(t))throw new _("insertobject-element-not-an-object",e,{object:t});const n=i||e.document.selection;let o=n;r.findOptimalPosition&&e.schema.isBlock(t)&&(o=e.createSelection(Vh(n,e,r.findOptimalPosition)));const s=En(n.getSelectedBlocks()),a={};return s&&Object.assign(a,e.schema.getAttributesWithProperty(s,"copyOnReplace",!0)),e.change((i=>{o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0});let n=t;const s=o.anchor.parent;!e.schema.checkChild(s,t)&&e.schema.checkChild(s,"paragraph")&&e.schema.checkChild("paragraph",t)&&(n=i.createElement("paragraph"),i.insert(t,n)),e.schema.setAllowedAttributes(n,a,i);const c=e.insertContent(n,o);return c.isCollapsed||r.setSelection&&function(e,t,i,r){const n=e.model;if("on"==i)return void e.setSelection(t,"on");if("after"!=i)throw new _("insertobject-invalid-place-parameter-value",n);let o=t.nextSibling;if(n.schema.isInline(t))return void e.setSelection(t,"after");const s=o&&n.schema.checkChild(o,"$text");!s&&n.schema.checkChild(t.parent,"paragraph")&&(o=e.createElement("paragraph"),n.schema.setAllowedAttributes(o,r,e),n.insertContent(o,e.createPositionAfter(t)));o&&e.setSelection(o,0)}(i,t,r.setSelection,a),c}))}function Rh(e,t){const{isForward:i,walker:r,unit:n,schema:o,treatEmojiAsSingleUnit:s}=e,{type:a,item:c,nextPosition:l}=t;if("text"==a)return"word"===e.unit?function(e,t){let i=e.position.textNode;i||(i=t?e.position.nodeAfter:e.position.nodeBefore);for(;i&&i.is("$text");){const r=e.position.offset-i.startOffset;if(Fh(i,r,t))i=t?e.position.nodeAfter:e.position.nodeBefore;else{if(Dh(i.data,r,t))break;e.next()}}return e.position}(r,i):function(e,t,i){const r=e.position.textNode;if(r){const n=r.data;let o=e.position.offset-r.startOffset;for(;Mn(n,o)||"character"==t&&On(n,o)||i&&Vn(n,o);)e.next(),o=e.position.offset-r.startOffset}return e.position}(r,n,s);if(a==(i?"elementStart":"elementEnd")){if(o.isSelectable(c))return Ql._createAt(c,i?"after":"before");if(o.checkChild(l,"$text"))return l}else{if(o.isLimit(c))return void r.skip((()=>!0));if(o.checkChild(l,"$text"))return l}}function Lh(e,t){const i=e.root,r=Ql._createAt(i,t?"end":0);return t?new nd(e,r):new nd(r,e)}function Dh(e,t,i){const r=t+(i?0:-1);return' ,.?!:;"-()'.includes(e.charAt(r))}function Fh(e,t,i){return t===(i?e.offsetSize:0)}class jh extends(q()){constructor(){super(),this.markers=new fh,this.document=new gh(this),this.schema=new ru,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(((e,t)=>{if("$marker"===t.name)return!0})),Yd(this),this.document.registerPostFixer(Fd),this.on("insertContent",((e,[t,i])=>{e.return=function(e,t,i){return e.change((r=>{const n=i||e.document.selection;n.isCollapsed||e.deleteContent(n,{doNotAutoparagraph:!0});const o=new Nh(e,r,n.anchor),s=[];let a;if(t.is("documentFragment")){if(t.markers.size){const e=[];for(const[i,r]of t.markers){const{start:t,end:n}=r,o=t.isEqual(n);e.push({position:t,name:i,isCollapsed:o},{position:n,name:i,isCollapsed:o})}e.sort((({position:e},{position:t})=>e.isBefore(t)?1:-1));for(const{position:i,name:n,isCollapsed:o}of e){let e=null,a=null;const c=i.parent===t&&i.isAtStart,l=i.parent===t&&i.isAtEnd;c||l?o&&(a=c?"start":"end"):(e=r.createElement("$marker"),r.insert(e,i)),s.push({name:n,element:e,collapsed:a})}}a=t.getChildren()}else a=[t];o.handleNodes(a);let c=o.getSelectionRange();if(t.is("documentFragment")&&s.length){const e=c?wd.fromRange(c):null,t={};for(let e=s.length-1;e>=0;e--){const{name:i,element:n,collapsed:a}=s[e],c=!t[i];if(c&&(t[i]=[]),n){const e=r.createPositionAt(n,"before");t[i].push(e),r.remove(n)}else{const e=o.getAffectedRange();if(!e){a&&t[i].push(o.position);continue}a?t[i].push(e[a]):t[i].push(c?e.start:e.end)}}for(const[e,[i,n]]of Object.entries(t))i&&n&&i.root===n.root&&r.addMarker(e,{usingOperation:!0,affectsData:!0,range:new nd(i,n)});e&&(c=e.toRange(),e.detach())}c&&(n instanceof yd?r.setSelection(c):n.setTo(c));const l=o.getAffectedRange()||e.createRange(n.anchor);return o.destroy(),l}))}(this,t,i)})),this.on("insertObject",((e,[t,i,r])=>{e.return=Bh(this,t,i,r)})),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 sh,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(e){_.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{e?"function"==typeof e?(t=e,e=new sh):e instanceof sh||(e=new sh(e)):e=new sh,this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(e){_.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,i,...r){const n=zh(t,i);return this.fire("insertContent",[e,n,i,...r])}insertObject(e,t,i,r,...n){const o=zh(t,i);return this.fire("insertObject",[e,o,r,r,...n])}deleteContent(e,t){Eh(this,e,t)}modifySelection(e,t){!function(e,t,i={}){const r=e.schema,n="backward"!=i.direction,o=i.unit?i.unit:"character",s=!!i.treatEmojiAsSingleUnit,a=t.focus,c=new Jl({boundaries:Lh(a,n),singleCharacters:!0,direction:n?"forward":"backward"}),l={walker:c,schema:r,isForward:n,unit:o,treatEmojiAsSingleUnit:s};let d;for(;d=c.next();){if(d.done)return;const i=Rh(l,d.value);if(i)return void(t instanceof yd?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(),r=t.getFirstRange();if(!r||r.isCollapsed)return i;const n=r.start.root,o=r.start.getCommonPath(r.end),s=n.getNodeByPath(o);let a;a=r.start.parent==r.end.parent?r:e.createRange(e.createPositionAt(s,r.start.path[o.length]),e.createPositionAt(s,r.end.path[o.length]+1));const c=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!=r){const t=r._getTransformedByMove(a.start,e.createPositionAt(i,0),c)[0],n=e.createRange(e.createPositionAt(i,0),t.start);Oh(e.createRange(t.end,e.createPositionAt(i,"end")),e),Oh(n,e)}return i}))}(this,e)}hasContent(e,t={}){const i=e instanceof nd?e:nd._createIn(e);if(i.isCollapsed)return!1;const{ignoreWhitespaces:r=!1,ignoreMarkers:n=!1}=t;if(!n)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(!r)return!0;if(-1!==e.data.search(/\S/))return!0}return!1}canEditAt(e){const t=zh(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,i){return new Ql(e,t,i)}createPositionAt(e,t){return Ql._createAt(e,t)}createPositionAfter(e){return Ql._createAfter(e)}createPositionBefore(e){return Ql._createBefore(e)}createRange(e,t){return new nd(e,t)}createRangeIn(e){return nd._createIn(e)}createRangeOn(e){return nd._createOn(e)}createSelection(...e){return new ud(...e)}createBatch(e){return new sh(e)}createOperationFromJSON(e){return $u.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 vh(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 zh(e,t){if(e)return e instanceof ud||e instanceof yd?e:e instanceof $l?t||0===t?new ud(e,t):e.is("rootElement")?new ud(e,"in"):new ud(e,"on"):new ud(e)}class Hh extends cl{constructor(){super(...arguments),this.domEventType="click"}onDomEvent(e){this.fire(e.type,e)}}class Uh extends cl{constructor(){super(...arguments),this.domEventType=["mousedown","mouseup","mouseover","mouseout"]}onDomEvent(e){this.fire(e.type,e)}}class Wh{constructor(e){this.document=e}createDocumentFragment(e){return new _c(this.document,e)}createElement(e,t,i){return new Wa(this.document,e,t,i)}createText(e){return new Us(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 r=i.getChildIndex(e);return this.removeChildren(r,1,i),this.insertChild(r,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 Wa(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){Ee(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 Qa._createAt(e,t)}createPositionAfter(e){return Qa._createAfter(e)}createPositionBefore(e){return Qa._createBefore(e)}createRange(e,t){return new Xa(e,t)}createRangeOn(e){return Xa._createOn(e)}createRangeIn(e){return Xa._createIn(e)}createSelection(...e){return new tc(...e)}}const $h=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,qh=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,Gh=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Kh=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,Yh=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Jh=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,Zh=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 Qh(e){return e.startsWith("#")?$h.test(e):e.startsWith("rgb")?qh.test(e)||Gh.test(e):e.startsWith("hsl")?Kh.test(e)||Yh.test(e):Zh.has(e.toLowerCase())}const Xh=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;const em=/^[+-]?[0-9]*([.][0-9]+)?%$/;const tm=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function im(e){return tm.includes(e)}const rm=["center","top","bottom","left","right"];function nm(e){return rm.includes(e)}const om=["fixed","scroll","local"];function sm(e){return om.includes(e)}const am=/^url\(/;function cm(e){return am.test(e)}function lm(e=""){if(""===e)return{top:void 0,right:void 0,bottom:void 0,left:void 0};const t=um(e),i=t[0],r=t[2]||i,n=t[1]||i;return{top:i,bottom:r,right:n,left:t[3]||n}}function dm({top:e,right:t,bottom:i,left:r}){const n=[];return r!==t?n.push(e,t,i,r):i!==e?n.push(e,t,i):t!==e?n.push(e,t):n.push(e),n.join(" ")}function um(e){const t=e.matchAll(Jh);return Array.from(t).map((e=>e[0]))}function hm(e){e.setNormalizer("background",(e=>{const t={},i=um(e);for(const e of i)im(e)?(t.repeat=t.repeat||[],t.repeat.push(e)):nm(e)?(t.position=t.position||[],t.position.push(e)):sm(e)?t.attachment=e:Qh(e)?t.color=e:cm(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 mm(e){var t,i;e.setNormalizer("margin",(t="margin",e=>({path:t,value:lm(e)}))),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",(i="margin",e=>{const{top:t,right:r,bottom:n,left:o}=e,s=[];return[t,r,o,n].every((e=>!!e))?s.push([i,dm(e)]):(t&&s.push([i+"-top",t]),r&&s.push([i+"-right",r]),n&&s.push([i+"-bottom",n]),o&&s.push([i+"-left",o])),s})),e.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}class gm{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 _("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 pm extends Tn{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 fm extends(q()){constructor(e={}){super();const t=this.constructor,i=e.language||t.defaultConfig&&t.defaultConfig.language;this._context=e.context||new Ps({language:i}),this._context._addEditor(this,!e.context);const r=Array.from(t.builtinPlugins||[]);this.config=new xr(e,t.defaultConfig),this.config.define("plugins",r),this.config.define(this._context._getEditorConfig()),this.plugins=new Ts(this,r,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new gm,this.set("state","initializing"),this.once("ready",(()=>this.state="ready"),{priority:"high"}),this.once("destroy",(()=>this.state="destroyed"),{priority:"high"}),this.model=new jh,this.on("change:isReadOnly",(()=>{this.model.document.isReadOnly=this.isReadOnly}));const n=new za;this.data=new _u(this.model,n),this.editing=new Xd(this.model,n),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new yu([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 pm(this),this.keystrokes.listenTo(this.editing.view.document)}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new _("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new _("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 _("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))}initPlugins(){const e=this.config,t=e.get("plugins"),i=e.get("removePlugins")||[],r=e.get("extraPlugins")||[],n=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(r),i,n)}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){_.rethrowUnexpectedError(e,this)}}focus(){this.editing.view.focus()}static create(...e){throw new Error("This is an abstract method.")}}function bm(e){return class extends e{setData(e){this.data.set(e)}getData(e){return this.data.get(e)}}}{const e=bm(Object);bm.setData=e.prototype.setData,bm.getData=e.prototype.getData}function wm(e){return class extends e{updateSourceElement(e){if(!this.sourceElement)throw new _("editor-missing-sourceelement",this);const t=this.config.get("updateSourceElementOnDestroy"),i=this.sourceElement instanceof HTMLTextAreaElement;if(!t&&!i)return void $r(this.sourceElement,"");const r="string"==typeof e?e:this.data.get();$r(this.sourceElement,r)}}}wm.updateSourceElement=wm(Object).prototype.updateSourceElement;class km extends Is{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new Cn({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new _("pendingactions-add-invalid-message",this);const t=new(q());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]()}}const vm='',_m='',ym='',xm={bold:'',cancel:vm,caption:'',check:_m,cog:'',eraser:ym,history:'',image:'',imageUpload:'',imageAssetManager:'',imageUrl:'',lowVision:'\n',textAlternative:'',loupe:'',importExport:'',paragraph:'',plus:'',text:'',alignBottom:'',alignMiddle:'',alignTop:'',alignLeft:'',alignCenter:'',alignRight:'',alignJustify:'',objectLeft:'',objectCenter:'',objectRight:'',objectFullWidth:'',objectInline:'',objectBlockLeft:'',objectBlockRight:'',objectSizeFull:'',objectSizeLarge:'',objectSizeSmall:'',objectSizeMedium:'',pencil:'',pilcrow:'',quote:'',threeVerticalDots:'',dragIndicator:''};var Am=i(7292),Cm={attributes:{"data-cke":!0}};Cm.setAttributes=Un(),Cm.insert=zn().bind(null,"head"),Cm.domAPI=Fn(),Cm.insertStyleElement=$n();Ln()(Am.A,Cm);Am.A&&Am.A.locals&&Am.A.locals;const{threeVerticalDots:Em}=xm,Sm={alignLeft:xm.alignLeft,bold:xm.bold,importExport:xm.importExport,paragraph:xm.paragraph,plus:xm.plus,text:xm.text,threeVerticalDots:xm.threeVerticalDots,pilcrow:xm.pilcrow,dragIndicator:xm.dragIndicator};class Tm extends Kn{constructor(e,t){super(e);const i=this.bindTemplate,r=this.t;this.options=t||{},this.set("ariaLabel",r("Editor toolbar")),this.set("maxWidth","auto"),this.items=this.createCollection(),this.focusTracker=new Sn,this.keystrokes=new Tn,this.set("class",void 0),this.set("isCompact",!1),this.itemsView=new Pm(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const n="rtl"===e.uiLanguageDirection;this._focusCycler=new ws({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[n?"arrowright":"arrowleft","arrowup"],focusNext:[n?"arrowleft":"arrowright","arrowdown"]}});const o=["ck","ck-toolbar",i.to("class"),i.if("isCompact","ck-toolbar_compact")];var s;this.options.shouldGroupWhenFull&&this.options.isFloating&&o.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:o,role:"toolbar","aria-label":i.to("ariaLabel"),style:{maxWidth:i.to("maxWidth")},tabindex:-1},children:this.children,on:{mousedown:(s=this,s.bindTemplate.to((e=>{e.target===s.element&&e.preventDefault()})))}}),this._behavior=this.options.shouldGroupWhenFull?new Mm(this):new Im(this)}render(){super.render(),this.focusTracker.add(this.element);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),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))}_buildItemsFromConfig(e,t,i){const r=ys(e),n=i||r.removeItems;return this._cleanItemsConfiguration(r.items,t,n).map((e=>F(e)?this._createNestedToolbarDropdown(e,t,n):"|"===e?new vs:"-"===e?new _s:t.create(e))).filter((e=>!!e))}_cleanItemsConfiguration(e,t,i){const r=e.filter(((e,r,n)=>"|"===e||-1===i.indexOf(e)&&("-"===e?!this.options.shouldGroupWhenFull||(y("toolbarview-line-break-ignored-when-grouping-items",n),!1):!(!F(e)&&!t.has(e))||(y("toolbarview-item-unavailable",{item:e}),!1))));return this._cleanSeparatorsAndLineBreaks(r)}_cleanSeparatorsAndLineBreaks(e){const t=e=>"-"!==e&&"|"!==e,i=e.length,r=e.findIndex(t);if(-1===r)return[];const n=i-e.slice().reverse().findIndex(t);return e.slice(r,n).filter(((e,i,r)=>{if(t(e))return!0;return!(i>0&&r[i-1]===e)}))}_createNestedToolbarDropdown(e,t,i){let{label:r,icon:n,items:o,tooltip:s=!0,withText:a=!1}=e;if(o=this._cleanItemsConfiguration(o,t,i),!o.length)return null;const c=$m(this.locale);return r||y("toolbarview-nested-toolbar-dropdown-missing-label",e),c.class="ck-toolbar__nested-toolbar-dropdown",c.buttonView.set({label:r,tooltip:s,withText:!!a}),!1!==n?c.buttonView.icon=Sm[n]||n||Em:c.buttonView.withText=!0,qm(c,(()=>c.toolbarView._buildItemsFromConfig(o,t,i))),c}}class Pm extends Kn{constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class Im{constructor(e){const t=e.bindTemplate;e.set("isVertical",!1),e.itemsView.children.bindTo(e.items).using((e=>e)),e.focusables.bindTo(e.items).using((e=>e)),e.extendTemplate({attributes:{class:[t.if("isVertical","ck-toolbar_vertical")]}})}render(){}destroy(){}}class Mm{constructor(e){this.resizeObserver=null,this.cachedPadding=null,this.shouldUpdateGroupingOnNextResize=!1,this.view=e,this.viewChildren=e.children,this.viewFocusables=e.focusables,this.viewItemsView=e.itemsView,this.viewFocusTracker=e.focusTracker,this.viewLocale=e.locale,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._updateFocusCycleableItems.bind(this)),e.children.on("change",this._updateFocusCycleableItems.bind(this)),e.items.on("change",((e,t)=>{const i=t.index,r=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()})),e.extendTemplate({attributes:{class:["ck-toolbar_grouping"]}})}render(e){this.viewElement=e.element,this._enableGroupingOnResize(),this._enableGroupingOnMaxWidthChange(e)}destroy(){this.groupedItemsDropdown.destroy(),this.resizeObserver.destroy()}_updateGrouping(){if(!this.viewElement.ownerDocument.body.contains(this.viewElement))return;if(!Zr(this.viewElement))return void(this.shouldUpdateGroupingOnNextResize=!0);const e=this.groupedItems.length;let t;for(;this._areItemsOverflowing;)this._groupLastItem(),t=!0;if(!t&&this.groupedItems.length){for(;this.groupedItems.length&&!this._areItemsOverflowing;)this._ungroupFirstItem();this._areItemsOverflowing&&this._groupLastItem()}this.groupedItems.length!==e&&this.view.fire("groupedItemsUpdate")}get _areItemsOverflowing(){if(!this.ungroupedItems.length)return!1;const e=this.viewElement,t=this.viewLocale.uiLanguageDirection,i=new Fr(e.lastChild),r=new Fr(e);if(!this.cachedPadding){const i=Nr.window.getComputedStyle(e),r="ltr"===t?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(i[r])}return"ltr"===t?i.right>r.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 vs),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=$m(e);return i.class="ck-toolbar__grouped-dropdown",i.panelPosition="ltr"===e.uiLanguageDirection?"sw":"se",qm(i,this.groupedItems),i.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:"rtl"===e.uiLanguageDirection?"se":"sw",icon:Em}),i}_updateFocusCycleableItems(){this.viewFocusables.clear(),this.ungroupedItems.map((e=>{this.viewFocusables.add(e)})),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}class Om extends Kn{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 Nm extends Kn{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}class Vm extends Kn{constructor(e,t=new ts){super(e);const i=this.bindTemplate,r=new Lm(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,r]),r.set({role:"group",ariaLabelledBy:t.id}),r.focusTracker.destroy(),r.keystrokes.destroy(),this.items=r.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 Nm)));e&&e.focus()}}}var Bm=i(2946),Rm={attributes:{"data-cke":!0}};Rm.setAttributes=Un(),Rm.insert=zn().bind(null,"head"),Rm.domAPI=Fn(),Rm.insertStyleElement=$n();Ln()(Bm.A,Rm);Bm.A&&Bm.A.locals&&Bm.A.locals;class Lm extends Kn{constructor(e){super(e),this._listItemGroupToChangeListeners=new WeakMap;const t=this.bindTemplate;this.focusables=new Bn,this.items=this.createCollection(),this.focusTracker=new Sn,this.keystrokes=new Tn,this._focusCycler=new ws({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 Vm?this._registerFocusableItemsGroup(e):e instanceof Om&&this._registerFocusableListItem(e);this.items.on("change",((e,t)=>{for(const e of t.removed)e instanceof Vm?this._deregisterFocusableItemsGroup(e):this._deregisterFocusableListItem(e);for(const e of Array.from(t.added).reverse())e instanceof Vm?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 r=void 0!==t?t+i:void 0;this._registerFocusableListItem(e,r)}));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)}}var Dm=i(8295),Fm={attributes:{"data-cke":!0}};Fm.setAttributes=Un(),Fm.insert=zn().bind(null,"head"),Fm.domAPI=Fn(),Fm.insertStyleElement=$n();Ln()(Dm.A,Fm);Dm.A&&Dm.A.locals&&Dm.A.locals;class jm extends Kn{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 Tn,this.focusTracker=new Sn,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 Ao;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 Ao,t=e.bindTemplate;return e.icon=fs,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}}var zm=i(5457),Hm={attributes:{"data-cke":!0}};Hm.setAttributes=Un(),Hm.insert=zn().bind(null,"head"),Hm.domAPI=Fn(),Hm.insertStyleElement=$n();Ln()(zm.A,Hm);zm.A&&zm.A.locals&&zm.A.locals;var Um=i(9036),Wm={attributes:{"data-cke":!0}};Wm.setAttributes=Un(),Wm.insert=zn().bind(null,"head"),Wm.domAPI=Fn(),Wm.insertStyleElement=$n();Ln()(Um.A,Wm);Um.A&&Um.A.locals&&Um.A.locals;function $m(e,t=bs){const i="function"==typeof t?new t(e):t,n=new hs(e),o=new ps(e,i,n);return i.bind("isEnabled").to(o),i instanceof jm?i.arrowView.bind("isOn").to(o,"isOpen"):i.bind("isOn").to(o,"isOpen"),function(e){(function(e){e.on("render",(()=>{r({emitter:e,activator:()=>e.isOpen,callback:()=>{e.isOpen=!1},contextElements:()=>[e.element,...e.focusTracker._elements]})}))})(e),function(e){e.on("execute",(t=>{t.source instanceof So||(e.isOpen=!1)}))}(e),function(e){e.focusTracker.on("change:isFocused",((t,i,r)=>{e.isOpen&&!r&&(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,r)=>{if(r)return;const n=e.panelView.element;n&&n.contains(Nr.document.activeElement)&&e.buttonView.focus()}))}(e),function(e){e.on("change:isOpen",((t,i,r)=>{r&&e.panelView.focus()}),{priority:"low"})}(e)}(o),o}function qm(e,t,i={}){e.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),e.isOpen?Gm(e,t,i):e.once("change:isOpen",(()=>Gm(e,t,i)),{priority:"highest"}),i.enableActiveItemFocusOnDropdownOpen&&Jm(e,(()=>e.toolbarView.items.find((e=>e.isOn))))}function Gm(e,t,i){const r=e.locale,n=r.t,o=e.toolbarView=new Tm(r),s="function"==typeof t?t():t;o.ariaLabel=i.ariaLabel||n("Dropdown toolbar"),i.maxWidth&&(o.maxWidth=i.maxWidth),i.class&&(o.class=i.class),i.isCompact&&(o.isCompact=i.isCompact),i.isVertical&&(o.isVertical=!0),s instanceof Bn?o.items.bindTo(s).using((e=>e)):o.items.addMany(s),e.panelView.children.add(o),o.items.delegate("execute").to(e)}function Km(e,t,i={}){e.isOpen?Ym(e,t,i):e.once("change:isOpen",(()=>Ym(e,t,i)),{priority:"highest"}),Jm(e,(()=>e.listView.items.find((e=>e instanceof Om&&e.children.first.isOn))))}function Ym(e,t,i){const r=e.locale,n=e.listView=new Lm(r),o="function"==typeof t?t():t;n.ariaLabel=i.ariaLabel,n.role=i.role,Zm(e,n.items,o,r),e.panelView.children.add(n),n.items.delegate("execute").to(e)}function Jm(e,t){e.on("change:isOpen",(()=>{if(!e.isOpen)return;const i=t();i&&("function"==typeof i.focus?i.focus():y("ui-dropdown-focus-child-on-open-child-missing-focus",{view:i}))}),{priority:k.low-10})}function Zm(e,t,i,r){t.bindTo(i).using((t=>{if("separator"===t.type)return new Nm(r);if("group"===t.type){const i=new Vm(r);return i.set({label:t.label}),Zm(e,i.items,t.items,r),i.items.delegate("execute").to(e),i}if("button"===t.type||"switchbutton"===t.type){const e=new Om(r);let i;return"button"===t.type?(i=new Ao(r),i.extendTemplate({attributes:{"aria-checked":i.bindTemplate.to("isOn")}})):i=new So(r),i.bind(...Object.keys(t.model)).to(t.model),i.delegate("execute").to(e),e.children.add(i),e}return null}))}const Qm=(e,t,i)=>{const r=new ls(e.locale);return r.set({id:t,ariaDescribedById:i}),r.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),r.bind("hasError").to(e,"errorText",(e=>!!e)),r.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(r),r},Xm=(e,t=0,i=1)=>e>i?i:eMath.round(i*e)/i,tg=(Math.PI,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?eg(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?eg(parseInt(e.substring(6,8),16)/255,2):1})),ig=({h:e,s:t,v:i,a:r})=>{const n=(200-t)*i/100;return{h:eg(e),s:eg(n>0&&n<200?t*i/100/(n<=100?n:200-n)*100:0),l:eg(n/2),a:eg(r,2)}},rg=e=>{const{h:t,s:i,l:r}=ig(e);return`hsl(${t}, ${i}%, ${r}%)`},ng=({h:e,s:t,v:i,a:r})=>{e=e/360*6,t/=100,i/=100;const n=Math.floor(e),o=i*(1-t),s=i*(1-(e-n)*t),a=i*(1-(1-e+n)*t),c=n%6;return{r:eg(255*[i,s,o,o,a,i][c]),g:eg(255*[a,i,i,s,o,o][c]),b:eg(255*[o,o,a,i,i,s][c]),a:eg(r,2)}},og=e=>{const t=e.toString(16);return t.length<2?"0"+t:t},sg=({r:e,g:t,b:i,a:r})=>{const n=r<1?og(eg(255*r)):"";return"#"+og(e)+og(t)+og(i)+n},ag=({r:e,g:t,b:i,a:r})=>{const n=Math.max(e,t,i),o=n-Math.min(e,t,i),s=o?n===e?(t-i)/o:n===t?2+(i-e)/o:4+(e-t)/o:0;return{h:eg(60*(s<0?s+6:s)),s:eg(n?o/n*100:0),v:eg(n/255*100),a:r}},cg=(e,t)=>{if(e===t)return!0;for(const i in e)if(e[i]!==t[i])return!1;return!0},lg={},dg=e=>{let t=lg[e];return t||(t=document.createElement("template"),t.innerHTML=e,lg[e]=t),t},ug=(e,t,i)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))};let hg=!1;const mg=e=>"touches"in e,gg=(e,t)=>{const i=mg(t)?t.touches[0]:t,r=e.el.getBoundingClientRect();ug(e.el,"move",e.getMove({x:Xm((i.pageX-(r.left+window.pageXOffset))/r.width),y:Xm((i.pageY-(r.top+window.pageYOffset))/r.height)}))};class pg{constructor(e,t,i,r){const n=dg(`
`);e.appendChild(n.content.cloneNode(!0));const o=e.querySelector(`[part=${t}]`);o.addEventListener("mousedown",this),o.addEventListener("touchstart",this),o.addEventListener("keydown",this),this.el=o,this.xy=r,this.nodes=[o.firstChild,o]}set dragging(e){const t=e?document.addEventListener:document.removeEventListener;t(hg?"touchmove":"mousemove",this),t(hg?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!(e=>!(hg&&!mg(e)||(hg||(hg=mg(e)),0)))(e)||!hg&&0!=e.button)return;this.el.focus(),gg(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),gg(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(),ug(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 fg extends pg{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:rg({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${eg(e)}`)}getMove(e,t){return{h:t?Xm(this.h+360*e.x,0,360):360*e.x}}}class bg extends pg{constructor(e){super(e,"saturation",'aria-label="Color"',!0)}update(e){this.hsva=e,this.style([{top:100-e.v+"%",left:`${e.s}%`,color:rg(e)},{"background-color":rg({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${eg(e.s)}%, Brightness ${eg(e.v)}%`)}getMove(e,t){return{s:t?Xm(this.hsva.s+100*e.x,0,100):100*e.x,v:t?Xm(this.hsva.v-100*e.y,0,100):Math.round(100-100*e.y)}}}const wg=Symbol("same"),kg=Symbol("color"),vg=Symbol("hsva"),_g=Symbol("update"),yg=Symbol("parts"),xg=Symbol("css"),Ag=Symbol("sliders");class Cg extends HTMLElement{static get observedAttributes(){return["color"]}get[xg](){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[Ag](){return[bg,fg]}get color(){return this[kg]}set color(e){if(!this[wg](e)){const t=this.colorModel.toHsva(e);this[_g](t),this[kg]=e}}constructor(){super();const e=dg(``),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[yg]=this[Ag].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 r=this.colorModel.fromAttr(i);this[wg](r)||(this.color=r)}handleEvent(e){const t=this[vg],i={...t,...e.detail};let r;this[_g](i),cg(i,t)||this[wg](r=this.colorModel.fromHsva(i))||(this[kg]=r,ug(this,"color-changed",{value:r}))}[wg](e){return this.color&&this.colorModel.equal(e,this.color)}[_g](e){this[vg]=e,this[yg].forEach((t=>t.update(e)))}}const Eg={defaultColor:"#000",toHsva:e=>ag(tg(e)),fromHsva:({h:e,s:t,v:i})=>sg(ng({h:e,s:t,v:i,a:1})),equal:(e,t)=>e.toLowerCase()===t.toLowerCase()||cg(tg(e),tg(t)),fromAttr:e=>e};class Sg extends Cg{get colorModel(){return Eg}}customElements.define("hex-color-picker",class extends Sg{});var Tg=i(5984),Pg={attributes:{"data-cke":!0}};Pg.setAttributes=Un(),Pg.insert=zn().bind(null,"head"),Pg.domAPI=Fn(),Pg.insertStyleElement=$n();Ln()(Tg.A,Pg);Tg.A&&Tg.A.locals&&Tg.A.locals;class Ig extends Kn{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=Qo((e=>{this.set("color",e),this.fire("colorSelected",{color:this.color})}),150,{leading:!0}),this.on("set:color",((e,t,i)=>{e.return=Lo(i,this._config.format||"hsl")})),this.on("change:color",(()=>{this._hexColor=Mg(this.color)})),this.on("change:_hexColor",(()=>{document.activeElement!==this.picker&&this.picker.setAttribute("color",this._hexColor),Mg(this.color)!=Mg(this._hexColor)&&(this.color=this._hexColor)}))}render(){if(super.render(),this.picker=Nr.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(){if(!this._config.hideInput&&(l.isGecko||l.isiOS||l.isSafari)){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 Og(e)));this.slidersView=this.createCollection(),e.forEach((e=>{this.slidersView.add(e)}))}_createInputRow(){const e=new Ng,t=this._createColorInput();return new Vg(this.locale,[e,t])}_createColorInput(){const e=new ns(this.locale,Qm),{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=t.trim(),i=e.startsWith("#")?e.substring(1):e;[3,4,6,8].includes(i.length)&&/(([0-9a-fA-F]{2}){3,4}|([0-9a-fA-F]){3,4})/.test(i)&&this._debounceColorPickerEvent("#"+i)}})),e}}function Mg(e){let t=function(e){if(!e)return"";const t=Do(e);return t?"hex"===t.space?t.hexValue:Lo(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 Og extends Kn{constructor(e){super(),this.element=e}focus(){this.element.focus()}}class Ng extends Kn{constructor(e){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__hash-view"]},children:"#"})}}class Vg extends Kn{constructor(e,t){super(e),this.children=this.createCollection(t),this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-picker__row"]},children:this.children})}}class Bg extends(q(Cn)){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 Rg='';class Lg extends Kn{constructor(e,{colors:t,columns:i,removeButtonLabel:r,documentColorsLabel:n,documentColorsCount:o,colorPickerLabel:s,focusTracker:a,focusables:c}){super(e);const l=this.bindTemplate;this.set("isVisible",!0),this.focusTracker=a,this.items=this.createCollection(),this.colorDefinitions=t,this.columns=i,this.documentColors=new Bg,this.documentColorsCount=o,this._focusables=c,this._removeButtonLabel=r,this._colorPickerLabel=s,this._documentColorsLabel=n,this.setTemplate({tag:"div",attributes:{class:["ck-color-grids-fragment",l.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,r=this.documentColorsCount;this.documentColors.clear();for(const n of i.getRoots()){const i=e.createRangeIn(n);for(const e of i.getItems())if(e.is("$textProxy")&&e.hasAttribute(t)&&(this._addColorToDocumentColors(e.getAttribute(t)),this.documentColors.length>=r))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=Yn.bind(this.documentColors,this.documentColors),t=new ts(this.locale);t.text=this._documentColorsLabel,t.extendTemplate({attributes:{class:["ck","ck-color-grid__label",e.if("isEmpty","ck-hidden")]}}),this.items.add(t),this.documentColorsGrid=this._createDocumentColorsGrid(),this.items.add(this.documentColorsGrid)}this._createColorPickerButton(),this._addColorSelectorElementsToFocusTracker(),this.focus()}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 Ao,this.colorPickerButtonView.set({label:this._colorPickerLabel,withText:!0,icon:Rg,class:"ck-color-selector__color-picker"}),this.colorPickerButtonView.on("execute",(()=>{this.fire("colorPicker:show")}))}_createRemoveColorButton(){const e=new Ao;return e.set({withText:!0,icon:ym,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 Oo(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=Yn.bind(this.documentColors,this.documentColors),t=new Oo(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 Po;return t.set({color:e.color,hasBorder:e.options&&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,r)=>{r&&(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}})}}class Dg extends Kn{constructor(e,{focusTracker:t,focusables:i,keystrokes:r,colorPickerViewConfig:n}){super(e),this.items=this.createCollection(),this.focusTracker=t,this.keystrokes=r,this.set("isVisible",!1),this.set("selectedColor",void 0),this._focusables=i,this._colorPickerViewConfig=n;const o=this.bindTemplate,{saveButtonView:s,cancelButtonView:a}=this._createActionButtons();this.saveButtonView=s,this.cancelButtonView=a,this.actionBarView=this._createActionBarView({saveButtonView:s,cancelButtonView:a}),this.setTemplate({tag:"div",attributes:{class:["ck-color-picker-fragment",o.if("isVisible","ck-hidden",(e=>!e))]},children:this.items})}render(){super.render();const e=new Ig(this.locale,{...this._colorPickerViewConfig});this.colorPickerView=e,this.colorPickerView.render(),this.selectedColor&&(e.color=this.selectedColor),this.listenTo(this,"change:selectedColor",((t,i,r)=>{e.color=r})),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()}_executeOnEnterPress(){this.keystrokes.set("enter",(e=>{this.isVisible&&this.focusTracker.focusedElement!==this.cancelButtonView.element&&(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 Kn,r=this.createCollection();return r.add(e),r.add(t),i.setTemplate({tag:"div",attributes:{class:["ck","ck-color-selector_action-bar"]},children:r}),i}_createActionButtons(){const e=this.locale,t=e.t,i=new Ao(e),r=new Ao(e);return i.set({icon:_m,class:"ck-button-save",type:"button",withText:!1,label:t("Accept")}),r.set({icon:vm,class:"ck-button-cancel",type:"button",withText:!1,label:t("Cancel")}),i.on("execute",(()=>{this.fire("execute",{source:"colorPickerSaveButton",value:this.selectedColor})})),r.on("execute",(()=>{this.fire("colorPicker:cancel")})),{saveButtonView:i,cancelButtonView:r}}_executeUponColorChange(){this.colorPickerView.on("colorSelected",((e,t)=>{this.fire("execute",{value:t.color,source:"colorPicker"}),this.set("selectedColor",t.color)}))}}var Fg=i(4476),jg={attributes:{"data-cke":!0}};jg.setAttributes=Un(),jg.insert=zn().bind(null,"head"),jg.domAPI=Fn(),jg.insertStyleElement=$n();Ln()(Fg.A,jg);Fg.A&&Fg.A.locals&&Fg.A.locals;class zg extends Kn{constructor(e,{colors:t,columns:i,removeButtonLabel:r,documentColorsLabel:n,documentColorsCount:o,colorPickerLabel:s,colorPickerViewConfig:a}){super(e),this.items=this.createCollection(),this.focusTracker=new Sn,this.keystrokes=new Tn,this._focusables=new Bn,this._colorPickerViewConfig=a,this._focusCycler=new ws({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.colorGridsFragmentView=new Lg(e,{colors:t,columns:i,removeButtonLabel:r,documentColorsLabel:n,documentColorsCount:o,colorPickerLabel:s,focusTracker:this.focusTracker,focusables:this._focusables}),this.colorPickerFragmentView=new Dg(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._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))}}class Hg{constructor(e){this._components=new Map,this.editor=e}*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set(Ug(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new _("componentfactory-item-missing",this,{name:e});return this._components.get(Ug(e)).callback(this.editor.locale)}has(e){return this._components.has(Ug(e))}}function Ug(e){return String(e).toLowerCase()}var Wg=i(9605),$g={attributes:{"data-cke":!0}};$g.setAttributes=Un(),$g.insert=zn().bind(null,"head"),$g.domAPI=Fn(),$g.insertStyleElement=$n();Ln()(Wg.A,$g);Wg.A&&Wg.A.locals&&Wg.A.locals;const qg=qr("px"),Gg=Nr.document.body,Kg={top:-99999,left:-99999,name:"arrowless",config:{withArrow:!1}};class Yg extends Kn{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.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",qg),left:t.to("left",qg)}},children:this.content})}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){this.show();const t=Yg.defaultPositions,i=Object.assign({},{element:this.element,positions:[t.southArrowNorth,t.southArrowNorthMiddleWest,t.southArrowNorthMiddleEast,t.southArrowNorthWest,t.southArrowNorthEast,t.northArrowSouth,t.northArrowSouthMiddleWest,t.northArrowSouthMiddleEast,t.northArrowSouthWest,t.northArrowSouthEast,t.viewportStickyNorth],limiter:Gg,fitInViewport:!0},e),r=Yg._getOptimalPosition(i)||Kg,n=parseInt(r.left),o=parseInt(r.top),s=r.name,a=r.config||{},{withArrow:c=!0}=a;this.top=o,this.left=n,this.position=s,this.withArrow=c}pin(e){this.unpin(),this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(e):this._stopPinning()},this._startPinning(e),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){this.attachTo(e);const t=Jg(e.target),i=e.limiter?Jg(e.limiter):Gg;this.listenTo(Nr.document,"scroll",((r,n)=>{const o=n.target,s=t&&o.contains(t),a=i&&o.contains(i);!s&&!a&&t&&i||this.attachTo(e)}),{useCapture:!0}),this.listenTo(Nr.window,"resize",(()=>{this.attachTo(e)}))}_stopPinning(){this.stopListening(Nr.document,"scroll"),this.stopListening(Nr.window,"resize")}}function Jg(e){return yr(e)?e:Rr(e)?e.commonAncestorContainer:"function"==typeof e?Jg(e()):null}function Zg(e={}){const{sideOffset:t=Yg.arrowSideOffset,heightOffset:i=Yg.arrowHeightOffset,stickyVerticalOffset:r=Yg.stickyVerticalOffset,config:n}=e;return{northWestArrowSouthWest:(e,i)=>({top:o(e,i),left:e.left-t,name:"arrow_sw",...n&&{config:n}}),northWestArrowSouthMiddleWest:(e,i)=>({top:o(e,i),left:e.left-.25*i.width-t,name:"arrow_smw",...n&&{config:n}}),northWestArrowSouth:(e,t)=>({top:o(e,t),left:e.left-t.width/2,name:"arrow_s",...n&&{config:n}}),northWestArrowSouthMiddleEast:(e,i)=>({top:o(e,i),left:e.left-.75*i.width+t,name:"arrow_sme",...n&&{config:n}}),northWestArrowSouthEast:(e,i)=>({top:o(e,i),left:e.left-i.width+t,name:"arrow_se",...n&&{config:n}}),northArrowSouthWest:(e,i)=>({top:o(e,i),left:e.left+e.width/2-t,name:"arrow_sw",...n&&{config:n}}),northArrowSouthMiddleWest:(e,i)=>({top:o(e,i),left:e.left+e.width/2-.25*i.width-t,name:"arrow_smw",...n&&{config:n}}),northArrowSouth:(e,t)=>({top:o(e,t),left:e.left+e.width/2-t.width/2,name:"arrow_s",...n&&{config:n}}),northArrowSouthMiddleEast:(e,i)=>({top:o(e,i),left:e.left+e.width/2-.75*i.width+t,name:"arrow_sme",...n&&{config:n}}),northArrowSouthEast:(e,i)=>({top:o(e,i),left:e.left+e.width/2-i.width+t,name:"arrow_se",...n&&{config:n}}),northEastArrowSouthWest:(e,i)=>({top:o(e,i),left:e.right-t,name:"arrow_sw",...n&&{config:n}}),northEastArrowSouthMiddleWest:(e,i)=>({top:o(e,i),left:e.right-.25*i.width-t,name:"arrow_smw",...n&&{config:n}}),northEastArrowSouth:(e,t)=>({top:o(e,t),left:e.right-t.width/2,name:"arrow_s",...n&&{config:n}}),northEastArrowSouthMiddleEast:(e,i)=>({top:o(e,i),left:e.right-.75*i.width+t,name:"arrow_sme",...n&&{config:n}}),northEastArrowSouthEast:(e,i)=>({top:o(e,i),left:e.right-i.width+t,name:"arrow_se",...n&&{config:n}}),southWestArrowNorthWest:e=>({top:s(e),left:e.left-t,name:"arrow_nw",...n&&{config:n}}),southWestArrowNorthMiddleWest:(e,i)=>({top:s(e),left:e.left-.25*i.width-t,name:"arrow_nmw",...n&&{config:n}}),southWestArrowNorth:(e,t)=>({top:s(e),left:e.left-t.width/2,name:"arrow_n",...n&&{config:n}}),southWestArrowNorthMiddleEast:(e,i)=>({top:s(e),left:e.left-.75*i.width+t,name:"arrow_nme",...n&&{config:n}}),southWestArrowNorthEast:(e,i)=>({top:s(e),left:e.left-i.width+t,name:"arrow_ne",...n&&{config:n}}),southArrowNorthWest:e=>({top:s(e),left:e.left+e.width/2-t,name:"arrow_nw",...n&&{config:n}}),southArrowNorthMiddleWest:(e,i)=>({top:s(e),left:e.left+e.width/2-.25*i.width-t,name:"arrow_nmw",...n&&{config:n}}),southArrowNorth:(e,t)=>({top:s(e),left:e.left+e.width/2-t.width/2,name:"arrow_n",...n&&{config:n}}),southArrowNorthMiddleEast:(e,i)=>({top:s(e),left:e.left+e.width/2-.75*i.width+t,name:"arrow_nme",...n&&{config:n}}),southArrowNorthEast:(e,i)=>({top:s(e),left:e.left+e.width/2-i.width+t,name:"arrow_ne",...n&&{config:n}}),southEastArrowNorthWest:e=>({top:s(e),left:e.right-t,name:"arrow_nw",...n&&{config:n}}),southEastArrowNorthMiddleWest:(e,i)=>({top:s(e),left:e.right-.25*i.width-t,name:"arrow_nmw",...n&&{config:n}}),southEastArrowNorth:(e,t)=>({top:s(e),left:e.right-t.width/2,name:"arrow_n",...n&&{config:n}}),southEastArrowNorthMiddleEast:(e,i)=>({top:s(e),left:e.right-.75*i.width+t,name:"arrow_nme",...n&&{config:n}}),southEastArrowNorthEast:(e,i)=>({top:s(e),left:e.right-i.width+t,name:"arrow_ne",...n&&{config:n}}),westArrowEast:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.left-t.width-i,name:"arrow_e",...n&&{config:n}}),eastArrowWest:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.right+i,name:"arrow_w",...n&&{config:n}}),viewportStickyNorth:(e,t,i,o)=>{const s=o||i;return e.getIntersection(s)?s.height-e.height>r?null:{top:s.top+r,left:e.left+e.width/2-t.width/2,name:"arrowless",config:{withArrow:!1,...n}}:null}};function o(e,t){return e.top-t.height-i}function s(e){return e.bottom+i}}Yg.arrowSideOffset=25,Yg.arrowHeightOffset=10,Yg.stickyVerticalOffset=20,Yg._getOptimalPosition=Qr,Yg.defaultPositions=Zg();var Qg=i(140),Xg={attributes:{"data-cke":!0}};Xg.setAttributes=Un(),Xg.insert=zn().bind(null,"head"),Xg.domAPI=Fn(),Xg.insertStyleElement=$n();Ln()(Qg.A,Xg);Qg.A&&Qg.A.locals&&Qg.A.locals;const ep="ck-tooltip";class tp extends(Pr()){constructor(e){if(super(),this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this._resizeObserver=null,tp._editors.add(e),tp._instance)return tp._instance;tp._instance=this,this.tooltipTextView=new Kn(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 Yg(e.locale),this.balloonPanelView.class=ep,this.balloonPanelView.content.add(this.tooltipTextView),this._pinTooltipDebounced=Qo(this._pinTooltip,600),this.listenTo(Nr.document,"mouseenter",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(Nr.document,"mouseleave",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(Nr.document,"focus",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(Nr.document,"blur",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(Nr.document,"scroll",this._onScroll.bind(this),{useCapture:!0}),this._watchdogExcluded=!0}destroy(e){const t=e.ui.view&&e.ui.view.body;tp._editors.delete(e),this.stopListening(e.ui),t&&t.has(this.balloonPanelView)&&t.remove(this.balloonPanelView),tp._editors.size||(this._unpinTooltip(),this.balloonPanelView.destroy(),this.stopListening(),tp._instance=null)}static getPositioningFunctions(e){const t=tp.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]}_onEnterOrFocus(e,{target:t}){const i=ip(t);var r;i&&(i!==this._currentElementWithTooltip&&(this._unpinTooltip(),this._pinTooltipDebounced(i,{text:(r=i).dataset.ckeTooltipText,position:r.dataset.ckeTooltipPosition||"s",cssClass:r.dataset.ckeTooltipClass||""})))}_onLeaveOrBlur(e,{target:t,relatedTarget:i}){if("mouseleave"===e.name){if(!yr(t))return;if(this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;const e=ip(t),r=ip(i);e&&e!==r&&this._unpinTooltip()}else{if(this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;this._unpinTooltip()}}_onScroll(e,{target:t}){this._currentElementWithTooltip&&(t.contains(this.balloonPanelView.element)&&t.contains(this._currentElementWithTooltip)||this._unpinTooltip())}_pinTooltip(e,{text:t,position:i,cssClass:r}){const n=En(tp._editors.values()).ui.view.body;n.has(this.balloonPanelView)||n.add(this.balloonPanelView),this.tooltipTextView.text=t,this.balloonPanelView.pin({target:e,positions:tp.getPositioningFunctions(i)}),this._resizeObserver=new Wr(e,(()=>{Zr(e)||this._unpinTooltip()})),this.balloonPanelView.class=[ep,r].filter((e=>e)).join(" ");for(const e of tp._editors)this.listenTo(e.ui,"update",this._updateTooltipPosition.bind(this),{priority:"low"});this._currentElementWithTooltip=e,this._currentTooltipPosition=i}_unpinTooltip(){this._pinTooltipDebounced.cancel(),this.balloonPanelView.unpin();for(const e of tp._editors)this.stopListening(e.ui,"update");this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this._resizeObserver&&this._resizeObserver.destroy()}_updateTooltipPosition(){Zr(this._currentElementWithTooltip)?this.balloonPanelView.pin({target:this._currentElementWithTooltip,positions:tp.getPositioningFunctions(this._currentTooltipPosition)}):this._unpinTooltip()}}function ip(e){return yr(e)?e.closest("[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])"):null}tp.defaultBalloonPositions=Zg({heightOffset:5,sideOffset:13}),tp._editors=new Set,tp._instance=null;const rp=function(e,t,i){var r=!0,n=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return F(i)&&(r="leading"in i?!!i.leading:r,n="trailing"in i?!!i.trailing:n),Qo(e,t,{leading:r,maxWait:t,trailing:n})};class np extends(Pr()){constructor(e){super(),this.editor=e,this._balloonView=null,this._lastFocusedEditableElement=null,this._showBalloonThrottled=rp(this._showBalloon.bind(this),50,{leading:!0}),e.on("ready",this._handleEditorReady.bind(this))}destroy(){const e=this._balloonView;e&&(e.unpin(),this._balloonView=null),this._showBalloonThrottled.cancel(),this.stopListening()}_handleEditorReady(){const e=this.editor;(!!e.config.get("ui.poweredBy.forceVisible")||"VALID"!==function(e){function t(e){return e.length>=40&&e.length<=255?"VALID":"INVALID"}if(!e)return"INVALID";let i="";try{i=atob(e)}catch(e){return"INVALID"}const r=i.split("-"),n=r[0],o=r[1];if(!o)return t(e);try{atob(o)}catch(i){try{if(atob(n),!atob(n).length)return t(e)}catch(i){return t(e)}}if(n.length<40||n.length>255)return"INVALID";let s="";try{atob(n),s=atob(o)}catch(e){return"INVALID"}if(8!==s.length)return"INVALID";const a=Number(s.substring(0,4)),c=Number(s.substring(4,6))-1,l=Number(s.substring(6,8)),d=new Date(a,c,l);return d{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()})))}_createBalloonView(){const e=this.editor,t=this._balloonView=new Yg,i=ap(e),r=new op(e.locale,i.label);t.content.add(r),t.set({class:"ck-powered-by-balloon"}),e.ui.view.body.add(t),e.ui.focusTracker.add(t.element),this._balloonView=t}_showBalloon(){if(!this._lastFocusedEditableElement)return;const e=function(e,t){const i=ap(e),r="right"===i.side?function(e,t){return sp(e,t,((e,i)=>e.left+e.width-i.width-t.horizontalOffset))}(t,i):function(e,t){return sp(e,t,(e=>e.left+t.horizontalOffset))}(t,i);return{target:t,positions:[r]}}(this.editor,this._lastFocusedEditableElement);e&&(this._balloonView||this._createBalloonView(),this._balloonView.pin(e))}_hideBalloon(){this._balloonView&&this._balloonView.unpin()}_updateLastFocusedEditableElement(){const e=this.editor,t=e.ui.focusTracker.isFocused,i=e.ui.focusTracker.focusedElement;if(!t||!i)return void(this._lastFocusedEditableElement=null);const r=Array.from(e.ui.getEditableElementsNames()).map((t=>e.ui.getEditableElement(t)));r.includes(i)?this._lastFocusedEditableElement=i:this._lastFocusedEditableElement=r[0]}}class op extends Kn{constructor(e,t){super(e);const i=new vo,r=this.bindTemplate;i.set({content:'\n',isColorInherited:!1}),i.extendTemplate({attributes:{style:{width:"53px",height:"10px"}}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-powered-by"],"aria-hidden":!0},children:[{tag:"a",attributes:{href:"https://ckeditor.com/?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:r.to((e=>e.preventDefault()))}}]})}}function sp(e,t,i){return(r,n)=>{const o=new Fr(e);if(o.width<350||o.height<50)return null;let s;s="inside"===t.position?o.bottom-n.height:o.bottom-n.height/2,s-=t.verticalOffset;const a=i(o,n),c=r.clone().moveTo(a,s).getIntersection(n.clone().moveTo(a,s)).getVisible();return!c||c.getArea()t.regionName===e));n||(n=new mp(this.view.locale),this.view.regionViews.add(n)),n.set({regionName:e,text:t,politeness:i})}}class hp extends Kn{constructor(e){super(e),this.regionViews=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-aria-live-announcer"]},children:this.regionViews})}}class mp extends Kn{constructor(e){super(e);const t=this.bindTemplate;this.set("regionName",""),this.set("text",""),this.set("politeness",dp.POLITE),this.setTemplate({tag:"div",attributes:{role:"region","data-region":t.to("regionName"),"aria-live":t.to("politeness")},children:[{text:t.to("text")}]})}}class gp extends(q()){constructor(e){super(),this.isReady=!1,this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[];const t=e.editing.view;this.editor=e,this.componentFactory=new Hg(e),this.focusTracker=new Sn,this.tooltipManager=new tp(e),this.poweredBy=new np(e),this.ariaLiveAnnouncer=new up(e),this.set("viewportOffset",this._readViewportOffsetFromConfig()),this.once("ready",(()=>{this.isReady=!0})),this.listenTo(t.document,"layoutChanged",this.update.bind(this)),this.listenTo(t,"scrollToTheSelection",this._handleScrollToTheSelection.bind(this)),this._initFocusTracking()}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy(),this.tooltipManager.destroy(this.editor),this.poweredBy.destroy();for(const e of this._editableElementsMap.values())e.ckeditorInstance=null,this.editor.keystrokes.stopListening(e);this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[]}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.element),this.editor.keystrokes.listenTo(e.element)):e.once("render",(()=>{this.focusTracker.add(e.element),this.editor.keystrokes.listenTo(e.element)})),this._focusableToolbarDefinitions.push({toolbarView:e,options:t})}get _editableElements(){return console.warn("editor-ui-deprecated-editable-elements: The EditorUI#_editableElements property has been deprecated and will be removed in the near future.",{editorUI:this}),this._editableElementsMap}_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,t=e.editing.view;let i,r;e.keystrokes.set("Alt+F10",((e,n)=>{const o=this.focusTracker.focusedElement;Array.from(this._editableElementsMap.values()).includes(o)&&!Array.from(t.domRoots.values()).includes(o)&&(i=o);const s=this._getCurrentFocusedToolbarDefinition();s&&r||(r=this._getFocusableCandidateToolbarDefinitions());for(let e=0;e{const n=this._getCurrentFocusedToolbarDefinition();n&&(i?(i.focus(),i=null):e.editing.view.focus(),n.options.afterBlur&&n.options.afterBlur(),r())}))}_getFocusableCandidateToolbarDefinitions(){const e=[];for(const t of this._focusableToolbarDefinitions){const{toolbarView:i,options:r}=t;(Zr(i.element)||r.beforeFocus)&&e.push(t)}return e.sort(((e,t)=>pp(e)-pp(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(),!!Zr(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}}function pp(e){const{toolbarView:t,options:i}=e;let r=10;return Zr(t.element)&&r--,i.isContextual&&r--,r}var fp=i(6460),bp={attributes:{"data-cke":!0}};bp.setAttributes=Un(),bp.insert=zn().bind(null,"head"),bp.domAPI=Fn(),bp.insertStyleElement=$n();Ln()(fp.A,bp);fp.A&&fp.A.locals&&fp.A.locals;class wp extends Kn{constructor(e){super(e),this.body=new bo(e)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}class kp extends wp{constructor(e){super(e),this.top=this.createCollection(),this.main=this.createCollection(),this._voiceLabelView=this._createVoiceLabel(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-editor","ck-rounded-corners"],role:"application",dir:e.uiLanguageDirection,lang:e.uiLanguage,"aria-labelledby":this._voiceLabelView.id},children:[this._voiceLabelView,{tag:"div",attributes:{class:["ck","ck-editor__top","ck-reset_all"],role:"presentation"},children:this.top},{tag:"div",attributes:{class:["ck","ck-editor__main"],role:"presentation"},children:this.main}]})}_createVoiceLabel(){const e=this.t,t=new ts;return t.text=e("Rich Text Editor"),t.extendTemplate({attributes:{class:"ck-voice-label"}}),t}}class vp extends Kn{constructor(e,t,i){super(e),this.name=null,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 r=e.document.getRoot(t.name);i.addClass(t.isFocused?"ck-focused":"ck-blurred",r),i.removeClass(t.isFocused?"ck-blurred":"ck-focused",r)}))}e.isRenderingInProgress?function i(r){e.once("change:isRenderingInProgress",((e,n,o)=>{o?i(r):t(r)}))}(this):t(this)}}class _p extends vp{constructor(e,t,i,r={}){super(e,t,i);const n=e.t;this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}}),this._generateLabel=r.label||(()=>n("Editor editing area: %0",this.name))}render(){super.render();const e=this._editingView;e.change((t=>{const i=e.document.getRoot(this.name);t.setAttribute("aria-label",this._generateLabel(this),i)}))}}var yp=i(4332),xp={attributes:{"data-cke":!0}};xp.setAttributes=Un(),xp.insert=zn().bind(null,"head"),xp.domAPI=Fn(),xp.insertStyleElement=$n();Ln()(yp.A,xp);yp.A&&yp.A.locals&&yp.A.locals;class Ap extends Kn{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 vo,this.iconView.content=t.icon,this.children.add(this.iconView));const r=new Kn(e);r.setTemplate({tag:"h2",attributes:{class:["ck","ck-form__header__label"]},children:[{text:i.to("label")}]}),this.children.add(r)}}class Cp extends Is{static get pluginName(){return"Notification"}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 Ep extends(q()){constructor(e,t){super(),t&&sl(this,t),e&&this.set(e)}}var Sp=i(9172),Tp={attributes:{"data-cke":!0}};Tp.setAttributes=Un(),Tp.insert=zn().bind(null,"head"),Tp.domAPI=Fn(),Tp.insertStyleElement=$n();Ln()(Sp.A,Tp);Sp.A&&Sp.A.locals&&Sp.A.locals;var Pp=i(2589),Ip={attributes:{"data-cke":!0}};Ip.setAttributes=Un(),Ip.insert=zn().bind(null,"head"),Ip.domAPI=Fn(),Ip.insertStyleElement=$n();Ln()(Pp.A,Ip);Pp.A&&Pp.A.locals&&Pp.A.locals;const Mp=qr("px");class Op extends xs{static get pluginName(){return"ContextualBalloon"}constructor(e){super(e),this._viewToStack=new Map,this._idToStack=new Map,this._view=null,this._rotatorView=null,this._fakePanelsView=null,this.positionLimiter=()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},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 _("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 _("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._getBalloonPosition()),this._fakePanelsView.updatePosition()}showStack(e){this.visibleStack=e;const t=this._idToStack.get(e);if(!t)throw new _("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}_createPanelView(){this._view=new Yg(this.editor.locale),this.editor.ui.view.body.add(this._view),this.editor.ui.focusTracker.add(this._view.element),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 Np(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 r=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[r,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 Vp(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:r=!1}){this.view.class=t,this.view.withArrow=i,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),r&&(this._singleViewMode=!0)}_getBalloonPosition(){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})),e}}class Np extends Kn{constructor(e){super(e);const t=e.t,i=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new Sn,this.buttonPrevView=this._createButtonView(t("Previous"),''),this.buttonNextView=this._createButtonView(t("Next"),''),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 Ao(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i}}class Vp extends Kn{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",Mp),left:i.to("left",Mp),width:i.to("width",Mp),height:i.to("height",Mp)}},children:this.content}),this.on("change:numberOfPanels",((e,t,i,r)=>{i>r?this._addPanels(i-r):this._removePanels(r-i),this.updatePosition()}))}_addPanels(e){for(;e--;){const e=new Kn;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:r}=new Fr(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:i,height:r})}}}var Bp=i(5847),Rp={attributes:{"data-cke":!0}};Rp.setAttributes=Un(),Rp.insert=zn().bind(null,"head"),Rp.domAPI=Fn(),Rp.insertStyleElement=$n();Ln()(Bp.A,Rp);Bp.A&&Bp.A.locals&&Bp.A.locals;const Lp=qr("px");class Dp extends Kn{constructor(e){super(e);const t=this.bindTemplate;this.set("isActive",!1),this.set("isSticky",!1),this.set("limiterElement",null),this.set("limiterBottomOffset",50),this.set("viewportTopOffset",0),this.set("_marginLeft",null),this.set("_isStickyToTheBottomOfLimiter",!1),this.set("_stickyTopOffset",null),this.set("_stickyBottomOffset",null),this.content=this.createCollection(),this._contentPanelPlaceholder=new Yn({tag:"div",attributes:{class:["ck","ck-sticky-panel__placeholder"],style:{display:t.to("isSticky",(e=>e?"block":"none")),height:t.to("isSticky",(e=>e?Lp(this._contentPanelRect.height):null))}}}).render(),this._contentPanel=new Yn({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?Lp(this._contentPanelPlaceholder.getBoundingClientRect().width):null)),top:t.to("_stickyTopOffset",(e=>e?Lp(e):e)),bottom:t.to("_stickyBottomOffset",(e=>e?Lp(e):e)),marginLeft:t.to("_marginLeft")}},children:this.content}).render(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-sticky-panel"]},children:[this._contentPanelPlaceholder,this._contentPanel]})}render(){super.render(),this.checkIfShouldBeSticky(),this.listenTo(Nr.document,"scroll",(()=>{this.checkIfShouldBeSticky()}),{useCapture:!0}),this.listenTo(this,"change:isActive",(()=>{this.checkIfShouldBeSticky()}))}checkIfShouldBeSticky(){if(!this.limiterElement||!this.isActive)return void this._unstick();const e=new Fr(this.limiterElement);let t=e.getVisible();if(t){const e=new Fr(Nr.window);e.top+=this.viewportTopOffset,e.height-=this.viewportTopOffset,t=t.getIntersection(e)}if(t&&e.topt.bottom){const i=Math.max(e.bottom-t.bottom,0)+this.limiterBottomOffset;e.bottom-i>e.top+this._contentPanelRect.height?this._stickToBottomOfLimiter(i):this._unstick()}else this._contentPanelRect.height+this.limiterBottomOffset{this.reset(),this.focus(),this.fire("reset")})),this.resetButtonView.bind("isVisible").to(this.fieldView,"isEmpty",(e=>!e)),this.fieldWrapperChildren.add(this.resetButtonView),this.extendTemplate({attributes:{class:"ck-search__query_with-reset"}}))}reset(){this.fieldView.reset(),this._viewConfig.showResetButton&&(this.resetButtonView.isVisible=!1)}}class jp extends Kn{constructor(){super();const e=this.bindTemplate;this.set({isVisible:!1,primaryText:"",secondaryText:""}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-search__info",e.if("isVisible","ck-hidden",(e=>!e))],tabindex:-1},children:[{tag:"span",children:[{text:[e.to("primaryText")]}]},{tag:"span",children:[{text:[e.to("secondaryText")]}]}]})}focus(){this.element.focus()}}class zp extends Kn{constructor(e){super(e),this.children=this.createCollection(),this.focusTracker=new Sn,this.setTemplate({tag:"div",attributes:{class:["ck","ck-search__results"],tabindex:-1},children:this.children}),this._focusCycler=new ws({focusables:this.children,focusTracker:this.focusTracker})}render(){super.render();for(const e of this.children)this.focusTracker.add(e.element)}focus(){this._focusCycler.focusFirst()}focusFirst(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}var Hp=/[\\^$.*+?()[\]{}|]/g,Up=RegExp(Hp.source);const Wp=function(e){return(e=ca(e))&&Up.test(e)?e.replace(Hp,"\\$&"):e};var $p=i(8998),qp={attributes:{"data-cke":!0}};qp.setAttributes=Un(),qp.insert=zn().bind(null,"head"),qp.domAPI=Fn(),qp.insertStyleElement=$n();Ln()($p.A,qp);$p.A&&$p.A.locals&&$p.A.locals;class Gp extends Kn{constructor(e,t){super(e),this._config=t,this.filteredView=t.filteredView,this.queryView=this._createSearchTextQueryView(),this.focusTracker=new Sn,this.keystrokes=new Tn,this.resultsView=new zp(e),this.children=this.createCollection(),this.focusableChildren=this.createCollection([this.queryView,this.resultsView]),this.set("isEnabled",!0),this.set("resultsCount",0),this.set("totalItemsCount",0),t.infoView&&t.infoView.instance?this.infoView=t.infoView.instance:(this.infoView=new jp,this._enableDefaultInfoViewBehavior(),this.on("render",(()=>{this.search("")}))),this.resultsView.children.addMany([this.infoView,this.filteredView]),this.focusCycler=new ws({focusables:this.focusableChildren,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.on("search",((e,{resultsCount:t,totalItemsCount:i})=>{this.resultsCount=t,this.totalItemsCount=i})),this.setTemplate({tag:"div",attributes:{class:["ck","ck-search",t.class||null],tabindex:"-1"},children:this.children})}render(){super.render(),this.children.addMany([this.queryView,this.resultsView]);const e=e=>e.stopPropagation();for(const e of this.focusableChildren)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}focus(){this.queryView.focus()}reset(){this.queryView.reset(),this.search("")}search(e){const t=e?new RegExp(Wp(e),"ig"):null,i=this.filteredView.filter(t);this.fire("search",{query:e,...i})}_createSearchTextQueryView(){const e=new Fp(this.locale,this._config.queryView);return this.listenTo(e.fieldView,"input",(()=>{this.search(e.fieldView.element.value)})),e.on("reset",(()=>this.reset())),e.bind("isEnabled").to(this),e}_enableDefaultInfoViewBehavior(){const e=this.locale.t,t=this.infoView;function i(e,{query:t,resultsCount:i,totalItemsCount:r}){return"function"==typeof e?e(t,i,r):e}this.on("search",((r,n)=>{if(n.resultsCount)t.set({isVisible:!1});else{const r=this._config.infoView&&this._config.infoView.text;let o,s;n.totalItemsCount?r&&r.notFound?(o=r.notFound.primary,s=r.notFound.secondary):(o=e("No results found"),s=""):r&&r.noSearchableItems?(o=r.noSearchableItems.primary,s=r.noSearchableItems.secondary):(o=e("No searchable items"),s=""),t.set({primaryText:i(o,n),secondaryText:i(s,n),isVisible:!0})}}))}}var Kp=i(3114),Yp={attributes:{"data-cke":!0}};Yp.setAttributes=Un(),Yp.insert=zn().bind(null,"head"),Yp.domAPI=Fn(),Yp.insertStyleElement=$n();Ln()(Kp.A,Yp);Kp.A&&Kp.A.locals&&Kp.A.locals;class Jp extends Gp{constructor(e,t){super(e,t),this._config=t;const i=qr("px");this.extendTemplate({attributes:{class:["ck-autocomplete"]}});const r=this.resultsView.bindTemplate;this.resultsView.set("isVisible",!1),this.resultsView.set("_position","s"),this.resultsView.set("_width",0),this.resultsView.extendTemplate({attributes:{class:[r.if("isVisible","ck-hidden",(e=>!e)),r.to("_position",(e=>`ck-search__results_${e}`))],style:{width:r.to("_width",i)}}}),this.focusTracker.on("change:isFocused",((e,i,r)=>{this._updateResultsVisibility(),r?this.resultsView.element.scrollTop=0:t.resetOnBlur&&this.queryView.reset()})),this.on("search",(()=>{this._updateResultsVisibility(),this._updateResultsViewWidthAndPosition()})),this.keystrokes.set("esc",((e,t)=>{this.resultsView.isVisible&&(this.queryView.focus(),this.resultsView.isVisible=!1,t())})),this.listenTo(Nr.document,"scroll",(()=>{this._updateResultsViewWidthAndPosition()})),this.on("change:isEnabled",(()=>{this._updateResultsVisibility()})),this.filteredView.on("execute",((e,{value:t})=>{this.focus(),this.reset(),this.queryView.fieldView.value=this.queryView.fieldView.element.value=t,this.resultsView.isVisible=!1})),this.resultsView.on("change:isVisible",(()=>{this._updateResultsViewWidthAndPosition()}))}_updateResultsViewWidthAndPosition(){if(!this.resultsView.isVisible)return;this.resultsView._width=new Fr(this.queryView.fieldView.element).width;const e=Jp._getOptimalPosition({element:this.resultsView.element,target:this.queryView.element,fitInViewport:!0,positions:Jp.defaultResultsPositions});this.resultsView._position=e?e.name:"s"}_updateResultsVisibility(){const e=void 0===this._config.queryMinChars?0:this._config.queryMinChars,t=this.queryView.fieldView.element.value.length;this.resultsView.isVisible=this.focusTracker.isFocused&&this.isEnabled&&t>=e}}Jp.defaultResultsPositions=[e=>({top:e.bottom,left:e.left,name:"s"}),(e,t)=>({top:e.top-t.height,left:e.left,name:"n"})],Jp._getOptimalPosition=Qr;const Zp=function(e){return function(t){return null==e?void 0:e[t]}};Zp({"&":"&","<":"<",">":">",'"':""","'":"'"});var Qp=/[&<>"']/g;RegExp(Qp.source);var Xp=i(8008),ef={attributes:{"data-cke":!0}};ef.setAttributes=Un(),ef.insert=zn().bind(null,"head"),ef.domAPI=Fn(),ef.insertStyleElement=$n();Ln()(Xp.A,ef);Xp.A&&Xp.A.locals&&Xp.A.locals;var tf=i(3832),rf={attributes:{"data-cke":!0}};rf.setAttributes=Un(),rf.insert=zn().bind(null,"head"),rf.domAPI=Fn(),rf.insertStyleElement=$n();Ln()(tf.A,rf);tf.A&&tf.A.locals&&tf.A.locals;class nf extends Kn{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 Ao(this.locale),t=e.bindTemplate;return e.set({withText:!0,icon:fs}),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}}var of=i(3876),sf={attributes:{"data-cke":!0}};sf.setAttributes=Un(),sf.insert=zn().bind(null,"head"),sf.domAPI=Fn(),sf.insertStyleElement=$n();Ln()(of.A,sf);of.A&&of.A.locals&&of.A.locals;qr("px");var af=i(473),cf={attributes:{"data-cke":!0}};cf.setAttributes=Un(),cf.insert=zn().bind(null,"head"),cf.domAPI=Fn(),cf.insertStyleElement=$n();Ln()(af.A,cf);af.A&&af.A.locals&&af.A.locals,qr("px");qr("px");class lf extends gp{constructor(e,t){super(e),this.view=t,this._toolbarConfig=ys(e.config.get("toolbar")),this._elementReplacer=new Q,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,r=t.editing.view,n=i.editable,o=r.document.getRoot();n.name=o.rootName,i.render();const s=n.element;this.setEditableElement(n.name,s),i.editable.bind("isFocused").to(this.focusTracker),r.attachDomRoot(s),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),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",(({top: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(),r=e.sourceElement;let n;const o=e.config.get("placeholder");o&&(n="string"==typeof o?o:o[this.view.editable.name]),!n&&r&&"textarea"===r.tagName.toLowerCase()&&(n=r.getAttribute("placeholder")),n&&(i.placeholder=n),Bs({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}_handleScrollToTheSelectionWithStickyPanel(e,t,i){const r=this.view.stickyPanel;if(r.isSticky){const e=new Fr(r.element).height;t.viewportOffset.top+=e}else{const e=()=>{this.editor.editing.view.scrollToTheSelection(i)};this.listenTo(r,"change:isSticky",e),setTimeout((()=>{this.stopListening(r,"change:isSticky",e)}),20)}}}var df=i(6775),uf={attributes:{"data-cke":!0}};uf.setAttributes=Un(),uf.insert=zn().bind(null,"head"),uf.domAPI=Fn(),uf.insertStyleElement=$n();Ln()(df.A,uf);df.A&&df.A.locals&&df.A.locals;class hf extends kp{constructor(e,t,i={}){super(e),this.stickyPanel=new Dp(e),this.toolbar=new Tm(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),this.editable=new _p(e,t)}render(){super.render(),this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}class mf{constructor(e){if(this.crashes=[],this.state="initializing",this._now=Date.now,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(){if(this.crashes.length<=this._crashNumberLimit)return!0;return(this.crashes[this.crashes.length-1].date-this.crashes[this.crashes.length-1-this._crashNumberLimit].date)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}}function gf(e,t=new Set){const i=[e],r=new Set;let n=0;for(;i.length>n;){const e=i[n++];if(!r.has(e)&&pf(e)&&!t.has(e))if(r.add(e),Symbol.iterator in e)try{for(const t of e)i.push(t)}catch(e){}else for(const t in e)"defaultValue"!==t&&i.push(e[t])}return r}function pf(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 ff(e,t,i=new Set){if(e===t&&("object"==typeof(r=e)&&null!==r))return!0;var r;const n=gf(e,i),o=gf(t,i);for(const e of n)if(o.has(e))return!0;return!1}class bf extends mf{constructor(e,t={}){super(t),this._editor=null,this._initUsingData=!0,this._editables={},this._throttledSave=rp(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||{},r={};for(const[n,o]of Object.entries(this._data.roots))o.isLoaded?(e[n]="",r[n]=i[n]||{}):t.push(n);const n={...this._config,extraPlugins:this._config.extraPlugins||[],lazyRoots:t,rootsAttributes:r,_watchdogInitialData:this._data};return delete n.initialData,n.extraPlugins.push(wf),this._initUsingData?this.create(e,n,n.context):yr(this._elementOrData)?this.create(this._elementOrData,n,n.context):this.create(this._editables,n,n.context)})).then((()=>{this._fire("restart")}))}create(e=this._elementOrData,t=this._config,i){return Promise.resolve().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")}))}destroy(){return Promise.resolve().then((()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_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,r=i.has("CommentsRepository")&&i.get("CommentsRepository"),n=i.has("TrackChanges")&&i.get("TrackChanges"),o={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};t.forEach((e=>{o.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&&(o.markers[t.name]={rangeJSON:t.getRange().toJSON(),usingOperation:t._managedUsingOperations,affectsData:t._affectsData});return r&&(o.commentThreads=JSON.stringify(r.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),n&&(o.suggestions=JSON.stringify(n.getSuggestions({toJSON:!0,skipNotAttached:!0}))),o}_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 ff(this._editor,e.context,this._excludedProps)}_cloneEditorConfiguration(e){return _r(e,((e,t)=>yr(e)||"context"===t?e:void 0))}}class wf{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 r of t.children)i._appendChild(this._createNode(e,r));return i}return e.createText(t.data,t.attributes)}_restoreEditorData(e){const t=this.editor;Object.entries(this._data.roots).forEach((([i,{content:r,attributes:n}])=>{const o=JSON.parse(r),s=JSON.parse(n),a=t.model.document.getRoot(i);for(const[t,i]of s)e.setAttribute(t,i,a);for(const t of o){const i=this._createNode(e,t);e.insert(i,a,"end")}})),Object.entries(this._data.markers).forEach((([i,r])=>{const{document:n}=t.model,{rangeJSON:{start:o,end:s},...a}=r,c=n.getRoot(o.root),l=e.createPositionFromPath(c,o.path,o.stickiness),d=e.createPositionFromPath(c,s.path,s.stickiness),u=e.createRange(l,d);e.addMarker(i,{range:u,...a})}))}_restoreCollaborationData(){const e=JSON.parse(this._data.commentThreads),t=JSON.parse(this._data.suggestions);e.forEach((e=>{const t=this.editor.config.get("collaboration.channelId"),i=this.editor.plugins.get("CommentsRepository");if(i.hasCommentThread(e.threadId)){i.getCommentThread(e.threadId).remove()}i.addCommentThread({channelId:t,...e})})),t.forEach((e=>{const t=this.editor.plugins.get("TrackChangesEditing");if(t.hasSuggestion(e.id)){t.getSuggestion(e.id).attributes=e.attributes}else t.addSuggestionData(e)}))}}const kf=Symbol("MainQueueId");class vf{constructor(){this._onEmptyCallbacks=[],this._queues=new Map,this._activeActions=0}onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){const i=e===kf;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());const r=(i?Promise.all(this._queues.values()):Promise.all([this._queues.get(kf),this._queues.get(e)])).then(t),n=r.catch((()=>{}));return this._queues.set(e,n),r.finally((()=>{this._activeActions--,this._queues.get(e)===n&&0===this._activeActions&&this._onEmptyCallbacks.forEach((e=>e()))}))}}function _f(e){return Array.isArray(e)?e:[e]}class yf extends(bm(wm(fm))){constructor(e,t={}){if(!xf(e)&&void 0!==t.initialData)throw new _("editor-create-initial-data",null);super(t),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return xf(e)?(t=e,t instanceof HTMLTextAreaElement?t.value:t.innerHTML):e;var t}(e)),xf(e)&&(this.sourceElement=e),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),r=new hf(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:i});this.ui=new lf(this,r),function(e){if(!ze(e.updateSourceElement))throw new _("attachtoform-missing-elementapi-interface",e);const t=e.sourceElement;if(function(e){return!!e&&"textarea"===e.tagName.toLowerCase()}(t)&&t.form){let i;const r=t.form,n=()=>e.updateSourceElement();ze(r.submit)&&(i=r.submit,r.submit=()=>{n(),i.apply(r)}),r.addEventListener("submit",n),e.on("destroy",(()=>{r.removeEventListener("submit",n),i&&(r.submit=i)}))}}(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise((i=>{const r=new this(e,t);i(r.initPlugins().then((()=>r.ui.init(xf(e)?e:null))).then((()=>r.data.init(r.config.get("initialData")))).then((()=>r.fire("ready"))).then((()=>r)))}))}}function xf(e){return yr(e)}yf.Context=Ps,yf.EditorWatchdog=bf,yf.ContextWatchdog=class extends mf{constructor(e,t={}){super(t),this._watchdogs=new Map,this._context=null,this._contextProps=new Set,this._actionQueues=new vf,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(kf,(()=>(this._contextConfig=e,this._create())))}getItem(e){return this._getWatchdog(e)._item}getItemState(e){return this._getWatchdog(e).state}add(e){const t=_f(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 bf(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:r,causesRestart:n})=>{this._fire("itemError",{itemId:e.id,error:r}),n&&this._actionQueues.enqueue(e.id,(()=>new Promise((i=>{const r=()=>{t.off("restart",r),this._fire("itemRestart",{itemId:e.id}),i()};t.on("restart",r)}))))})),t.create(e.sourceElementOrData,e.config,this._context);throw new Error(`Not supported item type: '${e.type}'.`)})))))}remove(e){const t=_f(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(kf,(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_restart(){return this._actionQueues.enqueue(kf,(()=>(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=gf(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 ff(this._context,e.context)}};class Af{constructor(e,t=20){this._batch=null,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 Cf extends Cs{constructor(e,t){super(e),this._buffer=new Af(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,r=e.text||"",n=r.length;let o=i.selection;if(e.selection?o=e.selection:e.range&&(o=t.createSelection(e.range)),!t.canEditAt(o))return;const s=e.resultRange;t.enqueueChange(this._buffer.batch,(e=>{this._buffer.lock();const a=Array.from(i.selection.getAttributes());t.deleteContent(o),r&&t.insertContent(e.createText(r,a),o),s?e.setSelection(s):o.is("documentSelection")||e.setSelection(o),this._buffer.unlock(),this._buffer.input(n)}))}}const Ef=["insertText","insertReplacementText"];class Sf extends ol{constructor(e){super(e),this.focusObserver=e.getObserver(Vl),l.isAndroid&&Ef.push("insertCompositionText");const t=e.document;t.on("beforeinput",((i,r)=>{if(!this.isEnabled)return;const{data:n,targetRanges:o,inputType:s,domEvent:a}=r;if(!Ef.includes(s))return;this.focusObserver.flush();const c=new f(t,"insertText");t.fire(c,new al(e,a,{text:n,selection:e.createSelection(o)})),c.stop.called&&i.stop()})),t.on("compositionend",((i,{data:r,domEvent:n})=>{this.isEnabled&&!l.isAndroid&&r&&t.fire("insertText",new al(e,n,{text:r,selection:t.selection}))}),{priority:"lowest"})}observe(){}stopObserving(){}}class Tf extends xs{static get pluginName(){return"Input"}init(){const e=this.editor,t=e.model,i=e.editing.view,r=t.document.selection;i.addObserver(Sf);const n=new Cf(e,e.config.get("typing.undoStep")||20);e.commands.add("insertText",n),e.commands.add("input",n),this.listenTo(i.document,"insertText",((r,n)=>{i.document.isComposing||n.preventDefault();const{text:o,selection:s,resultRange:a}=n,c=Array.from(s.getRanges()).map((t=>e.editing.mapper.toModelRange(t)));let d=o;if(l.isAndroid){const e=Array.from(c[0].getItems()).reduce(((e,t)=>e+(t.is("$textProxy")?t.data:"")),"");e&&(e.length<=d.length?d.startsWith(e)&&(d=d.substring(e.length),c[0].start=c[0].start.getShiftedBy(e.length)):e.startsWith(d)&&(c[0].start=c[0].start.getShiftedBy(d.length),d=""))}const u={text:d,selection:t.createSelection(c)};a&&(u.resultRange=e.editing.mapper.toModelRange(a)),e.execute("insertText",u),i.scrollToTheSelection()})),l.isAndroid?this.listenTo(i.document,"keydown",((e,o)=>{!r.isCollapsed&&229==o.keyCode&&i.document.isComposing&&Pf(t,n)})):this.listenTo(i.document,"compositionstart",(()=>{r.isCollapsed||Pf(t,n)}))}}function Pf(e,t){if(!t.isEnabled)return;const i=t.buffer;i.lock(),e.enqueueChange(i.batch,(()=>{e.deleteContent(e.document.selection)})),i.unlock()}class If extends Cs{constructor(e,t){super(e),this.direction=t,this._buffer=new Af(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,(r=>{this._buffer.lock();const n=r.createSelection(e.selection||i.selection);if(!t.canEditAt(n))return;const o=e.sequence||1,s=n.isCollapsed;if(n.isCollapsed&&t.modifySelection(n,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(o))return void this._replaceEntireContentWithParagraph(r);if(this._shouldReplaceFirstBlockWithParagraph(n,o))return void this.editor.execute("paragraph",{selection:n});if(n.isCollapsed)return;let a=0;n.getFirstRange().getMinimalFlatRanges().forEach((e=>{a+=X(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),t.deleteContent(n,{doNotResetEntireContent:s,direction:this.direction}),this._buffer.input(a),r.setSelection(n),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,i=t.document.selection,r=t.schema.getLimitElement(i);if(!(i.isCollapsed&&i.containsEntireContent(r)))return!1;if(!t.schema.checkChild(r,"paragraph"))return!1;const n=r.getChild(0);return!n||!n.is("element","paragraph")}_replaceEntireContentWithParagraph(e){const t=this.editor.model,i=t.document.selection,r=t.schema.getLimitElement(i),n=e.createElement("paragraph");e.remove(e.createRangeIn(r)),e.insert(n,r),e.setSelection(n,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const i=this.editor.model;if(t>1||"backward"!=this.direction)return!1;if(!e.isCollapsed)return!1;const r=e.getFirstPosition(),n=i.schema.getLimitElement(r),o=n.getChild(0);return r.parent==o&&(!!e.containsEntireContent(o)&&(!!i.schema.checkChild(n,"paragraph")&&"paragraph"!=o.name))}}const Mf="word",Of="selection",Nf="backward",Vf="forward",Bf={deleteContent:{unit:Of,direction:Nf},deleteContentBackward:{unit:"codePoint",direction:Nf},deleteWordBackward:{unit:Mf,direction:Nf},deleteHardLineBackward:{unit:Of,direction:Nf},deleteSoftLineBackward:{unit:Of,direction:Nf},deleteContentForward:{unit:"character",direction:Vf},deleteWordForward:{unit:Mf,direction:Vf},deleteHardLineForward:{unit:Of,direction:Vf},deleteSoftLineForward:{unit:Of,direction:Vf}};class Rf extends ol{constructor(e){super(e);const t=e.document;let i=0;t.on("keydown",(()=>{i++})),t.on("keyup",(()=>{i=0})),t.on("beforeinput",((r,n)=>{if(!this.isEnabled)return;const{targetRanges:o,domEvent:s,inputType:a}=n,c=Bf[a];if(!c)return;const d={direction:c.direction,unit:c.unit,sequence:i};d.unit==Of&&(d.selectionToRemove=e.createSelection(o[0])),"deleteContentBackward"===a&&(l.isAndroid&&(d.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}of t){if(e.parent.is("$text")){const t=e.parent.data,r=e.offset;if(Mn(t,r)||On(t,r)||Vn(t,r))continue;i++}else i++;if(i>1)return!0}return!1}(o)&&(d.unit=Of,d.selectionToRemove=e.createSelection(o)));const u=new rc(t,"delete",o[0]);t.fire(u,new al(e,s,d)),u.stop.called&&r.stop()})),l.isBlink&&function(e){const t=e.view,i=t.document;let r=null,n=!1;function o(e){return e==gn.backspace||e==gn.delete}function s(e){return e==gn.backspace?Nf:Vf}i.on("keydown",((e,{keyCode:t})=>{r=t,n=!1})),i.on("keyup",((a,{keyCode:c,domEvent:l})=>{const d=i.selection,u=e.isEnabled&&c==r&&o(c)&&!d.isCollapsed&&!n;if(r=null,u){const e=d.getFirstRange(),r=new rc(i,"delete",e),n={unit:Of,direction:s(c),selectionToRemove:d};i.fire(r,new al(t,l,n))}})),i.on("beforeinput",((e,{inputType:t})=>{const i=Bf[t];o(r)&&i&&i.direction==s(r)&&(n=!0)}),{priority:"high"}),i.on("beforeinput",((e,{inputType:t,data:i})=>{r==gn.delete&&"insertText"==t&&""==i&&e.stop()}),{priority:"high"})}(this)}observe(){}stopObserving(){}}class Lf extends xs{static get pluginName(){return"Delete"}init(){const e=this.editor,t=e.editing.view,i=t.document,r=e.model.document;t.addObserver(Rf),this._undoOnBackspace=!1;const n=new If(e,"forward");e.commands.add("deleteForward",n),e.commands.add("forwardDelete",n),e.commands.add("delete",new If(e,"backward")),this.listenTo(i,"delete",((r,n)=>{i.isComposing||n.preventDefault();const{direction:o,sequence:s,selectionToRemove:a,unit:c}=n,l="forward"===o?"deleteForward":"delete",d={sequence:s};if("selection"==c){const t=Array.from(a.getRanges()).map((t=>e.editing.mapper.toModelRange(t)));d.selection=e.model.createSelection(t)}else d.unit=c;e.execute(l,d),t.scrollToTheSelection()}),{priority:"low"}),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(r,"change",(()=>{this._undoOnBackspace=!1})))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class Df extends xs{static get requires(){return[Tf,Lf]}static get pluginName(){return"Typing"}}function Ff(e,t){let i=e.start;return{text:Array.from(e.getWalker({ignoreElementEnd:!1})).reduce(((e,{item:r})=>r.is("$text")||r.is("$textProxy")?e+r.data:(i=t.createPositionAfter(r),"")),""),range:t.createRange(i,e.end)}}class jf extends(q()){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,r=i.document.selection,n=i.createRange(i.createPositionAt(r.focus.parent,0),r.focus),{text:o,range:s}=Ff(n,i),a=this.testCallback(o);if(!a&&this.hasMatch&&this.fire("unmatched"),this._hasMatch=!!a,a){const i=Object.assign(t,{text:o,range:s});"object"==typeof a&&Object.assign(i,a),this.fire(`matched:${e}`,i)}}}class zf extends xs{static get pluginName(){return"TwoStepCaretMovement"}constructor(e){super(e),this._isNextGravityRestorationSkipped=!1,this.attributes=new Set,this._overrideUid=null}init(){const e=this.editor,t=e.model,i=e.editing.view,r=e.locale,n=t.document.selection;this.listenTo(i.document,"arrowKey",((e,t)=>{if(!n.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const i=t.keyCode==gn.arrowright,o=t.keyCode==gn.arrowleft;if(!i&&!o)return;const s=r.contentLanguageDirection;let a=!1;a="ltr"===s&&i||"rtl"===s&&o?this._handleForwardMovement(t):this._handleBackwardMovement(t),!0===a&&e.stop()}),{context:"$text",priority:"highest"}),this.listenTo(n,"change:range",((e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&Gf(n.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,r=i.document.selection,n=r.getFirstPosition();return!this._isGravityOverridden&&((!n.isAtStart||!Hf(r,t))&&(!!Gf(n,t)&&($f(e),Hf(r,t)&&Gf(n,t,!0)?Wf(i,t):this._overrideGravity(),!0)))}_handleBackwardMovement(e){const t=this.attributes,i=this.editor.model,r=i.document.selection,n=r.getFirstPosition();return this._isGravityOverridden?($f(e),this._restoreGravity(),Gf(n,t,!0)?Wf(i,t):Uf(i,t,n),!0):n.isAtStart?!!Hf(r,t)&&($f(e),Uf(i,t,n),!0):!Hf(r,t)&&Gf(n,t,!0)?($f(e),Uf(i,t,n),!0):!!qf(n,t)&&(n.isAtEnd&&!Hf(r,t)&&Gf(n,t)?($f(e),Uf(i,t,n),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1))}_enableClickingAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,r=e.editing.view.document;e.editing.view.addObserver(Uh);let n=!1;this.listenTo(r,"mousedown",(()=>{n=!0})),this.listenTo(r,"selectionChange",(()=>{const e=this.attributes;if(!n)return;if(n=!1,!i.isCollapsed)return;if(!Hf(i,e))return;const r=i.getFirstPosition();Gf(r,e)&&(r.isAtStart||Gf(r,e,!0)?Wf(t,e):this._isGravityOverridden||this._overrideGravity())}))}_enableInsertContentSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection,i=this.attributes;this.listenTo(e,"insertContent",(()=>{const r=t.getFirstPosition();Hf(t,i)&&Gf(r,i)&&Wf(e,i)}),{priority:"low"})}_handleDeleteContentAfterNode(){const e=this.editor,t=e.model,i=t.document.selection,r=e.editing.view;let n=!1,o=!1;this.listenTo(r.document,"delete",((e,t)=>{n="backward"===t.direction}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{if(!n)return;const e=i.getFirstPosition();o=Hf(i,this.attributes)&&!qf(e,this.attributes)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{n&&(n=!1,o||e.model.enqueueChange((()=>{const e=i.getFirstPosition();Hf(i,this.attributes)&&Gf(e,this.attributes)&&(e.isAtStart||Gf(e,this.attributes,!0)?Wf(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 Hf(e,t){for(const i of t)if(e.hasAttribute(i))return!0;return!1}function Uf(e,t,i){const r=i.nodeBefore;e.change((i=>{if(r){const t=[],n=e.schema.isObject(r)&&e.schema.isInline(r);for(const[i,o]of r.getAttributes())!e.schema.checkAttribute("$text",i)||n&&!1===e.schema.getAttributeProperties(i).copyFromObject||t.push([i,o]);i.setSelectionAttribute(t)}else i.removeSelectionAttribute(t)}))}function Wf(e,t){e.change((e=>{e.removeSelectionAttribute(t)}))}function $f(e){e.preventDefault()}function qf(e,t){return Gf(e.getShiftedBy(-1),t)}function Gf(e,t,i=!1){const{nodeBefore:r,nodeAfter:n}=e;for(const e of t){const t=r?r.getAttribute(e):void 0,o=n?n.getAttribute(e):void 0;if((!i||void 0!==t&&void 0!==o)&&o!==t)return!0}return!1}Kf('"'),Kf("'"),Kf("'"),Kf('"'),Kf('"'),Kf("'");function Kf(e){return new RegExp(`(^|\\s)(${e})([^${e}]*)(${e})$`)}function Yf(e,t,i,r){return r.createRange(Jf(e,t,i,!0,r),Jf(e,t,i,!1,r))}function Jf(e,t,i,r,n){let o=e.textNode||(r?e.nodeBefore:e.nodeAfter),s=null;for(;o&&o.getAttribute(t)==i;)s=o,o=r?o.previousSibling:o.nextSibling;return s?n.createPositionAt(s,r?"before":"after"):e}function Zf(e,t,i,r){const n=e.editing.view,o=new Set;n.document.registerPostFixer((n=>{const s=e.model.document.selection;let a=!1;if(s.hasAttribute(t)){const c=Yf(s.getFirstPosition(),t,s.getAttribute(t),e.model),l=e.editing.mapper.toViewRange(c);for(const e of l.getItems())e.is("element",i)&&!e.hasClass(r)&&(n.addClass(r,e),o.add(e),a=!0)}return a})),e.conversion.for("editingDowncast").add((e=>{function t(){n.change((e=>{for(const t of o.values())e.removeClass(r,t),o.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*Qf(e,t){for(const i of t)i&&e.getAttributeProperties(i[0]).copyOnEnter&&(yield i)}class Xf extends Cs{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,r=t.schema,n=i.isCollapsed,o=i.getFirstRange(),s=o.start.parent,a=o.end.parent;if(r.isLimit(s)||r.isLimit(a))return n||s!=a||t.deleteContent(i),!1;if(n){const t=Qf(e.model.schema,i.getAttributes());return eb(e,o.start),e.setSelectionAttribute(t),!0}{const r=!(o.start.isAtStart&&o.end.isAtEnd),n=s==a;if(t.deleteContent(i,{leaveUnmerged:r}),r){if(n)return eb(e,i.focus),!0;e.setSelection(a,0)}}return!1}}function eb(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}const tb={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class ib extends ol{constructor(e){super(e);const t=this.document;let i=!1;t.on("keydown",((e,t)=>{i=t.shiftKey})),t.on("beforeinput",((r,n)=>{if(!this.isEnabled)return;let o=n.inputType;l.isSafari&&i&&"insertParagraph"==o&&(o="insertLineBreak");const s=n.domEvent,a=tb[o];if(!a)return;const c=new rc(t,"enter",n.targetRanges[0]);t.fire(c,new al(e,s,{isSoft:a.isSoft})),c.stop.called&&r.stop()}))}observe(){}stopObserving(){}}class rb extends xs{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,i=t.document;t.addObserver(ib),e.commands.add("enter",new Xf(e)),this.listenTo(i,"enter",((r,n)=>{i.isComposing||n.preventDefault(),n.isSoft||(e.execute("enter"),t.scrollToTheSelection())}),{priority:"low"})}}class nb extends Cs{execute(){const e=this.editor.model,t=e.document;e.change((i=>{!function(e,t,i){const r=i.isCollapsed,n=i.getFirstRange(),o=n.start.parent,s=n.end.parent,a=o==s;if(r){const r=Qf(e.schema,i.getAttributes());ob(e,t,n.end),t.removeSelectionAttribute(i.getAttributeKeys()),t.setSelectionAttribute(r)}else{const r=!(n.start.isAtStart&&n.end.isAtEnd);e.deleteContent(i,{leaveUnmerged:r}),a?ob(e,t,i.focus):r&&t.setSelection(s,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 r=t.getFirstRange(),n=r.start.parent,o=r.end.parent;if((sb(n,e)||sb(o,e))&&n!==o)return!1;return!0}(e.schema,t.selection)}}function ob(e,t,i){const r=t.createElement("softBreak");e.insertContent(r,i),t.setSelection(r,"after")}function sb(e,t){return!e.is("rootElement")&&(t.isLimit(e)||sb(e.parent,t))}class ab extends xs{static get pluginName(){return"ShiftEnter"}init(){const e=this.editor,t=e.model.schema,i=e.conversion,r=e.editing.view,n=r.document;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")}),r.addObserver(ib),e.commands.add("shiftEnter",new nb(e)),this.listenTo(n,"enter",((t,i)=>{n.isComposing||i.preventDefault(),i.isSoft&&(e.execute("shiftEnter"),r.scrollToTheSelection())}),{priority:"low"})}}class cb extends(M()){constructor(){super(...arguments),this._stack=[]}add(e,t){const i=this._stack,r=i[0];this._insertDescriptor(e);const n=i[0];r===n||lb(r,n)||this.fire("change:top",{oldDescriptor:r,newDescriptor:n,writer:t})}remove(e,t){const i=this._stack,r=i[0];this._removeDescriptor(e);const n=i[0];r===n||lb(r,n)||this.fire("change:top",{oldDescriptor:r,newDescriptor:n,writer:t})}_insertDescriptor(e){const t=this._stack,i=t.findIndex((t=>t.id===e.id));if(lb(e,t[i]))return;i>-1&&t.splice(i,1);let r=0;for(;t[r]&&db(t[r],e);)r++;t.splice(r,0,e)}_removeDescriptor(e){const t=this._stack,i=t.findIndex((t=>t.id===e));i>-1&&t.splice(i,1)}}function lb(e,t){return e&&t&&e.priority==t.priority&&ub(e.classes)==ub(t.classes)}function db(e,t){return e.priority>t.priority||!(e.priorityub(t.classes)}function ub(e){return Array.isArray(e)?e.sort().join(","):e}const hb='',mb="ck-widget_selected";function gb(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function pb(e,t,i={}){if(!e.is("containerElement"))throw new _("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=_b,t.setCustomProperty("widgetLabel",[],e),i.label&&function(e,t){const i=e.getCustomProperty("widgetLabel");i.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 vo;return i.set("content",hb),i.render(),t.appendChild(i.element),t}));t.insert(t.createPositionAt(e,0),i),t.addClass(["ck-widget_with-selection-handle"],e)}(e,t),wb(e,t),e}function fb(e,t,i){if(t.classes&&i.addClass(yn(t.classes),e),t.attributes)for(const r in t.attributes)i.setAttribute(r,t.attributes[r],e)}function bb(e,t,i){if(t.classes&&i.removeClass(yn(t.classes),e),t.attributes)for(const r in t.attributes)i.removeAttribute(r,e)}function wb(e,t,i=fb,r=bb){const n=new cb;n.on("change:top",((t,n)=>{n.oldDescriptor&&r(e,n.oldDescriptor,n.writer),n.newDescriptor&&i(e,n.newDescriptor,n.writer)}));t.setCustomProperty("addHighlight",((e,t,i)=>n.add(t,i)),e),t.setCustomProperty("removeHighlight",((e,t,i)=>n.remove(t,i)),e)}function kb(e,t,i={}){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),t.setAttribute("role","textbox",e),i.label&&t.setAttribute("aria-label",i.label,e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",((i,r,n)=>{t.setAttribute("contenteditable",n?"false":"true",e)})),e.on("change:isFocused",((i,r,n)=>{n?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)})),wb(e,t),e}function vb(e,t){const i=e.getSelectedElement();if(i){const r=Ab(e);if(r)return t.createRange(t.createPositionAt(i,r))}return Vh(e,t)}function _b(){return null}const yb="widget-type-around";function xb(e,t,i){return!!e&&gb(e)&&!i.isInline(t)}function Ab(e){return e.getAttribute(yb)}var Cb=i(2137),Eb={attributes:{"data-cke":!0}};Eb.setAttributes=Un(),Eb.insert=zn().bind(null,"head"),Eb.domAPI=Fn(),Eb.insertStyleElement=$n();Ln()(Cb.A,Eb);Cb.A&&Cb.A.locals&&Cb.A.locals;const Sb=["before","after"],Tb=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,Pb="ck-widget__type-around_disabled";class Ib extends xs{constructor(){super(...arguments),this._currentFakeCaretModelElement=null}static get pluginName(){return"WidgetTypeAround"}static get requires(){return[rb,Lf]}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",((i,r,n)=>{t.change((e=>{for(const i of t.document.roots)n?e.removeClass(Pb,i):e.addClass(Pb,i)})),n||e.model.change((e=>{e.removeSelectionAttribute(yb)}))})),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,r=i.editing.view,n=i.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);i.execute("insertParagraph",{position:i.model.createPositionAt(e,t),attributes:n}),r.focus(),r.scrollToTheSelection()}_listenToIfEnabled(e,t,i,r){this.listenTo(e,t,((...e)=>{this.isEnabled&&i(...e)}),r)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=Ab(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,r={before:i("Insert paragraph before block"),after:i("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",((e,n,o)=>{const s=o.mapper.toViewElement(n.item);if(s&&xb(s,n.item,t)){!function(e,t,i){const r=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 Sb){const r=new Yn({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(Tb,!0)]});e.appendChild(r.render())}}(i,t),function(e){const t=new Yn({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(i),i}));e.insert(e.createPositionAt(i,"end"),r)}(o.writer,r,s);s.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,r=t.schema,n=e.editing.view;function o(e){return`ck-widget_type-around_show-fake-caret_${e}`}this._listenToIfEnabled(n.document,"arrowKey",((e,t)=>{this._handleArrowKeyPress(e,t)}),{context:[gb,"$text"],priority:"high"}),this._listenToIfEnabled(i,"change:range",((t,i)=>{i.directChange&&e.model.change((e=>{e.removeSelectionAttribute(yb)}))})),this._listenToIfEnabled(t.document,"change:data",(()=>{const t=i.getSelectedElement();if(t){if(xb(e.editing.mapper.toViewElement(t),t,r))return}e.model.change((e=>{e.removeSelectionAttribute(yb)}))})),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",((e,t,i)=>{const n=i.writer;if(this._currentFakeCaretModelElement){const e=i.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(n.removeClass(Sb.map(o),e),this._currentFakeCaretModelElement=null)}const s=t.selection.getSelectedElement();if(!s)return;const a=i.mapper.toViewElement(s);if(!xb(a,s,r))return;const c=Ab(t.selection);c&&(n.addClass(o(c),a),this._currentFakeCaretModelElement=s)})),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",((t,i,r)=>{r||e.model.change((e=>{e.removeSelectionAttribute(yb)}))}))}_handleArrowKeyPress(e,t){const i=this.editor,r=i.model,n=r.document.selection,o=r.schema,s=i.editing.view,a=function(e,t){const i=kn(e,t);return"down"===i||"right"===i}(t.keyCode,i.locale.contentLanguageDirection),c=s.document.selection.getSelectedElement();let l;xb(c,i.editing.mapper.toModelElement(c),o)?l=this._handleArrowKeyPressOnSelectedWidget(a):n.isCollapsed?l=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):t.shiftKey||(l=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),l&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,i=Ab(t.document.selection);return t.change((t=>{if(!i)return t.setSelectionAttribute(yb,e?"after":"before"),!0;if(!(i===(e?"after":"before")))return t.removeSelectionAttribute(yb),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,i=t.model,r=i.schema,n=t.plugins.get("Widget"),o=n._getObjectElementNextToSelection(e);return!!xb(t.editing.mapper.toViewElement(o),o,r)&&(i.change((t=>{n._setSelectionOverElement(o),t.setSelectionAttribute(yb,e?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,i=t.model,r=i.schema,n=t.editing.mapper,o=i.document.selection,s=e?o.getLastPosition().nodeBefore:o.getFirstPosition().nodeAfter;return!!xb(n.toViewElement(s),s,r)&&(i.change((t=>{t.setSelection(s,"on"),t.setSelectionAttribute(yb,e?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",((i,r)=>{const n=r.domTarget.closest(".ck-widget__type-around__button");if(!n)return;const o=function(e){return e.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(n),s=function(e,t){const i=e.closest(".ck-widget");return t.mapDomToView(i)}(n,t.domConverter),a=e.editing.mapper.toModelElement(s);this._insertParagraph(a,o),r.preventDefault(),i.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,i=e.editing.view;this._listenToIfEnabled(i.document,"enter",((i,r)=>{if("atTarget"!=i.eventPhase)return;const n=t.getSelectedElement(),o=e.editing.mapper.toViewElement(n),s=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:xb(o,n,s)&&(this._insertParagraph(n,r.isSoft?"before":"after"),a=!0),a&&(r.preventDefault(),i.stop())}),{context:gb})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view.document;this._listenToIfEnabled(e,"insertText",((t,i)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(i.selection=e.selection)}),{priority:"high"}),l.isAndroid?this._listenToIfEnabled(e,"keydown",((e,t)=>{229==t.keyCode&&this._insertParagraphAccordingToFakeCaretPosition()})):this._listenToIfEnabled(e,"compositionstart",(()=>{this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,i=e.model,r=i.schema;this._listenToIfEnabled(t.document,"delete",((t,n)=>{if("atTarget"!=t.eventPhase)return;const o=Ab(i.document.selection);if(!o)return;const s=n.direction,a=i.document.selection.getSelectedElement(),c="forward"==s;if("before"===o===c)e.execute("delete",{selection:i.createSelection(a,"on")});else{const t=r.getNearestSelectionRange(i.createPositionAt(a,o),s);if(t)if(t.isCollapsed){const n=i.createSelection(t.start);if(i.modifySelection(n,{direction:s}),n.focus.isEqual(t.start)){const e=function(e,t){let i=t;for(const r of t.getAncestors({parentFirst:!0})){if(r.childCount>1||e.isLimit(r))break;i=r}return i}(r,t.start.parent);i.deleteContent(i.createSelection(e,"on"),{doNotAutoparagraph:!0})}else i.change((i=>{i.setSelection(t),e.execute(c?"deleteForward":"delete")}))}else i.change((i=>{i.setSelection(t),e.execute(c?"deleteForward":"delete")}))}n.preventDefault(),t.stop()}),{context:gb})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,i=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",((e,[r,n])=>{if(n&&!n.is("documentSelection"))return;const o=Ab(i);return o?(e.stop(),t.change((e=>{const n=i.getSelectedElement(),s=t.createPositionAt(n,o),a=e.createSelection(s),c=t.insertContent(r,a);return e.setSelection(a),c}))):void 0}),{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",((e,i)=>{const[,r,n={}]=i;if(r&&!r.is("documentSelection"))return;const o=Ab(t);o&&(n.findOptimalPosition=o,i[3]=n)}),{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",((e,[i])=>{if(i&&!i.is("documentSelection"))return;Ab(t)&&e.stop()}),{priority:"high"})}}function Mb(e){const t=e.model;return(i,r)=>{const n=r.keyCode==gn.arrowup,o=r.keyCode==gn.arrowdown,s=r.shiftKey,a=t.document.selection;if(!n&&!o)return;const c=o;if(s&&function(e,t){return!e.isCollapsed&&e.isBackward==t}(a,c))return;const l=function(e,t,i){const r=e.model;if(i){const e=t.isCollapsed?t.focus:t.getLastPosition(),i=Ob(r,e,"forward");if(!i)return null;const n=r.createRange(e,i),o=Nb(r.schema,n,"backward");return o?r.createRange(e,o):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),i=Ob(r,e,"backward");if(!i)return null;const n=r.createRange(i,e),o=Nb(r.schema,n,"forward");return o?r.createRange(o,e):null}}(e,a,c);if(l){if(l.isCollapsed){if(a.isCollapsed)return;if(s)return}(l.isCollapsed||function(e,t,i){const r=e.model,n=e.view.domConverter;if(i){const e=r.createSelection(t.start);r.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=r.createRange(e.focus,t.end))}const o=e.mapper.toViewRange(t),s=n.viewRangeToDom(o),a=Fr.getDomRangeRects(s);let c;for(const e of a)if(void 0!==c){if(Math.round(e.top)>=c)return!1;c=Math.max(c,Math.round(e.bottom))}else c=Math.round(e.bottom);return!0}(e,l,c))&&(t.change((e=>{const i=c?l.end:l.start;if(s){const r=t.createSelection(a.anchor);r.setFocus(i),e.setSelection(r)}else e.setSelection(i)})),i.stop(),r.preventDefault(),r.stopPropagation())}}}function Ob(e,t,i){const r=e.schema,n=e.createRangeIn(t.root),o="forward"==i?"elementStart":"elementEnd";for(const{previousPosition:e,item:s,type:a}of n.getWalker({startPosition:t,direction:i})){if(r.isLimit(s)&&!r.isInline(s))return e;if(a==o&&r.isBlock(s))return null}return null}function Nb(e,t,i){const r="backward"==i?t.end:t.start;if(e.checkChild(r,"$text"))return r;for(const{nextPosition:r}of t.getWalker({direction:i}))if(e.checkChild(r,"$text"))return r;return null}var Vb=i(1066),Bb={attributes:{"data-cke":!0}};Bb.setAttributes=Un(),Bb.insert=zn().bind(null,"head"),Bb.domAPI=Fn(),Bb.insertStyleElement=$n();Ln()(Vb.A,Bb);Vb.A&&Vb.A.locals&&Vb.A.locals;class Rb extends xs{constructor(){super(...arguments),this._previouslySelected=new Set}static get pluginName(){return"Widget"}static get requires(){return[Ib,Lf]}init(){const e=this.editor,t=e.editing.view,i=t.document;this.editor.editing.downcastDispatcher.on("selection",((t,i,r)=>{const n=r.writer,o=i.selection;if(o.isCollapsed)return;const s=o.getSelectedElement();if(!s)return;const a=e.editing.mapper.toViewElement(s);var c;gb(a)&&(r.consumable.consume(o,"selection")&&n.setSelection(n.createRangeOn(a),{fake:!0,label:(c=a,c.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 r=i.writer,n=r.document.selection;let o=null;for(const e of n.getRanges())for(const t of e){const e=t.item;gb(e)&&!Lb(e,o)&&(r.addClass(mb,e),this._previouslySelected.add(e),o=e)}}),{priority:"low"}),t.addObserver(Uh),this.listenTo(i,"mousedown",((...e)=>this._onMousedown(...e))),this.listenTo(i,"arrowKey",((...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)}),{context:[gb,"$text"]}),this.listenTo(i,"arrowKey",((...e)=>{this._preventDefaultOnArrowKeyPress(...e)}),{context:"$root"}),this.listenTo(i,"arrowKey",Mb(this.editor.editing),{context:"$text"}),this.listenTo(i,"delete",((e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())}),{context:"$root"})}_onMousedown(e,t){const i=this.editor,r=i.editing.view,n=r.document;let o=t.target;if(t.domEvent.detail>=3)return void(this._selectBlockContent(o)&&t.preventDefault());if(function(e){let t=e;for(;t;){if(t.is("editableElement")&&!t.is("rootElement"))return!0;if(gb(t))return!1;t=t.parent}return!1}(o))return;if(!gb(o)&&(o=o.findAncestor(gb),!o))return;l.isAndroid&&t.preventDefault(),n.isFocused||r.focus();const s=i.editing.mapper.toModelElement(o);this._setSelectionOverElement(s)}_selectBlockContent(e){const t=this.editor,i=t.model,r=t.editing.mapper,n=i.schema,o=r.findMappedViewAncestor(this.editor.editing.view.createPositionAt(e,0)),s=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}(r.toModelElement(o),i.schema);return!!s&&(i.change((e=>{const t=n.isLimit(s)?null:function(e,t){const i=new Jl({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(s),n),i=e.createPositionAt(s,0),r=t?e.createPositionAt(t,0):e.createPositionAt(s,"end");e.setSelection(e.createRange(i,r))})),!0)}_handleSelectionChangeOnArrowKeyPress(e,t){const i=t.keyCode,r=this.editor.model,n=r.schema,o=r.document.selection,s=o.getSelectedElement(),a=kn(i,this.editor.locale.contentLanguageDirection),c="down"==a||"right"==a,l="up"==a||"down"==a;if(s&&n.isObject(s)){const i=c?o.getLastPosition():o.getFirstPosition(),s=n.getNearestSelectionRange(i,c?"forward":"backward");return void(s&&(r.change((e=>{e.setSelection(s)})),t.preventDefault(),e.stop()))}if(!o.isCollapsed&&!t.shiftKey){const i=o.getFirstPosition(),s=o.getLastPosition(),a=i.nodeAfter,l=s.nodeBefore;return void((a&&n.isObject(a)||l&&n.isObject(l))&&(r.change((e=>{e.setSelection(c?s:i)})),t.preventDefault(),e.stop()))}if(!o.isCollapsed)return;const d=this._getObjectElementNextToSelection(c);if(d&&n.isObject(d)){if(n.isInline(d)&&l)return;this._setSelectionOverElement(d),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const i=this.editor.model,r=i.schema,n=i.document.selection.getSelectedElement();n&&r.isObject(n)&&(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 r=t.anchor.parent;for(;r.isEmpty;){const t=r;r=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,r=t.document.selection,n=t.createSelection(r);if(t.modifySelection(n,{direction:e?"forward":"backward"}),n.isEqual(r))return null;const o=e?n.focus.nodeBefore:n.focus.nodeAfter;return o&&i.isObject(o)?o:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(mb,t);this._previouslySelected.clear()}}function Lb(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}class Db extends xs{constructor(){super(...arguments),this._toolbarDefinitions=new Map}static get requires(){return[Op]}static get pluginName(){return"WidgetToolbarRepository"}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||!gb(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:r,balloonClassName:n="ck-toolbar-container"}){if(!i.length)return void y("widget-toolbar-no-items",{toolbarId:e});const o=this.editor,s=o.t,a=new Tm(o.locale);if(a.ariaLabel=t||s("Widget toolbar"),this._toolbarDefinitions.has(e))throw new _("widget-toolbar-duplicated",this,{toolbarId:e});const c={view:a,getRelatedElement:r,balloonClassName:n,itemsConfig:i,initialized:!1};o.ui.addToolbar(a,{isContextual:!0,beforeFocus:()=>{const e=r(o.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 r of this._toolbarDefinitions.values()){const n=r.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&n)if(this.editor.ui.focusTracker.isFocused){const o=n.getAncestors().length;o>e&&(e=o,t=n,i=r)}else this._isToolbarVisible(r)&&this._hideToolbar(r);else this._isToolbarInBalloon(r)&&this._hideToolbar(r)}i&&this._showToolbar(i,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?Fb(this.editor,t):this._isToolbarInBalloon(e)||(e.initialized||(e.initialized=!0,e.view.fillFromConfig(e.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:e.view,position:jb(this.editor,t),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",(()=>{for(const e of this._toolbarDefinitions.values())if(this._isToolbarVisible(e)){const t=e.getRelatedElement(this.editor.editing.view.document.selection);Fb(this.editor,t)}})))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function Fb(e,t){const i=e.plugins.get("ContextualBalloon"),r=jb(e,t);i.updatePosition(r)}function jb(e,t){const i=e.editing.view,r=Yg.defaultPositions;return{target:i.domConverter.mapViewToDom(t),positions:[r.northArrowSouth,r.northArrowSouthWest,r.northArrowSouthEast,r.southArrowNorth,r.southArrowNorthWest,r.southArrowNorthEast,r.viewportStickyNorth]}}class zb extends(q()){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 r=new Fr(t);this.activeHandlePosition=function(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const i of t)if(e.classList.contains(Hb(i)))return i}(e),this._referenceCoordinates=function(e,t){const i=new Fr(e),r=t.split("-"),n={x:"right"==r[1]?i.right:i.left,y:"bottom"==r[0]?i.bottom:i.top};return n.x+=e.ownerDocument.defaultView.scrollX,n.y+=e.ownerDocument.defaultView.scrollY,n}(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=r.width,this._originalHeight=r.height,this._aspectRatio=r.width/r.height;const n=i.style.width;n&&n.match(/^\d+(\.\d*)?%$/)?this._originalWidthPercents=parseFloat(n):this._originalWidthPercents=function(e,t){const i=e.parentElement;let r=parseFloat(i.ownerDocument.defaultView.getComputedStyle(i).width);const n=5;let o=0,s=i;for(;isNaN(r);){if(s=s.parentElement,++o>n)return 0;r=parseFloat(i.ownerDocument.defaultView.getComputedStyle(s).width)}return t.width/r*100}(i,r)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}function Hb(e){return`ck-widget__resizer__handle-${e}`}class Ub extends Kn{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,r)=>"px"===e.unit?`${t}×${i}`:`${r}%`)),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 Wb extends(q()){constructor(e){super(),this._viewResizerWrapper=null,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 r=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"),r),i.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=r,this.isVisible||this.hide()})),this.on("change:isVisible",(()=>{this.isVisible?(this.show(),this.redraw()):this.hide()}))}begin(e){this._state=new zb(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||"%",r=("%"===i?t.widthPercents:t.width)+i;e.setStyle("width",r,this._options.viewElement)}));const i=this._getHandleHost(),r=new Fr(i),n=Math.round(r.width),o=Math.round(r.height),s=new Fr(i);t.width=Math.round(s.width),t.height=Math.round(s.height),this.redraw(r),this.state.update({...t,handleHostWidth:n,handleHostHeight:o})}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 r=t.parentElement,n=this._getHandleHost(),o=this._viewResizerWrapper,s=[o.getStyle("width"),o.getStyle("height"),o.getStyle("left"),o.getStyle("top")];let a;if(r.isSameNode(n)){const t=e||new Fr(n);a=[t.width+"px",t.height+"px",void 0,void 0]}else a=[n.offsetWidth+"px",n.offsetHeight+"px",n.offsetLeft+"px",n.offsetTop+"px"];"same"!==ee(s,a)&&this._options.editor.editing.view.change((e=>{e.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},o)}))}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={x:(r=e).pageX,y:r.pageY};var r;const n=!this._options.isCentered||this._options.isCentered(this),o={x:t._referenceCoordinates.x-(i.x+t.originalWidth),y:i.y-t.originalHeight-t._referenceCoordinates.y};n&&t.activeHandlePosition.endsWith("-right")&&(o.x=i.x-(t._referenceCoordinates.x+t.originalWidth)),n&&(o.x*=2);let s=Math.abs(t.originalWidth+o.x),a=Math.abs(t.originalHeight+o.y);return"width"==(s/t.aspectRatio>a?"width":"height")?a=s/t.aspectRatio:s=a*t.aspectRatio,{width:Math.round(s),height:Math.round(a),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*s*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 r of t)e.appendChild(new Yn({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(i=r,`ck-widget__resizer__handle-${i}`)}}).render());var i}_appendSizeUI(e){this._sizeView=new Ub,this._sizeView.render(),e.appendChild(this._sizeView.element)}}var $b=i(3122),qb={attributes:{"data-cke":!0}};qb.setAttributes=Un(),qb.insert=zn().bind(null,"head"),qb.domAPI=Fn(),qb.insertStyleElement=$n();Ln()($b.A,qb);$b.A&&$b.A.locals&&$b.A.locals;class Gb extends xs{constructor(){super(...arguments),this._resizers=new Map}static get pluginName(){return"WidgetResize"}init(){const e=this.editor.editing,t=Nr.window.document;this.set("selectedResizer",null),this.set("_activeResizer",null),e.view.addObserver(Uh),this._observer=new(Pr()),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=rp((()=>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(Nr.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 Wb(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 r=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(r)==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;Wb.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)}}class Kb extends Cs{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=function(e,t,i){const r=function(e,t){const i=vb(e,t),r=i.start.parent;if(r.isEmpty&&!r.is("element","$root"))return r.parent;return r}(e,i);return t.checkChild(r,"horizontalLine")}(i,t,e)}execute(){const e=this.editor.model;e.change((t=>{const i=t.createElement("horizontalLine");e.insertObject(i,null,null,{setSelection:"after"})}))}}var Yb=i(2101),Jb={attributes:{"data-cke":!0}};Jb.setAttributes=Un(),Jb.insert=zn().bind(null,"head"),Jb.domAPI=Fn(),Jb.insertStyleElement=$n();Ln()(Yb.A,Jb);Yb.A&&Yb.A.locals&&Yb.A.locals;class Zb extends xs{static get pluginName(){return"HorizontalLineEditing"}init(){const e=this.editor,t=e.model.schema,i=e.t,r=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),r.for("dataDowncast").elementToElement({model:"horizontalLine",view:(e,{writer:t})=>t.createEmptyElement("hr")}),r.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(e,{writer:t})=>{const r=i("Horizontal line"),n=t.createContainerElement("div",null,t.createEmptyElement("hr"));return t.addClass("ck-horizontal-line",n),t.setCustomProperty("hr",!0,n),function(e,t,i){return t.setCustomProperty("horizontalLine",!0,e),pb(e,t,{label:i})}(n,t,r)}}),r.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new Kb(e))}}class Qb extends xs{static get pluginName(){return"HorizontalLineUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("horizontalLine",(i=>{const r=e.commands.get("horizontalLine"),n=new Ao(i);return n.set({label:t("Horizontal line"),icon:'',tooltip:!0}),n.bind("isEnabled").to(r,"isEnabled"),this.listenTo(n,"execute",(()=>{e.execute("horizontalLine"),e.editing.view.focus()})),n}))}}class Xb extends xs{static get requires(){return[Zb,Qb,Rb]}static get pluginName(){return"HorizontalLine"}}function ew(e){const t=e.getSelectedElement();return t&&iw(t)?t:null}function tw(e){const t=e.getFirstPosition();if(!t)return null;let i=t.parent;for(;i;){if(i.is("element")&&iw(i))return i;i=i.parent}return null}function iw(e){return!!e.getCustomProperty("table")&&gb(e)}class rw extends xs{static get requires(){return[Db]}static get pluginName(){return"TableToolbar"}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(Db),r=e.config.get("table.contentToolbar"),n=e.config.get("table.tableToolbar");r&&i.register("tableContent",{ariaLabel:t("Table toolbar"),items:r,getRelatedElement:tw}),n&&i.register("table",{ariaLabel:t("Table toolbar"),items:n,getRelatedElement:ew})}}function nw(e,t,i,r,n=1){null!=t&&null!=n&&t>n?r.setAttribute(e,t,i):r.removeAttribute(e,i)}function ow(e,t,i={}){const r=e.createElement("tableCell",i);return e.insertElement("paragraph",r),e.insert(r,t),r}function sw(e,t){const i=t.parent.parent,r=parseInt(i.getAttribute("headingColumns")||"0"),{column:n}=e.getCellLocation(t);return!!r&&n{e.on("element:table",((e,t,i)=>{const r=t.viewItem;if(!i.consumable.test(r,{name:!0}))return;const{rows:n,headingRows:o,headingColumns:s}=function(e){let t,i=0;const r=[],n=[];let o;for(const s of Array.from(e.getChildren())){if("tbody"!==s.name&&"thead"!==s.name&&"tfoot"!==s.name)continue;"thead"!==s.name||o||(o=s);const e=Array.from(s.getChildren()).filter((e=>e.is("element","tr")));for(const a of e)if(o&&s===o||"tbody"===s.name&&Array.from(a.getChildren()).length&&Array.from(a.getChildren()).every((e=>e.is("element","th"))))i++,r.push(a);else{n.push(a);const e=lw(a);(!t||ei.convertItem(e,i.writer.createPositionAt(c,"end")))),i.convertChildren(r,i.writer.createPositionAt(c,"end")),c.isEmpty){const e=i.writer.createElement("tableRow");i.writer.insert(e,i.writer.createPositionAt(c,"end")),ow(i.writer,i.writer.createPositionAt(e,"end"))}i.updateConversionResult(c,t)}}))}}function cw(e){return t=>{t.on(`element:${e}`,((e,t,{writer:i})=>{if(!t.modelRange)return;const r=t.modelRange.start.nodeAfter,n=i.createPositionAt(r,0);if(t.viewItem.isEmpty)return void i.insertElement("paragraph",n);const o=Array.from(r.getChildren());if(o.every((e=>e.is("element","$marker")))){const e=i.createElement("paragraph");i.insert(e,i.createPositionAt(r,0));for(const t of o)i.move(i.createRangeOn(t),i.createPositionAt(e,"end"))}}),{priority:"low"})}}function lw(e){let t=0,i=0;const r=Array.from(e.getChildren()).filter((e=>"th"===e.name||"td"===e.name));for(;i1||n>1)&&this._recordSpans(i,n,r),this._shouldSkipSlot()||(t=this._formatOutValue(i)),this._nextCellAtColumn=this._column+r}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 uw(this,e,t,i)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._rowthis._endColumn;return e||t||i||r}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,i){const r={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 uw{constructor(e,t,i,r){this.cell=t,this.row=e._row,this.column=e._column,this.cellAnchorRow=i,this.cellAnchorColumn=r,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 hw(e,t){return(i,{writer:r})=>{const n=i.getAttribute("headingRows")||0,o=r.createContainerElement("table",null,[]),s=r.createContainerElement("figure",{class:"table"},o);n>0&&r.insert(r.createPositionAt(o,"end"),r.createContainerElement("thead",null,r.createSlot((e=>e.is("element","tableRow")&&e.indexe.is("element","tableRow")&&e.index>=n))));for(const{positionOffset:e,filter:i}of t.additionalSlots)r.insert(r.createPositionAt(o,e),r.createSlot(i));return r.insert(r.createPositionAt(o,"after"),r.createSlot((e=>!e.is("element","tableRow")&&!t.additionalSlots.some((({filter:t})=>t(e)))))),t.asWidget?function(e,t){return t.setCustomProperty("table",!0,e),pb(e,t,{hasSelectionHandle:!0})}(s,r):s}}function mw(e={}){return(t,{writer:i})=>{const r=t.parent,n=r.parent,o=n.getChildIndex(r),s=new dw(n,{row:o}),a=n.getAttribute("headingRows")||0,c=n.getAttribute("headingColumns")||0;let l=null;for(const r of s)if(r.cell==t){const t=r.row{if(!t.parent.is("element","tableCell"))return null;if(!pw(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 pw(e){return 1==e.parent.childCount&&!!e.getAttributeKeys().next().done}class fw extends Cs{refresh(){const e=this.editor.model,t=e.document.selection,i=e.schema;this.isEnabled=function(e,t){const i=e.getFirstPosition().parent,r=i===i.root?i:i.parent;return t.checkChild(r,"table")}(t,i)}execute(e={}){const t=this.editor,i=t.model,r=t.plugins.get("TableUtils"),n=t.config.get("table.defaultHeadings.rows"),o=t.config.get("table.defaultHeadings.columns");void 0===e.headingRows&&n&&(e.headingRows=n),void 0===e.headingColumns&&o&&(e.headingColumns=o),i.change((t=>{const n=r.createTable(t,e);i.insertObject(n,null,null,{findOptimalPosition:"auto"}),t.setSelection(t.createPositionAt(n.getNodeByPath([0,0,0]),0))}))}}class bw extends Cs{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"),r="above"===this.order,n=i.getSelectionAffectedTableCells(t),o=i.getRowIndexes(n),s=r?o.first:o.last,a=n[0].findAncestor("table");i.insertRows(a,{at:r?s:s+1,copyStructureFromAbove:!r})}}class ww extends Cs{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"),r="left"===this.order,n=i.getSelectionAffectedTableCells(t),o=i.getColumnIndexes(n),s=r?o.first:o.last,a=n[0].findAncestor("table");i.insertColumns(a,{columns:1,at:r?s:s+1})}}class kw extends Cs{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)}}function vw(e,t,i){const{startRow:r,startColumn:n,endRow:o,endColumn:s}=t,a=i.createElement("table"),c=o-r+1;for(let e=0;e0){nw("headingRows",o-i,e,n,0)}const s=parseInt(t.getAttribute("headingColumns")||"0");if(s>0){nw("headingColumns",s-r,e,n,0)}}(a,e,r,n,i),a}function _w(e,t,i=0){const r=[],n=new dw(e,{startRow:i,endRow:t-1});for(const e of n){const{row:i,cellHeight:n}=e;i1&&(a.rowspan=c);const l=parseInt(e.getAttribute("colspan")||"1");l>1&&(a.colspan=l);const d=o+s,u=[...new dw(n,{startRow:o,endRow:d,includeAllSlots:!0})];let h,m=null;for(const t of u){const{row:r,column:n,cell:o}=t;o===e&&void 0===h&&(h=n),void 0!==h&&h===n&&r===d&&(m=ow(i,t.getPositionBefore(),a))}return nw("rowspan",s,e,i),m}function xw(e,t){const i=[],r=new dw(e);for(const e of r){const{column:r,cellWidth:n}=e;r1&&(o.colspan=s);const a=parseInt(e.getAttribute("rowspan")||"1");a>1&&(o.rowspan=a);const c=ow(r,r.createPositionAfter(e),o);return nw("colspan",n,e,r),c}function Cw(e,t,i,r,n,o){const s=parseInt(e.getAttribute("colspan")||"1"),a=parseInt(e.getAttribute("rowspan")||"1");if(i+s-1>n){nw("colspan",n-i+1,e,o,1)}if(t+a-1>r){nw("rowspan",r-t+1,e,o,1)}}function Ew(e,t){const i=t.getColumns(e),r=new Array(i).fill(0);for(const{column:t}of new dw(e))r[t]++;const n=r.reduce(((e,t,i)=>t?e:[...e,i]),[]);if(n.length>0){const i=n[n.length-1];return t.removeColumns(e,{at:i}),!0}return!1}function Sw(e,t){const i=[],r=t.getRows(e);for(let t=0;t0){const r=i[i.length-1];return t.removeRows(e,{at:r}),!0}return!1}function Tw(e,t){Ew(e,t)||Sw(e,t)}function Pw(e,t){const i=Array.from(new dw(e,{startColumn:t.firstColumn,endColumn:t.lastColumn,row:t.lastRow}));if(i.every((({cellHeight:e})=>1===e)))return t.lastRow;const r=i[0].cellHeight-1;return t.lastRow+r}function Iw(e,t){const i=Array.from(new dw(e,{startRow:t.firstRow,endRow:t.lastRow,column:t.lastColumn}));if(i.every((({cellWidth:e})=>1===e)))return t.lastColumn;const r=i[0].cellWidth-1;return t.lastColumn+r}class Mw extends Cs{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],r=this.value,n=this.direction;e.change((e=>{const t="right"==n||"down"==n,o=t?i:r,s=t?r:i,a=s.parent;!function(e,t,i){Ow(e)||(Ow(t)&&i.remove(i.createRangeIn(t)),i.move(i.createRangeIn(e),i.createPositionAt(t,"end")));i.remove(e)}(s,o,e);const c=this.isHorizontal?"colspan":"rowspan",l=parseInt(i.getAttribute(c)||"1"),d=parseInt(r.getAttribute(c)||"1");e.setAttribute(c,l+d,o),e.setSelection(e.createRangeIn(o));const u=this.editor.plugins.get("TableUtils");Tw(a.findAncestor("table"),u)}))}_getMergeableCell(){const e=this.editor.model.document,t=this.editor.plugins.get("TableUtils"),i=t.getTableCellsContainingSelection(e.selection)[0];if(!i)return;const r=this.isHorizontal?function(e,t,i){const r=e.parent,n=r.parent,o="right"==t?e.nextSibling:e.previousSibling,s=(n.getAttribute("headingColumns")||0)>0;if(!o)return;const a="right"==t?e:o,c="right"==t?o:e,{column:l}=i.getCellLocation(a),{column:d}=i.getCellLocation(c),u=parseInt(a.getAttribute("colspan")||"1"),h=sw(i,a),m=sw(i,c);if(s&&h!=m)return;return l+u===d?o:void 0}(i,this.direction,t):function(e,t,i){const r=e.parent,n=r.parent,o=n.getChildIndex(r);if("down"==t&&o===i.getRows(n)-1||"up"==t&&0===o)return null;const s=parseInt(e.getAttribute("rowspan")||"1"),a=n.getAttribute("headingRows")||0,c="down"==t&&o+s===a,l="up"==t&&o===a;if(a&&(c||l))return null;const d=parseInt(e.getAttribute("rowspan")||"1"),u="down"==t?o+d:o,h=[...new dw(n,{endRow:u})],m=h.find((t=>t.cell===e)),g=m.column,p=h.find((({row:e,cellHeight:i,column:r})=>r===g&&("down"==t?e===u:u===e+i)));return p&&p.cell?p.cell:null}(i,this.direction,t);if(!r)return;const n=this.isHorizontal?"rowspan":"colspan",o=parseInt(i.getAttribute(n)||"1");return parseInt(r.getAttribute(n)||"1")===o?r:void 0}}function Ow(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}class Nw extends Cs{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),i=t[0];if(i){const r=i.findAncestor("table"),n=e.getRows(r)-1,o=e.getRowIndexes(t),s=0===o.first&&o.last===n;this.isEnabled=!s}else this.isEnabled=!1}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),i=t.getSelectionAffectedTableCells(e.document.selection),r=t.getRowIndexes(i),n=i[0],o=n.findAncestor("table"),s=t.getCellLocation(n).column;e.change((e=>{const i=r.last-r.first+1;t.removeRows(o,{at:r.first,rows:i});const n=function(e,t,i,r){const n=e.getChild(Math.min(t,r-1));let o=n.getChild(0),s=0;for(const e of n.getChildren()){if(s>i)return o;o=e,s+=parseInt(e.getAttribute("colspan")||"1")}return o}(o,r.first,s,t.getRows(o));e.setSelection(e.createPositionAt(n,0))}))}}class Vw extends Cs{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),i=t[0];if(i){const r=i.findAncestor("table"),n=e.getColumns(r),{first:o,last:s}=e.getColumnIndexes(t);this.isEnabled=s-oe.cell===t)).column,last:n.find((e=>e.cell===i)).column},s=function(e,t,i,r){const n=parseInt(i.getAttribute("colspan")||"1");return n>1?i:t.previousSibling||i.nextSibling?i.nextSibling||t.previousSibling:r.first?e.reverse().find((({column:e})=>ee>r.last)).cell}(n,t,i,o);this.editor.model.change((t=>{const i=o.last-o.first+1;e.removeColumns(r,{at:o.first,columns:i}),t.setSelection(t.createPositionAt(s,0))}))}}class Bw extends Cs{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,i=e.getSelectionAffectedTableCells(t.document.selection),r=i.length>0;this.isEnabled=r,this.value=r&&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,r=t.getSelectionAffectedTableCells(i.document.selection),n=r[0].findAncestor("table"),{first:o,last:s}=t.getRowIndexes(r),a=this.value?o:s+1,c=n.getAttribute("headingRows")||0;i.change((e=>{if(a){const t=_w(n,a,a>c?c:0);for(const{cell:i}of t)yw(i,a,e)}nw("headingRows",a,n,e,0)}))}_isInHeading(e,t){const i=parseInt(t.getAttribute("headingRows")||"0");return!!i&&e.parent.index0;this.isEnabled=r,this.value=r&&i.every((e=>sw(t,e)))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),i=this.editor.model,r=t.getSelectionAffectedTableCells(i.document.selection),n=r[0].findAncestor("table"),{first:o,last:s}=t.getColumnIndexes(r),a=this.value?o:s+1;i.change((e=>{if(a){const t=xw(n,a);for(const{cell:i,column:r}of t)Aw(i,r,a,e)}nw("headingColumns",a,n,e,0)}))}}function Lw(e){if(e.is("element","tableColumnGroup"))return e;const t=e.getChildren();return Array.from(t).find((e=>e.is("element","tableColumnGroup")))}function Dw(e){const t=Lw(e);return t?Array.from(t.getChildren()):[]}class Fw extends xs{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,i=t.parent,r=i.getChildIndex(t),n=new dw(i,{row:r});for(const{cell:t,row:i,column:r}of n)if(t===e)return{row:i,column:r}}createTable(e,t){const i=e.createElement("table"),r=t.rows||2,n=t.columns||2;return jw(e,i,0,r,n),t.headingRows&&nw("headingRows",Math.min(t.headingRows,r),i,e,0),t.headingColumns&&nw("headingColumns",Math.min(t.headingColumns,n),i,e,0),i}insertRows(e,t={}){const i=this.editor.model,r=t.at||0,n=t.rows||1,o=void 0!==t.copyStructureFromAbove,s=t.copyStructureFromAbove?r-1:r,a=this.getRows(e),c=this.getColumns(e);if(r>a)throw new _("tableutils-insertrows-insert-out-of-range",this,{options:t});i.change((t=>{const i=e.getAttribute("headingRows")||0;if(i>r&&nw("headingRows",i+n,e,t,0),!o&&(0===r||r===a))return void jw(t,e,r,n,c);const l=o?Math.max(r,s):r,d=new dw(e,{endRow:l}),u=new Array(c).fill(1);for(const{row:e,column:i,cellHeight:a,cellWidth:c,cell:l}of d){const d=e+a-1,h=e<=s&&s<=d;e0&&ow(t,n,r>1?{colspan:r}:void 0),e+=Math.abs(r)-1}}}))}insertColumns(e,t={}){const i=this.editor.model,r=t.at||0,n=t.columns||1;i.change((t=>{const i=e.getAttribute("headingColumns");rn-1)throw new _("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});i.change((t=>{const i={first:o,last:s},{cellsToMove:r,cellsToTrim:n}=function(e,{first:t,last:i}){const r=new Map,n=[];for(const{row:o,column:s,cellHeight:a,cell:c}of new dw(e,{endRow:i})){const e=o+a-1;if(o>=t&&o<=i&&e>i){const e=a-(i-o+1);r.set(s,{cell:c,rowspan:e})}if(o=t){let r;r=e>=i?i-t+1:e-t+1,n.push({cell:c,rowspan:a-r})}}return{cellsToMove:r,cellsToTrim:n}}(e,i);if(r.size){!function(e,t,i,r){const n=new dw(e,{includeAllSlots:!0,row:t}),o=[...n],s=e.getChild(t);let a;for(const{column:e,cell:t,isAnchor:n}of o)if(i.has(e)){const{cell:t,rowspan:n}=i.get(e),o=a?r.createPositionAfter(a):r.createPositionAt(s,0);r.move(r.createRangeOn(t),o),nw("rowspan",n,t,r),a=t}else n&&(a=t)}(e,s+1,r,t)}for(let i=s;i>=o;i--)t.remove(e.getChild(i));for(const{rowspan:e,cell:i}of n)nw("rowspan",e,i,t);!function(e,{first:t,last:i},r){const n=e.getAttribute("headingRows")||0;if(t{!function(e,t,i){const r=e.getAttribute("headingColumns")||0;if(r&&t.first=r;n--){for(const{cell:i,column:r,cellWidth:o}of[...new dw(e)])r<=n&&o>1&&r+o>n?nw("colspan",o-1,i,t):r===n&&t.remove(i);if(i[n]){const e=0===n?i[1]:i[n-1],r=parseFloat(i[n].getAttribute("columnWidth")),o=parseFloat(e.getAttribute("columnWidth"));t.remove(i[n]),t.setAttribute("columnWidth",r+o+"%",e)}}Sw(e,this)||Ew(e,this)}))}splitCellVertically(e,t=2){const i=this.editor.model,r=e.parent.parent,n=parseInt(e.getAttribute("rowspan")||"1"),o=parseInt(e.getAttribute("colspan")||"1");i.change((i=>{if(o>1){const{newCellsSpan:r,updatedSpan:s}=Hw(o,t);nw("colspan",s,e,i);const a={};r>1&&(a.colspan=r),n>1&&(a.rowspan=n);zw(o>t?t-1:o-1,i,i.createPositionAfter(e),a)}if(ot===e)),l=a.filter((({cell:t,cellWidth:i,column:r})=>t!==e&&r===c||rc));for(const{cell:e,cellWidth:t}of l)i.setAttribute("colspan",t+s,e);const d={};n>1&&(d.rowspan=n),zw(s,i,i.createPositionAfter(e),d);const u=r.getAttribute("headingColumns")||0;u>c&&nw("headingColumns",u+s,r,i)}}))}splitCellHorizontally(e,t=2){const i=this.editor.model,r=e.parent,n=r.parent,o=n.getChildIndex(r),s=parseInt(e.getAttribute("rowspan")||"1"),a=parseInt(e.getAttribute("colspan")||"1");i.change((i=>{if(s>1){const r=[...new dw(n,{startRow:o,endRow:o+s-1,includeAllSlots:!0})],{newCellsSpan:c,updatedSpan:l}=Hw(s,t);nw("rowspan",l,e,i);const{column:d}=r.find((({cell:t})=>t===e)),u={};c>1&&(u.rowspan=c),a>1&&(u.colspan=a);for(const e of r){const{column:t,row:r}=e;r>=o+l&&t===d&&(r+o+l)%c==0&&zw(1,i,e.getPositionBefore(),u)}}if(so){const e=n+r;i.setAttribute("rowspan",e,t)}const l={};a>1&&(l.colspan=a),jw(i,n,o+1,r,1,l);const d=n.getAttribute("headingRows")||0;d>o&&nw("headingRows",d+r,n,i)}}))}getColumns(e){return[...e.getChild(0).getChildren()].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 dw(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}getTableCellsContainingSelection(e){const t=[];for(const i of e.getRanges()){const e=i.start.findAncestor("tableCell");e&&t.push(e)}return t}getSelectionAffectedTableCells(e){const t=this.getSelectedTableCells(e);return t.length?t:this.getTableCellsContainingSelection(e)}getRowIndexes(e){const t=e.map((e=>e.parent.index));return this._getFirstLastIndexesObject(t)}getColumnIndexes(e){const t=e[0].findAncestor("table"),i=[...new dw(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 r=0;for(const n of e){const{row:e,column:o}=this.getCellLocation(n),s=parseInt(n.getAttribute("rowspan"))||1,a=parseInt(n.getAttribute("colspan"))||1;t.add(e),i.add(o),s>1&&t.add(e+s-1),a>1&&i.add(o+a-1),r+=s*a}const n=function(e,t){const i=Array.from(e.values()),r=Array.from(t.values()),n=Math.max(...i),o=Math.min(...i),s=Math.max(...r),a=Math.min(...r);return(n-o+1)*(s-a+1)}(t,i);return n==r}sortRanges(e){return Array.from(e).sort(Uw)}_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),r=parseInt(t.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(i,r))return!1;const n=this.getColumnIndexes(e),o=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(n,o)}_areIndexesInSameSection({first:e,last:t},i){return e{const r=t.getSelectedTableCells(e.document.selection),n=r.shift(),{mergeWidth:o,mergeHeight:s}=function(e,t,i){let r=0,n=0;for(const e of t){const{row:t,column:o}=i.getCellLocation(e);r=Gw(e,o,r,"colspan"),n=Gw(e,t,n,"rowspan")}const{row:o,column:s}=i.getCellLocation(e),a=r-s,c=n-o;return{mergeWidth:a,mergeHeight:c}}(n,r,t);nw("colspan",o,n,i),nw("rowspan",s,n,i);for(const e of r)$w(e,n,i);Tw(n.findAncestor("table"),t),i.setSelection(n,"in")}))}}function $w(e,t,i){qw(e)||(qw(t)&&i.remove(i.createRangeIn(t)),i.move(i.createRangeIn(e),i.createPositionAt(t,"end"))),i.remove(e)}function qw(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}function Gw(e,t,i,r){const n=parseInt(e.getAttribute(r)||"1");return Math.max(i,t+n)}class Kw extends Cs{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),r=t.getRowIndexes(i),n=i[0].findAncestor("table"),o=[];for(let t=r.first;t<=r.last;t++)for(const i of n.getChild(t).getChildren())o.push(e.createRangeOn(i));e.change((e=>{e.setSelection(o)}))}}class Yw extends Cs{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),r=i[0],n=i.pop(),o=r.findAncestor("table"),s=e.getCellLocation(r),a=e.getCellLocation(n),c=Math.min(s.column,a.column),l=Math.max(s.column,a.column),d=[];for(const e of new dw(o,{startColumn:c,endColumn:l}))d.push(t.createRangeOn(e.cell));t.change((e=>{e.setSelection(d)}))}}function Jw(e){e.document.registerPostFixer((t=>function(e,t){const i=t.document.differ.getChanges();let r=!1;const n=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")),Xw(t)&&(i=t.range.start.findAncestor("table")),i&&!n.has(i)&&(r=Zw(i,e)||r,r=Qw(i,e)||r,n.add(i))}return r}(t,e)))}function Zw(e,t){let i=!1;const r=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),r=[];for(const{row:n,cell:o,cellHeight:s}of new dw(e)){if(s<2)continue;const e=ne){const t=e-n;r.push({cell:o,rowspan:t})}}return r}(e);if(r.length){i=!0;for(const e of r)nw("rowspan",e.rowspan,e.cell,t,1)}return i}function Qw(e,t){let i=!1;const r=function(e){const t=new Array(e.childCount).fill(0);for(const{rowIndex:i}of new dw(e,{includeAllSlots:!0}))t[i]++;return t}(e),n=[];for(const[t,i]of r.entries())!i&&e.getChild(t).is("element","tableRow")&&n.push(t);if(n.length){i=!0;for(const i of n.reverse())t.remove(e.getChild(i)),r.splice(i,1)}const o=r.filter(((t,i)=>e.getChild(i).is("element","tableRow"))),s=o[0];if(!o.every((e=>e===s))){const r=o.reduce(((e,t)=>t>e?t:e),0);for(const[n,s]of o.entries()){const o=r-s;if(o){for(let i=0;ifunction(e,t){const i=t.document.differ.getChanges();let r=!1;for(const t of i)"insert"==t.type&&"table"==t.name&&(r=tk(t.position.nodeAfter,e)||r),"insert"==t.type&&"tableRow"==t.name&&(r=ik(t.position.nodeAfter,e)||r),"insert"==t.type&&"tableCell"==t.name&&(r=rk(t.position.nodeAfter,e)||r),"remove"!=t.type&&"insert"!=t.type||!nk(t)||(r=rk(t.position.parent,e)||r);return r}(t,e)))}function tk(e,t){let i=!1;for(const r of e.getChildren())r.is("element","tableRow")&&(i=ik(r,t)||i);return i}function ik(e,t){let i=!1;for(const r of e.getChildren())i=rk(r,t)||i;return i}function rk(e,t){if(0==e.childCount)return t.insertElement("paragraph",e),!0;const i=Array.from(e.getChildren()).filter((e=>e.is("$text")));for(const e of i)t.wrap(t.createRangeOn(e),"paragraph");return!!i.length}function nk(e){return!!e.position.parent.is("element","tableCell")&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)}function ok(e,t){if(!e.is("element","paragraph"))return!1;const i=t.toViewElement(e);return!!i&&pw(e)!==i.is("element","span")}var sk=i(2350),ak={attributes:{"data-cke":!0}};ak.setAttributes=Un(),ak.insert=zn().bind(null,"head"),ak.domAPI=Fn(),ak.insertStyleElement=$n();Ln()(sk.A,ak);sk.A&&sk.A.locals&&sk.A.locals;class ck extends xs{static get pluginName(){return"TableEditing"}static get requires(){return[Fw]}constructor(e){super(e),this._additionalSlots=[]}init(){const e=this.editor,t=e.model,i=t.schema,r=e.conversion,n=e.plugins.get(Fw);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}),r.for("upcast").add((e=>{e.on("element:figure",((e,t,i)=>{if(!i.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const r=function(e){for(const t of e.getChildren())if(t.is("element","table"))return t}(t.viewItem);if(!r||!i.consumable.test(r,{name:!0}))return;i.consumable.consume(t.viewItem,{name:!0,classes:"table"});const n=En(i.convertItem(r,t.modelCursor).modelRange.getItems());n?(i.convertChildren(t.viewItem,i.writer.createPositionAt(n,"end")),i.updateConversionResult(n,t)):i.consumable.revert(t.viewItem,{name:!0,classes:"table"})}))})),r.for("upcast").add(aw()),r.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:hw(n,{asWidget:!0,additionalSlots:this._additionalSlots})}),r.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:hw(n,{additionalSlots:this._additionalSlots})}),r.for("upcast").elementToElement({model:"tableRow",view:"tr"}),r.for("upcast").add((e=>{e.on("element:tr",((e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()}),{priority:"high"})})),r.for("downcast").elementToElement({model:"tableRow",view:(e,{writer:t})=>e.isEmpty?t.createEmptyElement("tr"):t.createContainerElement("tr")}),r.for("upcast").elementToElement({model:"tableCell",view:"td"}),r.for("upcast").elementToElement({model:"tableCell",view:"th"}),r.for("upcast").add(cw("td")),r.for("upcast").add(cw("th")),r.for("editingDowncast").elementToElement({model:"tableCell",view:mw({asWidget:!0})}),r.for("dataDowncast").elementToElement({model:"tableCell",view:mw()}),r.for("editingDowncast").elementToElement({model:"paragraph",view:gw({asWidget:!0}),converterPriority:"high"}),r.for("dataDowncast").elementToElement({model:"paragraph",view:gw(),converterPriority:"high"}),r.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),r.for("upcast").attributeToAttribute({model:{key:"colspan",value:lk("colspan")},view:"colspan"}),r.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),r.for("upcast").attributeToAttribute({model:{key:"rowspan",value:lk("rowspan")},view:"rowspan"}),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new fw(e)),e.commands.add("insertTableRowAbove",new bw(e,{order:"above"})),e.commands.add("insertTableRowBelow",new bw(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new ww(e,{order:"left"})),e.commands.add("insertTableColumnRight",new ww(e,{order:"right"})),e.commands.add("removeTableRow",new Nw(e)),e.commands.add("removeTableColumn",new Vw(e)),e.commands.add("splitTableCellVertically",new kw(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new kw(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new Ww(e)),e.commands.add("mergeTableCellRight",new Mw(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new Mw(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new Mw(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new Mw(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new Rw(e)),e.commands.add("setTableRowHeader",new Bw(e)),e.commands.add("selectTableRow",new Kw(e)),e.commands.add("selectTableColumn",new Yw(e)),Jw(t),ek(t),this.listenTo(t.document,"change:data",(()=>{!function(e,t){const i=e.document.differ;for(const e of i.getChanges()){let i,r=!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,r="headingRows"==e.attributeKey}else"tableRow"!=e.name&&"tableCell"!=e.name||(i=e.position.findAncestor("table"),r="tableRow"==e.name);if(!i)continue;const n=i.getAttribute("headingRows")||0,o=i.getAttribute("headingColumns")||0,s=new dw(i);for(const e of s){const i=e.rowok(e,t.mapper)));for(const e of i)t.reconvertItem(e)}}(t,e.editing)}))}registerAdditionalSlot(e){this._additionalSlots.push(e)}}function lk(e){return t=>{const i=parseInt(t.getAttribute(e));return Number.isNaN(i)||i<=0?null:i}}var dk=i(1241),uk={attributes:{"data-cke":!0}};uk.setAttributes=Un(),uk.insert=zn().bind(null,"head"),uk.domAPI=Fn(),uk.insertStyleElement=$n();Ln()(dk.A,uk);dk.A&&dk.A.locals&&dk.A.locals;class hk extends Kn{constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new Tn,this.focusTracker=new Sn,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:r}=t.target.dataset;this.items.get(10*(parseInt(i,10)-1)+(parseInt(r,10)-1)).focus()})),this.focusTracker.on("change:focusedElement",((e,t,i)=>{if(!i)return;const{row:r,column:n}=i.dataset;this.set({rows:parseInt(r),columns:parseInt(n)})})),this.on("change:columns",(()=>this._highlightGridBoxes())),this.on("change:rows",(()=>this._highlightGridBoxes()))}render(){super.render(),s({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)}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map(((i,r)=>{const n=Math.floor(r/10){const r=e.commands.get("insertTable"),n=$m(i);let o;return n.bind("isEnabled").to(r),n.buttonView.set({icon:'',label:t("Insert table"),tooltip:!0}),n.on("change:isOpen",(()=>{o||(o=new hk(i),n.panelView.children.add(o),o.delegate("execute").to(n),n.on("execute",(()=>{e.execute("insertTable",{rows:o.rows,columns:o.columns}),e.editing.view.focus()})))})),n})),e.ui.componentFactory.add("tableColumn",(e=>{const r=[{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"),'',r,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 r=[{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"),'',r,e)}))}_prepareDropdown(e,t,i,r){const n=this.editor,o=$m(r),s=this._fillDropdownWithListOptions(o,i);return o.buttonView.set({label:e,icon:t,tooltip:!0}),o.bind("isEnabled").toMany(s,"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(o,"execute",(e=>{n.execute(e.source.commandName),e.source instanceof So||n.editing.view.focus()})),o}_prepareMergeSplitButtonDropdown(e,t,i,r){const n=this.editor,o=$m(r,jm),s="mergeTableCells",a=n.commands.get(s),c=this._fillDropdownWithListOptions(o,i);return o.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),o.bind("isEnabled").toMany([a,...c],"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(o.buttonView,"execute",(()=>{n.execute(s),n.editing.view.focus()})),this.listenTo(o,"execute",(e=>{n.execute(e.source.commandName),n.editing.view.focus()})),o}_fillDropdownWithListOptions(e,t){const i=this.editor,r=[],n=new Cn;for(const e of t)gk(e,i,r,n);return Km(e,n),r}}function gk(e,t,i,r){if("button"===e.type||"switchbutton"===e.type){const r=e.model=new Ep(e.model),{commandName:n,bindIsOn:o}=e.model,s=t.commands.get(n);i.push(s),r.set({commandName:n}),r.bind("isEnabled").to(s),o&&r.bind("isOn").to(s,"value"),r.set({withText:!0})}r.add(e)}var pk=i(2744),fk={attributes:{"data-cke":!0}};fk.setAttributes=Un(),fk.insert=zn().bind(null,"head"),fk.domAPI=Fn(),fk.insertStyleElement=$n();Ln()(pk.A,fk);pk.A&&pk.A.locals&&pk.A.locals;class bk extends xs{static get pluginName(){return"TableSelection"}static get requires(){return[Fw,Fw]}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(Fw),t=this.editor.model.document.selection,i=e.getSelectedTableCells(t);return 0==i.length?null:i}getSelectionAsFragment(){const e=this.editor.plugins.get(Fw),t=this.getSelectedTableCells();return t?this.editor.model.change((i=>{const r=i.createDocumentFragment(),{first:n,last:o}=e.getColumnIndexes(t),{first:s,last:a}=e.getRowIndexes(t),c=t[0].findAncestor("table");let l=a,d=o;if(e.isSelectionRectangular(t)){const e={firstColumn:n,lastColumn:o,firstRow:s,lastRow:a};l=Pw(c,e),d=Iw(c,e)}const u=vw(c,{startRow:s,startColumn:n,endRow:l,endColumn:d},i);return i.insert(u,r,0),r})):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=En(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,r)=>{const n=r.writer;!function(e){for(const i of t)e.removeClass("ck-editor__editable_selected",i);t.clear()}(n);const o=this.getSelectedTableCells();if(!o)return;for(const e of o){const i=r.mapper.toViewElement(e);n.addClass("ck-editor__editable_selected",i),t.add(i)}const s=r.mapper.toViewElement(o[o.length-1]);n.setSelection(s,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 r=i.createPositionAt(t[0],0),n=e.model.schema.getNearestSelectionRange(r);i.setSelection(n)}))}}))}_handleDeleteContent(e,t){const i=this.editor.plugins.get(Fw),r=t[0],n=t[1],o=this.editor.model,s=!n||"backward"==n.direction,a=i.getSelectedTableCells(r);a.length&&(e.stop(),o.change((e=>{const t=a[s?a.length-1:0];o.change((e=>{for(const t of a)o.deleteContent(e.createSelection(t,"in"))}));const i=o.schema.getNearestSelectionRange(e.createPositionAt(t,0));r.is("documentSelection")?e.setSelection(i):r.setTo(i)})))}_handleInsertTextEvent(e,t){const i=this.editor,r=this.getSelectedTableCells();if(!r)return;const n=i.editing.view,o=i.editing.mapper,s=r.map((e=>n.createRangeOn(o.toViewElement(e))));t.selection=n.createSelection(s)}_getCellsToSelect(e,t){const i=this.editor.plugins.get("TableUtils"),r=i.getCellLocation(e),n=i.getCellLocation(t),o=Math.min(r.row,n.row),s=Math.max(r.row,n.row),a=Math.min(r.column,n.column),c=Math.max(r.column,n.column),l=new Array(s-o+1).fill(null).map((()=>[])),d={startRow:o,endRow:s,startColumn:a,endColumn:c};for(const{row:t,cell:i}of new dw(e.findAncestor("table"),d))l[t-o].push(i);const u=n.rowe.reverse())),{cells:l.flat(),backward:u||h}}}class wk extends xs{static get pluginName(){return"TableClipboard"}static get requires(){return[bk,Fw]}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"copy",((e,t)=>this._onCopyCut(e,t))),this.listenTo(t,"cut",((e,t)=>this._onCopyCut(e,t))),this.listenTo(e.model,"insertContent",((e,[t,i])=>this._onInsertContent(e,t,i)),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(e,t){const i=this.editor.plugins.get(bk);if(!i.getSelectedTableCells())return;if("cut"==e.name&&!this.editor.model.canEditAt(this.editor.model.document.selection))return;t.preventDefault(),e.stop();const r=this.editor.data,n=this.editor.editing.view.document,o=r.toView(i.getSelectionAsFragment());n.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:o,method:e.name})}_onInsertContent(e,t,i){if(i&&!i.is("documentSelection"))return;const r=this.editor.model,n=this.editor.plugins.get(Fw);let o=this.getTableIfOnlyTableInContent(t,r);if(!o)return;const s=n.getSelectionAffectedTableCells(r.document.selection);s.length?(e.stop(),r.change((e=>{const t={width:n.getColumns(o),height:n.getRows(o)},i=function(e,t,i,r){const n=e[0].findAncestor("table"),o=r.getColumnIndexes(e),s=r.getRowIndexes(e),a={firstColumn:o.first,lastColumn:o.last,firstRow:s.first,lastRow:s.last},c=1===e.length;c&&(a.lastRow+=t.height-1,a.lastColumn+=t.width-1,function(e,t,i,r){const n=r.getColumns(e),o=r.getRows(e);i>n&&r.insertColumns(e,{at:n,columns:i-n});t>o&&r.insertRows(e,{at:o,rows:t-o})}(n,a.lastRow+1,a.lastColumn+1,r));c||!r.isSelectionRectangular(e)?function(e,t,i){const{firstRow:r,lastRow:n,firstColumn:o,lastColumn:s}=t,a={first:r,last:n},c={first:o,last:s};vk(e,o,a,i),vk(e,s+1,a,i),kk(e,r,c,i),kk(e,n+1,c,i,r)}(n,a,i):(a.lastRow=Pw(n,a),a.lastColumn=Iw(n,a));return a}(s,t,e,n),r=i.lastRow-i.firstRow+1,a=i.lastColumn-i.firstColumn+1,c={startRow:0,startColumn:0,endRow:Math.min(r,t.height)-1,endColumn:Math.min(a,t.width)-1};o=vw(o,c,e);const l=s[0].findAncestor("table"),d=this._replaceSelectedCellsWithPasted(o,t,l,i,e);if(this.editor.plugins.get("TableSelection").isEnabled){const t=n.sortRanges(d.map((t=>e.createRangeOn(t))));e.setSelection(t)}else e.setSelection(d[0],0)}))):Tw(o,n)}_replaceSelectedCellsWithPasted(e,t,i,r,n){const{width:o,height:s}=t,a=function(e,t,i){const r=new Array(i).fill(null).map((()=>new Array(t).fill(null)));for(const{column:t,row:i,cell:n}of new dw(e))r[i][t]=n;return r}(e,o,s),c=[...new dw(i,{startRow:r.firstRow,endRow:r.lastRow,startColumn:r.firstColumn,endColumn:r.lastColumn,includeAllSlots:!0})],l=[];let d;for(const e of c){const{row:t,column:i}=e;i===r.firstColumn&&(d=e.getPositionBefore());const c=t-r.firstRow,u=i-r.firstColumn,h=a[c%s][u%o],m=h?n.cloneElement(h):null,g=this._replaceTableSlotCell(e,m,d,n);g&&(Cw(g,t,i,r.lastRow,r.lastColumn,n),l.push(g),d=n.createPositionAfter(g))}const u=parseInt(i.getAttribute("headingRows")||"0"),h=parseInt(i.getAttribute("headingColumns")||"0"),m=r.firstRow_k(e,t,i))).map((({cell:e})=>yw(e,t,r)))}function vk(e,t,i,r){if(t<1)return;return xw(e,t).filter((({row:e,cellHeight:t})=>_k(e,t,i))).map((({cell:e,column:i})=>Aw(e,i,t,r)))}function _k(e,t,i){const r=e+t-1,{first:n,last:o}=i;return e>=n&&e<=o||e=n}class yk extends xs{static get pluginName(){return"TableKeyboard"}static get requires(){return[bk,Fw]}init(){const e=this.editor.editing.view.document;this.listenTo(e,"arrowKey",((...e)=>this._onArrowKey(...e)),{context:"table"}),this.listenTo(e,"tab",((...e)=>this._handleTabOnSelectedTable(...e)),{context:"figure"}),this.listenTo(e,"tab",((...e)=>this._handleTab(...e)),{context:["th","td"]})}_handleTabOnSelectedTable(e,t){const i=this.editor,r=i.model.document.selection.getSelectedElement();r&&r.is("element","table")&&(t.preventDefault(),t.stopPropagation(),e.stop(),i.model.change((e=>{e.setSelection(e.createRangeIn(r.getChild(0).getChild(0)))})))}_handleTab(e,t){const i=this.editor,r=this.editor.plugins.get(Fw),n=this.editor.plugins.get("TableSelection"),o=i.model.document.selection,s=!t.shiftKey;let a=r.getTableCellsContainingSelection(o)[0];if(a||(a=n.getFocusCell()),!a)return;t.preventDefault(),t.stopPropagation(),e.stop();const c=a.parent,l=c.parent,d=l.getChildIndex(c),u=c.getChildIndex(a),h=0===u;if(!s&&h&&0===d)return void i.model.change((e=>{e.setSelection(e.createRangeOn(l))}));const m=u===c.childCount-1,g=d===r.getRows(l)-1;if(s&&g&&m&&(i.execute("insertTableRowBelow"),d===r.getRows(l)-1))return void i.model.change((e=>{e.setSelection(e.createRangeOn(l))}));let p;if(s&&m){const e=l.getChild(d+1);p=e.getChild(0)}else if(!s&&h){const e=l.getChild(d-1);p=e.getChild(e.childCount-1)}else p=c.getChild(u+(s?1:-1));i.model.change((e=>{e.setSelection(e.createRangeIn(p))}))}_onArrowKey(e,t){const i=this.editor,r=kn(t.keyCode,i.locale.contentLanguageDirection);this._handleArrowKeys(r,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const i=this.editor.plugins.get(Fw),r=this.editor.plugins.get("TableSelection"),n=this.editor.model,o=n.document.selection,s=["right","down"].includes(e),a=i.getSelectedTableCells(o);if(a.length){let i;return i=t?r.getFocusCell():s?a[a.length-1]:a[0],this._navigateFromCellInDirection(i,e,t),!0}const c=o.focus.findAncestor("tableCell");if(!c)return!1;if(!o.isCollapsed)if(t){if(o.isBackward==s&&!o.containsEntireContent(c))return!1}else{const e=o.getSelectedElement();if(!e||!n.schema.isObject(e))return!1}return!!this._isSelectionAtCellEdge(o,c,s)&&(this._navigateFromCellInDirection(c,e,t),!0)}_isSelectionAtCellEdge(e,t,i){const r=this.editor.model,n=this.editor.model.schema,o=i?e.getLastPosition():e.getFirstPosition();if(!n.getLimitElement(o).is("element","tableCell")){return r.createPositionAt(t,i?"end":0).isTouching(o)}const s=r.createSelection(o);return r.modifySelection(s,{direction:i?"forward":"backward"}),o.isEqual(s.focus)}_navigateFromCellInDirection(e,t,i=!1){const r=this.editor.model,n=e.findAncestor("table"),o=[...new dw(n,{includeAllSlots:!0})],{row:s,column:a}=o[o.length-1],c=o.find((({cell:t})=>t==e));let{row:l,column:d}=c;switch(t){case"left":d--;break;case"up":l--;break;case"right":d+=c.cellWidth;break;case"down":l+=c.cellHeight}if(l<0||l>s||d<0&&l<=0||d>a&&l>=s)return void r.change((e=>{e.setSelection(e.createRangeOn(n))}));d<0?(d=i?0:a,l--):d>a&&(d=i?a:0,l++);const u=o.find((e=>e.row==l&&e.column==d)).cell,h=["right","down"].includes(t),m=this.editor.plugins.get("TableSelection");if(i&&m.isEnabled){const t=m.getAnchorCell()||e;m.setCellSelection(t,u)}else{const e=r.createPositionAt(u,h?0:"end");r.change((t=>{t.setSelection(e)}))}}}class xk extends cl{constructor(){super(...arguments),this.domEventType=["mousemove","mouseleave"]}onDomEvent(e){this.fire(e.type,e)}}class Ak extends xs{static get pluginName(){return"TableMouse"}static get requires(){return[bk,Fw]}init(){this.editor.editing.view.addObserver(xk),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(Fw);let i=!1;const r=e.plugins.get(bk);this.listenTo(e.editing.view.document,"mousedown",((n,o)=>{const s=e.model.document.selection;if(!this.isEnabled||!r.isEnabled)return;if(!o.domEvent.shiftKey)return;const a=r.getAnchorCell()||t.getTableCellsContainingSelection(s)[0];if(!a)return;const c=this._getModelTableCellFromDomEvent(o);c&&Ck(a,c)&&(i=!0,r.setCellSelection(a,c),o.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,r=!1,n=!1;const o=e.plugins.get(bk);this.listenTo(e.editing.view.document,"mousedown",((e,i)=>{this.isEnabled&&o.isEnabled&&(i.domEvent.shiftKey||i.domEvent.ctrlKey||i.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(i)))})),this.listenTo(e.editing.view.document,"mousemove",((e,s)=>{if(!s.domEvent.buttons)return;if(!t)return;const a=this._getModelTableCellFromDomEvent(s);a&&Ck(t,a)&&(i=a,r||i==t||(r=!0)),r&&(n=!0,o.setCellSelection(t,i),s.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{r=!1,n=!1,t=null,i=null})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{n&&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 Ck(e,t){return e.parent.parent==t.parent.parent}var Ek=i(1120),Sk={attributes:{"data-cke":!0}};Sk.setAttributes=Un(),Sk.insert=zn().bind(null,"head"),Sk.domAPI=Fn(),Sk.insertStyleElement=$n();Ln()(Ek.A,Sk);Ek.A&&Ek.A.locals&&Ek.A.locals;class Tk extends xs{static get requires(){return[ck,mk,bk,Ak,yk,wk,Rb]}static get pluginName(){return"Table"}}function Pk(e,t,i,r){let n,o=null;"function"==typeof r?n=r:(o=e.commands.get(r),n=()=>{e.execute(r)}),e.model.document.on("change:data",((s,a)=>{if(o&&!o.isEnabled||!t.isEnabled)return;const c=En(e.model.document.selection.getRanges());if(!c.isCollapsed)return;if(a.isUndo||!a.isLocal)return;const l=Array.from(e.model.document.differ.getChanges()),d=l[0];if(1!=l.length||"insert"!==d.type||"$text"!=d.name||1!=d.length)return;const u=d.position.parent;if(u.is("element","codeBlock"))return;if(u.is("element","listItem")&&"function"!=typeof r&&!["numberedList","bulletedList","todoList"].includes(r))return;if(o&&!0===o.value)return;const h=u.getChild(0),m=e.model.createRangeOn(h);if(!m.containsRange(c)&&!c.end.isEqual(m.end))return;const g=i.exec(h.data.substr(0,c.end.offset));g&&e.model.enqueueChange((t=>{const i=t.createPositionAt(u,0),r=t.createPositionAt(u,g[0].length),o=new wd(i,r);if(!1!==n({match:g})){t.remove(o);const i=e.model.document.selection.getFirstRange(),r=t.createRangeIn(u);!u.isEmpty||r.isEqual(i)||r.containsRange(i,!0)||t.remove(u)}o.detach(),e.model.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}))}))}function Ik(e,t,i,r){let n,o;i instanceof RegExp?n=i:o=i,o=o||(e=>{let t;const i=[],r=[];for(;null!==(t=n.exec(e))&&!(t&&t.length<4);){let{index:e,1:n,2:o,3:s}=t;const a=n+o+s;e+=t[0].length-a.length;const c=[e,e+n.length],l=[e+n.length+o.length,e+n.length+o.length+s.length];i.push(c),i.push(l),r.push([e+n.length,e+n.length+o.length])}return{remove:i,format:r}}),e.model.document.on("change:data",((i,n)=>{if(n.isUndo||!n.isLocal||!t.isEnabled)return;const s=e.model,a=s.document.selection;if(!a.isCollapsed)return;const c=Array.from(s.document.differ.getChanges()),l=c[0];if(1!=c.length||"insert"!==l.type||"$text"!=l.name||1!=l.length)return;const d=a.focus,u=d.parent,{text:h,range:m}=function(e,t){let i=e.start;const r=Array.from(e.getItems()).reduce(((e,r)=>!r.is("$text")&&!r.is("$textProxy")||r.getAttribute("code")?(i=t.createPositionAfter(r),""):e+r.data),"");return{text:r,range:t.createRange(i,e.end)}}(s.createRange(s.createPositionAt(u,0),d),s),g=o(h),p=Mk(m.start,g.format,s),f=Mk(m.start,g.remove,s);p.length&&f.length&&s.enqueueChange((t=>{if(!1!==r(t,p)){for(const e of f.reverse())t.remove(e);s.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}}))}))}function Mk(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]))))}class Ok extends xs{static get requires(){return[Lf]}static get pluginName(){return"Autoformat"}afterInit(){this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats()}_addListAutoformats(){const e=this.editor.commands;e.get("bulletedList")&&Pk(this.editor,this,/^[*-]\s$/,"bulletedList"),e.get("numberedList")&&Pk(this.editor,this,/^1[.|)]\s$/,"numberedList"),e.get("todoList")&&Pk(this.editor,this,/^\[\s?\]\s$/,"todoList"),e.get("checkTodoList")&&Pk(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=Nk(this.editor,"bold");Ik(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,e),Ik(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,e)}if(e.get("italic")){const e=Nk(this.editor,"italic");Ik(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,e),Ik(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,e)}if(e.get("code")){const e=Nk(this.editor,"code");Ik(this.editor,this,/(`)([^`]+)(`)$/g,e)}if(e.get("strikethrough")){const e=Nk(this.editor,"strikethrough");Ik(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],r=new RegExp(`^(#{${i}})\\s$`);Pk(this.editor,this,r,(()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute("heading",{value:t})}))}))}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&Pk(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const e=this.editor,t=e.model.document.selection;e.commands.get("codeBlock")&&Pk(e,this,/^```$/,(()=>{if(t.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})}))}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&Pk(this.editor,this,/^---$/,"horizontalLine")}}function Nk(e,t){return(i,r)=>{if(!e.commands.get(t).isEnabled)return!1;const n=e.model.schema.getValidRanges(r,t);for(const e of n)i.setAttribute(t,!0,e);i.removeSelectionAttribute(t)}}class Vk extends cl{constructor(e){super(e),this.domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"];const t=this.document;function i(e){return(i,r)=>{r.preventDefault();const n=r.dropRange?[r.dropRange]:null,o=new f(t,e);t.fire(o,{dataTransfer:r.dataTransfer,method:i.name,targetRanges:n,target:r.target,domEvent:r.domEvent}),o.stop.called&&r.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,r={dataTransfer:new Ll(t,{cacheFiles:i})};"drop"!=e.type&&"dragover"!=e.type||(r.dropRange=function(e,t){const i=t.target.ownerDocument,r=t.clientX,n=t.clientY;let o;i.caretRangeFromPoint&&i.caretRangeFromPoint(r,n)?o=i.caretRangeFromPoint(r,n):t.rangeParent&&(o=i.createRange(),o.setStart(t.rangeParent,t.rangeOffset),o.collapse(!0));if(o)return e.domConverter.domRangeToView(o);return null}(this.view,e)),this.fire(e.type,e,r)}}const Bk=["figcaption","li"],Rk=["ol","ul"];function Lk(e){if(e.is("$text")||e.is("$textProxy"))return e.data;if(e.is("element","img")&&e.hasAttribute("alt"))return e.getAttribute("alt");if(e.is("element","br"))return"\n";let t="",i=null;for(const r of e.getChildren())t+=Dk(r,i)+Lk(r),i=r;return t}function Dk(e,t){return t?e.is("element","li")&&!e.isEmpty&&e.getChild(0).is("containerElement")||Rk.includes(e.name)&&Rk.includes(t.name)?"\n\n":e.is("containerElement")||t.is("containerElement")?Bk.includes(e.name)||Bk.includes(t.name)?"\n":"\n\n":"":""}class Fk extends xs{static get pluginName(){return"ClipboardPipeline"}init(){this.editor.editing.view.addObserver(Vk),this._setupPasteDrop(),this._setupCopyCut()}_fireOutputTransformationEvent(e,t,i){const r=this.editor.model.getSelectedContent(t);this.fire("outputTransformation",{dataTransfer:e,content:r,method:i})}_setupPasteDrop(){const e=this.editor,t=e.model,i=e.editing.view,r=i.document;this.listenTo(r,"clipboardInput",((t,i)=>{"paste"!=i.method||e.model.canEditAt(e.model.document.selection)||t.stop()}),{priority:"highest"}),this.listenTo(r,"clipboardInput",((e,t)=>{const r=t.dataTransfer;let n;if(t.content)n=t.content;else{let e="";r.getData("text/html")?e=function(e){return e.replace(/(\s+)<\/span>/g,((e,t)=>1==t.length?" ":t)).replace(//g,"")}(r.getData("text/html")):r.getData("text/plain")&&(((o=(o=r.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("

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

${o}

`),e=o),n=this.editor.data.htmlProcessor.toView(e)}var o;const s=new f(this,"inputTransformation");this.fire(s,{content:n,dataTransfer:r,targetRanges:t.targetRanges,method:t.method}),s.stop.called&&e.stop(),i.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,i)=>{if(i.content.isEmpty)return;const r=this.editor.data.toModel(i.content,"$clipboardHolder");0!=r.childCount&&(e.stop(),t.change((()=>{this.fire("contentInsertion",{content:r,method:i.method,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,i)=>{i.resultRange=t.insertContent(i.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,r=(e,i)=>{const r=i.dataTransfer;i.preventDefault(),this._fireOutputTransformationEvent(r,t.selection,e.name)};this.listenTo(i,"copy",r,{priority:"low"}),this.listenTo(i,"cut",((t,i)=>{e.model.canEditAt(e.model.document.selection)?r(t,i):i.preventDefault()}),{priority:"low"}),this.listenTo(this,"outputTransformation",((t,r)=>{const n=e.data.toView(r.content);i.fire("clipboardOutput",{dataTransfer:r.dataTransfer,content:n,method:r.method})}),{priority:"low"}),this.listenTo(i,"clipboardOutput",((i,r)=>{r.content.isEmpty||(r.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(r.content)),r.dataTransfer.setData("text/plain",Lk(r.content))),"cut"==r.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}const jk=qr("px");class zk extends Kn{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=>jk(e))),top:e.to("top",(e=>jk(e))),width:e.to("width",(e=>jk(e)))}}})}}class Hk extends xs{constructor(){super(...arguments),this.removeDropMarkerDelayed=In((()=>this.removeDropMarker()),40),this._updateDropMarkerThrottled=rp((e=>this._updateDropMarker(e)),40),this._reconvertMarkerThrottled=rp((()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")}),0),this._dropTargetLineView=new zk,this._domEmitter=new(Pr()),this._scrollables=new Map}static get pluginName(){return"DragDropTarget"}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,r,n,o){this.removeDropMarkerDelayed.cancel();const s=Uk(this.editor,e,t,i,r,n,o);if(s)return o&&o.containsRange(s)?this.removeDropMarker():void this._updateDropMarkerThrottled(s)}getFinalDropRange(e,t,i,r,n,o){const s=Uk(this.editor,e,t,i,r,n,o);return this.removeDropMarker(),s}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,r=e.start.nodeAfter,n=e.start.parent,o=i?t.mapper.toViewElement(i):null,s=o?t.view.domConverter.mapViewToDom(o):null,a=r?t.mapper.toViewElement(r):null,c=a?t.view.domConverter.mapViewToDom(a):null,l=t.mapper.toViewElement(n),d=t.view.domConverter.mapViewToDom(l),u=this._getScrollableRect(l),{scrollX:h,scrollY:m}=Nr.window,g=s?new Fr(s):null,p=c?new Fr(c):null,f=new Fr(d).excludeScrollbarsAndBorders(),b=g?g.bottom:f.top,w=p?p.top:f.bottom,k=Nr.window.getComputedStyle(d),v=b<=w?(b+w)/2:w;if(u.topa.schema.checkChild(o,e)))){if(a.schema.checkChild(o,"$text"))return a.createRange(o);if(t)return $k(e,Gk(e,t.parent),r,n)}}}else if(a.schema.isInline(l))return $k(e,l,r,n);if(a.schema.isBlock(l))return $k(e,l,r,n);if(a.schema.checkChild(l,"$block")){const t=Array.from(l.getChildren()).filter((t=>t.is("element")&&!Wk(e,t)));let i=0,o=t.length;if(0==o)return a.createRange(a.createPositionAt(l,"end"));for(;i{i?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")})),l.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(Nr.document,"dragover",((e,t)=>this._handleBlockDragging(t))),this._domEmitter.listenTo(Nr.document,"drop",((e,t)=>this._handleBlockDragging(t))),this._domEmitter.listenTo(Nr.document,"dragend",(()=>this._handleBlockDragEnd()),{useCapture:!0}),this.isEnabled&&t.setAttribute("draggable","true"),this.on("change:isEnabled",((e,i,r)=>{t.setAttribute("draggable",r?"true":"false")}))}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(e){if(!this.isEnabled)return;const t=this.editor.model,i=t.document.selection,r=this.editor.editing.view,n=Array.from(i.getSelectedBlocks()),o=t.createRange(t.createPositionBefore(n[0]),t.createPositionAfter(n[n.length-1]));t.change((e=>e.setSelection(o))),this._isBlockDragging=!0,r.focus(),r.getObserver(Vk).onDomEvent(e)}_handleBlockDragging(e){if(!this.isEnabled||!this._isBlockDragging)return;const t=e.clientX+("ltr"==this.editor.locale.contentLanguageDirection?100:-100),i=e.clientY,r=document.elementFromPoint(t,i),n=this.editor.editing.view;r&&r.closest(".ck-editor__editable")&&n.getObserver(Vk).onDomEvent({...e,type:e.type,dataTransfer:e.dataTransfer,target:r,clientX:t,clientY:i,preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}}var Yk=i(72),Jk={attributes:{"data-cke":!0}};Jk.setAttributes=Un(),Jk.insert=zn().bind(null,"head"),Jk.domAPI=Fn(),Jk.insertStyleElement=$n();Ln()(Yk.A,Jk);Yk.A&&Yk.A.locals&&Yk.A.locals;class Zk extends xs{constructor(){super(...arguments),this._clearDraggableAttributesDelayed=In((()=>this._clearDraggableAttributes()),40),this._blockMode=!1,this._domEmitter=new(Pr())}static get pluginName(){return"DragDrop"}static get requires(){return[Fk,Rb,Hk,Kk]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,t.addObserver(Vk),t.addObserver(Uh),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)})),l.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,r=i.document,n=e.plugins.get(Hk);this.listenTo(r,"dragstart",((e,i)=>{if(i.target&&i.target.is("editableElement"))return void i.preventDefault();if(this._prepareDraggedRange(i.target),!this._draggedRange)return void i.preventDefault();this._draggingUid=w(),i.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",i.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const r=t.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(i.dataTransfer,r,"dragstart");const{dataTransfer:n,domTarget:o,domEvent:s}=i,{clientX:a}=s;this._updatePreview({dataTransfer:n,domTarget:o,clientX:a}),i.stopPropagation(),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(r,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this._domEmitter.listenTo(Nr.document,"dragend",(()=>{this._blockMode=!1}),{useCapture:!0}),this.listenTo(r,"dragenter",(()=>{this.isEnabled&&i.focus()})),this.listenTo(r,"dragleave",(()=>{n.removeDropMarkerDelayed()})),this.listenTo(r,"dragging",((e,t)=>{if(!this.isEnabled)return void(t.dataTransfer.dropEffect="none");const{clientX:i,clientY:r}=t.domEvent;n.updateDropMarker(t.target,t.targetRanges,i,r,this._blockMode,this._draggedRange),this._draggedRange||(t.dataTransfer.dropEffect="copy"),l.isGecko||("copy"==t.dataTransfer.effectAllowed?t.dataTransfer.dropEffect="copy":["all","copyMove"].includes(t.dataTransfer.effectAllowed)&&(t.dataTransfer.dropEffect="move")),e.stop()}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get(Hk);this.listenTo(t,"clipboardInput",((t,r)=>{if("drop"!=r.method)return;const{clientX:n,clientY:o}=r.domEvent,s=i.getFinalDropRange(r.target,r.targetRanges,n,o,this._blockMode,this._draggedRange);if(!s)return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=r.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==Qk(r.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(s,!0))return this._finalizeDragging(!1),void t.stop();r.targetRanges=[e.editing.mapper.toViewRange(s)]}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(Fk);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"==Qk(t.dataTransfer),r=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(r&&i)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"mousedown",((r,n)=>{if(l.isAndroid||!n)return;this._clearDraggableAttributesDelayed.cancel();let o=Xk(n.target);if(l.isBlink&&!e.isReadOnly&&!o&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();e&&gb(e)||(o=i.selection.editableElement)}o&&(t.change((e=>{e.setAttribute("draggable","true",o)})),this._draggableElement=e.editing.mapper.toModelElement(o))})),this.listenTo(i,"mouseup",(()=>{l.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;if(t.plugins.get(Hk).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 r=t.getFirstPosition().parent;r.isEmpty&&!i.schema.checkChild(r,"$text")&&i.schema.checkChild(r,"paragraph")&&e.insertElement("paragraph",r,0)})),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(e){const t=this.editor,i=t.model,r=i.document.selection,n=e?Xk(e):null;if(n){const e=t.editing.mapper.toModelElement(n);if(this._draggedRange=wd.fromRange(i.createRangeOn(e)),this._blockMode=i.schema.isBlock(e),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}return}if(r.isCollapsed&&!r.getFirstPosition().parent.isEmpty)return;const o=Array.from(r.getSelectedBlocks()),s=r.getFirstRange();if(0==o.length)return void(this._draggedRange=wd.fromRange(s));const a=ev(i,o);if(o.length>1)this._draggedRange=wd.fromRange(a),this._blockMode=!0;else if(1==o.length){const e=s.start.isTouching(a.start)&&s.end.isTouching(a.end);this._draggedRange=wd.fromRange(e?a:s),this._blockMode=e}i.change((e=>e.setSelection(this._draggedRange.toRange())))}_updatePreview({dataTransfer:e,domTarget:t,clientX:i}){const r=this.editor.editing.view,n=r.document.selection.editableElement,o=r.domConverter.mapViewToDom(n),s=Nr.window.getComputedStyle(o);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=we(Nr.document,"div",{style:"position: fixed; left: -999999px;"}),Nr.document.body.appendChild(this._previewContainer));const a=new Fr(o);if(o.contains(t))return;const c=parseFloat(s.paddingLeft),d=we(Nr.document,"div");d.className="ck ck-content",d.style.width=s.width,d.style.paddingLeft=`${a.left-i+c}px`,l.isiOS&&(d.style.backgroundColor="white"),d.innerHTML=e.getData("text/html"),e.setDragImage(d,0,0),this._previewContainer.appendChild(d)}}function Qk(e){return l.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function Xk(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(gb);if(gb(e))return e;const t=e.findAncestor((e=>gb(e)||e.is("editableElement")));return gb(t)?t:null}function ev(e,t){const i=t[0],r=t[t.length-1],n=i.getCommonAncestor(r),o=e.createPositionBefore(i),s=e.createPositionAfter(r);if(n&&n.is("element")&&!e.schema.isLimit(n)){const t=e.createRangeOn(n),i=o.isTouching(t.start),r=s.isTouching(t.end);if(i&&r)return ev(e,[n])}return e.createRange(o,s)}class tv extends xs{static get pluginName(){return"PastePlainText"}static get requires(){return[Fk]}init(){const e=this.editor,t=e.model,i=e.editing.view,r=i.document,n=t.document.selection;let o=!1;i.addObserver(Vk),this.listenTo(r,"keydown",((e,t)=>{o=t.shiftKey})),e.plugins.get(Fk).on("contentInsertion",((e,i)=>{(o||function(e,t){if(e.childCount>1)return!1;const i=e.getChild(0);if(t.isObject(i))return!1;return 0==Array.from(i.getAttributeKeys()).length}(i.content,t.schema))&&t.change((e=>{const r=Array.from(n.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));n.isCollapsed||t.deleteContent(n,{doNotAutoparagraph:!0}),r.push(...n.getAttributes());const o=e.createRangeIn(i.content);for(const t of o.getItems())t.is("$textProxy")&&e.setAttributes(r,t)}))}))}}class iv extends xs{static get pluginName(){return"Clipboard"}static get requires(){return[Fk,Zk,tv]}}class rv extends Cs{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)||!nv(e.schema,i))do{if(i=i.parent,!i)return}while(!nv(e.schema,i));e.change((e=>{e.setSelection(i,"in")}))}}function nv(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const ov=bn("Ctrl+A");class sv extends xs{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new rv(e)),this.listenTo(t,"keydown",((t,i)=>{fn(i)===ov&&(e.execute("selectAll"),i.preventDefault())}))}}class av extends xs{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(t=>{const i=e.commands.get("selectAll"),r=new Ao(t),n=t.t;return r.set({label:n("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),r.bind("isEnabled").to(i,"isEnabled"),this.listenTo(r,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),r}))}}class cv extends xs{static get requires(){return[sv,av]}static get pluginName(){return"SelectAll"}}class lv extends Cs{constructor(e){super(e),this._stack=[],this._createdBatches=new WeakSet,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 r=this.editor.model,n=r.document,o=[],s=e.map((e=>e.getTransformedByOperations(i))),a=s.flat();for(const e of s){const t=e.filter((e=>e.root!=n.graveyard)).filter((e=>!uv(e,a)));t.length&&(dv(t),o.push(t[0]))}o.length&&r.change((e=>{e.setSelection(o,{backward:t})}))}_undo(e,t){const i=this.editor.model,r=i.document;this._createdBatches.add(t);const n=e.operations.slice().filter((e=>e.isDocumentOperation));n.reverse();for(const e of n){const n=e.baseVersion+1,o=Array.from(r.history.getOperations(n)),s=Ju([e.getReversed()],o,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let n of s){const o=n.affectedSelectable;o&&!i.canEditAt(o)&&(n=new ju(n.baseVersion)),t.addOperation(n),i.applyOperation(n),r.history.setOperationAsUndone(e,n)}}}}function dv(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}class hv extends lv{execute(e=null){const t=e?this._stack.findIndex((t=>t.batch==e)):this._stack.length-1,i=this._stack.splice(t,1)[0],r=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(r,(()=>{this._undo(i.batch,r);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,r),this.refresh()}}class mv extends lv{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,r=this.editor.model.document.history.getOperations(i);this._restoreSelection(e.selection.ranges,e.selection.isBackward,r),this._undo(e.batch,t)})),this.refresh()}}class gv extends xs{constructor(){super(...arguments),this._batchRegistry=new WeakSet}static get pluginName(){return"UndoEditing"}init(){const e=this.editor;this._undoCommand=new hv(e),this._redoCommand=new mv(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 r=i.batch,n=this._redoCommand.createdBatches.has(r),o=this._undoCommand.createdBatches.has(r);this._batchRegistry.has(r)||(this._batchRegistry.add(r),r.isUndoable&&(n?this._undoCommand.addBatch(r):o||(this._undoCommand.addBatch(r),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")}}const pv='',fv='';class bv extends xs{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,i=e.t,r="ltr"==t.uiLanguageDirection?pv:fv,n="ltr"==t.uiLanguageDirection?fv:pv;this._addButton("undo",i("Undo"),"CTRL+Z",r),this._addButton("redo",i("Redo"),"CTRL+Y",n)}_addButton(e,t,i,r){const n=this.editor;n.ui.componentFactory.add(e,(o=>{const s=n.commands.get(e),a=new Ao(o);return a.set({label:t,icon:r,keystroke:i,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",(()=>{n.execute(e),n.editing.view.focus()})),a}))}}class wv extends xs{static get requires(){return[gv,bv]}static get pluginName(){return"Undo"}}class kv extends xs{static get requires(){return[iv,rb,cv,ab,Df,wv]}static get pluginName(){return"Essentials"}}class vv extends Cs{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,r=t.document.selection,n=Array.from(r.getSelectedBlocks()),o=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(o){const t=n.filter((e=>_v(e)||xv(i,e)));this._applyQuote(e,t)}else this._removeQuote(e,n.filter(_v))}))}_getValue(){const e=En(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!_v(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=En(e.getSelectedBlocks());return!!i&&xv(t,i)}_removeQuote(e,t){yv(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=[];yv(e,t).reverse().forEach((t=>{let r=_v(t.start);r||(r=e.createElement("blockQuote"),e.wrap(t,r)),i.push(r)})),i.reverse().reduce(((t,i)=>t.nextSibling==i?(e.merge(e.createPositionAfter(t)),t):i))}}function _v(e){return"blockQuote"==e.parent.name?e.parent:null}function yv(e,t){let i,r=0;const n=[];for(;r{const r=e.model.document.differ.getChanges();for(const e of r)if("insert"==e.type){const r=e.position.nodeAfter;if(!r)continue;if(r.is("element","blockQuote")&&r.isEmpty)return i.remove(r),!0;if(r.is("element","blockQuote")&&!t.checkChild(e.position,r))return i.unwrap(r),!0;if(r.is("element")){const e=i.createRangeIn(r);for(const r of e.getItems())if(r.is("element","blockQuote")&&!t.checkChild(i.createPositionBefore(r),r))return i.unwrap(r),!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,r=e.model.document.selection,n=e.commands.get("blockQuote");this.listenTo(i,"enter",((t,i)=>{if(!r.isCollapsed||!n.value)return;r.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||!r.isCollapsed||!n.value)return;const o=r.getLastPosition().parent;o.isEmpty&&!o.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"})}}var Cv=i(1699),Ev={attributes:{"data-cke":!0}};Ev.setAttributes=Un(),Ev.insert=zn().bind(null,"head"),Ev.domAPI=Fn(),Ev.insertStyleElement=$n();Ln()(Cv.A,Ev);Cv.A&&Cv.A.locals&&Cv.A.locals;class Sv extends xs{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",(i=>{const r=e.commands.get("blockQuote"),n=new Ao(i);return n.set({label:t("Block quote"),icon:xm.quote,tooltip:!0,isToggleable:!0}),n.bind("isOn","isEnabled").to(r,"value","isEnabled"),this.listenTo(n,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),n}))}}class Tv extends xs{static get requires(){return[Av,Sv]}static get pluginName(){return"BlockQuote"}}function Pv(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 Iv(e,t,i){const r={};for(const n of e)if("class"===t){r[n[t].split(" ").shift()]=n[i]}else r[n[t]]=n[i];return r}function Mv(e){return e.data.match(/^(\s*)/)[0]}function Ov(e){const t=e.document.selection,i=[];if(t.isCollapsed)return[t.anchor];const r=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:t}of r){if(!t.is("$textProxy"))continue;const{parent:r,startOffset:n}=t.textNode;if(!r.is("element","codeBlock"))continue;const o=Mv(t.textNode),s=e.createPositionAt(r,n+o.length);i.push(s)}return i}function Nv(e){const t=En(e.getSelectedBlocks());return!!t&&t.is("element","codeBlock")}function Vv(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}class Bv extends Cs{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,r=i.document.selection,n=Pv(t)[0],o=Array.from(r.getSelectedBlocks()),s=null==e.forceValue?!this.value:e.forceValue,a=function(e,t,i){if(e.language)return e.language;if(e.usePreviousLanguageChoice&&t)return t;return i}(e,this._lastLanguage,n.language);i.change((e=>{s?this._applyCodeBlock(e,o,a):this._removeCodeBlock(e,o)}))}_getValue(){const e=En(this.editor.model.document.selection.getSelectedBlocks());return!!!(!e||!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=En(e.getSelectedBlocks());return!!i&&Vv(t,i)}_applyCodeBlock(e,t,i){this._lastLanguage=i;const r=this.editor.model.schema,n=t.filter((e=>Vv(r,e)));for(const t of n)e.rename(t,"codeBlock"),e.setAttribute("language",i,t),r.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter((e=>!r.checkChild(t,e))).forEach((t=>e.remove(t)));n.reverse().forEach(((t,i)=>{const r=n[i+1];t.previousSibling===r&&(e.appendElement("softBreak",r),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)),r=i.nodeAfter;e.rename(r,"paragraph"),e.removeAttribute("language",r),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}class Rv extends Cs{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=Ov(e);for(const r of i){const i=t.createText(this._indentSequence);e.insertContent(i,r)}}))}_checkEnabled(){return!!this._indentSequence&&Nv(this.editor.model.document.selection)}}class Lv extends Cs{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=Ov(e);for(const i of t){const t=Dv(e,i,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!Nv(e.document.selection)&&Ov(e).some((t=>Dv(e,t,this._indentSequence)))}}function Dv(e,t,i){const r=function(e){let t=e.parent.getChild(e.index);t&&!t.is("element","softBreak")||(t=e.nodeBefore);if(!t||t.is("element","softBreak"))return null;return t}(t);if(!r)return null;const n=Mv(r),o=n.lastIndexOf(i);if(o+i.length!==n.length)return null;if(-1===o)return null;const{parent:s,startOffset:a}=r;return e.createRange(e.createPositionAt(s,a+o),e.createPositionAt(s,a+o+i.length))}function Fv(e,t,i=!1){const r=Iv(t,"language","class"),n=Iv(t,"language","label");return(t,o,s)=>{const{writer:a,mapper:c,consumable:l}=s;if(!l.consume(o.item,"insert"))return;const d=o.item.getAttribute("language"),u=c.toViewPosition(e.createPositionBefore(o.item)),h={};i&&(h["data-language"]=n[d],h.spellcheck="false");const m=r[d]?{class:r[d]}:void 0,g=a.createContainerElement("code",m),p=a.createContainerElement("pre",h,g);a.insert(u,p),c.bindElements(o.item,g)}}const jv="paragraph";class zv extends xs{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[ab]}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:"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,r=e.editing.view,n=e.plugins.has("DocumentListEditing")?e.plugins.get("DocumentListEditing"):null,o=Pv(e);e.commands.add("codeBlock",new Bv(e)),e.commands.add("indentCodeBlock",new Rv(e)),e.commands.add("outdentCodeBlock",new Lv(e)),this.listenTo(r.document,"tab",((t,i)=>{const r=i.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(r).isEnabled&&(e.execute(r),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",isBlock:!0,allowAttributes:["language"]}),t.addAttributeCheck(((e,t)=>!!(e.endsWith("codeBlock")&&n&&n.getListAttributeNames().includes(t))||!e.endsWith("codeBlock $text")&&void 0)),e.model.schema.addChildCheck(((e,t)=>{if(e.endsWith("codeBlock")&&t.isObject)return!1})),e.editing.downcastDispatcher.on("insert:codeBlock",Fv(i,o,!0)),e.data.downcastDispatcher.on("insert:codeBlock",Fv(i,o)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,i,r)=>{if("codeBlock"!==i.item.parent.name)return;const{writer:n,mapper:o,consumable:s}=r;if(!s.consume(i.item,"insert"))return;const a=o.toViewPosition(e.createPositionBefore(i.item));n.insert(a,n.createText("\n"))}}(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const i=Iv(t,"class","language"),r=t[0].language;return(e,t,n)=>{const o=t.viewItem,s=o.parent;if(!s||!s.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:c}=n;if(!a.test(o,{name:!0}))return;const l=c.createElement("codeBlock"),d=[...o.getClassNames()];d.length||d.push("");for(const e of d){const t=i[e];if(t){c.setAttribute("language",t,l);break}}l.hasAttribute("language")||c.setAttribute("language",r,l),n.convertChildren(o,l),n.safeInsert(l,t.modelCursor)&&(a.consume(o,{name:!0}),n.updateConversionResult(l,t))}}(0,o)),e.data.upcastDispatcher.on("text",((e,t,{consumable:i,writer:r})=>{let n=t.modelCursor;if(!i.test(t.viewItem))return;if(!n.findAncestor("codeBlock"))return;i.consume(t.viewItem);const o=t.viewItem.data.split("\n").map((e=>r.createText(e))),s=o[o.length-1];for(const e of o)if(r.insert(e,n),n=n.getShiftedBy(e.offsetSize),e!==s){const e=r.createElement("softBreak");r.insert(e,n),n=r.createPositionAfter(e)}t.modelRange=r.createRange(t.modelCursor,n),t.modelCursor=n})),e.data.upcastDispatcher.on("element:pre",((e,t,{consumable:i})=>{const r=t.viewItem;if(r.findAncestor("pre"))return;const n=Array.from(r.getChildren()),o=n.find((e=>e.is("element","code")));if(o)for(const e of n)e!==o&&e.is("$text")&&i.consume(e,{name:!0})}),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,r)=>{let n=i.createRange(i.document.selection.anchor);if(r.targetRanges&&(n=e.editing.mapper.toModelRange(r.targetRanges[0])),!n.start.parent.is("element","codeBlock"))return;const o=r.dataTransfer.getData("text/plain"),s=new Wh(e.editing.view.document);r.content=function(e,t){const i=e.createDocumentFragment(),r=t.split("\n"),n=r.reduce(((t,i,n)=>(t.push(i),n{const n=r.anchor;!r.isCollapsed&&n.parent.is("element","codeBlock")&&n.hasSameParentAs(r.focus)&&i.change((i=>{const o=e.return;if(n.parent.is("element")&&(o.childCount>1||r.containsEntireContent(n.parent))){const t=i.createElement("codeBlock",n.parent.getAttributes());i.append(o,t);const r=i.createDocumentFragment();return i.append(t,r),void(e.return=r)}const s=o.getChild(0);t.checkAttribute(s,"code")&&i.setAttribute("code",!0,s)}))}))}afterInit(){const e=this.editor,t=e.commands,i=t.get("indent"),r=t.get("outdent");i&&i.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),r&&r.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,r=i.document,n=e.editing.view,o=r.selection.getLastPosition(),s=o.nodeAfter;if(t||!r.selection.isCollapsed||!o.isAtStart)return!1;if(!Uv(s))return!1;return e.model.change((t=>{e.execute("enter");const i=r.selection.anchor.parent.previousSibling;t.rename(i,jv),t.setSelection(i,"in"),e.model.schema.removeDisallowedAttributes([i],t),t.remove(s)})),n.scrollToTheSelection(),!0}(e,i.isSoft)||function(e,t){const i=e.model,r=i.document,n=e.editing.view,o=r.selection.getLastPosition(),s=o.nodeBefore;let a;if(t||!r.selection.isCollapsed||!o.isAtEnd||!s||!s.previousSibling)return!1;if(Uv(s)&&Uv(s.previousSibling))a=i.createRange(i.createPositionBefore(s.previousSibling),i.createPositionAfter(s));else if(Hv(s)&&Uv(s.previousSibling)&&Uv(s.previousSibling.previousSibling))a=i.createRange(i.createPositionBefore(s.previousSibling.previousSibling),i.createPositionAfter(s));else{if(!(Hv(s)&&Uv(s.previousSibling)&&Hv(s.previousSibling.previousSibling)&&s.previousSibling.previousSibling&&Uv(s.previousSibling.previousSibling.previousSibling)))return!1;a=i.createRange(i.createPositionBefore(s.previousSibling.previousSibling.previousSibling),i.createPositionAfter(s))}return e.model.change((t=>{t.remove(a),e.execute("enter");const i=r.selection.anchor.parent;t.rename(i,jv),e.model.schema.removeDisallowedAttributes([i],t)})),n.scrollToTheSelection(),!0}(e,i.isSoft)||function(e){const t=e.model,i=t.document,r=i.selection.getLastPosition(),n=r.nodeBefore||r.textNode;let o;n&&n.is("$text")&&(o=Mv(n));e.model.change((t=>{e.execute("shiftEnter"),o&&t.insertText(o,i.selection.anchor)}))}(e),i.preventDefault(),t.stop())}),{context:"pre"})}}function Hv(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function Uv(e){return e&&e.is("element","softBreak")}var Wv=i(2969),$v={attributes:{"data-cke":!0}};$v.setAttributes=Un(),$v.insert=zn().bind(null,"head"),$v.domAPI=Fn(),$v.insertStyleElement=$n();Ln()(Wv.A,$v);Wv.A&&Wv.A.locals&&Wv.A.locals;class qv extends xs{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,r=Pv(e);i.add("codeBlock",(i=>{const n=e.commands.get("codeBlock"),o=$m(i,jm),s=o.buttonView,a=t("Insert code block");return s.set({label:a,tooltip:!0,icon:'',isToggleable:!0}),s.bind("isOn").to(n,"value",(e=>!!e)),s.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()})),o.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),o.class="ck-code-block-dropdown",o.bind("isEnabled").to(n),Km(o,(()=>this._getLanguageListItemDefinitions(r)),{role:"menu",ariaLabel:a}),o}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new Cn;for(const r of e){const e={type:"button",model:new Ep({_codeBlockLanguage:r.language,label:r.label,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(t=>t===e.model._codeBlockLanguage)),i.add(e)}return i}}class Gv extends xs{static get requires(){return[zv,qv]}static get pluginName(){return"CodeBlock"}}class Kv extends Cs{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=En(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&Yv(t,e.schema)}execute(e={}){const t=this.editor.model,i=t.document,r=e.selection||i.selection;t.canEditAt(r)&&t.change((e=>{const i=r.getSelectedBlocks();for(const r of i)!r.is("element","paragraph")&&Yv(r,t.schema)&&e.rename(r,"paragraph")}))}}function Yv(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class Jv extends Cs{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,i=e.attributes;let r=e.position;t.canEditAt(r)&&t.change((e=>{if(r=this._findPositionToInsertParagraph(r,e),!r)return;const n=e.createElement("paragraph");i&&t.schema.setAllowedAttributes(n,i,e),t.insertContent(n,r),e.setSelection(n,"in")}))}_findPositionToInsertParagraph(e,t){const i=this.editor.model;if(i.schema.checkChild(e,"paragraph"))return e;const r=i.schema.findAllowedParent(e,"paragraph");if(!r)return null;const n=e.parent,o=i.schema.checkChild(n,"$text");return n.isEmpty||o&&e.isAtEnd?i.createPositionAfter(n):!n.isEmpty&&o&&e.isAtStart?i.createPositionBefore(n):t.split(e,r).position}}class Zv extends xs{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new Kv(e)),e.commands.add("insertParagraph",new Jv(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>Zv.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}Zv.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class Qv extends Cs{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=En(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>Xv(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,i=t.document,r=e.value;t.change((e=>{const n=Array.from(i.selection.getSelectedBlocks()).filter((e=>Xv(e,r,t.schema)));for(const t of n)t.is("element",r)||e.rename(t,r)}))}}function Xv(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const e_="paragraph";class t_ extends xs{static get pluginName(){return"HeadingEditing"}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[Zv]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const r of t)"paragraph"!==r.model&&(e.model.schema.register(r.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(r),i.push(r.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new Qv(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,r)=>{const n=e.model.document.selection.getFirstPosition().parent;i.some((e=>n.is("element",e.model)))&&!n.is("element",e_)&&0===n.childCount&&r.writer.rename(n,e_)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:k.low+1})}}var i_=i(2452),r_={attributes:{"data-cke":!0}};r_.setAttributes=Un(),r_.insert=zn().bind(null,"head"),r_.domAPI=Fn(),r_.insertStyleElement=$n();Ln()(i_.A,r_);i_.A&&i_.A.locals&&i_.A.locals;class n_ extends xs{static get pluginName(){return"HeadingUI"}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),r=t("Choose heading"),n=t("Heading");e.ui.componentFactory.add("heading",(t=>{const o={},s=new Cn,a=e.commands.get("heading"),c=e.commands.get("paragraph"),l=[a];for(const e of i){const t={type:"button",model:new Ep({label:e.title,class:e.class,role:"menuitemradio",withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(c,"value"),t.model.set("commandName","paragraph"),l.push(c)):(t.model.bind("isOn").to(a,"value",(t=>t===e.model)),t.model.set({commandName:"heading",commandValue:e.model})),s.add(t),o[e.model]=e.title}const d=$m(t);return Km(d,s,{ariaLabel:n,role:"menu"}),d.buttonView.set({ariaLabel:n,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:n}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some((e=>e)))),d.buttonView.bind("label").to(a,"value",c,"value",((e,t)=>{const i=e||t&&"paragraph";return"boolean"==typeof i?r:o[i]?o[i]:r})),this.listenTo(d,"execute",(t=>{const{commandName:i,commandValue:r}=t.source;e.execute(i,r?{value:r}:void 0),e.editing.view.focus()})),d}))}}class o_ extends xs{static get requires(){return[t_,n_]}static get pluginName(){return"Heading"}}class s_ extends Cs{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,r=Array.from(i.selection.getSelectedBlocks()).filter((e=>c_(e,t.schema))),n=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(n){let t=r[r.length-1].nextSibling,i=Number.POSITIVE_INFINITY,n=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=i;)o>n.getAttribute("listIndent")&&(o=n.getAttribute("listIndent")),n.getAttribute("listIndent")==o&&e[t?"unshift":"push"](n),n=n[t?"previousSibling":"nextSibling"]}}function c_(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class l_ extends Cs{constructor(e,t){super(e),this._indentBy="forward"==t?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document;let i=Array.from(t.selection.getSelectedBlocks());e.change((e=>{const t=i[i.length-1];let r=t.nextSibling;for(;r&&"listItem"==r.name&&r.getAttribute("listIndent")>t.getAttribute("listIndent");)i.push(r),r=r.nextSibling;this._indentBy<0&&(i=i.reverse());for(const t of i){const i=t.getAttribute("listIndent")+this._indentBy;i<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",i,t)}this.fire("_executeCleanup",i)}))}_checkEnabled(){const e=En(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("element","listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),i=e.getAttribute("listType");let r=e.previousSibling;for(;r&&r.is("element","listItem")&&r.getAttribute("listIndent")>=t;){if(r.getAttribute("listIndent")==t)return r.getAttribute("listType")==i;r=r.previousSibling}return!1}return!0}}function d_(e,t){const i=t.mapper,r=t.writer,n="numbered"==e.getAttribute("listType")?"ol":"ul",o=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=k_,t}(r),s=r.createContainerElement(n,null);return r.insert(r.createPositionAt(s,0),o),i.bindElements(e,o),o}function u_(e,t,i,r){const n=t.parent,o=i.mapper,s=i.writer;let a=o.toViewPosition(r.createPositionBefore(e));const c=g_(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),l=e.previousSibling;if(c&&c.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=o.toViewElement(c);a=s.breakContainer(s.createPositionAfter(e))}else if(l&&"listItem"==l.name){a=o.toViewPosition(r.createPositionAt(l,"end"));const e=o.findMappedViewAncestor(a),t=function(e){for(const t of e.getChildren())if("ul"==t.name||"ol"==t.name)return t;return null}(e);a=t?s.createPositionBefore(t):s.createPositionAt(e,"end")}else a=o.toViewPosition(r.createPositionBefore(e));if(a=m_(a),s.insert(a,n),l&&"listItem"==l.name){const e=o.toViewElement(l),i=s.createRange(s.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of i)if(e.item.is("element","li")){const r=s.breakContainer(s.createPositionBefore(e.item)),n=e.item.parent,o=s.createPositionAt(t,"end");h_(s,o.nodeBefore,o.nodeAfter),s.move(s.createRangeOn(n),o),i._position=r}}else{const i=n.nextSibling;if(i&&(i.is("element","ul")||i.is("element","ol"))){let r=null;for(const t of i.getChildren()){const i=o.toModelElement(t);if(!(i&&i.getAttribute("listIndent")>e.getAttribute("listIndent")))break;r=t}r&&(s.breakContainer(s.createPositionAfter(r)),s.move(s.createRangeOn(r.parent),s.createPositionAt(t,"end")))}}h_(s,n,n.nextSibling),h_(s,n.previousSibling,n)}function h_(e,t,i){return!t||!i||"ul"!=t.name&&"ol"!=t.name||t.name!=i.name||t.getAttribute("class")!==i.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function m_(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function g_(e,t){const i=!!t.sameIndent,r=!!t.smallerIndent,n=t.listIndent;let o=e;for(;o&&"listItem"==o.name;){const e=o.getAttribute("listIndent");if(i&&n==e||r&&n>e)return o;o="forward"===t.direction?o.nextSibling:o.previousSibling}return null}function p_(e,t,i,r){e.ui.componentFactory.add(t,(n=>{const o=e.commands.get(t),s=new Ao(n);return s.set({label:i,icon:r,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),s.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),s}))}function f_(e,t){const i=[],r=e.parent,n={ignoreElementEnd:!1,startPosition:e,shallow:!0,direction:t},o=r.getAttribute("listIndent"),s=[...new Jl(n)].filter((e=>e.item.is("element"))).map((e=>e.item));for(const e of s){if(!e.is("element","listItem"))break;if(e.getAttribute("listIndent")o)){if(e.getAttribute("listType")!==r.getAttribute("listType"))break;if(e.getAttribute("listStyle")!==r.getAttribute("listStyle"))break;if(e.getAttribute("listReversed")!==r.getAttribute("listReversed"))break;if(e.getAttribute("listStart")!==r.getAttribute("listStart"))break;"backward"===t?i.unshift(e):i.push(e)}}return i}const b_=["disc","circle","square"],w_=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function k_(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:Ga.call(this)}class v_ extends xs{static get pluginName(){return"ListUtils"}getListTypeFromListStyleType(e){return function(e){return b_.includes(e)?"bulleted":w_.includes(e)?"numbered":null}(e)}getSelectedListItems(e){return function(e){let t=[...e.document.selection.getSelectedBlocks()].filter((e=>e.is("element","listItem"))).map((t=>{const i=e.change((e=>e.createPositionAt(t,0)));return[...f_(i,"backward"),...f_(i,"forward")]})).flat();return t=[...new Set(t)],t}(e)}getSiblingNodes(e,t){return f_(e,t)}}function __(e){return(t,i,r)=>{const n=r.consumable;if(!n.test(i.item,"insert")||!n.test(i.item,"attribute:listType")||!n.test(i.item,"attribute:listIndent"))return;n.consume(i.item,"insert"),n.consume(i.item,"attribute:listType"),n.consume(i.item,"attribute:listIndent");const o=i.item;u_(o,d_(o,r),r,e)}}const y_=(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const r=i.mapper.toViewElement(t.item),n=i.writer;n.breakContainer(n.createPositionBefore(r)),n.breakContainer(n.createPositionAfter(r));const o=r.parent,s="numbered"==t.attributeNewValue?"ol":"ul";n.rename(s,o)},x_=(e,t,i)=>{i.consumable.consume(t.item,e.name);const r=i.mapper.toViewElement(t.item).parent,n=i.writer;h_(n,r,r.nextSibling),h_(n,r.previousSibling,r)};const A_=(e,t,i)=>{if(i.consumable.test(t.item,e.name)&&"listItem"!=t.item.name){let e=i.mapper.toViewPosition(t.range.start);const r=i.writer,n=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=r.breakContainer(e),"li"==e.parent.name);){const t=e,i=r.createPositionAt(e.parent,"end");if(!t.isEqual(i)){const e=r.remove(r.createRange(t,i));n.push(e)}e=r.createPositionAfter(e.parent)}if(n.length>0){for(let t=0;t0){const t=h_(r,i,i.nextSibling);t&&t.parent==i&&e.offset--}}h_(r,e.nodeBefore,e.nodeAfter)}}},C_=(e,t,i)=>{const r=i.mapper.toViewPosition(t.position),n=r.nodeBefore,o=r.nodeAfter;h_(i.writer,n,o)},E_=(e,t,i)=>{if(i.consumable.consume(t.viewItem,{name:!0})){const e=i.writer,r=e.createElement("listItem"),n=function(e){let t=0,i=e.parent;for(;i;){if(i.is("element","li"))t++;else{const e=i.previousSibling;e&&e.is("element","li")&&t++}i=i.parent}return t}(t.viewItem);e.setAttribute("listIndent",n,r);const o=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",o,r),!i.safeInsert(r,t.modelCursor))return;const s=function(e,t,i){const{writer:r,schema:n}=i;let o=r.createPositionAfter(e);for(const s of t)if("ul"==s.name||"ol"==s.name)o=i.convertItem(s,o).modelCursor;else{const t=i.convertItem(s,r.createPositionAt(e,"end")),a=t.modelRange.start.nodeAfter;a&&a.is("element")&&!n.checkChild(e,a.name)&&(e=t.modelCursor.parent.is("element","listItem")?t.modelCursor.parent:M_(t.modelCursor),o=r.createPositionAfter(e))}return o}(r,t.viewItem.getChildren(),i);t.modelRange=e.createRange(t.modelCursor,s),i.updateConversionResult(r,t)}},S_=(e,t,i)=>{if(i.consumable.test(t.viewItem,{name:!0})){const e=Array.from(t.viewItem.getChildren());for(const t of e){!(t.is("element","li")||N_(t))&&t._remove()}}},T_=(e,t,i)=>{if(i.consumable.test(t.viewItem,{name:!0})){if(0===t.viewItem.childCount)return;const e=[...t.viewItem.getChildren()];let i=!1;for(const t of e)i&&!N_(t)&&t._remove(),N_(t)&&(i=!0)}};function P_(e){return(t,i)=>{if(i.isPhantom)return;const r=i.modelPosition.nodeBefore;if(r&&r.is("element","listItem")){const t=i.mapper.toViewElement(r),n=t.getAncestors().find(N_),o=e.createPositionAt(t,0).getWalker();for(const e of o){if("elementStart"==e.type&&e.item.is("element","li")){i.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==n){i.viewPosition=e.nextPosition;break}}}}}const I_=function(e,[t,i]){const r=this;let n,o=t.is("documentFragment")?t.getChild(0):t;if(n=i?r.createSelection(i):r.document.selection,o&&o.is("element","listItem")){const e=n.getFirstPosition();let t=null;if(e.parent.is("element","listItem")?t=e.parent:e.nodeBefore&&e.nodeBefore.is("element","listItem")&&(t=e.nodeBefore),t){const e=t.getAttribute("listIndent");if(e>0)for(;o&&o.is("element","listItem");)o._setAttribute("listIndent",o.getAttribute("listIndent")+e),o=o.nextSibling}}};function M_(e){const t=new Jl({startPosition:e});let i;do{i=t.next()}while(!i.value.item.is("element","listItem"));return i.value.item}function O_(e,t,i,r,n,o){const s=g_(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e}),a=n.mapper,c=n.writer,l=s?s.getAttribute("listIndent"):null;let d;if(s)if(l==e){const e=a.toViewElement(s).parent;d=c.createPositionAfter(e)}else{const e=o.createPositionAt(s,"end");d=a.toViewPosition(e)}else d=i;d=m_(d);for(const e of[...r.getChildren()])N_(e)&&(d=c.move(c.createRangeOn(e),d).end,h_(c,e,e.nextSibling),h_(c,e.previousSibling,e))}function N_(e){return e.is("element","ol")||e.is("element","ul")}var V_=i(7894),B_={attributes:{"data-cke":!0}};B_.setAttributes=Un(),B_.insert=zn().bind(null,"head"),B_.domAPI=Fn(),B_.insertStyleElement=$n();Ln()(V_.A,B_);V_.A&&V_.A.locals&&V_.A.locals;class R_ extends xs{static get pluginName(){return"ListEditing"}static get requires(){return[rb,Lf,v_]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,i=e.editing;var r;e.model.document.registerPostFixer((t=>function(e,t){const i=e.document.differ.getChanges(),r=new Map;let n=!1;for(const r of i)if("insert"==r.type&&"listItem"==r.name)o(r.position);else if("insert"==r.type&&"listItem"!=r.name){if("$text"!=r.name){const i=r.position.nodeAfter;i.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",i),n=!0),i.hasAttribute("listType")&&(t.removeAttribute("listType",i),n=!0),i.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",i),n=!0),i.hasAttribute("listReversed")&&(t.removeAttribute("listReversed",i),n=!0),i.hasAttribute("listStart")&&(t.removeAttribute("listStart",i),n=!0);for(const t of Array.from(e.createRangeIn(i)).filter((e=>e.item.is("element","listItem"))))o(t.previousPosition)}o(r.position.getShiftedBy(r.length))}else"remove"==r.type&&"listItem"==r.name?o(r.position):("attribute"==r.type&&"listIndent"==r.attributeKey||"attribute"==r.type&&"listType"==r.attributeKey)&&o(r.range.start);for(const e of r.values())s(e),a(e);return n;function o(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(r.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,r.has(e))return;r.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&r.set(t,t)}}function s(e){let i=0,r=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(o>i){let s;null===r?(r=o-i,s=i):(r>o&&(r=o),s=o-r),t.setAttribute("listIndent",s,e),n=!0}else r=null,i=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let i=[],r=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(r&&r.getAttribute("listIndent")>o&&(i=i.slice(0,o+1)),0!=o)if(i[o]){const r=i[o];e.getAttribute("listType")!=r&&(t.setAttribute("listType",r,e),n=!0)}else i[o]=e.getAttribute("listType");r=e,e=e.nextSibling}}}(e.model,t))),i.mapper.registerViewToModelLength("li",L_),t.mapper.registerViewToModelLength("li",L_),i.mapper.on("modelToViewPosition",P_(i.view)),i.mapper.on("viewToModelPosition",(r=e.model,(e,t)=>{const i=t.viewPosition,n=i.parent,o=t.mapper;if("ul"==n.name||"ol"==n.name){if(i.isAtEnd){const e=o.toModelElement(i.nodeBefore),n=o.getModelLength(i.nodeBefore);t.modelPosition=r.createPositionBefore(e).getShiftedBy(n)}else{const e=o.toModelElement(i.nodeAfter);t.modelPosition=r.createPositionBefore(e)}e.stop()}else if("li"==n.name&&i.nodeBefore&&("ul"==i.nodeBefore.name||"ol"==i.nodeBefore.name)){const s=o.toModelElement(n);let a=1,c=i.nodeBefore;for(;c&&N_(c);)a+=o.getModelLength(c),c=c.previousSibling;t.modelPosition=r.createPositionBefore(s).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",P_(i.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",A_,{priority:"high"}),t.on("insert:listItem",__(e.model)),t.on("attribute:listType:listItem",y_,{priority:"high"}),t.on("attribute:listType:listItem",x_,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,i,r)=>{if(!r.consumable.consume(i.item,"attribute:listIndent"))return;const n=r.mapper.toViewElement(i.item),o=r.writer;o.breakContainer(o.createPositionBefore(n)),o.breakContainer(o.createPositionAfter(n));const s=n.parent,a=s.previousSibling,c=o.createRangeOn(s);o.remove(c),a&&a.nextSibling&&h_(o,a,a.nextSibling),O_(i.attributeOldValue+1,i.range.start,c.start,n,r,e),u_(i.item,n,r,e);for(const e of i.item.getChildren())r.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,i,r)=>{const n=r.mapper.toViewPosition(i.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,o=r.writer;o.breakContainer(o.createPositionBefore(n)),o.breakContainer(o.createPositionAfter(n));const s=n.parent,a=s.previousSibling,c=o.createRangeOn(s),l=o.remove(c);a&&a.nextSibling&&h_(o,a,a.nextSibling),O_(r.mapper.toModelElement(n).getAttribute("listIndent")+1,i.position,c.start,n,r,e);for(const e of o.createRangeIn(l).getItems())r.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",C_,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",A_,{priority:"high"}),t.on("insert:listItem",__(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",S_,{priority:"high"}),e.on("element:ol",S_,{priority:"high"}),e.on("element:li",T_,{priority:"high"}),e.on("element:li",E_)})),e.model.on("insertContent",I_,{priority:"high"}),e.commands.add("numberedList",new s_(e,"numbered")),e.commands.add("bulletedList",new s_(e,"bulleted")),e.commands.add("indentList",new l_(e,"forward")),e.commands.add("outdentList",new l_(e,"backward"));const n=i.view.document;this.listenTo(n,"enter",((e,t)=>{const i=this.editor.model.document,r=i.selection.getLastPosition().parent;i.selection.isCollapsed&&"listItem"==r.name&&r.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(n,"delete",((e,t)=>{if("backward"!==t.direction)return;const i=this.editor.model.document.selection;if(!i.isCollapsed)return;const r=i.getFirstPosition();if(!r.isAtStart)return;const n=r.parent;if("listItem"!==n.name)return;n.previousSibling&&"listItem"===n.previousSibling.name||(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(e.editing.view.document,"tab",((t,i)=>{const r=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(r).isEnabled&&(e.execute(r),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"li"})}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),i&&i.registerChildCommand(e.get("outdentList"))}}function L_(e){let t=1;for(const i of e.getChildren())if("ul"==i.name||"ol"==i.name)for(const e of i.getChildren())t+=L_(e);return t}class D_ extends xs{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;p_(this.editor,"numberedList",e("Numbered List"),''),p_(this.editor,"bulletedList",e("Bulleted List"),'')}}class F_ extends xs{static get requires(){return[R_,D_]}static get pluginName(){return"List"}}function j_(e,t){return`${e}:${t=t||_n(e)}`}class z_ extends Cs{refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"language")}execute({languageCode:e,textDirection:t}={}){const i=this.editor.model,r=i.document.selection,n=!!e&&j_(e,t);i.change((e=>{if(r.isCollapsed)n?e.setSelectionAttribute("language",n):e.removeSelectionAttribute("language");else{const t=i.schema.getValidRanges(r.getRanges(),"language");for(const i of t)n?e.setAttribute("language",n,i):e.removeAttribute("language",i)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.getAttribute("language")||!1;for(const e of i.getRanges())for(const i of e.getItems())if(t.checkAttribute(i,"language"))return i.getAttribute("language")||!1;return!1}}class H_ extends xs{static get pluginName(){return"TextPartLanguageEditing"}constructor(e){super(e),e.config.define("language",{textPartLanguage:[{title:"Arabic",languageCode:"ar"},{title:"French",languageCode:"fr"},{title:"Spanish",languageCode:"es"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"language"}),e.model.schema.setAttributeProperties("language",{copyOnEnter:!0}),this._defineConverters(),e.commands.add("textPartLanguage",new z_(e))}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToAttribute({model:{key:"language",value:e=>j_(e.getAttribute("lang"),e.getAttribute("dir"))},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),e.for("downcast").attributeToElement({model:"language",view:(e,{writer:t},i)=>{if(!e)return;if(!i.item.is("$textProxy")&&!i.item.is("documentSelection"))return;const{languageCode:r,textDirection:n}=function(e){const[t,i]=e.split(":");return{languageCode:t,textDirection:i}}(e);return t.createAttributeElement("span",{lang:r,dir:n})}})}}class U_ extends xs{static get pluginName(){return"TextPartLanguageUI"}init(){const e=this.editor,t=e.t,i=e.config.get("language.textPartLanguage"),r=t("Choose language"),n=t("Remove language"),o=t("Language");e.ui.componentFactory.add("textPartLanguage",(t=>{const s=new Cn,a={},c=e.commands.get("textPartLanguage");s.add({type:"button",model:new Ep({label:n,languageCode:!1,withText:!0})}),s.add({type:"separator"});for(const e of i){const t={type:"button",model:new Ep({label:e.title,languageCode:e.languageCode,role:"menuitemradio",textDirection:e.textDirection,withText:!0})},i=j_(e.languageCode,e.textDirection);t.model.bind("isOn").to(c,"value",(e=>e===i)),s.add(t),a[i]=e.title}const l=$m(t);return Km(l,s,{ariaLabel:o,role:"menu"}),l.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),l.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),l.bind("isEnabled").to(c,"isEnabled"),l.buttonView.bind("label").to(c,"value",(e=>e&&a[e]||r)),this.listenTo(l,"execute",(t=>{c.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()})),l}))}}class W_ extends xs{static get requires(){return[H_,U_]}static get pluginName(){return"TextPartLanguage"}}class $_ extends Cs{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 r of t.document.roots)r.hasClass(e)?(i.removeClass(e,r),this.value=!1):(i.addClass(e,r),this.value=!0)}))}}class q_ extends xs{static get pluginName(){return"ShowBlocksEditing"}init(){const{editor:e}=this;e.commands.add("showBlocks",new $_(e))}}var G_=i(2501),K_={attributes:{"data-cke":!0}};K_.setAttributes=Un(),K_.insert=zn().bind(null,"head"),K_.domAPI=Fn(),K_.insertStyleElement=$n();Ln()(G_.A,K_);G_.A&&G_.A.locals&&G_.A.locals;class Y_ extends xs{static get pluginName(){return"ShowBlocksUI"}init(){const e=this.editor;e.ui.componentFactory.add("showBlocks",(t=>{const i=e.commands.get("showBlocks"),r=new Ao(t),n=t.t;return r.set({label:n("Show blocks"),icon:'',tooltip:!0}),r.bind("isOn").to(i,"value",i,"isEnabled",((e,t)=>e&&t)),r.bind("isEnabled").to(i),this.listenTo(r,"execute",(()=>{e.execute("showBlocks"),e.editing.view.focus()})),r}))}}class J_ extends xs{static get pluginName(){return"ShowBlocks"}static get requires(){return[q_,Y_]}}class Z_ extends Cs{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,r=e.value,n=e.batch,o=e=>{if(i.isCollapsed)r?e.setSelectionAttribute(this.attributeKey,r):e.removeSelectionAttribute(this.attributeKey);else{const n=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of n)r?e.setAttribute(this.attributeKey,r,t):e.removeAttribute(this.attributeKey,t)}};n?t.enqueueChange(n,(e=>{o(e)})):t.change((e=>{o(e)}))}}const Q_="fontSize",X_="fontFamily",ey="fontColor",ty="fontBackgroundColor";function iy(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 ry(e){return t=>t.getStyle(e).replace(/\s/g,"")}function ny(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class oy extends Z_{constructor(e){super(e,X_)}}function sy(e){return e.map(ay).filter((e=>void 0!==e))}function ay(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=e.replace(/"|'/g,"").split(","),i=t[0],r=t.map(cy).join(", ");return{title:i,model:r,view:{name:"span",styles:{"font-family":r},priority:7}}}(e):void 0}function cy(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class ly extends xs{static get pluginName(){return"FontFamilyEditing"}constructor(e){super(e),e.config.define(X_,{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:X_}),e.model.schema.setAttributeProperties(X_,{isFormatting:!0,copyOnEnter:!0});const t=sy(e.config.get("fontFamily.options")).filter((e=>e.model)),i=iy(X_,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(X_,new oy(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:X_,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:X_,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:X_,value:e=>e.getAttribute("face")}})}}class dy extends xs{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),r=e.commands.get(X_),n=t("Font Family");e.ui.componentFactory.add(X_,(t=>{const o=$m(t);return Km(o,(()=>function(e,t){const i=new Cn;for(const r of e){const e={type:"button",model:new Ep({commandName:X_,commandParam:r.model,label:r.title,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(e=>e===r.model||!(!e||!r.model)&&e.split(",")[0].replace(/'/g,"").toLowerCase()===r.model.toLowerCase())),r.view&&"string"!=typeof r.view&&r.view.styles&&e.model.set("labelStyle",`font-family: ${r.view.styles["font-family"]}`),i.add(e)}return i}(i,r)),{role:"menu",ariaLabel:n}),o.buttonView.set({label:n,icon:'',tooltip:!0}),o.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),o.bind("isEnabled").to(r),this.listenTo(o,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),o}))}_getLocalizedOptions(){const e=this.editor,t=e.t;return sy(e.config.get(X_).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class uy extends xs{static get requires(){return[ly,dy]}static get pluginName(){return"FontFamily"}}class hy extends Z_{constructor(e){super(e,Q_)}}function my(e){return e.map((e=>function(e){"number"==typeof e&&(e=String(e));if("object"==typeof e&&(t=e,t.title&&t.model&&t.view))return py(e);var t;const i=function(e){return"string"==typeof e?gy[e]:gy[e.model]}(e);if(i)return py(i);if("default"===e)return{model:void 0,title:"Default"};if(function(e){let t;if("object"==typeof e){if(!e.model)throw new _("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}(e))return;return function(e){"string"==typeof e&&(e={title:e,model:`${parseFloat(e)}px`});return e.view={name:"span",styles:{"font-size":e.model}},py(e)}(e)}(e))).filter((e=>void 0!==e))}const gy={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 py(e){return e.view&&"string"!=typeof e.view&&!e.view.priority&&(e.view.priority=7),e}const fy=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class by extends xs{static get pluginName(){return"FontSizeEditing"}constructor(e){super(e),e.config.define(Q_,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Q_}),e.model.schema.setAttributeProperties(Q_,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=my(this.editor.config.get("fontSize.options")).filter((e=>e.model)),r=iy(Q_,i);t?(this._prepareAnyValueConverters(r),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(r),e.commands.add(Q_,new hy(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter((e=>{return!(t=String(e),Xh.test(t)||function(e){return em.test(e)}(String(e)));var t}));if(i.length)throw new _("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:Q_,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:Q_,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:Q_,value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let r=parseInt(t,10);i&&(r=3+r);const n=fy.length-1,o=Math.min(Math.max(r,0),n);return fy[o]}}})}}var wy=i(5195),ky={attributes:{"data-cke":!0}};ky.setAttributes=Un(),ky.insert=zn().bind(null,"head"),ky.domAPI=Fn(),ky.insertStyleElement=$n();Ln()(wy.A,ky);wy.A&&wy.A.locals&&wy.A.locals;class vy extends xs{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),r=e.commands.get(Q_),n=t("Font Size");e.ui.componentFactory.add(Q_,(t=>{const o=$m(t);return Km(o,(()=>function(e,t){const i=new Cn;for(const r of e){const e={type:"button",model:new Ep({commandName:Q_,commandParam:r.model,label:r.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};r.view&&"string"!=typeof r.view&&(r.view.styles&&e.model.set("labelStyle",`font-size:${r.view.styles["font-size"]}`),r.view.classes&&e.model.set("class",`${e.model.class} ${r.view.classes}`)),e.model.bind("isOn").to(t,"value",(e=>e===r.model)),i.add(e)}return i}(i,r)),{role:"menu",ariaLabel:n}),o.buttonView.set({label:n,icon:'',tooltip:!0}),o.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),o.bind("isEnabled").to(r),this.listenTo(o,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),o}))}_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 my(e.config.get(Q_).options).map((e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class _y extends xs{static get requires(){return[by,vy]}static get pluginName(){return"FontSize"}normalizeSizeOptions(e){return my(e)}}class yy extends Z_{constructor(e){super(e,ey)}}class xy extends xs{static get pluginName(){return"FontColorEditing"}constructor(e){super(e),e.config.define(ey,{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:ey,value:ry("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:ey,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:ey,view:ny("color")}),e.commands.add(ey,new yy(e)),e.model.schema.extend("$text",{allowAttributes:ey}),e.model.schema.setAttributeProperties(ey,{isFormatting:!0,copyOnEnter:!0})}}class Ay extends xs{constructor(e,{commandName:t,componentName:i,icon:r,dropdownLabel:n}){super(e),this.commandName=t,this.componentName=i,this.icon=r,this.dropdownLabel=n,this.columns=e.config.get(`${this.componentName}.columns`),this.colorSelectorView=void 0}init(){const e=this.editor,t=e.locale,i=t.t,r=e.commands.get(this.commandName),n=e.config.get(this.componentName),o=function(e){return e.map(To).filter((e=>!!e))}(n.colors),s=function(e,t){const i=e.t,r={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=r[e.label];return t&&t!=e.label&&(e.label=t),e}))}(t,o),a=n.documentColors,c=!1!==n.colorPicker;e.ui.componentFactory.add(this.componentName,(t=>{const o=$m(t);let l=!1;return this.colorSelectorView=function({dropdownView:e,colors:t,columns:i,removeButtonLabel:r,colorPickerLabel:n,documentColorsLabel:o,documentColorsCount:s,colorPickerViewConfig:a}){const c=e.locale,l=new zg(c,{colors:t,columns:i,removeButtonLabel:r,colorPickerLabel:n,documentColorsLabel:o,documentColorsCount:s,colorPickerViewConfig:a});return e.colorSelectorView=l,e.panelView.children.add(l),l}({dropdownView:o,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!==a?i("Document colors"):"",documentColorsCount:void 0===a?this.columns:a,colorPickerViewConfig:!!c&&(n.colorPicker||{})}),this.colorSelectorView.bind("selectedColor").to(r,"value"),o.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),o.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),o.bind("isEnabled").to(r),this.colorSelectorView.on("execute",((t,i)=>{o.isOpen&&e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),"colorPicker"!==i.source&&e.editing.view.focus(),"colorPickerSaveButton"===i.source&&(o.isOpen=!1)})),this.colorSelectorView.on("colorPicker:show",(()=>{this._undoStepBatch=e.model.createBatch()})),this.colorSelectorView.on("colorPicker:cancel",(()=>{this._undoStepBatch.operations.length&&(o.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()})),o.on("change:isOpen",((t,i,r)=>{l||(l=!0,o.colorSelectorView.appendUI()),r&&(0!==a&&this.colorSelectorView.updateDocumentColors(e.model,this.componentName),this.colorSelectorView.updateSelectedColors(),this.colorSelectorView.showColorGridsFragment())})),Jm(o,(()=>o.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find((e=>e.isOn)))),o}))}}class Cy extends Ay{constructor(e){const t=e.locale.t;super(e,{commandName:ey,componentName:ey,icon:'',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class Ey extends xs{static get requires(){return[xy,Cy]}static get pluginName(){return"FontColor"}}class Sy extends Z_{constructor(e){super(e,ty)}}class Ty extends xs{static get pluginName(){return"FontBackgroundColorEditing"}constructor(e){super(e),e.config.define(ty,{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(hm),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:ty,value:ry("background-color")}}),e.conversion.for("downcast").attributeToElement({model:ty,view:ny("background-color")}),e.commands.add(ty,new Sy(e)),e.model.schema.extend("$text",{allowAttributes:ty}),e.model.schema.setAttributeProperties(ty,{isFormatting:!0,copyOnEnter:!0})}}class Py extends Ay{constructor(e){const t=e.locale.t;super(e,{commandName:ty,componentName:ty,icon:'',dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class Iy extends xs{static get requires(){return[Ty,Py]}static get pluginName(){return"FontBackgroundColor"}}class My extends xs{static get requires(){return[uy,_y,Ey,Iy]}static get pluginName(){return"Font"}}function Oy(e,t){if(!e.childCount)return;const i=new Wh(e.document),r=function(e,t){const i=t.createRangeIn(e),r=new $s({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),n=[];for(const e of i)if("elementStart"===e.type&&r.match(e.item)){const t=By(e.item);n.push({element:e.item,id:t.id,order:t.order,indent:t.indent})}return n}(e,i);if(!r.length)return;let n=null,o=1;r.forEach(((e,s)=>{const a=function(e,t){if(!e)return!0;if(e.id!==t.id)return t.indent-e.indent!=1;const i=t.element.previousSibling;if(!i)return!0;return r=i,!(r.is("element","ol")||r.is("element","ul"));var r}(r[s-1],e),c=a?null:r[s-1],l=(u=e,(d=c)?u.indent-d.indent:u.indent-1);var d,u;if(a&&(n=null,o=1),!n||0!==l){const r=function(e,t){const i=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),r=/mso-level-number-format:([^;]{0,100});/gi,n=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,o=i.exec(t);let s="decimal",a="ol",c=null;if(o&&o[1]){const t=r.exec(o[1]);if(t&&t[1]&&(s=t[1].trim(),a="bullet"!==s&&"image"!==s?"ol":"ul"),"bullet"===s){const t=function(e){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;if("o"===i)return"circle";if("·"===i)return"disc";if("§"===i)return"square";return null}(e.element);t&&(s=t)}else{const e=n.exec(o[1]);e&&e[1]&&(c=parseInt(e[1]))}}return{type:a,startIndex:c,style:Ny(s)}}(e,t);if(n){if(e.indent>o){const e=n.getChild(n.childCount-1),t=e.getChild(e.childCount-1);n=Vy(r,t,i),o+=1}else if(e.indent1&&i.setAttribute("start",e.startIndex,n),n}function By(e){const t={},i=e.getStyle("mso-list");if(i){const e=i.match(/(^|\s{1,100})l(\d+)/i),r=i.match(/\s{0,100}lfo(\d+)/i),n=i.match(/\s{0,100}level(\d+)/i);e&&r&&n&&(t.id=e[2],t.order=r[1],t.indent=parseInt(n[1]))}return t}function Ry(e,t){if(!e.childCount)return;const i=new Wh(e.document),r=function(e,t){const i=t.createRangeIn(e),r=new $s({name:/v:(.+)/}),n=[];for(const e of i){if("elementStart"!=e.type)continue;const t=e.item,i=t.previousSibling,o=i&&i.is("element")?i.name:null;r.match(t)&&t.getAttribute("o:gfxdata")&&"v:shapetype"!==o&&n.push(e.item.getAttribute("id"))}return n}(e,i);!function(e,t,i){const r=i.createRangeIn(t),n=new $s({name:"img"}),o=[];for(const t of r)if(t.item.is("element")&&n.match(t.item)){const i=t.item,r=i.getAttribute("v:shapes")?i.getAttribute("v:shapes").split(" "):[];r.length&&r.every((t=>e.indexOf(t)>-1))?o.push(i):i.getAttribute("src")||o.push(i)}for(const e of o)i.remove(e)}(r,e,i),function(e,t,i){const r=i.createRangeIn(t),n=[];for(const t of r)if("elementStart"==t.type&&t.item.is("element","v:shape")){const i=t.item.getAttribute("id");if(e.includes(i))continue;o(t.item.parent.getChildren(),i)||n.push(t.item)}for(const e of n){const t={src:s(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const r=i.createElement("img",t);i.insertChild(e.index+1,r,e.parent)}function o(e,t){for(const i of e)if(i.is("element")){if("img"==i.name&&i.getAttribute("v:shapes")==t)return!0;if(o(i.getChildren(),t))return!0}return!1}function s(e){for(const t of e.getChildren())if(t.is("element")&&t.getAttribute("src"))return t.getAttribute("src")}}(r,e,i),function(e,t){const i=t.createRangeIn(e),r=new $s({name:/v:(.+)/}),n=[];for(const e of i)"elementStart"==e.type&&r.match(e.item)&&n.push(e.item);for(const e of n)t.remove(e)}(e,i);const n=function(e,t){const i=t.createRangeIn(e),r=new $s({name:"img"}),n=[];for(const e of i)e.item.is("element")&&r.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&n.push(e.item);return n}(e,i);n.length&&function(e,t,i){if(e.length===t.length)for(let r=0;rString.fromCharCode(parseInt(e,16)))).join(""))}const Dy=//i,Fy=/xmlns:o="urn:schemas-microsoft-com/i;class jy{constructor(e){this.document=e}isActive(e){return Dy.test(e)||Fy.test(e)}execute(e){const{body:t,stylesString:i}=e._parsedData;Oy(t,i),Ry(t,e.dataTransfer.getData("text/rtf")),function(e){const t=[],i=new Wh(e.document);for(const{item:r}of i.createRangeIn(e))if(r.is("element")){for(const e of r.getClassNames())/\bmso/gi.exec(e)&&i.removeClass(e,r);for(const e of r.getStyleNames())/\bmso/gi.exec(e)&&i.removeStyle(e,r);r.is("element","w:sdt")&&t.push(r)}for(const e of t){const t=e.parent,r=t.getChildIndex(e);i.insertChild(r,e.getChildren(),t),i.remove(e)}}(t),e.content=t}}function zy(e,t,i,{blockElements:r,inlineObjectElements:n}){let o=i.createPositionAt(e,"forward"==t?"after":"before");return o=o.getLastMatchingPosition((({item:e})=>e.is("element")&&!r.includes(e.name)&&!n.includes(e.name)),{direction:t}),"forward"==t?o.nodeAfter:o.nodeBefore}function Hy(e,t){return!!e&&e.is("element")&&t.includes(e.name)}const Uy=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class Wy{constructor(e){this.document=e}isActive(e){return Uy.test(e)}execute(e){const t=new Wh(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 r=e.getChildIndex(i);t.remove(i),t.insertChild(r,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 dc(t.document.stylesProcessor),r=new el(i,{renderingMode:"data"}),n=r.blockElements,o=r.inlineObjectElements,s=[];for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","br")){const i=zy(e,"forward",t,{blockElements:n,inlineObjectElements:o}),r=zy(e,"backward",t,{blockElements:n,inlineObjectElements:o}),a=Hy(i,n);(Hy(r,n)||a)&&s.push(e)}}for(const e of s)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(i,t),e.content=i}}const $y=/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length)))}function Ky(e,t){const i=new DOMParser,r=function(e){return Gy(Gy(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="",r=e.indexOf(t);if(r<0)return e;const n=e.indexOf(i,r+t.length);return e.substring(0,r+t.length)+(n>=0?e.substring(n):"")}(e=(e=e.replace(//g,"")}(r.getData("text/html")):r.getData("text/plain")&&(((o=(o=r.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("

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

${o}

`),e=o),n=this.editor.data.htmlProcessor.toView(e)}var o;const s=new f(this,"inputTransformation");this.fire(s,{content:n,dataTransfer:r,targetRanges:t.targetRanges,method:t.method}),s.stop.called&&e.stop(),i.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,i)=>{if(i.content.isEmpty)return;const r=this.editor.data.toModel(i.content,"$clipboardHolder");0!=r.childCount&&(e.stop(),t.change((()=>{this.fire("contentInsertion",{content:r,method:i.method,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,i)=>{i.resultRange=t.insertContent(i.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,r=(e,i)=>{const r=i.dataTransfer;i.preventDefault(),this._fireOutputTransformationEvent(r,t.selection,e.name)};this.listenTo(i,"copy",r,{priority:"low"}),this.listenTo(i,"cut",((t,i)=>{e.model.canEditAt(e.model.document.selection)?r(t,i):i.preventDefault()}),{priority:"low"}),this.listenTo(this,"outputTransformation",((t,r)=>{const n=e.data.toView(r.content);i.fire("clipboardOutput",{dataTransfer:r.dataTransfer,content:n,method:r.method})}),{priority:"low"}),this.listenTo(i,"clipboardOutput",((i,r)=>{r.content.isEmpty||(r.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(r.content)),r.dataTransfer.setData("text/plain",Lk(r.content))),"cut"==r.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}const jk=qr("px");class zk extends Kn{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=>jk(e))),top:e.to("top",(e=>jk(e))),width:e.to("width",(e=>jk(e)))}}})}}class Hk extends xs{constructor(){super(...arguments),this.removeDropMarkerDelayed=In((()=>this.removeDropMarker()),40),this._updateDropMarkerThrottled=rp((e=>this._updateDropMarker(e)),40),this._reconvertMarkerThrottled=rp((()=>{this.editor.model.markers.has("drop-target")&&this.editor.editing.reconvertMarker("drop-target")}),0),this._dropTargetLineView=new zk,this._domEmitter=new(Pr()),this._scrollables=new Map}static get pluginName(){return"DragDropTarget"}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,r,n,o){this.removeDropMarkerDelayed.cancel();const s=Uk(this.editor,e,t,i,r,n,o);if(s)return o&&o.containsRange(s)?this.removeDropMarker():void this._updateDropMarkerThrottled(s)}getFinalDropRange(e,t,i,r,n,o){const s=Uk(this.editor,e,t,i,r,n,o);return this.removeDropMarker(),s}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,r=e.start.nodeAfter,n=e.start.parent,o=i?t.mapper.toViewElement(i):null,s=o?t.view.domConverter.mapViewToDom(o):null,a=r?t.mapper.toViewElement(r):null,c=a?t.view.domConverter.mapViewToDom(a):null,l=t.mapper.toViewElement(n),d=t.view.domConverter.mapViewToDom(l),u=this._getScrollableRect(l),{scrollX:h,scrollY:m}=Nr.window,g=s?new Fr(s):null,p=c?new Fr(c):null,f=new Fr(d).excludeScrollbarsAndBorders(),b=g?g.bottom:f.top,w=p?p.top:f.bottom,k=Nr.window.getComputedStyle(d),v=b<=w?(b+w)/2:w;if(u.topa.schema.checkChild(o,e)))){if(a.schema.checkChild(o,"$text"))return a.createRange(o);if(t)return $k(e,Gk(e,t.parent),r,n)}}}else if(a.schema.isInline(l))return $k(e,l,r,n);if(a.schema.isBlock(l))return $k(e,l,r,n);if(a.schema.checkChild(l,"$block")){const t=Array.from(l.getChildren()).filter((t=>t.is("element")&&!Wk(e,t)));let i=0,o=t.length;if(0==o)return a.createRange(a.createPositionAt(l,"end"));for(;i{i?(this.forceDisabled("readOnlyMode"),this._isBlockDragging=!1):this.clearForceDisabled("readOnlyMode")})),l.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(Nr.document,"dragover",((e,t)=>this._handleBlockDragging(t))),this._domEmitter.listenTo(Nr.document,"drop",((e,t)=>this._handleBlockDragging(t))),this._domEmitter.listenTo(Nr.document,"dragend",(()=>this._handleBlockDragEnd()),{useCapture:!0}),this.isEnabled&&t.setAttribute("draggable","true"),this.on("change:isEnabled",((e,i,r)=>{t.setAttribute("draggable",r?"true":"false")}))}}destroy(){return this._domEmitter.stopListening(),super.destroy()}_handleBlockDragStart(e){if(!this.isEnabled)return;const t=this.editor.model,i=t.document.selection,r=this.editor.editing.view,n=Array.from(i.getSelectedBlocks()),o=t.createRange(t.createPositionBefore(n[0]),t.createPositionAfter(n[n.length-1]));t.change((e=>e.setSelection(o))),this._isBlockDragging=!0,r.focus(),r.getObserver(Vk).onDomEvent(e)}_handleBlockDragging(e){if(!this.isEnabled||!this._isBlockDragging)return;const t=e.clientX+("ltr"==this.editor.locale.contentLanguageDirection?100:-100),i=e.clientY,r=document.elementFromPoint(t,i),n=this.editor.editing.view;r&&r.closest(".ck-editor__editable")&&n.getObserver(Vk).onDomEvent({...e,type:e.type,dataTransfer:e.dataTransfer,target:r,clientX:t,clientY:i,preventDefault:()=>e.preventDefault(),stopPropagation:()=>e.stopPropagation()})}_handleBlockDragEnd(){this._isBlockDragging=!1}}var Yk=i(72),Jk={attributes:{"data-cke":!0}};Jk.setAttributes=Un(),Jk.insert=zn().bind(null,"head"),Jk.domAPI=Fn(),Jk.insertStyleElement=$n();Ln()(Yk.A,Jk);Yk.A&&Yk.A.locals&&Yk.A.locals;class Zk extends xs{constructor(){super(...arguments),this._clearDraggableAttributesDelayed=In((()=>this._clearDraggableAttributes()),40),this._blockMode=!1,this._domEmitter=new(Pr())}static get pluginName(){return"DragDrop"}static get requires(){return[Fk,Rb,Hk,Kk]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,t.addObserver(Vk),t.addObserver(Uh),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)})),l.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,r=i.document,n=e.plugins.get(Hk);this.listenTo(r,"dragstart",((e,i)=>{if(i.target&&i.target.is("editableElement"))return void i.preventDefault();if(this._prepareDraggedRange(i.target),!this._draggedRange)return void i.preventDefault();this._draggingUid=w(),i.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",i.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const r=t.createSelection(this._draggedRange.toRange());this.editor.plugins.get("ClipboardPipeline")._fireOutputTransformationEvent(i.dataTransfer,r,"dragstart");const{dataTransfer:n,domTarget:o,domEvent:s}=i,{clientX:a}=s;this._updatePreview({dataTransfer:n,domTarget:o,clientX:a}),i.stopPropagation(),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(r,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this._domEmitter.listenTo(Nr.document,"dragend",(()=>{this._blockMode=!1}),{useCapture:!0}),this.listenTo(r,"dragenter",(()=>{this.isEnabled&&i.focus()})),this.listenTo(r,"dragleave",(()=>{n.removeDropMarkerDelayed()})),this.listenTo(r,"dragging",((e,t)=>{if(!this.isEnabled)return void(t.dataTransfer.dropEffect="none");const{clientX:i,clientY:r}=t.domEvent;n.updateDropMarker(t.target,t.targetRanges,i,r,this._blockMode,this._draggedRange),this._draggedRange||(t.dataTransfer.dropEffect="copy"),l.isGecko||("copy"==t.dataTransfer.effectAllowed?t.dataTransfer.dropEffect="copy":["all","copyMove"].includes(t.dataTransfer.effectAllowed)&&(t.dataTransfer.dropEffect="move")),e.stop()}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get(Hk);this.listenTo(t,"clipboardInput",((t,r)=>{if("drop"!=r.method)return;const{clientX:n,clientY:o}=r.domEvent,s=i.getFinalDropRange(r.target,r.targetRanges,n,o,this._blockMode,this._draggedRange);if(!s)return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=r.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==Qk(r.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(s,!0))return this._finalizeDragging(!1),void t.stop();r.targetRanges=[e.editing.mapper.toViewRange(s)]}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(Fk);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"==Qk(t.dataTransfer),r=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(r&&i)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"mousedown",((r,n)=>{if(l.isAndroid||!n)return;this._clearDraggableAttributesDelayed.cancel();let o=Xk(n.target);if(l.isBlink&&!e.isReadOnly&&!o&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();e&&gb(e)||(o=i.selection.editableElement)}o&&(t.change((e=>{e.setAttribute("draggable","true",o)})),this._draggableElement=e.editing.mapper.toModelElement(o))})),this.listenTo(i,"mouseup",(()=>{l.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;if(t.plugins.get(Hk).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 r=t.getFirstPosition().parent;r.isEmpty&&!i.schema.checkChild(r,"$text")&&i.schema.checkChild(r,"paragraph")&&e.insertElement("paragraph",r,0)})),this._draggedRange.detach(),this._draggedRange=null)}_prepareDraggedRange(e){const t=this.editor,i=t.model,r=i.document.selection,n=e?Xk(e):null;if(n){const e=t.editing.mapper.toModelElement(n);if(this._draggedRange=wd.fromRange(i.createRangeOn(e)),this._blockMode=i.schema.isBlock(e),t.plugins.has("WidgetToolbarRepository")){t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}return}if(r.isCollapsed&&!r.getFirstPosition().parent.isEmpty)return;const o=Array.from(r.getSelectedBlocks()),s=r.getFirstRange();if(0==o.length)return void(this._draggedRange=wd.fromRange(s));const a=ev(i,o);if(o.length>1)this._draggedRange=wd.fromRange(a),this._blockMode=!0;else if(1==o.length){const e=s.start.isTouching(a.start)&&s.end.isTouching(a.end);this._draggedRange=wd.fromRange(e?a:s),this._blockMode=e}i.change((e=>e.setSelection(this._draggedRange.toRange())))}_updatePreview({dataTransfer:e,domTarget:t,clientX:i}){const r=this.editor.editing.view,n=r.document.selection.editableElement,o=r.domConverter.mapViewToDom(n),s=Nr.window.getComputedStyle(o);this._previewContainer?this._previewContainer.firstElementChild&&this._previewContainer.removeChild(this._previewContainer.firstElementChild):(this._previewContainer=we(Nr.document,"div",{style:"position: fixed; left: -999999px;"}),Nr.document.body.appendChild(this._previewContainer));const a=new Fr(o);if(o.contains(t))return;const c=parseFloat(s.paddingLeft),d=we(Nr.document,"div");d.className="ck ck-content",d.style.width=s.width,d.style.paddingLeft=`${a.left-i+c}px`,l.isiOS&&(d.style.backgroundColor="white"),d.innerHTML=e.getData("text/html"),e.setDragImage(d,0,0),this._previewContainer.appendChild(d)}}function Qk(e){return l.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function Xk(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(gb);if(gb(e))return e;const t=e.findAncestor((e=>gb(e)||e.is("editableElement")));return gb(t)?t:null}function ev(e,t){const i=t[0],r=t[t.length-1],n=i.getCommonAncestor(r),o=e.createPositionBefore(i),s=e.createPositionAfter(r);if(n&&n.is("element")&&!e.schema.isLimit(n)){const t=e.createRangeOn(n),i=o.isTouching(t.start),r=s.isTouching(t.end);if(i&&r)return ev(e,[n])}return e.createRange(o,s)}class tv extends xs{static get pluginName(){return"PastePlainText"}static get requires(){return[Fk]}init(){const e=this.editor,t=e.model,i=e.editing.view,r=i.document,n=t.document.selection;let o=!1;i.addObserver(Vk),this.listenTo(r,"keydown",((e,t)=>{o=t.shiftKey})),e.plugins.get(Fk).on("contentInsertion",((e,i)=>{(o||function(e,t){if(e.childCount>1)return!1;const i=e.getChild(0);if(t.isObject(i))return!1;return 0==Array.from(i.getAttributeKeys()).length}(i.content,t.schema))&&t.change((e=>{const r=Array.from(n.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));n.isCollapsed||t.deleteContent(n,{doNotAutoparagraph:!0}),r.push(...n.getAttributes());const o=e.createRangeIn(i.content);for(const t of o.getItems())t.is("$textProxy")&&e.setAttributes(r,t)}))}))}}class iv extends xs{static get pluginName(){return"Clipboard"}static get requires(){return[Fk,Zk,tv]}}class rv extends Cs{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)||!nv(e.schema,i))do{if(i=i.parent,!i)return}while(!nv(e.schema,i));e.change((e=>{e.setSelection(i,"in")}))}}function nv(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const ov=bn("Ctrl+A");class sv extends xs{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new rv(e)),this.listenTo(t,"keydown",((t,i)=>{fn(i)===ov&&(e.execute("selectAll"),i.preventDefault())}))}}class av extends xs{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(t=>{const i=e.commands.get("selectAll"),r=new Ao(t),n=t.t;return r.set({label:n("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),r.bind("isEnabled").to(i,"isEnabled"),this.listenTo(r,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),r}))}}class cv extends xs{static get requires(){return[sv,av]}static get pluginName(){return"SelectAll"}}class lv extends Cs{constructor(e){super(e),this._stack=[],this._createdBatches=new WeakSet,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 r=this.editor.model,n=r.document,o=[],s=e.map((e=>e.getTransformedByOperations(i))),a=s.flat();for(const e of s){const t=e.filter((e=>e.root!=n.graveyard)).filter((e=>!uv(e,a)));t.length&&(dv(t),o.push(t[0]))}o.length&&r.change((e=>{e.setSelection(o,{backward:t})}))}_undo(e,t){const i=this.editor.model,r=i.document;this._createdBatches.add(t);const n=e.operations.slice().filter((e=>e.isDocumentOperation));n.reverse();for(const e of n){const n=e.baseVersion+1,o=Array.from(r.history.getOperations(n)),s=Ju([e.getReversed()],o,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let n of s){const o=n.affectedSelectable;o&&!i.canEditAt(o)&&(n=new ju(n.baseVersion)),t.addOperation(n),i.applyOperation(n),r.history.setOperationAsUndone(e,n)}}}}function dv(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}class hv extends lv{execute(e=null){const t=e?this._stack.findIndex((t=>t.batch==e)):this._stack.length-1,i=this._stack.splice(t,1)[0],r=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(r,(()=>{this._undo(i.batch,r);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,r),this.refresh()}}class mv extends lv{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,r=this.editor.model.document.history.getOperations(i);this._restoreSelection(e.selection.ranges,e.selection.isBackward,r),this._undo(e.batch,t)})),this.refresh()}}class gv extends xs{constructor(){super(...arguments),this._batchRegistry=new WeakSet}static get pluginName(){return"UndoEditing"}init(){const e=this.editor;this._undoCommand=new hv(e),this._redoCommand=new mv(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 r=i.batch,n=this._redoCommand.createdBatches.has(r),o=this._undoCommand.createdBatches.has(r);this._batchRegistry.has(r)||(this._batchRegistry.add(r),r.isUndoable&&(n?this._undoCommand.addBatch(r):o||(this._undoCommand.addBatch(r),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")}}const pv='',fv='';class bv extends xs{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,i=e.t,r="ltr"==t.uiLanguageDirection?pv:fv,n="ltr"==t.uiLanguageDirection?fv:pv;this._addButton("undo",i("Undo"),"CTRL+Z",r),this._addButton("redo",i("Redo"),"CTRL+Y",n)}_addButton(e,t,i,r){const n=this.editor;n.ui.componentFactory.add(e,(o=>{const s=n.commands.get(e),a=new Ao(o);return a.set({label:t,icon:r,keystroke:i,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",(()=>{n.execute(e),n.editing.view.focus()})),a}))}}class wv extends xs{static get requires(){return[gv,bv]}static get pluginName(){return"Undo"}}class kv extends xs{static get requires(){return[iv,rb,cv,ab,Df,wv]}static get pluginName(){return"Essentials"}}class vv extends Cs{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,r=t.document.selection,n=Array.from(r.getSelectedBlocks()),o=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(o){const t=n.filter((e=>_v(e)||xv(i,e)));this._applyQuote(e,t)}else this._removeQuote(e,n.filter(_v))}))}_getValue(){const e=En(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!_v(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=En(e.getSelectedBlocks());return!!i&&xv(t,i)}_removeQuote(e,t){yv(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=[];yv(e,t).reverse().forEach((t=>{let r=_v(t.start);r||(r=e.createElement("blockQuote"),e.wrap(t,r)),i.push(r)})),i.reverse().reduce(((t,i)=>t.nextSibling==i?(e.merge(e.createPositionAfter(t)),t):i))}}function _v(e){return"blockQuote"==e.parent.name?e.parent:null}function yv(e,t){let i,r=0;const n=[];for(;r{const r=e.model.document.differ.getChanges();for(const e of r)if("insert"==e.type){const r=e.position.nodeAfter;if(!r)continue;if(r.is("element","blockQuote")&&r.isEmpty)return i.remove(r),!0;if(r.is("element","blockQuote")&&!t.checkChild(e.position,r))return i.unwrap(r),!0;if(r.is("element")){const e=i.createRangeIn(r);for(const r of e.getItems())if(r.is("element","blockQuote")&&!t.checkChild(i.createPositionBefore(r),r))return i.unwrap(r),!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,r=e.model.document.selection,n=e.commands.get("blockQuote");this.listenTo(i,"enter",((t,i)=>{if(!r.isCollapsed||!n.value)return;r.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||!r.isCollapsed||!n.value)return;const o=r.getLastPosition().parent;o.isEmpty&&!o.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"})}}var Cv=i(1699),Ev={attributes:{"data-cke":!0}};Ev.setAttributes=Un(),Ev.insert=zn().bind(null,"head"),Ev.domAPI=Fn(),Ev.insertStyleElement=$n();Ln()(Cv.A,Ev);Cv.A&&Cv.A.locals&&Cv.A.locals;class Sv extends xs{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",(i=>{const r=e.commands.get("blockQuote"),n=new Ao(i);return n.set({label:t("Block quote"),icon:xm.quote,tooltip:!0,isToggleable:!0}),n.bind("isOn","isEnabled").to(r,"value","isEnabled"),this.listenTo(n,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),n}))}}class Tv extends xs{static get requires(){return[Av,Sv]}static get pluginName(){return"BlockQuote"}}function Pv(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 Iv(e,t,i){const r={};for(const n of e)if("class"===t){r[n[t].split(" ").shift()]=n[i]}else r[n[t]]=n[i];return r}function Mv(e){return e.data.match(/^(\s*)/)[0]}function Ov(e){const t=e.document.selection,i=[];if(t.isCollapsed)return[t.anchor];const r=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:t}of r){if(!t.is("$textProxy"))continue;const{parent:r,startOffset:n}=t.textNode;if(!r.is("element","codeBlock"))continue;const o=Mv(t.textNode),s=e.createPositionAt(r,n+o.length);i.push(s)}return i}function Nv(e){const t=En(e.getSelectedBlocks());return!!t&&t.is("element","codeBlock")}function Vv(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}class Bv extends Cs{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,r=i.document.selection,n=Pv(t)[0],o=Array.from(r.getSelectedBlocks()),s=null==e.forceValue?!this.value:e.forceValue,a=function(e,t,i){if(e.language)return e.language;if(e.usePreviousLanguageChoice&&t)return t;return i}(e,this._lastLanguage,n.language);i.change((e=>{s?this._applyCodeBlock(e,o,a):this._removeCodeBlock(e,o)}))}_getValue(){const e=En(this.editor.model.document.selection.getSelectedBlocks());return!!!(!e||!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=En(e.getSelectedBlocks());return!!i&&Vv(t,i)}_applyCodeBlock(e,t,i){this._lastLanguage=i;const r=this.editor.model.schema,n=t.filter((e=>Vv(r,e)));for(const t of n)e.rename(t,"codeBlock"),e.setAttribute("language",i,t),r.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter((e=>!r.checkChild(t,e))).forEach((t=>e.remove(t)));n.reverse().forEach(((t,i)=>{const r=n[i+1];t.previousSibling===r&&(e.appendElement("softBreak",r),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)),r=i.nodeAfter;e.rename(r,"paragraph"),e.removeAttribute("language",r),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}class Rv extends Cs{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=Ov(e);for(const r of i){const i=t.createText(this._indentSequence);e.insertContent(i,r)}}))}_checkEnabled(){return!!this._indentSequence&&Nv(this.editor.model.document.selection)}}class Lv extends Cs{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=Ov(e);for(const i of t){const t=Dv(e,i,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!Nv(e.document.selection)&&Ov(e).some((t=>Dv(e,t,this._indentSequence)))}}function Dv(e,t,i){const r=function(e){let t=e.parent.getChild(e.index);t&&!t.is("element","softBreak")||(t=e.nodeBefore);if(!t||t.is("element","softBreak"))return null;return t}(t);if(!r)return null;const n=Mv(r),o=n.lastIndexOf(i);if(o+i.length!==n.length)return null;if(-1===o)return null;const{parent:s,startOffset:a}=r;return e.createRange(e.createPositionAt(s,a+o),e.createPositionAt(s,a+o+i.length))}function Fv(e,t,i=!1){const r=Iv(t,"language","class"),n=Iv(t,"language","label");return(t,o,s)=>{const{writer:a,mapper:c,consumable:l}=s;if(!l.consume(o.item,"insert"))return;const d=o.item.getAttribute("language"),u=c.toViewPosition(e.createPositionBefore(o.item)),h={};i&&(h["data-language"]=n[d],h.spellcheck="false");const m=r[d]?{class:r[d]}:void 0,g=a.createContainerElement("code",m),p=a.createContainerElement("pre",h,g);a.insert(u,p),c.bindElements(o.item,g)}}const jv="paragraph";class zv extends xs{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[ab]}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:"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,r=e.editing.view,n=e.plugins.has("DocumentListEditing")?e.plugins.get("DocumentListEditing"):null,o=Pv(e);e.commands.add("codeBlock",new Bv(e)),e.commands.add("indentCodeBlock",new Rv(e)),e.commands.add("outdentCodeBlock",new Lv(e)),this.listenTo(r.document,"tab",((t,i)=>{const r=i.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(r).isEnabled&&(e.execute(r),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",isBlock:!0,allowAttributes:["language"]}),t.addAttributeCheck(((e,t)=>!!(e.endsWith("codeBlock")&&n&&n.getListAttributeNames().includes(t))||!e.endsWith("codeBlock $text")&&void 0)),e.model.schema.addChildCheck(((e,t)=>{if(e.endsWith("codeBlock")&&t.isObject)return!1})),e.editing.downcastDispatcher.on("insert:codeBlock",Fv(i,o,!0)),e.data.downcastDispatcher.on("insert:codeBlock",Fv(i,o)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,i,r)=>{if("codeBlock"!==i.item.parent.name)return;const{writer:n,mapper:o,consumable:s}=r;if(!s.consume(i.item,"insert"))return;const a=o.toViewPosition(e.createPositionBefore(i.item));n.insert(a,n.createText("\n"))}}(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const i=Iv(t,"class","language"),r=t[0].language;return(e,t,n)=>{const o=t.viewItem,s=o.parent;if(!s||!s.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:c}=n;if(!a.test(o,{name:!0}))return;const l=c.createElement("codeBlock"),d=[...o.getClassNames()];d.length||d.push("");for(const e of d){const t=i[e];if(t){c.setAttribute("language",t,l);break}}l.hasAttribute("language")||c.setAttribute("language",r,l),n.convertChildren(o,l),n.safeInsert(l,t.modelCursor)&&(a.consume(o,{name:!0}),n.updateConversionResult(l,t))}}(0,o)),e.data.upcastDispatcher.on("text",((e,t,{consumable:i,writer:r})=>{let n=t.modelCursor;if(!i.test(t.viewItem))return;if(!n.findAncestor("codeBlock"))return;i.consume(t.viewItem);const o=t.viewItem.data.split("\n").map((e=>r.createText(e))),s=o[o.length-1];for(const e of o)if(r.insert(e,n),n=n.getShiftedBy(e.offsetSize),e!==s){const e=r.createElement("softBreak");r.insert(e,n),n=r.createPositionAfter(e)}t.modelRange=r.createRange(t.modelCursor,n),t.modelCursor=n})),e.data.upcastDispatcher.on("element:pre",((e,t,{consumable:i})=>{const r=t.viewItem;if(r.findAncestor("pre"))return;const n=Array.from(r.getChildren()),o=n.find((e=>e.is("element","code")));if(o)for(const e of n)e!==o&&e.is("$text")&&i.consume(e,{name:!0})}),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,r)=>{let n=i.createRange(i.document.selection.anchor);if(r.targetRanges&&(n=e.editing.mapper.toModelRange(r.targetRanges[0])),!n.start.parent.is("element","codeBlock"))return;const o=r.dataTransfer.getData("text/plain"),s=new Wh(e.editing.view.document);r.content=function(e,t){const i=e.createDocumentFragment(),r=t.split("\n"),n=r.reduce(((t,i,n)=>(t.push(i),n{const n=r.anchor;!r.isCollapsed&&n.parent.is("element","codeBlock")&&n.hasSameParentAs(r.focus)&&i.change((i=>{const o=e.return;if(n.parent.is("element")&&(o.childCount>1||r.containsEntireContent(n.parent))){const t=i.createElement("codeBlock",n.parent.getAttributes());i.append(o,t);const r=i.createDocumentFragment();return i.append(t,r),void(e.return=r)}const s=o.getChild(0);t.checkAttribute(s,"code")&&i.setAttribute("code",!0,s)}))}))}afterInit(){const e=this.editor,t=e.commands,i=t.get("indent"),r=t.get("outdent");i&&i.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),r&&r.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,r=i.document,n=e.editing.view,o=r.selection.getLastPosition(),s=o.nodeAfter;if(t||!r.selection.isCollapsed||!o.isAtStart)return!1;if(!Uv(s))return!1;return e.model.change((t=>{e.execute("enter");const i=r.selection.anchor.parent.previousSibling;t.rename(i,jv),t.setSelection(i,"in"),e.model.schema.removeDisallowedAttributes([i],t),t.remove(s)})),n.scrollToTheSelection(),!0}(e,i.isSoft)||function(e,t){const i=e.model,r=i.document,n=e.editing.view,o=r.selection.getLastPosition(),s=o.nodeBefore;let a;if(t||!r.selection.isCollapsed||!o.isAtEnd||!s||!s.previousSibling)return!1;if(Uv(s)&&Uv(s.previousSibling))a=i.createRange(i.createPositionBefore(s.previousSibling),i.createPositionAfter(s));else if(Hv(s)&&Uv(s.previousSibling)&&Uv(s.previousSibling.previousSibling))a=i.createRange(i.createPositionBefore(s.previousSibling.previousSibling),i.createPositionAfter(s));else{if(!(Hv(s)&&Uv(s.previousSibling)&&Hv(s.previousSibling.previousSibling)&&s.previousSibling.previousSibling&&Uv(s.previousSibling.previousSibling.previousSibling)))return!1;a=i.createRange(i.createPositionBefore(s.previousSibling.previousSibling.previousSibling),i.createPositionAfter(s))}return e.model.change((t=>{t.remove(a),e.execute("enter");const i=r.selection.anchor.parent;t.rename(i,jv),e.model.schema.removeDisallowedAttributes([i],t)})),n.scrollToTheSelection(),!0}(e,i.isSoft)||function(e){const t=e.model,i=t.document,r=i.selection.getLastPosition(),n=r.nodeBefore||r.textNode;let o;n&&n.is("$text")&&(o=Mv(n));e.model.change((t=>{e.execute("shiftEnter"),o&&t.insertText(o,i.selection.anchor)}))}(e),i.preventDefault(),t.stop())}),{context:"pre"})}}function Hv(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function Uv(e){return e&&e.is("element","softBreak")}var Wv=i(2969),$v={attributes:{"data-cke":!0}};$v.setAttributes=Un(),$v.insert=zn().bind(null,"head"),$v.domAPI=Fn(),$v.insertStyleElement=$n();Ln()(Wv.A,$v);Wv.A&&Wv.A.locals&&Wv.A.locals;class qv extends xs{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,r=Pv(e);i.add("codeBlock",(i=>{const n=e.commands.get("codeBlock"),o=$m(i,jm),s=o.buttonView,a=t("Insert code block");return s.set({label:a,tooltip:!0,icon:'',isToggleable:!0}),s.bind("isOn").to(n,"value",(e=>!!e)),s.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()})),o.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),o.class="ck-code-block-dropdown",o.bind("isEnabled").to(n),Km(o,(()=>this._getLanguageListItemDefinitions(r)),{role:"menu",ariaLabel:a}),o}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new Cn;for(const r of e){const e={type:"button",model:new Ep({_codeBlockLanguage:r.language,label:r.label,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(t=>t===e.model._codeBlockLanguage)),i.add(e)}return i}}class Gv extends xs{static get requires(){return[zv,qv]}static get pluginName(){return"CodeBlock"}}class Kv extends Cs{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=En(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&Yv(t,e.schema)}execute(e={}){const t=this.editor.model,i=t.document,r=e.selection||i.selection;t.canEditAt(r)&&t.change((e=>{const i=r.getSelectedBlocks();for(const r of i)!r.is("element","paragraph")&&Yv(r,t.schema)&&e.rename(r,"paragraph")}))}}function Yv(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class Jv extends Cs{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,i=e.attributes;let r=e.position;t.canEditAt(r)&&t.change((e=>{if(r=this._findPositionToInsertParagraph(r,e),!r)return;const n=e.createElement("paragraph");i&&t.schema.setAllowedAttributes(n,i,e),t.insertContent(n,r),e.setSelection(n,"in")}))}_findPositionToInsertParagraph(e,t){const i=this.editor.model;if(i.schema.checkChild(e,"paragraph"))return e;const r=i.schema.findAllowedParent(e,"paragraph");if(!r)return null;const n=e.parent,o=i.schema.checkChild(n,"$text");return n.isEmpty||o&&e.isAtEnd?i.createPositionAfter(n):!n.isEmpty&&o&&e.isAtStart?i.createPositionBefore(n):t.split(e,r).position}}class Zv extends xs{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new Kv(e)),e.commands.add("insertParagraph",new Jv(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>Zv.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}Zv.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class Qv extends Cs{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=En(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>Xv(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,i=t.document,r=e.value;t.change((e=>{const n=Array.from(i.selection.getSelectedBlocks()).filter((e=>Xv(e,r,t.schema)));for(const t of n)t.is("element",r)||e.rename(t,r)}))}}function Xv(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const e_="paragraph";class t_ extends xs{static get pluginName(){return"HeadingEditing"}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[Zv]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const r of t)"paragraph"!==r.model&&(e.model.schema.register(r.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(r),i.push(r.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new Qv(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,r)=>{const n=e.model.document.selection.getFirstPosition().parent;i.some((e=>n.is("element",e.model)))&&!n.is("element",e_)&&0===n.childCount&&r.writer.rename(n,e_)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:k.low+1})}}var i_=i(2452),r_={attributes:{"data-cke":!0}};r_.setAttributes=Un(),r_.insert=zn().bind(null,"head"),r_.domAPI=Fn(),r_.insertStyleElement=$n();Ln()(i_.A,r_);i_.A&&i_.A.locals&&i_.A.locals;class n_ extends xs{static get pluginName(){return"HeadingUI"}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),r=t("Choose heading"),n=t("Heading");e.ui.componentFactory.add("heading",(t=>{const o={},s=new Cn,a=e.commands.get("heading"),c=e.commands.get("paragraph"),l=[a];for(const e of i){const t={type:"button",model:new Ep({label:e.title,class:e.class,role:"menuitemradio",withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(c,"value"),t.model.set("commandName","paragraph"),l.push(c)):(t.model.bind("isOn").to(a,"value",(t=>t===e.model)),t.model.set({commandName:"heading",commandValue:e.model})),s.add(t),o[e.model]=e.title}const d=$m(t);return Km(d,s,{ariaLabel:n,role:"menu"}),d.buttonView.set({ariaLabel:n,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:n}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some((e=>e)))),d.buttonView.bind("label").to(a,"value",c,"value",((e,t)=>{const i=e||t&&"paragraph";return"boolean"==typeof i?r:o[i]?o[i]:r})),this.listenTo(d,"execute",(t=>{const{commandName:i,commandValue:r}=t.source;e.execute(i,r?{value:r}:void 0),e.editing.view.focus()})),d}))}}class o_ extends xs{static get requires(){return[t_,n_]}static get pluginName(){return"Heading"}}class s_ extends Cs{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,r=Array.from(i.selection.getSelectedBlocks()).filter((e=>c_(e,t.schema))),n=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(n){let t=r[r.length-1].nextSibling,i=Number.POSITIVE_INFINITY,n=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=i;)o>n.getAttribute("listIndent")&&(o=n.getAttribute("listIndent")),n.getAttribute("listIndent")==o&&e[t?"unshift":"push"](n),n=n[t?"previousSibling":"nextSibling"]}}function c_(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class l_ extends Cs{constructor(e,t){super(e),this._indentBy="forward"==t?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document;let i=Array.from(t.selection.getSelectedBlocks());e.change((e=>{const t=i[i.length-1];let r=t.nextSibling;for(;r&&"listItem"==r.name&&r.getAttribute("listIndent")>t.getAttribute("listIndent");)i.push(r),r=r.nextSibling;this._indentBy<0&&(i=i.reverse());for(const t of i){const i=t.getAttribute("listIndent")+this._indentBy;i<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",i,t)}this.fire("_executeCleanup",i)}))}_checkEnabled(){const e=En(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("element","listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),i=e.getAttribute("listType");let r=e.previousSibling;for(;r&&r.is("element","listItem")&&r.getAttribute("listIndent")>=t;){if(r.getAttribute("listIndent")==t)return r.getAttribute("listType")==i;r=r.previousSibling}return!1}return!0}}function d_(e,t){const i=t.mapper,r=t.writer,n="numbered"==e.getAttribute("listType")?"ol":"ul",o=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=k_,t}(r),s=r.createContainerElement(n,null);return r.insert(r.createPositionAt(s,0),o),i.bindElements(e,o),o}function u_(e,t,i,r){const n=t.parent,o=i.mapper,s=i.writer;let a=o.toViewPosition(r.createPositionBefore(e));const c=g_(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),l=e.previousSibling;if(c&&c.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=o.toViewElement(c);a=s.breakContainer(s.createPositionAfter(e))}else if(l&&"listItem"==l.name){a=o.toViewPosition(r.createPositionAt(l,"end"));const e=o.findMappedViewAncestor(a),t=function(e){for(const t of e.getChildren())if("ul"==t.name||"ol"==t.name)return t;return null}(e);a=t?s.createPositionBefore(t):s.createPositionAt(e,"end")}else a=o.toViewPosition(r.createPositionBefore(e));if(a=m_(a),s.insert(a,n),l&&"listItem"==l.name){const e=o.toViewElement(l),i=s.createRange(s.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of i)if(e.item.is("element","li")){const r=s.breakContainer(s.createPositionBefore(e.item)),n=e.item.parent,o=s.createPositionAt(t,"end");h_(s,o.nodeBefore,o.nodeAfter),s.move(s.createRangeOn(n),o),i._position=r}}else{const i=n.nextSibling;if(i&&(i.is("element","ul")||i.is("element","ol"))){let r=null;for(const t of i.getChildren()){const i=o.toModelElement(t);if(!(i&&i.getAttribute("listIndent")>e.getAttribute("listIndent")))break;r=t}r&&(s.breakContainer(s.createPositionAfter(r)),s.move(s.createRangeOn(r.parent),s.createPositionAt(t,"end")))}}h_(s,n,n.nextSibling),h_(s,n.previousSibling,n)}function h_(e,t,i){return!t||!i||"ul"!=t.name&&"ol"!=t.name||t.name!=i.name||t.getAttribute("class")!==i.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function m_(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function g_(e,t){const i=!!t.sameIndent,r=!!t.smallerIndent,n=t.listIndent;let o=e;for(;o&&"listItem"==o.name;){const e=o.getAttribute("listIndent");if(i&&n==e||r&&n>e)return o;o="forward"===t.direction?o.nextSibling:o.previousSibling}return null}function p_(e,t,i,r){e.ui.componentFactory.add(t,(n=>{const o=e.commands.get(t),s=new Ao(n);return s.set({label:i,icon:r,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),s.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),s}))}function f_(e,t){const i=[],r=e.parent,n={ignoreElementEnd:!1,startPosition:e,shallow:!0,direction:t},o=r.getAttribute("listIndent"),s=[...new Jl(n)].filter((e=>e.item.is("element"))).map((e=>e.item));for(const e of s){if(!e.is("element","listItem"))break;if(e.getAttribute("listIndent")o)){if(e.getAttribute("listType")!==r.getAttribute("listType"))break;if(e.getAttribute("listStyle")!==r.getAttribute("listStyle"))break;if(e.getAttribute("listReversed")!==r.getAttribute("listReversed"))break;if(e.getAttribute("listStart")!==r.getAttribute("listStart"))break;"backward"===t?i.unshift(e):i.push(e)}}return i}const b_=["disc","circle","square"],w_=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function k_(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:Ga.call(this)}class v_ extends xs{static get pluginName(){return"ListUtils"}getListTypeFromListStyleType(e){return function(e){return b_.includes(e)?"bulleted":w_.includes(e)?"numbered":null}(e)}getSelectedListItems(e){return function(e){let t=[...e.document.selection.getSelectedBlocks()].filter((e=>e.is("element","listItem"))).map((t=>{const i=e.change((e=>e.createPositionAt(t,0)));return[...f_(i,"backward"),...f_(i,"forward")]})).flat();return t=[...new Set(t)],t}(e)}getSiblingNodes(e,t){return f_(e,t)}}function __(e){return(t,i,r)=>{const n=r.consumable;if(!n.test(i.item,"insert")||!n.test(i.item,"attribute:listType")||!n.test(i.item,"attribute:listIndent"))return;n.consume(i.item,"insert"),n.consume(i.item,"attribute:listType"),n.consume(i.item,"attribute:listIndent");const o=i.item;u_(o,d_(o,r),r,e)}}const y_=(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const r=i.mapper.toViewElement(t.item),n=i.writer;n.breakContainer(n.createPositionBefore(r)),n.breakContainer(n.createPositionAfter(r));const o=r.parent,s="numbered"==t.attributeNewValue?"ol":"ul";n.rename(s,o)},x_=(e,t,i)=>{i.consumable.consume(t.item,e.name);const r=i.mapper.toViewElement(t.item).parent,n=i.writer;h_(n,r,r.nextSibling),h_(n,r.previousSibling,r)};const A_=(e,t,i)=>{if(i.consumable.test(t.item,e.name)&&"listItem"!=t.item.name){let e=i.mapper.toViewPosition(t.range.start);const r=i.writer,n=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=r.breakContainer(e),"li"==e.parent.name);){const t=e,i=r.createPositionAt(e.parent,"end");if(!t.isEqual(i)){const e=r.remove(r.createRange(t,i));n.push(e)}e=r.createPositionAfter(e.parent)}if(n.length>0){for(let t=0;t0){const t=h_(r,i,i.nextSibling);t&&t.parent==i&&e.offset--}}h_(r,e.nodeBefore,e.nodeAfter)}}},C_=(e,t,i)=>{const r=i.mapper.toViewPosition(t.position),n=r.nodeBefore,o=r.nodeAfter;h_(i.writer,n,o)},E_=(e,t,i)=>{if(i.consumable.consume(t.viewItem,{name:!0})){const e=i.writer,r=e.createElement("listItem"),n=function(e){let t=0,i=e.parent;for(;i;){if(i.is("element","li"))t++;else{const e=i.previousSibling;e&&e.is("element","li")&&t++}i=i.parent}return t}(t.viewItem);e.setAttribute("listIndent",n,r);const o=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",o,r),!i.safeInsert(r,t.modelCursor))return;const s=function(e,t,i){const{writer:r,schema:n}=i;let o=r.createPositionAfter(e);for(const s of t)if("ul"==s.name||"ol"==s.name)o=i.convertItem(s,o).modelCursor;else{const t=i.convertItem(s,r.createPositionAt(e,"end")),a=t.modelRange.start.nodeAfter;a&&a.is("element")&&!n.checkChild(e,a.name)&&(e=t.modelCursor.parent.is("element","listItem")?t.modelCursor.parent:M_(t.modelCursor),o=r.createPositionAfter(e))}return o}(r,t.viewItem.getChildren(),i);t.modelRange=e.createRange(t.modelCursor,s),i.updateConversionResult(r,t)}},S_=(e,t,i)=>{if(i.consumable.test(t.viewItem,{name:!0})){const e=Array.from(t.viewItem.getChildren());for(const t of e){!(t.is("element","li")||N_(t))&&t._remove()}}},T_=(e,t,i)=>{if(i.consumable.test(t.viewItem,{name:!0})){if(0===t.viewItem.childCount)return;const e=[...t.viewItem.getChildren()];let i=!1;for(const t of e)i&&!N_(t)&&t._remove(),N_(t)&&(i=!0)}};function P_(e){return(t,i)=>{if(i.isPhantom)return;const r=i.modelPosition.nodeBefore;if(r&&r.is("element","listItem")){const t=i.mapper.toViewElement(r),n=t.getAncestors().find(N_),o=e.createPositionAt(t,0).getWalker();for(const e of o){if("elementStart"==e.type&&e.item.is("element","li")){i.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==n){i.viewPosition=e.nextPosition;break}}}}}const I_=function(e,[t,i]){const r=this;let n,o=t.is("documentFragment")?t.getChild(0):t;if(n=i?r.createSelection(i):r.document.selection,o&&o.is("element","listItem")){const e=n.getFirstPosition();let t=null;if(e.parent.is("element","listItem")?t=e.parent:e.nodeBefore&&e.nodeBefore.is("element","listItem")&&(t=e.nodeBefore),t){const e=t.getAttribute("listIndent");if(e>0)for(;o&&o.is("element","listItem");)o._setAttribute("listIndent",o.getAttribute("listIndent")+e),o=o.nextSibling}}};function M_(e){const t=new Jl({startPosition:e});let i;do{i=t.next()}while(!i.value.item.is("element","listItem"));return i.value.item}function O_(e,t,i,r,n,o){const s=g_(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e}),a=n.mapper,c=n.writer,l=s?s.getAttribute("listIndent"):null;let d;if(s)if(l==e){const e=a.toViewElement(s).parent;d=c.createPositionAfter(e)}else{const e=o.createPositionAt(s,"end");d=a.toViewPosition(e)}else d=i;d=m_(d);for(const e of[...r.getChildren()])N_(e)&&(d=c.move(c.createRangeOn(e),d).end,h_(c,e,e.nextSibling),h_(c,e.previousSibling,e))}function N_(e){return e.is("element","ol")||e.is("element","ul")}var V_=i(7894),B_={attributes:{"data-cke":!0}};B_.setAttributes=Un(),B_.insert=zn().bind(null,"head"),B_.domAPI=Fn(),B_.insertStyleElement=$n();Ln()(V_.A,B_);V_.A&&V_.A.locals&&V_.A.locals;class R_ extends xs{static get pluginName(){return"ListEditing"}static get requires(){return[rb,Lf,v_]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,i=e.editing;var r;e.model.document.registerPostFixer((t=>function(e,t){const i=e.document.differ.getChanges(),r=new Map;let n=!1;for(const r of i)if("insert"==r.type&&"listItem"==r.name)o(r.position);else if("insert"==r.type&&"listItem"!=r.name){if("$text"!=r.name){const i=r.position.nodeAfter;i.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",i),n=!0),i.hasAttribute("listType")&&(t.removeAttribute("listType",i),n=!0),i.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",i),n=!0),i.hasAttribute("listReversed")&&(t.removeAttribute("listReversed",i),n=!0),i.hasAttribute("listStart")&&(t.removeAttribute("listStart",i),n=!0);for(const t of Array.from(e.createRangeIn(i)).filter((e=>e.item.is("element","listItem"))))o(t.previousPosition)}o(r.position.getShiftedBy(r.length))}else"remove"==r.type&&"listItem"==r.name?o(r.position):("attribute"==r.type&&"listIndent"==r.attributeKey||"attribute"==r.type&&"listType"==r.attributeKey)&&o(r.range.start);for(const e of r.values())s(e),a(e);return n;function o(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(r.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,r.has(e))return;r.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&r.set(t,t)}}function s(e){let i=0,r=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(o>i){let s;null===r?(r=o-i,s=i):(r>o&&(r=o),s=o-r),t.setAttribute("listIndent",s,e),n=!0}else r=null,i=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let i=[],r=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(r&&r.getAttribute("listIndent")>o&&(i=i.slice(0,o+1)),0!=o)if(i[o]){const r=i[o];e.getAttribute("listType")!=r&&(t.setAttribute("listType",r,e),n=!0)}else i[o]=e.getAttribute("listType");r=e,e=e.nextSibling}}}(e.model,t))),i.mapper.registerViewToModelLength("li",L_),t.mapper.registerViewToModelLength("li",L_),i.mapper.on("modelToViewPosition",P_(i.view)),i.mapper.on("viewToModelPosition",(r=e.model,(e,t)=>{const i=t.viewPosition,n=i.parent,o=t.mapper;if("ul"==n.name||"ol"==n.name){if(i.isAtEnd){const e=o.toModelElement(i.nodeBefore),n=o.getModelLength(i.nodeBefore);t.modelPosition=r.createPositionBefore(e).getShiftedBy(n)}else{const e=o.toModelElement(i.nodeAfter);t.modelPosition=r.createPositionBefore(e)}e.stop()}else if("li"==n.name&&i.nodeBefore&&("ul"==i.nodeBefore.name||"ol"==i.nodeBefore.name)){const s=o.toModelElement(n);let a=1,c=i.nodeBefore;for(;c&&N_(c);)a+=o.getModelLength(c),c=c.previousSibling;t.modelPosition=r.createPositionBefore(s).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",P_(i.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",A_,{priority:"high"}),t.on("insert:listItem",__(e.model)),t.on("attribute:listType:listItem",y_,{priority:"high"}),t.on("attribute:listType:listItem",x_,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,i,r)=>{if(!r.consumable.consume(i.item,"attribute:listIndent"))return;const n=r.mapper.toViewElement(i.item),o=r.writer;o.breakContainer(o.createPositionBefore(n)),o.breakContainer(o.createPositionAfter(n));const s=n.parent,a=s.previousSibling,c=o.createRangeOn(s);o.remove(c),a&&a.nextSibling&&h_(o,a,a.nextSibling),O_(i.attributeOldValue+1,i.range.start,c.start,n,r,e),u_(i.item,n,r,e);for(const e of i.item.getChildren())r.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,i,r)=>{const n=r.mapper.toViewPosition(i.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,o=r.writer;o.breakContainer(o.createPositionBefore(n)),o.breakContainer(o.createPositionAfter(n));const s=n.parent,a=s.previousSibling,c=o.createRangeOn(s),l=o.remove(c);a&&a.nextSibling&&h_(o,a,a.nextSibling),O_(r.mapper.toModelElement(n).getAttribute("listIndent")+1,i.position,c.start,n,r,e);for(const e of o.createRangeIn(l).getItems())r.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",C_,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",A_,{priority:"high"}),t.on("insert:listItem",__(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",S_,{priority:"high"}),e.on("element:ol",S_,{priority:"high"}),e.on("element:li",T_,{priority:"high"}),e.on("element:li",E_)})),e.model.on("insertContent",I_,{priority:"high"}),e.commands.add("numberedList",new s_(e,"numbered")),e.commands.add("bulletedList",new s_(e,"bulleted")),e.commands.add("indentList",new l_(e,"forward")),e.commands.add("outdentList",new l_(e,"backward"));const n=i.view.document;this.listenTo(n,"enter",((e,t)=>{const i=this.editor.model.document,r=i.selection.getLastPosition().parent;i.selection.isCollapsed&&"listItem"==r.name&&r.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(n,"delete",((e,t)=>{if("backward"!==t.direction)return;const i=this.editor.model.document.selection;if(!i.isCollapsed)return;const r=i.getFirstPosition();if(!r.isAtStart)return;const n=r.parent;if("listItem"!==n.name)return;n.previousSibling&&"listItem"===n.previousSibling.name||(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(e.editing.view.document,"tab",((t,i)=>{const r=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(r).isEnabled&&(e.execute(r),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"li"})}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),i&&i.registerChildCommand(e.get("outdentList"))}}function L_(e){let t=1;for(const i of e.getChildren())if("ul"==i.name||"ol"==i.name)for(const e of i.getChildren())t+=L_(e);return t}class D_ extends xs{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;p_(this.editor,"numberedList",e("Numbered List"),''),p_(this.editor,"bulletedList",e("Bulleted List"),'')}}class F_ extends xs{static get requires(){return[R_,D_]}static get pluginName(){return"List"}}function j_(e,t){return`${e}:${t=t||_n(e)}`}class z_ extends Cs{refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"language")}execute({languageCode:e,textDirection:t}={}){const i=this.editor.model,r=i.document.selection,n=!!e&&j_(e,t);i.change((e=>{if(r.isCollapsed)n?e.setSelectionAttribute("language",n):e.removeSelectionAttribute("language");else{const t=i.schema.getValidRanges(r.getRanges(),"language");for(const i of t)n?e.setAttribute("language",n,i):e.removeAttribute("language",i)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.getAttribute("language")||!1;for(const e of i.getRanges())for(const i of e.getItems())if(t.checkAttribute(i,"language"))return i.getAttribute("language")||!1;return!1}}class H_ extends xs{static get pluginName(){return"TextPartLanguageEditing"}constructor(e){super(e),e.config.define("language",{textPartLanguage:[{title:"Arabic",languageCode:"ar"},{title:"French",languageCode:"fr"},{title:"Spanish",languageCode:"es"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"language"}),e.model.schema.setAttributeProperties("language",{copyOnEnter:!0}),this._defineConverters(),e.commands.add("textPartLanguage",new z_(e))}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToAttribute({model:{key:"language",value:e=>j_(e.getAttribute("lang"),e.getAttribute("dir"))},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),e.for("downcast").attributeToElement({model:"language",view:(e,{writer:t},i)=>{if(!e)return;if(!i.item.is("$textProxy")&&!i.item.is("documentSelection"))return;const{languageCode:r,textDirection:n}=function(e){const[t,i]=e.split(":");return{languageCode:t,textDirection:i}}(e);return t.createAttributeElement("span",{lang:r,dir:n})}})}}class U_ extends xs{static get pluginName(){return"TextPartLanguageUI"}init(){const e=this.editor,t=e.t,i=e.config.get("language.textPartLanguage"),r=t("Choose language"),n=t("Remove language"),o=t("Language");e.ui.componentFactory.add("textPartLanguage",(t=>{const s=new Cn,a={},c=e.commands.get("textPartLanguage");s.add({type:"button",model:new Ep({label:n,languageCode:!1,withText:!0})}),s.add({type:"separator"});for(const e of i){const t={type:"button",model:new Ep({label:e.title,languageCode:e.languageCode,role:"menuitemradio",textDirection:e.textDirection,withText:!0})},i=j_(e.languageCode,e.textDirection);t.model.bind("isOn").to(c,"value",(e=>e===i)),s.add(t),a[i]=e.title}const l=$m(t);return Km(l,s,{ariaLabel:o,role:"menu"}),l.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),l.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),l.bind("isEnabled").to(c,"isEnabled"),l.buttonView.bind("label").to(c,"value",(e=>e&&a[e]||r)),this.listenTo(l,"execute",(t=>{c.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()})),l}))}}class W_ extends xs{static get requires(){return[H_,U_]}static get pluginName(){return"TextPartLanguage"}}class $_ extends Cs{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 r of t.document.roots)r.hasClass(e)?(i.removeClass(e,r),this.value=!1):(i.addClass(e,r),this.value=!0)}))}}class q_ extends xs{static get pluginName(){return"ShowBlocksEditing"}init(){const{editor:e}=this;e.commands.add("showBlocks",new $_(e))}}var G_=i(2501),K_={attributes:{"data-cke":!0}};K_.setAttributes=Un(),K_.insert=zn().bind(null,"head"),K_.domAPI=Fn(),K_.insertStyleElement=$n();Ln()(G_.A,K_);G_.A&&G_.A.locals&&G_.A.locals;class Y_ extends xs{static get pluginName(){return"ShowBlocksUI"}init(){const e=this.editor;e.ui.componentFactory.add("showBlocks",(t=>{const i=e.commands.get("showBlocks"),r=new Ao(t),n=t.t;return r.set({label:n("Show blocks"),icon:'',tooltip:!0}),r.bind("isOn").to(i,"value",i,"isEnabled",((e,t)=>e&&t)),r.bind("isEnabled").to(i),this.listenTo(r,"execute",(()=>{e.execute("showBlocks"),e.editing.view.focus()})),r}))}}class J_ extends xs{static get pluginName(){return"ShowBlocks"}static get requires(){return[q_,Y_]}}class Z_ extends Cs{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,r=e.value,n=e.batch,o=e=>{if(i.isCollapsed)r?e.setSelectionAttribute(this.attributeKey,r):e.removeSelectionAttribute(this.attributeKey);else{const n=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of n)r?e.setAttribute(this.attributeKey,r,t):e.removeAttribute(this.attributeKey,t)}};n?t.enqueueChange(n,(e=>{o(e)})):t.change((e=>{o(e)}))}}const Q_="fontSize",X_="fontFamily",ey="fontColor",ty="fontBackgroundColor";function iy(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 ry(e){return t=>t.getStyle(e).replace(/\s/g,"")}function ny(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class oy extends Z_{constructor(e){super(e,X_)}}function sy(e){return e.map(ay).filter((e=>void 0!==e))}function ay(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=e.replace(/"|'/g,"").split(","),i=t[0],r=t.map(cy).join(", ");return{title:i,model:r,view:{name:"span",styles:{"font-family":r},priority:7}}}(e):void 0}function cy(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class ly extends xs{static get pluginName(){return"FontFamilyEditing"}constructor(e){super(e),e.config.define(X_,{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:X_}),e.model.schema.setAttributeProperties(X_,{isFormatting:!0,copyOnEnter:!0});const t=sy(e.config.get("fontFamily.options")).filter((e=>e.model)),i=iy(X_,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(X_,new oy(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:X_,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:X_,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:X_,value:e=>e.getAttribute("face")}})}}class dy extends xs{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),r=e.commands.get(X_),n=t("Font Family");e.ui.componentFactory.add(X_,(t=>{const o=$m(t);return Km(o,(()=>function(e,t){const i=new Cn;for(const r of e){const e={type:"button",model:new Ep({commandName:X_,commandParam:r.model,label:r.title,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(e=>e===r.model||!(!e||!r.model)&&e.split(",")[0].replace(/'/g,"").toLowerCase()===r.model.toLowerCase())),r.view&&"string"!=typeof r.view&&r.view.styles&&e.model.set("labelStyle",`font-family: ${r.view.styles["font-family"]}`),i.add(e)}return i}(i,r)),{role:"menu",ariaLabel:n}),o.buttonView.set({label:n,icon:'',tooltip:!0}),o.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),o.bind("isEnabled").to(r),this.listenTo(o,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),o}))}_getLocalizedOptions(){const e=this.editor,t=e.t;return sy(e.config.get(X_).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class uy extends xs{static get requires(){return[ly,dy]}static get pluginName(){return"FontFamily"}}class hy extends Z_{constructor(e){super(e,Q_)}}function my(e){return e.map((e=>function(e){"number"==typeof e&&(e=String(e));if("object"==typeof e&&(t=e,t.title&&t.model&&t.view))return py(e);var t;const i=function(e){return"string"==typeof e?gy[e]:gy[e.model]}(e);if(i)return py(i);if("default"===e)return{model:void 0,title:"Default"};if(function(e){let t;if("object"==typeof e){if(!e.model)throw new _("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}(e))return;return function(e){"string"==typeof e&&(e={title:e,model:`${parseFloat(e)}px`});return e.view={name:"span",styles:{"font-size":e.model}},py(e)}(e)}(e))).filter((e=>void 0!==e))}const gy={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 py(e){return e.view&&"string"!=typeof e.view&&!e.view.priority&&(e.view.priority=7),e}const fy=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class by extends xs{static get pluginName(){return"FontSizeEditing"}constructor(e){super(e),e.config.define(Q_,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Q_}),e.model.schema.setAttributeProperties(Q_,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=my(this.editor.config.get("fontSize.options")).filter((e=>e.model)),r=iy(Q_,i);t?(this._prepareAnyValueConverters(r),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(r),e.commands.add(Q_,new hy(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter((e=>{return!(t=String(e),Xh.test(t)||function(e){return em.test(e)}(String(e)));var t}));if(i.length)throw new _("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:Q_,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:Q_,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:Q_,value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let r=parseInt(t,10);i&&(r=3+r);const n=fy.length-1,o=Math.min(Math.max(r,0),n);return fy[o]}}})}}var wy=i(5195),ky={attributes:{"data-cke":!0}};ky.setAttributes=Un(),ky.insert=zn().bind(null,"head"),ky.domAPI=Fn(),ky.insertStyleElement=$n();Ln()(wy.A,ky);wy.A&&wy.A.locals&&wy.A.locals;class vy extends xs{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),r=e.commands.get(Q_),n=t("Font Size");e.ui.componentFactory.add(Q_,(t=>{const o=$m(t);return Km(o,(()=>function(e,t){const i=new Cn;for(const r of e){const e={type:"button",model:new Ep({commandName:Q_,commandParam:r.model,label:r.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};r.view&&"string"!=typeof r.view&&(r.view.styles&&e.model.set("labelStyle",`font-size:${r.view.styles["font-size"]}`),r.view.classes&&e.model.set("class",`${e.model.class} ${r.view.classes}`)),e.model.bind("isOn").to(t,"value",(e=>e===r.model)),i.add(e)}return i}(i,r)),{role:"menu",ariaLabel:n}),o.buttonView.set({label:n,icon:'',tooltip:!0}),o.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),o.bind("isEnabled").to(r),this.listenTo(o,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),o}))}_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 my(e.config.get(Q_).options).map((e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class _y extends xs{static get requires(){return[by,vy]}static get pluginName(){return"FontSize"}normalizeSizeOptions(e){return my(e)}}class yy extends Z_{constructor(e){super(e,ey)}}class xy extends xs{static get pluginName(){return"FontColorEditing"}constructor(e){super(e),e.config.define(ey,{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:ey,value:ry("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:ey,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:ey,view:ny("color")}),e.commands.add(ey,new yy(e)),e.model.schema.extend("$text",{allowAttributes:ey}),e.model.schema.setAttributeProperties(ey,{isFormatting:!0,copyOnEnter:!0})}}class Ay extends xs{constructor(e,{commandName:t,componentName:i,icon:r,dropdownLabel:n}){super(e),this.commandName=t,this.componentName=i,this.icon=r,this.dropdownLabel=n,this.columns=e.config.get(`${this.componentName}.columns`),this.colorSelectorView=void 0}init(){const e=this.editor,t=e.locale,i=t.t,r=e.commands.get(this.commandName),n=e.config.get(this.componentName),o=function(e){return e.map(To).filter((e=>!!e))}(n.colors),s=function(e,t){const i=e.t,r={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=r[e.label];return t&&t!=e.label&&(e.label=t),e}))}(t,o),a=n.documentColors,c=!1!==n.colorPicker;e.ui.componentFactory.add(this.componentName,(t=>{const o=$m(t);let l=!1;return this.colorSelectorView=function({dropdownView:e,colors:t,columns:i,removeButtonLabel:r,colorPickerLabel:n,documentColorsLabel:o,documentColorsCount:s,colorPickerViewConfig:a}){const c=e.locale,l=new zg(c,{colors:t,columns:i,removeButtonLabel:r,colorPickerLabel:n,documentColorsLabel:o,documentColorsCount:s,colorPickerViewConfig:a});return e.colorSelectorView=l,e.panelView.children.add(l),l}({dropdownView:o,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!==a?i("Document colors"):"",documentColorsCount:void 0===a?this.columns:a,colorPickerViewConfig:!!c&&(n.colorPicker||{})}),this.colorSelectorView.bind("selectedColor").to(r,"value"),o.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),o.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),o.bind("isEnabled").to(r),this.colorSelectorView.on("execute",((t,i)=>{o.isOpen&&e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),"colorPicker"!==i.source&&e.editing.view.focus(),"colorPickerSaveButton"===i.source&&(o.isOpen=!1)})),this.colorSelectorView.on("colorPicker:show",(()=>{this._undoStepBatch=e.model.createBatch()})),this.colorSelectorView.on("colorPicker:cancel",(()=>{this._undoStepBatch.operations.length&&(o.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()})),o.on("change:isOpen",((t,i,r)=>{l||(l=!0,o.colorSelectorView.appendUI()),r&&(0!==a&&this.colorSelectorView.updateDocumentColors(e.model,this.componentName),this.colorSelectorView.updateSelectedColors(),this.colorSelectorView.showColorGridsFragment())})),Jm(o,(()=>o.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find((e=>e.isOn)))),o}))}}class Cy extends Ay{constructor(e){const t=e.locale.t;super(e,{commandName:ey,componentName:ey,icon:'',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class Ey extends xs{static get requires(){return[xy,Cy]}static get pluginName(){return"FontColor"}}class Sy extends Z_{constructor(e){super(e,ty)}}class Ty extends xs{static get pluginName(){return"FontBackgroundColorEditing"}constructor(e){super(e),e.config.define(ty,{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(hm),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:ty,value:ry("background-color")}}),e.conversion.for("downcast").attributeToElement({model:ty,view:ny("background-color")}),e.commands.add(ty,new Sy(e)),e.model.schema.extend("$text",{allowAttributes:ty}),e.model.schema.setAttributeProperties(ty,{isFormatting:!0,copyOnEnter:!0})}}class Py extends Ay{constructor(e){const t=e.locale.t;super(e,{commandName:ty,componentName:ty,icon:'',dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class Iy extends xs{static get requires(){return[Ty,Py]}static get pluginName(){return"FontBackgroundColor"}}class My extends xs{static get requires(){return[uy,_y,Ey,Iy]}static get pluginName(){return"Font"}}function Oy(e,t){if(!e.childCount)return;const i=new Wh(e.document),r=function(e,t){const i=t.createRangeIn(e),r=new $s({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),n=[];for(const e of i)if("elementStart"===e.type&&r.match(e.item)){const t=By(e.item);n.push({element:e.item,id:t.id,order:t.order,indent:t.indent})}return n}(e,i);if(!r.length)return;let n=null,o=1;r.forEach(((e,s)=>{const a=function(e,t){if(!e)return!0;if(e.id!==t.id)return t.indent-e.indent!=1;const i=t.element.previousSibling;if(!i)return!0;return r=i,!(r.is("element","ol")||r.is("element","ul"));var r}(r[s-1],e),c=a?null:r[s-1],l=(u=e,(d=c)?u.indent-d.indent:u.indent-1);var d,u;if(a&&(n=null,o=1),!n||0!==l){const r=function(e,t){const i=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),r=/mso-level-number-format:([^;]{0,100});/gi,n=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,o=i.exec(t);let s="decimal",a="ol",c=null;if(o&&o[1]){const t=r.exec(o[1]);if(t&&t[1]&&(s=t[1].trim(),a="bullet"!==s&&"image"!==s?"ol":"ul"),"bullet"===s){const t=function(e){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;if("o"===i)return"circle";if("·"===i)return"disc";if("§"===i)return"square";return null}(e.element);t&&(s=t)}else{const e=n.exec(o[1]);e&&e[1]&&(c=parseInt(e[1]))}}return{type:a,startIndex:c,style:Ny(s)}}(e,t);if(n){if(e.indent>o){const e=n.getChild(n.childCount-1),t=e.getChild(e.childCount-1);n=Vy(r,t,i),o+=1}else if(e.indent1&&i.setAttribute("start",e.startIndex,n),n}function By(e){const t={},i=e.getStyle("mso-list");if(i){const e=i.match(/(^|\s{1,100})l(\d+)/i),r=i.match(/\s{0,100}lfo(\d+)/i),n=i.match(/\s{0,100}level(\d+)/i);e&&r&&n&&(t.id=e[2],t.order=r[1],t.indent=parseInt(n[1]))}return t}function Ry(e,t){if(!e.childCount)return;const i=new Wh(e.document),r=function(e,t){const i=t.createRangeIn(e),r=new $s({name:/v:(.+)/}),n=[];for(const e of i){if("elementStart"!=e.type)continue;const t=e.item,i=t.previousSibling,o=i&&i.is("element")?i.name:null;r.match(t)&&t.getAttribute("o:gfxdata")&&"v:shapetype"!==o&&n.push(e.item.getAttribute("id"))}return n}(e,i);!function(e,t,i){const r=i.createRangeIn(t),n=new $s({name:"img"}),o=[];for(const t of r)if(t.item.is("element")&&n.match(t.item)){const i=t.item,r=i.getAttribute("v:shapes")?i.getAttribute("v:shapes").split(" "):[];r.length&&r.every((t=>e.indexOf(t)>-1))?o.push(i):i.getAttribute("src")||o.push(i)}for(const e of o)i.remove(e)}(r,e,i),function(e,t,i){const r=i.createRangeIn(t),n=[];for(const t of r)if("elementStart"==t.type&&t.item.is("element","v:shape")){const i=t.item.getAttribute("id");if(e.includes(i))continue;o(t.item.parent.getChildren(),i)||n.push(t.item)}for(const e of n){const t={src:s(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const r=i.createElement("img",t);i.insertChild(e.index+1,r,e.parent)}function o(e,t){for(const i of e)if(i.is("element")){if("img"==i.name&&i.getAttribute("v:shapes")==t)return!0;if(o(i.getChildren(),t))return!0}return!1}function s(e){for(const t of e.getChildren())if(t.is("element")&&t.getAttribute("src"))return t.getAttribute("src")}}(r,e,i),function(e,t){const i=t.createRangeIn(e),r=new $s({name:/v:(.+)/}),n=[];for(const e of i)"elementStart"==e.type&&r.match(e.item)&&n.push(e.item);for(const e of n)t.remove(e)}(e,i);const n=function(e,t){const i=t.createRangeIn(e),r=new $s({name:"img"}),n=[];for(const e of i)e.item.is("element")&&r.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&n.push(e.item);return n}(e,i);n.length&&function(e,t,i){if(e.length===t.length)for(let r=0;rString.fromCharCode(parseInt(e,16)))).join(""))}const Dy=//i,Fy=/xmlns:o="urn:schemas-microsoft-com/i;class jy{constructor(e){this.document=e}isActive(e){return Dy.test(e)||Fy.test(e)}execute(e){const{body:t,stylesString:i}=e._parsedData;Oy(t,i),Ry(t,e.dataTransfer.getData("text/rtf")),function(e){const t=[],i=new Wh(e.document);for(const{item:r}of i.createRangeIn(e))if(r.is("element")){for(const e of r.getClassNames())/\bmso/gi.exec(e)&&i.removeClass(e,r);for(const e of r.getStyleNames())/\bmso/gi.exec(e)&&i.removeStyle(e,r);r.is("element","w:sdt")&&t.push(r)}for(const e of t){const t=e.parent,r=t.getChildIndex(e);i.insertChild(r,e.getChildren(),t),i.remove(e)}}(t),e.content=t}}function zy(e,t,i,{blockElements:r,inlineObjectElements:n}){let o=i.createPositionAt(e,"forward"==t?"after":"before");return o=o.getLastMatchingPosition((({item:e})=>e.is("element")&&!r.includes(e.name)&&!n.includes(e.name)),{direction:t}),"forward"==t?o.nodeAfter:o.nodeBefore}function Hy(e,t){return!!e&&e.is("element")&&t.includes(e.name)}const Uy=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class Wy{constructor(e){this.document=e}isActive(e){return Uy.test(e)}execute(e){const t=new Wh(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 r=e.getChildIndex(i);t.remove(i),t.insertChild(r,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 dc(t.document.stylesProcessor),r=new el(i,{renderingMode:"data"}),n=r.blockElements,o=r.inlineObjectElements,s=[];for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","br")){const i=zy(e,"forward",t,{blockElements:n,inlineObjectElements:o}),r=zy(e,"backward",t,{blockElements:n,inlineObjectElements:o}),a=Hy(i,n);(Hy(r,n)||a)&&s.push(e)}}for(const e of s)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(i,t),e.content=i}}const $y=/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length)))}function Ky(e,t){const i=new DOMParser,r=function(e){return Gy(Gy(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="",r=e.indexOf(t);if(r<0)return e;const n=e.indexOf(i,r+t.length);return e.substring(0,r+t.length)+(n>=0?e.substring(n):"")}(e=(e=e.replace(/