From 5b2e1bcc8293878d4ebc6d9810aca6e0eb40a840 Mon Sep 17 00:00:00 2001 From: mostafaznv Date: Fri, 5 May 2023 11:41:04 +0000 Subject: [PATCH 1/4] Update Assets --- dist/css/field.css | 2 +- dist/js/field.js | 2 +- dist/js/field.js.LICENSE.txt | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/css/field.css b/dist/css/field.css index 9a2a916..0291a3f 100644 --- a/dist/css/field.css +++ b/dist/css/field.css @@ -1 +1 @@ -.ck.ck-reset.ck-editor .ck.ck-toolbar{border-radius:10px 10px 0 0}.ck.ck-reset.ck-editor .ck-editor__editable_inline{border-radius:0 0 10px 10px;margin:0;padding:0 10px}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media{background-color:#fff;border:1px solid #dee2e6;border-radius:3px;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);display:inline-block;max-width:100%;padding:5px;text-align:center}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image img,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media img{height:auto;margin-bottom:4px;margin-left:auto;margin-right:auto;max-width:100%;width:100%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-left,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-right{clear:both;display:table;float:none;margin-left:auto;margin-right:auto;max-width:100%;width:auto}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image img,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center img,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-left img,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-right img{max-width:100%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-left,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-right{max-width:50%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center{max-width:75%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center:after{clear:both;display:block}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-right{float:right;margin-bottom:.5em;margin-left:1.5em;margin-top:.5em}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-left{float:left;margin-bottom:.5em;margin-right:1.5em;margin-top:.5em}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure figcaption{color:#000;font-size:13px;text-align:center}@media only screen and (max-width:768px){.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center{max-width:85%}}@media only screen and (max-width:576px){.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-left,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-right{float:none;margin-left:auto;margin-right:auto;max-width:100%}}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media{display:block;height:auto;width:auto}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media .embed-responsive{display:block;overflow:hidden;padding:0;position:relative;width:100%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media .embed-responsive:before{content:"";display:block}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media .embed-responsive-16by9:before{padding-top:56.25%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media .embed-responsive-16by9 .embed-responsive-item,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media .embed-responsive-16by9 iframe{border:0;bottom:0;height:100%;left:0;position:absolute;top:0;width:100%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table{-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar;display:block;overflow-x:auto;width:100%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table{background-color:#fff;box-shadow:0 0 15px #dee2e6;font-size-adjust:.5;margin-bottom:0;width:100%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table thead th{line-height:1em;text-align:left;white-space:nowrap}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table thead td,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table thead th{border:1px solid #dee2e6;padding:.5em;white-space:pre-wrap}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table tbody th{white-space:nowrap}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table tbody td,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table tbody th{border:1px solid #dee2e6;line-height:1em;min-width:50px;padding:.5em;vertical-align:top;white-space:pre-wrap}.ck.ck-reset.ck-editor .ck-editor__editable_inline *{font-family:Arial,Helvetica,sans-serif}.ck.ck-reset.ck-editor .ck-editor__editable_inline blockquote,.ck.ck-reset.ck-editor .ck-editor__editable_inline li,.ck.ck-reset.ck-editor .ck-editor__editable_inline ol,.ck.ck-reset.ck-editor .ck-editor__editable_inline p,.ck.ck-reset.ck-editor .ck-editor__editable_inline ul{font-size:13pt!important;line-height:1.6!important}.ck.ck-reset.ck-editor .ck-editor__editable_inline blockquote,.ck.ck-reset.ck-editor .ck-editor__editable_inline h1,.ck.ck-reset.ck-editor .ck-editor__editable_inline h2,.ck.ck-reset.ck-editor .ck-editor__editable_inline h3,.ck.ck-reset.ck-editor .ck-editor__editable_inline h4,.ck.ck-reset.ck-editor .ck-editor__editable_inline h5,.ck.ck-reset.ck-editor .ck-editor__editable_inline h6,.ck.ck-reset.ck-editor .ck-editor__editable_inline ol,.ck.ck-reset.ck-editor .ck-editor__editable_inline p,.ck.ck-reset.ck-editor .ck-editor__editable_inline ul{margin:15px 0}.ck.ck-reset.ck-editor .ck-editor__editable_inline h1,.ck.ck-reset.ck-editor .ck-editor__editable_inline h2,.ck.ck-reset.ck-editor .ck-editor__editable_inline h3,.ck.ck-reset.ck-editor .ck-editor__editable_inline h4,.ck.ck-reset.ck-editor .ck-editor__editable_inline h5,.ck.ck-reset.ck-editor .ck-editor__editable_inline h6{clear-after:both}.ck.ck-reset.ck-editor .ck-editor__editable_inline hr{background-color:#eee;border:none;clear:both;display:block;height:5px;margin:20px 0;padding:0}.ck.ck-editor__editable:not(.ck-editor__nested-editable).ck-focused{box-shadow:none!important}.ck-responsive-form .ck-labeled-input{display:block;float:none!important;margin-bottom:8px!important;margin-left:0!important;width:100%!important}.ck-widget.raw-html-embed .raw-html-embed__buttons-wrapper{z-index:1}.w-4\/5{width:80%}.p-sticky{position:-webkit-sticky;position:sticky}.max-h-full{max-height:100%} +.ck.ck-reset.ck-editor .ck.ck-toolbar{border-radius:10px 10px 0 0}.ck.ck-reset.ck-editor .ck-editor__editable_inline{border-radius:0 0 10px 10px;margin:0;padding:0 10px}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media{background-color:#fff;border:1px solid #dee2e6;border-radius:3px;box-shadow:0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);display:inline-block;max-width:100%;padding:5px;text-align:center}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image img,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media img{height:auto;margin-bottom:4px;margin-left:auto;margin-right:auto;max-width:100%;width:100%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-left,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-right{clear:both;display:table;float:none;margin-left:auto;margin-right:auto;max-width:100%;width:auto}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image img,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center img,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-left img,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-right img{max-width:100%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-left,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-right{max-width:50%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center{max-width:75%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center:after{clear:both;display:block}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-right{float:right;margin-bottom:.5em;margin-left:1.5em;margin-top:.5em}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-left{float:left;margin-bottom:.5em;margin-right:1.5em;margin-top:.5em}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure figcaption{color:#000;font-size:13px;text-align:center}@media only screen and (max-width:768px){.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center{max-width:85%}}@media only screen and (max-width:576px){.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-center,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-left,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.image.image-style-align-right{float:none;margin-left:auto;margin-right:auto;max-width:100%}}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media{display:block;height:auto;width:auto}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media .embed-responsive{display:block;overflow:hidden;padding:0;position:relative;width:100%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media .embed-responsive:before{content:"";display:block}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media .embed-responsive-16by9:before{padding-top:56.25%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media .embed-responsive-16by9 .embed-responsive-item,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.media .embed-responsive-16by9 iframe{border:0;bottom:0;height:100%;left:0;position:absolute;top:0;width:100%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table{-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar;display:block;overflow-x:auto;width:100%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table{background-color:#fff;box-shadow:0 0 15px #dee2e6;font-size-adjust:.5;margin-bottom:0;width:100%}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table thead th{line-height:1em;text-align:left;white-space:nowrap}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table thead td,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table thead th{border:1px solid #dee2e6;padding:.5em;white-space:pre-wrap}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table tbody th{white-space:nowrap}.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table tbody td,.ck.ck-reset.ck-editor .ck-editor__editable_inline figure.table table tbody th{border:1px solid #dee2e6;line-height:1em;min-width:50px;padding:.5em;vertical-align:top;white-space:pre-wrap}.ck.ck-reset.ck-editor .ck-editor__editable_inline *{font-family:Arial,Helvetica,sans-serif}.ck.ck-reset.ck-editor .ck-editor__editable_inline blockquote,.ck.ck-reset.ck-editor .ck-editor__editable_inline li,.ck.ck-reset.ck-editor .ck-editor__editable_inline ol,.ck.ck-reset.ck-editor .ck-editor__editable_inline p,.ck.ck-reset.ck-editor .ck-editor__editable_inline ul{font-size:13pt!important;line-height:1.6!important}.ck.ck-reset.ck-editor .ck-editor__editable_inline blockquote,.ck.ck-reset.ck-editor .ck-editor__editable_inline h1,.ck.ck-reset.ck-editor .ck-editor__editable_inline h2,.ck.ck-reset.ck-editor .ck-editor__editable_inline h3,.ck.ck-reset.ck-editor .ck-editor__editable_inline h4,.ck.ck-reset.ck-editor .ck-editor__editable_inline h5,.ck.ck-reset.ck-editor .ck-editor__editable_inline h6,.ck.ck-reset.ck-editor .ck-editor__editable_inline ol,.ck.ck-reset.ck-editor .ck-editor__editable_inline p,.ck.ck-reset.ck-editor .ck-editor__editable_inline ul{margin:15px 0}.ck.ck-reset.ck-editor .ck-editor__editable_inline h1,.ck.ck-reset.ck-editor .ck-editor__editable_inline h2,.ck.ck-reset.ck-editor .ck-editor__editable_inline h3,.ck.ck-reset.ck-editor .ck-editor__editable_inline h4,.ck.ck-reset.ck-editor .ck-editor__editable_inline h5,.ck.ck-reset.ck-editor .ck-editor__editable_inline h6{clear-after:both}.ck.ck-reset.ck-editor .ck-editor__editable_inline hr{background-color:#eee;border:none;clear:both;display:block;height:5px;margin:20px 0;padding:0}.ck.ck-editor__editable:not(.ck-editor__nested-editable).ck-focused{box-shadow:none!important}.ck-responsive-form .ck-labeled-input{display:block;float:none!important;margin-bottom:8px!important;margin-left:0!important;width:100%!important}.ck-widget.raw-html-embed .raw-html-embed__buttons-wrapper{z-index:1}.w-4\/5{width:80%}.p-sticky{position:sticky}.max-h-full{max-height:100%} diff --git a/dist/js/field.js b/dist/js/field.js index e7e52c9..e08e027 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","Align center":"Align center","Align left":"Align left","Align right":"Align right",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",Code:"Code",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","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","Empty snippet content":"Empty snippet content","Enter image caption":"Enter image caption","Font Background Color":"Font Background Color","Font Color":"Font Color","Font Family":"Font Family","Font Size":"Font Size","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","Horizontal line":"Horizontal line","HTML snippet":"HTML snippet",Huge:"Huge","Image toolbar":"Image toolbar","image widget":"image widget","In line":"In line","Increase indent":"Increase indent","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 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 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","Numbered List":"Numbered List","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",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","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 more items":"Show more items","Side image":"Side image",Small:"Small",Source:"Source","Split cell horizontally":"Split cell horizontally","Split cell vertically":"Split cell vertically",Strikethrough:"Strikethrough",Subscript:"Subscript",Superscript:"Superscript","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",Turquoise:"Turquoise",Underline:"Underline",Undo:"Undo",Unlink:"Unlink","Upload failed":"Upload failed","Upload in progress":"Upload in progress",White:"White","Widget toolbar":"Widget toolbar","Wrap text":"Wrap text",Yellow:"Yellow"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),(()=>{var __webpack_modules__={7757:(e,t,n)=>{e.exports=n(5666)},1185:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{Z:()=>__WEBPACK_DEFAULT_EXPORT__});var _ckeditor_ckeditor__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(7930),_snippet_browser__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(7791),_media_browser__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(8783),_mixins_hasUUID__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(9034),laravel_nova__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(9226),laravel_nova__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(laravel_nova__WEBPACK_IMPORTED_MODULE_4__),lodash_debounce__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(3279),lodash_debounce__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(lodash_debounce__WEBPACK_IMPORTED_MODULE_5__),regex_parser__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(9350),regex_parser__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(regex_parser__WEBPACK_IMPORTED_MODULE_6__);function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function _objectSpread(e){for(var t=1;t1&&t.editing.view.change((function(n){n.setStyle("height","".concat(e.field.height,"px"),t.editing.view.document.getRoot())})),e.field.readonly&&t.enableReadOnlyMode(e.$options[e.editorUUID])})).catch((function(t){e.$toasted.show(t.toString(),{type:"error"})}))},beforeUnmount:function(){var e=this;this.$options[this.editorName]&&this.$options[this.editorName].destroy().then((function(){return e.$options[e.editorName]=null})).catch((function(t){return e.$toasted.show(t.toString(),{type:"error"})}))}}},7556:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});const i="data:image/webp;base64,UklGRhAjAABXRUJQVlA4WAoAAAASAAAA/wAA/wAAQU5JTQYAAAAAAAD/AABBTk1G+AMAAAAAAAAAAP8AAP8AAEYAAAJWUDgg4AMAALAdAJ0BKgABAAE+USiTRqEEMqsEBAFBLS3cLsAWP5O/9AXwD//l8t5c6IMDtnbJd/oaOzcoYW2mW9x1gAqyLbTLe46wAVZFtplvcdYAKsi20y3uOsAFWRbaZb3HWACrIttJoy9avTLxwbGGfoJWsf8IF0x1gActLVsXlbNDwmIeUKhCaxCnSDrUJJB9UF/LL8y46wAVYzC/yg0/tyR+x78/CNJvoxFEveF3M1x0lESZxjrABVXb+RnjGWjRbKIEiDJU6Gdf2jNjjHWACrJia4wC6Y6wAVZFtplvcdYAKsi20y3uOsAFWRbaZb3HWACrIttMt7jUAAD+/v9Bx6G2bGZUcL4XL/d3UpnDj6w4+sOPwRobZriOoyiaRRPi8ZFslOwwi5cMW6eGAwMpGeBZHx6odmEvMztlp0GkPSqB+XTMlEx1GUTSDFkoBcNCSTnQaQ9KoH5dMyU7lqchxB36cgls1FBQcxtC3wwMiCWzUUFA8zb6Gp3s9TjoRZOX1Cn4wd18HQj61jLKIVNZ1iuV7WAAAI2B/PrXdqXtKZ4N4Bh8/P4F4ATZBgpEF711D8cfTPZjtPcXa5oBX2TeyLcuL6sLHIefdnYnlyAAAABqFZNQi072jYy02EBwx3buCFWH00k+yoGgSVa2lyDupn6VahW33YV0AAAIJhEguXPMrUk98EcHUvUUjN97fTsZmtrJUQKv6WEUvWTDk689hIYKVJ0xlgf/RJCy0OE8AWyzufTo8GOiZalEkwoI/eyYyfVXZ452ltZJN1g7DSQ9RvgrpzD/DTz+L6dQW8vvwtv7I3OlU+bpUrEdgjqSoJaP5CRlXbK6oVWb6iTmW1qR3jT2/NoFSNK0EIMjCV0tXyRlSuQnSH4JK63RoQsfFNKRQ1bp4YDAyuLhJQp2/XsD/atuLSeGokwuHZtjvJyu/L0roS8+KgX5NEM/BL0lwgOxSYm5/m7fs+ScFfHn1h7+7k9vHnbIllz0/yj6t/59z5Ns9FmP5fIW07UnZF5rpB6aagx1egrGX6SdY1FPzaA6V6PuGsXdukyvABgQDeHiqWKcpVh22ZhupSZiszXg/TJ5PgD12i0bCd3MM3zx/8TXsC8BlZMTh1Gug7hyj9iuzV1puO43UL5LKPg9JvCL0vxsl1FAg0170ACktdskvy3ubCgeozhLZqKCgQ+sOIO/TkAOEZ5xtDPSrnFkLDe7TWdhhFy6l2pyklXOLIWG8fEtuiqRjlU6MRcayE9iiSjlV3tktmooKDmNoW+T0AuGhJJxFaw4g79OQS2aigoOY2hb5PeryLRsJyk5DiDv05BLZqKCf+AAQU5NRq4CAAAxAAAxAAA7AAA7AABGAAAAQUxQSCoAAAABDzD/ERFCUQCQkQYiqa7Zze69I/ovICiywA3J4WbEp8n2zwECflzqowBWUDggZAIAAPAOAJ0BKjwAPAA+RRyLRAN/lcAAAIiWkADqE2ay7+E+lfmm+W8Sy1mr/J0wPGP0VqsRuDTvmcKlYc7EzmRO+eIFffVAGiAnyCXa98MzZkPbKdnKCRq0vRflGxyzZ8zOdH2K27tZF63aqrtih7mTEdo5/TLBG4YXKuo0sVtu4+0AAP7/1RyPVM7gMkGwG3loUKiXluV6b1ee6Taz7sPvUHuQvvmZumuSmEIPrX7R96shZAaOHqTe1oz499FxXraM2PJzFHD5D/SVi9GbQe6xhEU5BvUEr9xv22RU6W0vjHK0anoXi9fCB5OLyNLvfU/RnOUH5sj4mJVaZFgkTSbOf8ZORV7D3TSlya8IctQ7wiZFWXKV1EmCAkTJUQK1Tb6JapOnBZLXjJ6Obee3K4/fbnDQ+DIyuK/SwCGtqJDC5fzkYHZAR3OldmUKgOCPWnsV66Mtryrf/XF/lriCtJV1ZMObgncmygbMygF97Evih58ssjUsJWCx9aTu08bMuuNpqA8f2M2r9BgQ//Kcd3z7hen79c98ZOXfXwf2vilCiy5wo74w1o+e7pZZzoHyc9h/9Vm9ZYD9TC7t1oqKPw2H09faFf5U2KthssNZwO75lzX7n8DOOk2TMJL/qL/6HXIlvsvzcVWz+aRZvpoHLqwi7jbw1rK/v1+oXP9sx0IbQz12l8SjRcwnlHejMGQwnd+r6LMdDOt5wdg5Dy4p2kK9/5NXR1hN+4VpilVgVobl1Yu11QJ3phdBbSy2QaUc3Y+WTx1FH3dfqjUE/HIy218OmV3la5jF0l3mOWMf5uANHbKG+LIAAEFOTUbAAgAAMQAAMQAAOwAAOwAARgAAAEFMUEgsAAAAAQ8w/xERQk3bSMwzeEhH/Zn1qc4R/SebtDFr+4jWuA8kfr4bpLVRIDmu9ChWUDggdAIAABAPAJ0BKjwAPAA+TR6LRAN/FcAAAJiWkADqbsuYodx3TTtGKJ9tD/tIt1//8ClOGLzVbtSpUKOTcY/3kyme0CCaYYZ2b9NHE/w7S6i1pd0fAKi3ap4b/9/8egeK/yplj7SiCgLoksxhOAnP7OikmI8b0ZBuQLrPDdWmznukqeTQAAD+/9UcllgyMqF+xN2UQhvVvHYz+JXP6b1ee6krOr5yivQRKSJGL0+3k/yAtBdBbmIn/UuQdWPv/bw79D5aeQAYJbmVVEtm72G5zOOm2w+mG2yj71aAh/THL3uyJKkjioHNMDh6f+hHPeFVGj0gbKFIBECbuZcK5o9qm7szvlmIh4xsQperYdY3yIOxRNxr3gMXrrmNYM/H9YmLy1tcL3PHc0EFl1Vo0/zbTWpmbWMxV1TBeCXzrv0qSxxlf/BTNAdcmyTxUHAImCyoZ0rDh7PuiRVFthnHV2Z+ov8ntXL/ylkzy/t91xOGhFZ4BkmkRSj7Eh80tb12KUqxcO+vqtckZOSPV+/fRy9rTmr6VdbFS9hY9cv8WWgwuaUeIlkszySFI5BDXMXzPknAdeA24z14/5LOJYd+0fBX78cbsExiNe0/Ti0j2H8WZ5AcKXodqb39NYdeO7G/2bIBTSkPt/rE0JcG8To8U3HuPNcrhhG9Dk+cnAW1JhnJzIp7VAWSqmr5ZxvZ8eew36zcOjSYM+1rCX3vHdjlHnB5otRuaApApWpU9FGuDyX/NxQ6XdRZLTMKqN5TqFtD/1zfirfEAV5kDjnP2UG7P86Tm7mZcpfoomPntW9yKTzNnhTytEw/npkmBpgJTu7HFi1aJiTnwnVwAABBTk1GqAIAADEAADEAADsAADsAAEYAAABBTFBIMQAAAAEPMP8REUJRAJCRBiKprtnN7r0j+q+2bRtGLknGvCFZuA9ia7HrIOM/TkDAj5P0UQAAVlA4IFYCAABwDwCdASo8ADwAPkkejEQDf0CgAACQlpANULb5xnfSk6eW/pjGjsGprIP2sVUHICr8/voP6ux9G3WgopiulgNL4NZOT2GAQuDED9ue35WyX1L1N/rsbDzGjaUn/x6/Klav2sDGFr4rmCavQkBEJ3IwQGtiL75iRyPezPEyNwDF4T1YtAAA/v+1EFNCOdFIkmgBZuHCMWTe2tMwA1cqNgqTL0DFN9Eu1CL47/PId/ECuywJFWpcfp5gUVcCuL/WrVDHa9ar3eIHDZwV4JaD64fqyTfov2CGt+loB0rMauycdaBKVl9yz3lq2MHOMHQXtCXzqX4b1IFq/xezekU8xVgeMEet//VqxbKmQlDPMxp78cCboT4KIeAhH7vcGa/Vx7GmaZPI78WMxBZywc0hVYqOqSYlqazXUZBofVPZ7zf2x3WVrnAPlr4EoHBwOwT/Gao0O2RIpXS2lnKFG1Gx4KVQhZh/AUSmryihI4fKJ1NKlJE2loceu/rThRizxVSEFJl5HJ+/wJjIP/lvYKfz///22/Ubh6iLXrAqrUlknlVKsnoM+mh390v+HFGBgiyNC0fMHjaeakX9Sr3ECks++dJ95x8xhh39P5Asbbj0egO3G17/pKVJP040/HuEzT6TZAbo5YKNYKpwXPrmJcXHRBy0NftdDGfvHplySC9q2iszAKNYYUJBpHfmRu0Je2K3va4HuoqyiwSNj/It40TVpAc529xvdy9HfSpPPUvw0pC4TPmPZYMyeywKeOqE7zL3ltYxzeQLfHk4ZM5dBfxOg6OP4Jz+AAAAQU5NRqgCAAAxAAAxAAA7AAA7AABGAAAAQUxQSCkAAAABDzD/ERFCTdtIzDN4SEf9mfWpzhH9FxAUWeCG1vhTIDmuNA0yTTs/AQBWUDggXgIAAJAPAJ0BKjwAPAA+SRyMRAN/VcAAAJCWkA1QuCf+OxyLSy5+Wtpp2glE+yRfKT6JLhk+LowdfzocrR4gePwUlUv4IyN2sdzgrbIZsiLZs/CWR4eHWjl0bVn/7ky6h5zCPWer5XkS5KNwXEISc8Qpql54hHAbvGnEzgTyLhcWktvQovraAAAA/v+1EFfcl7JULrEOwbNw4Rc/CAshmp88RfKOTXKapVPOFNwy/y+pmLr214AVNEdrma7c57/sWjqWfZGOXFDlOFgp4jT6UdW3HqCDpH5Dk9gkgu6YRWeW+lcAYb/xRa5oX8zWxdxjNxOKD2+TnUeki78Hyy4jvY2AFiEZZojCWz8SHbN30HEvTLQJpc681QBg9q5trPu5a1zaO4NZw4ABnBlk90ngkokhebKFE147s+qpl35IqMuQLdYKesmfEkyARHGy1WwKLME4zcdQsKaLJVdIacM96AT8N12MbWjvRYApM8s7jI82jqQ8Py6Fj9XA+46FH82qH3JFZY5/0vcEnQ/mIO04x9EiHSavC6lUaiuGf3tv1IlS/zcf/0peSE1t0j9cFOk5G3SzXqh3o14kdqMvpSA4H9VvEEMZ1aW/chbSGI/j8OZiEdVxG1DHyeB/vC8WsIMNBvMqtFdgHXqlZwCGyUZLIzJnX47+E40ir+91Z5vRCAsaIJLwi6nShOf3L8B9vsMP1ze1r+ZvPPDCZTW5DugYBAIX5DzwH6NusMhKaYw0buToelRbrQsXcnNbzNK5y9K+tq+nsfuESVLBkkv7p2tannyw+EBWW/W1Z0MjwJiplWAAAEFOTUbEAgAAMQAAMQAAOwAAOwAARgAAAEFMUEgvAAAAAQ8w/xERQlEjSco6WEljfZwtHcM/ov8CgiIL3LA2PQy8zY5/TkD4uabbwNvs5CcAVlA4IHQCAAAQDwCdASo8ADwAPkkcjEQDf1XAAACQlpANUIDW3bxriz1vpEstZq/ydcPaP2VBujgejarHVnJRbeuiql5laj5mFES/aEHIFKOQYaxm4V7QLo75Z16f8ntt6xPSjyf5KZBNUb3lrCvThUWn2OVtZnnbqTkX4ryDgM29WalQOFEiUgAA/v+1EFfcmqJvhBPkSeoyj9qa8SBNjc/MZBlwzF1W+oKH1y98NNuona8Dtn8nQxQ8mZ7h1MdBHGh3vzTHm8Fjdjnvi9aYs6yF8vvzGucKM5lCM7QkAHMYYScEK73VVCMJpXFvmuG/6iK7YiAF+FohXXfHnjeu3aYvitvS0VXPjnlDJnhWJGoR1jhmE55PFPhiZ+MdniUKby2QtzZtIiPQ291d7lIf6d2ZL6SFLyxP8mGFI4vptiClKRE0XBfp6Uf1rgy0ngOE9FPo0ede/Wd2tkdb4OW6WlZC7XjhzBqdv9+1nOvb3GczFYxp+NjZc4j+S+O2/GcVqMEXB5DFMet1L3ZPE8gUNqYQS7k4vzR1HtarxKUsn/Mn+WY1+I6utMg9dn7iTCGb3Sg7902j9UKz//UfISDlZJZ7N2aGd3b9bSof66qDYtNHVgCcj4L06ReHIOp5nYN/jF/Rncpa0KQUZBjZdH5PlHmR5aFP17DwqMY6Eu4PC1+PYzH50yX9xR8iYTl5eneFLp9lqBaYTQTr1re3MrdYu9lSuBFqLfUq97J/+Ba+1O1mq8Xpg3fcJyaj7Tif+8GP8WUc66Mmu7OEivWey7G2sUGAYiSFcNZC3O9nEmfXd3bxb5L+Qn6PI5FwqEqdqb0bLbk+XOAAmX8AAAAAQU5NRq4CAAAxAAAxAAA6AAA7AABGAAAAQUxQSDQAAAABDzD/ERFCUdtIzv4W1lAfZtdrCET0n0DSxhX4a5S5/Eymle8/DxSe9qPW/ZApmkwrP38CVlA4IFoCAADwDgCdASo7ADwAPkkejEQDXy7MgACQlpANUJuTGn3gy1tJS0wnPKLMwUzLJvyLNoI91ciIKe6MUFC3MYj+WLaJY/UOzlfJ4/atyClGSAn0H4KEkubaVz+jMTh1Bs1IsRzbll3lwGI6YLreXhhW71NZPTVK9t+yWrihEnwLb4KmgAD+/7UQSk8vL3Vx0fA4XPXmkOd47yGanu46UZr/JNJDUN8DtYEkqbhPSfT1PXhGL87hi3bw2HlY7wYvr3RvAR2WRSTsD9m38a7k96QNriiSpIEE7iGWop8cblsOUjbydcRvmo7iv+CRoVkIhby/3eaM1vjcJvemAVxxcMUax3veuN5t7Gb/ZTb3LeKc2kRkruGRIebtf1DBcFhqXeCIv4Z6PRPrT7myHlxlE37uO6kcSN2/YYV698E/rBJmUYysZp2oEtUpFeBGKY5kLLID/6KoLwNlhmVMVGJJk6KxsYe+J/yVXfSWhYZxjmX648veblY6OxNDc9Sa/i4dY4G3ZUJtkVOxRjROccyNrZHXwN4EfhvMfkAY75HXBM/Kfbrwf8Du2l2raTl+Jxz/LKGqh7vrupw+eUNk+RW8cPv9UNSB/eb9lev3vG0V/GXdoWVipybFP/zoJ092jNM/8RkW+59vRI3wUv3uW3wwYOP7yqLKA69HniZnnzcmKgFigozRlrslEG0Z8Z4nF5DnrbhvDjVTXUmfUd56klx7uRfldgLCNoS/i9qoS71pySSHeEGxQVDFVVk7edF72iN2E3AFtJofzaorrPsQ0sPwZZh2ZnnxFKaiQd/+pFugAEFOTUakAgAAMQAAMQAAOwAAOwAARgAAAEFMUEgtAAAAAQ8w/xERQk3bSMwzeEhH/Zn1qc4R/SeQtHEF/hpa40+B5LjSIMR4vyCDtNYIAFZQOCBWAgAA8A4AnQEqPAA8AD5FHIlEA59i1QAAiJaQDVRbNxs8A6sVcAXGZEAncHS6pWpN7Lnf9C3EEcxyq3cnS8VOKpmt+d4oY9KdnUSIO/tWm5lclxEXkkxuf1OPY3QMQk+Vd5MnTaa17Sb7pVHhvgG435yLyjKTyy29NRXUv/eX24nfmAAA/v92NVacR3l/tn/Av/Zyn/w13KcnXkmxdo4Py6HHqLAJUN5zvucx5AMWanpDISLNC5TtLj0M5Sib2XKV9a2sShnX05+4y8cToEo9xW+TEF7Zb1O8W12NoRjVkk8IdLLuL8iYvQ4KurYIyhU3AuMmtkdbO1AheMktcA8asUr22dlzj/K1noW0TdsITmfh22T5t7nmH9NA7SMgXHf/uSoNXw3BWAu7IadvagODPFC5unKp58aOZMQZZhpa3hiYS8Clf7CSO0rG3Pepl+31EdOvxFipH9k3V6ZoE1s7YK4bjrBRmH4tLZhofPvE4hgUOLp1chu5tqfaSxwFiEG5L2Bxu8P3UbektCs1FVinhxjSfmMPpmwAqHcWPqaA7CpANpOplGny9IUBnKgHOuWOD+8bFEvJnjoWHtRLmNw/Z+21nkFO4FvK3/eF/kqx35+Zeh2WLRImpsp2JsbiPiJieFondpg99iQsDOYO89H/OSlRwVh6T0UGFVchqhZTMFrOaK5IFJIZxCI05/ERPMxQieb/Gb2Lmf2Bf3h7vInvm/5thtt5a5BLxAykA6ajELtyY+NtZT2VOV+BLefIrQfzoM+TY/jfsqUaVJcoteVdX+mOMShDNhcAAEFOTUaoAgAAMQAAMQAAOwAAOwAARgAAAEFMUEgoAAAAAQ8w/xERQk3bSMwzeEhH/Zn1qc4R/RcSJJg9ojX+FEiOKw2CTCtfK1ZQOCBgAgAAcA8AnQEqPAA8AD5FHIhEA592AACIlpANVIMA7WMevOa6AOUzUZtFAZ7LYyvaxvNFmfnUqbfyz0QRpstx+gv4d0Hgq6OUuu0UV7q1Xk2xXeEEvOUz4MzmOH97lwC0HZ/16Um1IAAOrCrtvEA6GfzGmJWEknfhXqxmxKq7GuAXVj2ST6oAAP75bxK+N5e/he4pXtl4U8mM7P+CCA/zd3/tczTbuLcCqZftyxIPjZnBh6Vhl/2jOyXOc4gUsK4p1RWeMfVO11qbnBDCnaeRVDijhBszZ6E85eazOEPKgVjW4U05lmqb9/uonx4x5MwdSi1jvJ1TtyVJ2GnvrPrQ2TNerWGx1N8sPhjyIOPUvuRth54bRIhUg8Qqaswueu4nAOFbBibOC92eXdDo3IZCKHPRf3gmftp3Pivu1jt7SMnKOtVNpkE+fsX0LDj400eU98v66UT6b5uLXoNCwcLX1y5E+f+lYtXQMP0jSlBp0FpZf5Dzq3ZlBzma+eCyVI4TeTbJzqosRDW4unrwSEg/xI1l2fyisnK7g5LVCmmyCuE5KHhDaBUdGLzHcz382qidQMgVuEEoGnRLLYUmkLlNG0w5Vmuj4+NfJzyyimKmh/JsCRwvVsGlrIkVvVvx9p4eZsAhkyu0KaXw+WLOHOPUGFT0YmSiRsu35QVishy7DYSASgQJjX5S4NAGWV4+ON9g0zz6vHFIr+P70VeluLXsARV4UXRJtQNS1Q4FtPwK9ZkpQKYWNHZbKmPIgd1D3QHNRGKaYbLxNAb5SUpjC3YoqQTItIzske2GEq4aPHzN5//gAABBTk1GmgIAADEAADEAADsAADoAAEYAAABBTFBIKAAAAAEPMP8REUJN20jMM3hIR/2Z9anOEf0XEiSYPaI1/hRIjisNgkwrXwtWUDggUgIAALAOAJ0BKjwAOwA+UR6LRCEHPikABAFBLSAaqLa2NvOtlr6adpot5SPiQSXcPNlXVjhTaqb6wFDn/8dddJff1R8zJUTb+R1zqIgkfAYPZeZFSXyqzzHGegDFWrBJOt577+AjZcpWoA1AscaLLcbdJyUnlcfwLFV73YyFa8an8AD+/3Y1g/DsEKjkyYZfu99LFNfWef+uW+8IdovdAYOomw4nNwYxLvC6/4sI4x8GUbK4zkS2wgRwBha80ZU5aCPkxVwEH7kEXtXlHbhrJ2KgSkN5m7KAzlizmSIv+NW6bxGmn/yINxb67/cT2SfhyzmybcCwtMPPKHqMKJYZDKVS5/amMcfRdu0XPeCPe5xFIdFDH0fsxQzajXiXsYeyZsTh7czGMlLX+cANZZm0Lahe6kzQYtlayDqtreP8QoX/I5nNz/5pKIPlLrM2yyq6feTbdnZTnTEFm2/Twq7kkuD8HDSAe+6WGSvq+smhfgKO9EXLiRuan1+3gqplAYAGiAFOzUAjALbG6Rp0RXbBhEcx5X6/m83zYY1s6k67+seyAc0CChzTCId1fI/Ci2LxpYu/DTlC18S6kf8+pkReoMxeLINIlVpSuBom2qGyU4CZxCLpwtDTYKQKdr6eHOt2XqxrKI+wj07XkT0ff2yFwMqUoN9ZfTYpYHurIINRzrxJmnZT9eJNy8tDCUZE69s+Sm93gSzMmyA05rElBKZJPdCS+2zfrv9YTJDNjURyOVrcGimUIRmSuFMmMNq1fafJwcJg4iA8Ys5GnXrejSeEZEcYAeLgAEFOTUaoAgAAMQAAMQAAOwAAOwAARgAAAEFMUEgtAAAAAQ8w/xERQlEkqREOkLTW1xmQ7IvjH9F/IUGC2SOheR9wmnzDYDxOGgROk68VAFZQOCBaAgAA8A4AnQEqPAA8AD5FHIpEA592gAAAiJaQDVRbb5z449ghphmnDv2psVpgNPX7hrBFk408J2wM0iJCAeLEjsNOO7Cwg0x0izQzkpkMGZ9czL08RtDfeAVL+fiiqC5iSEZ10v4/ZJ4YgDv5gZjaHJx09gRSoTIrGGGxEQR4lBMmywAA/v92NQnYQdt+lKNg2R6dsvvJTxFHYpkUdFMWe2kazz/FhHCuj5zAS9AI/E51IpyV2V8PAVw4W8Znp3XAg0pR+wKCupm+W2aGs9H5YoH/Rt+B+96Qa/s8pm6f/Sj+uf+DwAOLvI2K6v6X4Hfum8u42D4IJ1Ju2rA5vt0hq22A7qX5/Y53VjTiGD8jvMNVug5Md1oClnc0V3Gkb6y+TZgr76/CRKatYqW1GAHoqJsc5eWHFEuTBhqEoHxx3ux195XlLoG8xpuK+eqGtxyJTuoMOL1h8dO87M2/iEClFvpLa44RSRZfg/DJzShSH8VvpbbDo582X3/af2nv0oXmt/Y/XxRLHAnHeCjnsamwFA3pqJR3dKVXOvp0n7da9x+nv08nwkY6CDFPD/ZWNM9fJJbEr8L4IHT9HfPFWt055iIg0ht0rIYgWvlmC7BMqI0ynlctiCaRXNOytXGm9LzS2PmRS9sjUwpdHgC4pCrDD/tR7meR67vSiWnAZkxWvrenoO9TDMxcriD63xJH+Sbmm73Cr4+zBW52MbrTvl/h57fCBbwmOR8cW5sa+kcwA87gCmfTFooG21nFxja65a7i3vCgo0NZluaw5cERzFoa8BS4B96VAuJkM2FwAABBTk1G1gMAAAAAAAAAAP8AAP8AAEYAAAJWUDggvgMAANAdAJ0BKgABAAE+USiSRqEEOpMCBAFBLS3cLsAWP5O/9AXwD//l8t14zO4mWppoWjQYHZuUMLbMYBcTUAVZFtmMAuJqAKsi2zGAXE1AFWRbZjALiagCrItsxgFxNQBVkW2XMuOqmh/LIXHKngz0v5ubGGzGAXE0WY7Mx2fzaDtRF5QqEKBiVIN0kBvaw+w9i62zGAXEtdh19f9hvx5jNvzpnz4XTSi8qCFyXIQ+1u2sJ1WRbZi9VUbiQPPqYRWmKttDMKEIokC+lDgAqyLbMaFuJqAKsi2zGAXE1AFWRbZjALiagCrItsxgFxNQBVkW2YwC4moApgAA/v7/QcehtmxmVHC+Fy/3d1KZw4+sOPrDj8EaG2a4jqMomkUT4vGRbJTsMIuXDFunhgMDKRngWR8eqHZhLzM7ZadBpD0qgfl0zJRMdRlE0gxZKAXDQkk50GkPSqB+XTMlO5anIcQd+nIJbNRQUHMbQt8MDIgls1FBQPM7fQvxid6z3OhVgaIeGvNWELlByw+VKnmE74KghF2g+oraMjeQ0IHAAATf+IUjP0b3+vfHcyHxR4nLitt0YxVMHmpar3By30m8f0drBIz/E3GUFyAsm/eJ8BM+ZBKbgFCyPcwfRAAANwnqh2YXeyi2SnYYPs9fjgMohLWNwvTkVQJDomtJL3FW7pAAAANl7kvSlw0fZLfWf+XiZhy1R8L7A91imtE+5MHB2gl43/onTacgGR/ArpIa6mTpv5kYnt0yRfDLB5O0z0KkzPZr+rWd6Pp2cQjTwt75pVP1FnMWbzTW/N/jgKYr/g1lNgR/ROwrlwhxxN32Y356Y6Pf5lqbP5AGoUnydN11Tw9v8tds0pwSS20V7d8REm7Vbf5jvK0aK6i9kFDRJvndZzbl2ccR0/8459E9ALhoADXJTsMIvjFIpnRGk0yhb7h4SBEySm9kp9FN4Z1UibyPJu1p3AOBmmQ2arBatrnnqiTBinmL3g4wBADGOKqKwZBasFPYeWD7zfinTEkxtlWbH/Cu8jK/7RjIamsWIKn2LbGRDm9/1nAHrtFo2E7uYZvnj/4fwSC/y7dAKXCIZyoXe8ldxQMVkeUcWJn3PiDXy8UB7c2n7h1jqLd2CvlsS7NdGshPYoLMnj1Q7MJaL46FBQsdadBpD0qg9HkWjYTlJyklXy48iqRjlU6DyilpsID4ppSKVjmxlpsID5bS2kY5VOjEXGshPYoko5VOg8opabCA+KaUilY5sZabCA+W0tpGOVToxFxrIT2KJKOVTn/AAAA="},7930:(e,t,n)=>{"use strict";n.d(t,{Z:()=>HT});const i=function(){try{return navigator.userAgent.toLowerCase()}catch(e){return""}}(),o={isMac:s(i),isWindows:function(e){return e.indexOf("windows")>-1}(i),isGecko:function(e){return!!e.match(/gecko\/\d+/)}(i),isSafari:function(e){return e.indexOf(" applewebkit/")>-1&&-1===e.indexOf("chrome")}(i),isiOS:function(e){return!!e.match(/iphone|ipad/i)||s(e)&&navigator.maxTouchPoints>0}(i),isAndroid:function(e){return e.indexOf("android")>-1}(i),isBlink:function(e){return e.indexOf("chrome/")>-1&&e.indexOf("edge/")<0}(i),features:{isRegExpUnicodePropertySupported:function(){let e=!1;try{e=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch(e){}return e}()}},r=o;function s(e){return e.indexOf("macintosh")>-1}function a(e,t,n,i){n=n||function(e,t){return e===t};const o=Array.isArray(e)?e:Array.prototype.slice.call(e),r=Array.isArray(t)?t:Array.prototype.slice.call(t),s=function(e,t,n){const i=c(e,t,n);if(-1===i)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const o=l(e,i),r=l(t,i),s=c(o,r,n),a=e.length-s,d=t.length-s;return{firstIndex:i,lastIndexOld:a,lastIndexNew:d}}(o,r,n),a=i?function(e,t){const{firstIndex:n,lastIndexOld:i,lastIndexNew:o}=e;if(-1===n)return Array(t).fill("equal");let r=[];n>0&&(r=r.concat(Array(n).fill("equal")));o-n>0&&(r=r.concat(Array(o-n).fill("insert")));i-n>0&&(r=r.concat(Array(i-n).fill("delete")));o0&&n.push({index:i,type:"insert",values:e.slice(i,r)});o-i>0&&n.push({index:i+(r-i),type:"delete",howMany:o-i});return n}(r,s);return a}function c(e,t,n){for(let i=0;i200||o>200||i+o>300)return d.fastDiff(e,t,n,!0);let r,s;if(ol?-1:1;u[i+d]&&(u[i]=u[i+d].slice(0)),u[i]||(u[i]=[]),u[i].push(o>l?r:s);let m=Math.max(o,l),f=m-i;for(;fl;f--)h[f]=m(f);h[l]=m(l),g++}while(h[l]!==c);return u[l].slice(1)}function u(e,...t){t.forEach((t=>{const n=Object.getOwnPropertyNames(t),i=Object.getOwnPropertySymbols(t);n.concat(i).forEach((n=>{if(n in e.prototype)return;if("function"==typeof t&&("length"==n||"name"==n||"prototype"==n))return;const i=Object.getOwnPropertyDescriptor(t,n);i.enumerable=!1,Object.defineProperty(e.prototype,n,i)}))}))}d.fastDiff=a;const h=function(){return function e(){e.called=!0}};class m{constructor(e,t){this.source=e,this.name=t,this.path=[],this.stop=h(),this.off=h()}}const f=new Array(256).fill("").map(((e,t)=>("0"+t.toString(16)).slice(-2)));function g(){const e=4294967296*Math.random()>>>0,t=4294967296*Math.random()>>>0,n=4294967296*Math.random()>>>0,i=4294967296*Math.random()>>>0;return"e"+f[e>>0&255]+f[e>>8&255]+f[e>>16&255]+f[e>>24&255]+f[t>>0&255]+f[t>>8&255]+f[t>>16&255]+f[t>>24&255]+f[n>>0&255]+f[n>>8&255]+f[n>>16&255]+f[n>>24&255]+f[i>>0&255]+f[i>>8&255]+f[i>>16&255]+f[i>>24&255]}const p={get(e="normal"){return"number"!=typeof e?this[e]||this.normal:e},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};function b(e,t){const n=p.get(t.priority);for(let i=0;i{if("object"==typeof t&&null!==t){if(n.has(t))return`[object ${t.constructor.name}]`;n.add(t)}return t},o=t?` ${JSON.stringify(t,i)}`:"",r=_(e);return e+o+r}(e,n)),this.name="CKEditorError",this.context=t,this.data=n}is(e){return"CKEditorError"===e}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;const n=new w(e.message,t);throw n.stack=e.stack,n}}function k(e,t){console.warn(...v(e,t))}function _(e){return`\nRead more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-${e}`}function v(e,t){const n=_(e);return t?[e,t,n]:[e,n]}const y="35.4.0",x="object"==typeof window?window:n.g;if(x.CKEDITOR_VERSION)throw new w("ckeditor-duplicated-modules",null);x.CKEDITOR_VERSION=y;const A=Symbol("listeningTo"),C=Symbol("emitterId"),E=Symbol("delegations"),T=S(Object);function S(e){if(!e)return T;return class extends e{on(e,t,n){this.listenTo(this,e,t,n)}once(e,t,n){let i=!1;this.listenTo(this,e,((e,...n)=>{i||(i=!0,e.off(),t.call(this,e,...n))}),n)}off(e,t){this.stopListening(this,e,t)}listenTo(e,t,n,i={}){let o,r;this[A]||(this[A]={});const s=this[A];I(e)||P(e);const a=I(e);(o=s[a])||(o=s[a]={emitter:e,callbacks:{}}),(r=o.callbacks[t])||(r=o.callbacks[t]=[]),r.push(n),function(e,t,n,i,o){t._addEventListener?t._addEventListener(n,i,o):e._addEventListener.call(t,n,i,o)}(this,e,t,n,i)}stopListening(e,t,n){const i=this[A];let o=e&&I(e);const r=i&&o?i[o]:void 0,s=r&&t?r.callbacks[t]:void 0;if(!(!i||e&&!r||t&&!s))if(n){D(this,e,t,n);-1!==s.indexOf(n)&&(1===s.length?delete r.callbacks[t]:D(this,e,t,n))}else if(s){for(;n=s.pop();)D(this,e,t,n);delete r.callbacks[t]}else if(r){for(t in r.callbacks)this.stopListening(e,t);delete i[o]}else{for(o in i)this.stopListening(i[o].emitter);delete this[A]}}fire(e,...t){try{const n=e instanceof m?e:new m(this,e),i=n.name;let o=R(this,i);if(n.path.push(this),o){const e=[n,...t];o=Array.from(o);for(let t=0;t{this[E]||(this[E]=new Map),e.forEach((e=>{const i=this[E].get(e);i?i.set(t,n):this[E].set(e,new Map([[t,n]]))}))}}}stopDelegating(e,t){if(this[E])if(e)if(t){const n=this[E].get(e);n&&n.delete(t)}else this[E].delete(e);else this[E].clear()}_addEventListener(e,t,n){!function(e,t){const n=M(e);if(n[t])return;let i=t,o=null;const r=[];for(;""!==i&&!n[i];)n[i]={callbacks:[],childEvents:[]},r.push(n[i]),o&&n[i].childEvents.push(o),o=i,i=i.substr(0,i.lastIndexOf(":"));if(""!==i){for(const e of r)e.callbacks=n[i].callbacks.slice();n[i].childEvents.push(o)}}(this,e);const i=O(this,e),o={callback:t,priority:p.get(n.priority)};for(const e of i)b(e,o)}_removeEventListener(e,t){const n=O(this,e);for(const e of n)for(let n=0;n-1?R(e,t.substr(0,t.lastIndexOf(":"))):null}function N(e,t,n){for(let[i,o]of e){o?"function"==typeof o&&(o=o(t.name)):o=t.name;const e=new m(t.source,o);e.path=[...t.path],i.fire(e,...n)}}function D(e,t,n,i){t._removeEventListener?t._removeEventListener(n,i):e._removeEventListener.call(t,n,i)}["on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach((e=>{S[e]=T.prototype[e]}));const L=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},V=Symbol("observableProperties"),B=Symbol("boundObservables"),j=Symbol("boundProperties"),z=Symbol("decoratedMethods"),F=Symbol("decoratedOriginal"),U=H(S());function H(e){if(!e)return U;return class extends e{set(e,t){if(L(e))return void Object.keys(e).forEach((t=>{this.set(t,e[t])}),this);W(this);const n=this[V];if(e in this&&!n.has(e))throw new w("observable-set-cannot-override",this);Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>n.get(e),set(t){const i=n.get(e);let o=this.fire(`set:${e}`,e,t,i);void 0===o&&(o=t),i===o&&n.has(e)||(n.set(e,o),this.fire(`change:${e}`,e,o,i))}}),this[e]=t}bind(...e){if(!e.length||!$(e))throw new w("observable-bind-wrong-properties",this);if(new Set(e).size!==e.length)throw new w("observable-bind-duplicate-properties",this);W(this);const t=this[j];e.forEach((e=>{if(t.has(e))throw new w("observable-bind-rebind",this)}));const n=new Map;return e.forEach((e=>{const i={property:e,to:[]};t.set(e,i),n.set(e,i)})),{to:q,toMany:Z,_observable:this,_bindProperties:e,_to:[],_bindings:n}}unbind(...e){if(!this[V])return;const t=this[j],n=this[B];if(e.length){if(!$(e))throw new w("observable-unbind-wrong-properties",this);e.forEach((e=>{const i=t.get(e);i&&(i.to.forEach((([e,t])=>{const o=n.get(e),r=o[t];r.delete(i),r.size||delete o[t],Object.keys(o).length||(n.delete(e),this.stopListening(e,"change"))})),t.delete(e))}))}else n.forEach(((e,t)=>{this.stopListening(t,"change")})),n.clear(),t.clear()}decorate(e){W(this);const t=this[e];if(!t)throw new w("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:e});this.on(e,((e,n)=>{e.return=t.apply(this,n)})),this[e]=function(...t){return this.fire(e,t)},this[e][F]=t,this[z]||(this[z]=[]),this[z].push(e)}stopListening(e,t,n){if(!e&&this[z]){for(const e of this[z])this[e]=this[e][F];delete this[z]}super.stopListening(e,t,n)}}}function W(e){e[V]||(Object.defineProperty(e,V,{value:new Map}),Object.defineProperty(e,B,{value:new Map}),Object.defineProperty(e,j,{value:new Map}))}function q(...e){const t=function(...e){if(!e.length)throw new w("observable-bind-to-parse-error",null);const t={to:[]};let n;"function"==typeof e[e.length-1]&&(t.callback=e.pop());return e.forEach((e=>{if("string"==typeof e)n.properties.push(e);else{if("object"!=typeof e)throw new w("observable-bind-to-parse-error",null);n={observable:e,properties:[]},t.to.push(n)}})),t}(...e),n=Array.from(this._bindings.keys()),i=n.length;if(!t.callback&&t.to.length>1)throw new w("observable-bind-to-no-callback",this);if(i>1&&t.callback)throw new w("observable-bind-to-extra-callback",this);var o;t.to.forEach((e=>{if(e.properties.length&&e.properties.length!==i)throw new w("observable-bind-to-properties-length",this);e.properties.length||(e.properties=this._bindProperties)})),this._to=t.to,t.callback&&(this._bindings.get(n[0]).callback=t.callback),o=this._observable,this._to.forEach((e=>{const t=o[B];let n;t.get(e.observable)||o.listenTo(e.observable,"change",((i,r)=>{n=t.get(e.observable)[r],n&&n.forEach((e=>{K(o,e.property)}))}))})),function(e){let t;e._bindings.forEach(((n,i)=>{e._to.forEach((o=>{t=o.properties[n.callback?0:e._bindProperties.indexOf(i)],n.to.push([o.observable,t]),function(e,t,n,i){const o=e[B],r=o.get(n),s=r||{};s[i]||(s[i]=new Set);s[i].add(t),r||o.set(n,s)}(e._observable,n,o.observable,t)}))}))}(this),this._bindProperties.forEach((e=>{K(this._observable,e)}))}function Z(e,t,n){if(this._bindings.size>1)throw new w("observable-bind-to-many-not-one-binding",this);this.to(...function(e,t){const n=e.map((e=>[e,t]));return Array.prototype.concat.apply([],n)}(e,t),n)}function $(e){return e.every((e=>"string"==typeof e))}function K(e,t){const n=e[j].get(t);let i;n.callback?i=n.callback.apply(e,n.to.map((e=>e[0][e[1]]))):(i=n.to[0],i=i[0][i[1]]),Object.prototype.hasOwnProperty.call(e,t)?e[t]=i:e.set(t,i)}["set","bind","unbind","decorate","on","once","off","listenTo","stopListening","fire","delegate","stopDelegating","_addEventListener","_removeEventListener"].forEach((e=>{H[e]=U.prototype[e]}));class G{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 Y(e){let t=0;for(const n of e)t++;return t}function Q(e,t){const n=Math.min(e.length,t.length);for(let i=0;i-1};const Me=function(e,t){var n=this.__data__,i=Ee(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this};function Oe(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991};var Ut={};Ut["[object Float32Array]"]=Ut["[object Float64Array]"]=Ut["[object Int8Array]"]=Ut["[object Int16Array]"]=Ut["[object Int32Array]"]=Ut["[object Uint8Array]"]=Ut["[object Uint8ClampedArray]"]=Ut["[object Uint16Array]"]=Ut["[object Uint32Array]"]=!0,Ut["[object Arguments]"]=Ut["[object Array]"]=Ut["[object ArrayBuffer]"]=Ut["[object Boolean]"]=Ut["[object DataView]"]=Ut["[object Date]"]=Ut["[object Error]"]=Ut["[object Function]"]=Ut["[object Map]"]=Ut["[object Number]"]=Ut["[object Object]"]=Ut["[object RegExp]"]=Ut["[object Set]"]=Ut["[object String]"]=Ut["[object WeakMap]"]=!1;const Ht=function(e){return me(e)&&Ft(e.length)&&!!Ut[ue(e)]};const Wt=function(e){return function(t){return e(t)}};var qt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Zt=qt&&"object"==typeof module&&module&&!module.nodeType&&module,$t=Zt&&Zt.exports===qt&&X.process;const Kt=function(){try{var e=Zt&&Zt.require&&Zt.require("util").types;return e||$t&&$t.binding&&$t.binding("util")}catch(e){}}();var Gt=Kt&&Kt.isTypedArray;const Yt=Gt?Wt(Gt):Ht;var Qt=Object.prototype.hasOwnProperty;const Jt=function(e,t){var n=he(e),i=!n&&Rt(e),o=!n&&!i&&Bt(e),r=!n&&!i&&!o&&Yt(e),s=n||i||o||r,a=s?St(e.length,String):[],c=a.length;for(var l in e)!t&&!Qt.call(e,l)||s&&("length"==l||o&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||zt(l,c))||a.push(l);return a};var Xt=Object.prototype;const en=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Xt)};const tn=pe(Object.keys,Object);var nn=Object.prototype.hasOwnProperty;const on=function(e){if(!en(e))return tn(e);var t=[];for(var n in Object(e))nn.call(e,n)&&"constructor"!=n&&t.push(n);return t};const rn=function(e){return null!=e&&Ft(e.length)&&!Be(e)};const sn=function(e){return rn(e)?Jt(e):on(e)};const an=function(e,t){return e&&Tt(t,sn(t),e)};const cn=function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t};var ln=Object.prototype.hasOwnProperty;const dn=function(e){if(!L(e))return cn(e);var t=en(e),n=[];for(var i in e)("constructor"!=i||!t&&ln.call(e,i))&&n.push(i);return n};const un=function(e){return rn(e)?Jt(e,!0):dn(e)};const hn=function(e,t){return e&&Tt(t,un(t),e)};var mn="object"==typeof exports&&exports&&!exports.nodeType&&exports,fn=mn&&"object"==typeof module&&module&&!module.nodeType&&module,gn=fn&&fn.exports===mn?te.Buffer:void 0,pn=gn?gn.allocUnsafe:void 0;const bn=function(e,t){if(t)return e.slice();var n=e.length,i=pn?pn(n):new e.constructor(n);return e.copy(i),i};const wn=function(e,t){var n=-1,i=e.length;for(t||(t=Array(i));++n{this._setToTarget(e,i,t[i],n)}))}}function yi(e){return ki(e,xi)}function xi(e){return _i(e)?e:void 0}function Ai(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 Ci(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}const Ei=Ti(S());function Ti(e){if(!e)return Ei;return class extends e{listenTo(e,t,n,i={}){if(Ai(e)||Ci(e)){const o={capture:!!i.useCapture,passive:!!i.usePassive},r=this._getProxyEmitter(e,o)||new Si(e,o);this.listenTo(r,t,n,i)}else super.listenTo(e,t,n,i)}stopListening(e,t,n){if(Ai(e)||Ci(e)){const i=this._getAllProxyEmitters(e);for(const e of i)this.stopListening(e,t,n)}else super.stopListening(e,t,n)}_getProxyEmitter(e,t){return function(e,t){const n=e[A];return n&&n[t]?n[t].emitter:null}(this,Pi(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=>{Ti[e]=Ei.prototype[e]}));class Si extends(S()){constructor(e,t){super(),P(this,Pi(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,n){this.attach(e),S().prototype._addEventListener.call(this,e,t,n)}_removeEventListener(e,t){S().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 Pi(e,t){let n=function(e){return e["data-ck-expando"]||(e["data-ck-expando"]=g())}(e);for(const e of Object.keys(t).sort())t[e]&&(n+="-"+e);return n}let Ii;try{Ii={window,document}}catch(e){Ii={window:{},document:{}}}const Mi=Ii;function Oi(e){const t=[];let n=e;for(;n&&n.nodeType!=Node.DOCUMENT_NODE;)t.unshift(n),n=n.parentNode;return t}function Ri(e){return"[object Text]"==Object.prototype.toString.call(e)}function Ni(e){return"[object Range]"==Object.prototype.toString.apply(e)}function Di(e){const t=e.ownerDocument.defaultView.getComputedStyle(e);return{top:parseInt(t.borderTopWidth,10),right:parseInt(t.borderRightWidth,10),bottom:parseInt(t.borderBottomWidth,10),left:parseInt(t.borderLeftWidth,10)}}const Li=["top","right","bottom","left","width","height"];class Vi{constructor(e){const t=Ni(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),zi(e)||t)if(t){const t=Vi.getDomRangeRects(e);Bi(this,Vi.getBoundingRect(t))}else Bi(this,e.getBoundingClientRect());else if(Ci(e)){const{innerWidth:t,innerHeight:n}=e;Bi(this,{top:0,right:t,bottom:n,left:0,width:t,height:n})}else Bi(this,e)}clone(){return new Vi(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};return t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0?null:new Vi(t)}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(!ji(e)){let n=e.parentNode||e.commonAncestorContainer;for(;n&&!ji(n);){const e=new Vi(n),i=t.getIntersection(e);if(!i)return null;i.getArea(){for(const t of e){const e=Fi._getElementCallbacks(t.target);if(e)for(const n of e)n(t)}}))}}function Ui(e,t){e instanceof HTMLTextAreaElement&&(e.value=t),e.innerHTML=t}function Hi(e){return t=>t+e}function Wi(e){let t=0;for(;e.previousSibling;)e=e.previousSibling,t++;return t}function qi(e,t,n){e.insertBefore(n,e.childNodes[t]||null)}function Zi(e){return e&&e.nodeType===Node.COMMENT_NODE}function $i(e){return!!(e&&e.getClientRects&&e.getClientRects().length)}function Ki({element:e,target:t,positions:n,limiter:i,fitInViewport:o,viewportOffsetConfig:r}){Be(t)&&(t=t()),Be(i)&&(i=i());const s=function(e){return e&&e.parentNode?e.offsetParent===Mi.document.body?null:e.offsetParent:null}(e),a=new Vi(e),c=new Vi(t);let l;const d=o&&function(e){e=Object.assign({top:0,bottom:0,left:0,right:0},e);const t=new Vi(Mi.window);return t.top+=e.top,t.height-=e.top,t.bottom-=e.bottom,t.height-=e.bottom,t}(r)||null,u={targetRect:c,elementRect:a,positionedElementAncestor:s,viewportRect:d};if(i||o){const e=i&&new Vi(i).getVisible();Object.assign(u,{limiterRect:e,viewportRect:d}),l=function(e,t){const{elementRect:n}=t,i=n.getArea(),o=e.map((e=>new Yi(e,t))).filter((e=>!!e.name));let r=0,s=null;for(const e of o){const{limiterIntersectionArea:t,viewportIntersectionArea:n}=e;if(t===i)return e;const o=n**2+t**2;o>r&&(r=o,s=e)}return s}(n,u)||new Yi(n[0],u)}else l=new Yi(n[0],u);return l}function Gi(e){const{scrollX:t,scrollY:n}=Mi.window;return e.clone().moveBy(t,n)}Fi._observerInstance=null,Fi._elementCallbacks=null;class Yi{constructor(e,t){const n=e(t.targetRect,t.elementRect,t.viewportRect);if(!n)return;const{left:i,top:o,name:r,config:s}=n;this.name=r,this.config=s,this._positioningFunctionCorrdinates={left:i,top:o},this._options=t}get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get limiterIntersectionArea(){const e=this._options.limiterRect;if(e){const t=this._options.viewportRect;if(!t)return e.getIntersectionArea(this._rect);{const n=e.getIntersection(t);if(n)return n.getIntersectionArea(this._rect)}}return 0}get viewportIntersectionArea(){const e=this._options.viewportRect;return e?e.getIntersectionArea(this._rect):0}get _rect(){return this._cachedRect||(this._cachedRect=this._options.elementRect.clone().moveTo(this._positioningFunctionCorrdinates.left,this._positioningFunctionCorrdinates.top)),this._cachedRect}get _absoluteRect(){return this._cachedAbsoluteRect||(this._cachedAbsoluteRect=Gi(this._rect),this._options.positionedElementAncestor&&function(e,t){const n=Gi(new Vi(t)),i=Di(t);let o=0,r=0;o-=n.left,r-=n.top,o+=t.scrollLeft,r+=t.scrollTop,o-=i.left,r-=i.top,e.moveBy(o,r)}(this._cachedAbsoluteRect,this._options.positionedElementAncestor)),this._cachedAbsoluteRect}}function Qi(e){const t=e.parentNode;t&&t.removeChild(e)}function Ji(e,t,n){const i=t.clone().moveBy(0,n),o=t.clone().moveBy(0,-n),r=new Vi(e).excludeScrollbarsAndBorders();if(![o,i].every((e=>r.contains(e)))){let{scrollX:s,scrollY:a}=e;to(o,r)?a-=r.top-t.top+n:eo(i,r)&&(a+=t.bottom-r.bottom+n),no(t,r)?s-=r.left-t.left+n:io(t,r)&&(s+=t.right-r.right+n),e.scrollTo(s,a)}}function Xi(e,t){const n=oo(e);let i,o;for(;e!=n.document.body;)o=t(),i=new Vi(e).excludeScrollbarsAndBorders(),i.contains(o)||(to(o,i)?e.scrollTop-=i.top-o.top:eo(o,i)&&(e.scrollTop+=o.bottom-i.bottom),no(o,i)?e.scrollLeft-=i.left-o.left:io(o,i)&&(e.scrollLeft+=o.right-i.right)),e=e.parentNode}function eo(e,t){return e.bottom>t.bottom}function to(e,t){return e.topt.right}function oo(e){return Ni(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function ro(e){if(Ni(e)){let t=e.commonAncestorContainer;return Ri(t)&&(t=t.parentNode),t}return e.parentNode}function so(e,t){const n=oo(e),i=new Vi(e);if(n===t)return i;{let e=n;for(;e!=t;){const t=e.frameElement,n=new Vi(t).excludeScrollbarsAndBorders();i.moveBy(n.left,n.top),e=e.parent}}return i}const ao={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},co={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},lo=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++){const n=String.fromCharCode(t);e[n.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}(),uo=Object.fromEntries(Object.entries(lo).map((([e,t])=>[t,e.charAt(0).toUpperCase()+e.slice(1)])));function ho(e){let t;if("string"==typeof e){if(t=lo[e.toLowerCase()],!t)throw new w("keyboard-unknown-key",null,{key:e})}else t=e.keyCode+(e.altKey?lo.alt:0)+(e.ctrlKey?lo.ctrl:0)+(e.shiftKey?lo.shift:0)+(e.metaKey?lo.cmd:0);return t}function mo(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 ho(e.slice(0,-1));const t=ho(e);return r.isMac&&t==lo.ctrl?lo.cmd:t}(e):e)).reduce(((e,t)=>t+e),0)}function fo(e){let t=mo(e);return Object.entries(r.isMac?ao:co).reduce(((e,[n,i])=>(0!=(t&lo[n])&&(t&=~lo[n],e+=i),e)),"")+(t?uo[t]:"")}function go(e,t){const n="ltr"===t;switch(e){case lo.arrowleft:return n?"left":"right";case lo.arrowright:return n?"right":"left";case lo.arrowup:return"up";case lo.arrowdown:return"down"}}const po=["ar","ara","fa","per","fas","he","heb","ku","kur","ug","uig"];function bo(e){return po.includes(e)?"rtl":"ltr"}function wo(e){return Array.isArray(e)?e:[e]}function ko(e,t,n=1){if("number"!=typeof n)throw new w("translation-service-quantity-not-a-number",null,{quantity:n});const i=Object.keys(Mi.window.CKEDITOR_TRANSLATIONS).length;1===i&&(e=Object.keys(Mi.window.CKEDITOR_TRANSLATIONS)[0]);const o=t.id||t.string;if(0===i||!function(e,t){return!!Mi.window.CKEDITOR_TRANSLATIONS[e]&&!!Mi.window.CKEDITOR_TRANSLATIONS[e].dictionary[t]}(e,o))return 1!==n?t.plural:t.string;const r=Mi.window.CKEDITOR_TRANSLATIONS[e].dictionary,s=Mi.window.CKEDITOR_TRANSLATIONS[e].getPluralForm||(e=>1===e?0:1),a=r[o];if("string"==typeof a)return a;return a[Number(s(n))]}Mi.window.CKEDITOR_TRANSLATIONS||(Mi.window.CKEDITOR_TRANSLATIONS={});class _o{constructor({uiLanguage:e="en",contentLanguage:t}={}){this.uiLanguage=e,this.contentLanguage=t||this.uiLanguage,this.uiLanguageDirection=bo(this.uiLanguage),this.contentLanguageDirection=bo(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=wo(t),"string"==typeof e&&(e={string:e});const n=!!e.plural?t[0]:1;return function(e,t){return e.replace(/%(\d+)/g,((e,n)=>nthis._items.length||t<0)throw new w("collection-add-item-invalid-index",this);let n=0;for(const i of e){const e=this._getItemIdBeforeAdding(i),o=t+n;this._items.splice(o,0,i),this._itemMap.set(e,i),this.fire("add",i,o),n++}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 w("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,n]=this._remove(e);return this.fire("change",{added:[],removed:[t],index:n}),t}map(e,t){return this._items.map(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 w("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,n=(n,i,o)=>{const r=t._bindToCollection==this,s=t._bindToInternalToExternalMap.get(i);if(r&&s)this._bindToExternalToInternalMap.set(i,s),this._bindToInternalToExternalMap.set(s,i);else{const n=e(i);if(!n)return void this._skippedIndexesFromExternal.push(o);let r=o;for(const e of this._skippedIndexesFromExternal)o>e&&r--;for(const e of t._skippedIndexesFromExternal)r>=e&&r++;this._bindToExternalToInternalMap.set(i,n),this._bindToInternalToExternalMap.set(n,i),this.add(n,r);for(let e=0;e{const i=this._bindToExternalToInternalMap.get(t);i&&this.remove(i),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce(((e,t)=>(nt&&e.push(t),e)),[])}))}_getItemIdBeforeAdding(e){const t=this._idProperty;let n;if(t in e){if(n=e[t],"string"!=typeof n)throw new w("collection-add-invalid-id",this);if(this.get(n))throw new w("collection-add-item-already-exists",this)}else e[t]=n=g();return n}_remove(e){let t,n,i,o=!1;const r=this._idProperty;if("string"==typeof e?(n=e,i=this._itemMap.get(n),o=!i,i&&(t=this._items.indexOf(i))):"number"==typeof e?(t=e,i=this._items[t],o=!i,i&&(n=i[r])):(i=e,n=i[r],t=this._items.indexOf(i),o=-1==t||!this._itemMap.get(n)),o)throw new w("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(n);const s=this._bindToInternalToExternalMap.get(i);return this._bindToInternalToExternalMap.delete(i),this._bindToExternalToInternalMap.delete(s),this.fire("remove",i,t),[i,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}function yo(e){const t=e.next();return t.done?null:t.value}class xo extends(Ti(H())){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 w("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 Ao{constructor(){this._listener=new(Ti())}listenTo(e){this._listener.listenTo(e,"keydown",((e,t)=>{this._listener.fire("_keydown:"+ho(t),t)}))}set(e,t,n={}){const i=mo(e),o=n.priority;this._listener.listenTo(this._listener,"_keydown:"+i,((e,n)=>{t(n,(()=>{n.preventDefault(),n.stopPropagation(),e.stop()})),e.return=!0}),{priority:o})}press(e){return!!this._listener.fire("_keydown:"+ho(e),e)}destroy(){this._listener.stopListening()}}function Co(e){return J(e)?new Map(e):function(e){const t=new Map;for(const n in e)t.set(n,e[n]);return t}(e)}function Eo(e,t){return!!(n=e.charAt(t-1))&&1==n.length&&/[\ud800-\udbff]/.test(n)&&function(e){return!!e&&1==e.length&&/[\udc00-\udfff]/.test(e)}(e.charAt(t));var n}function To(e,t){return!!(n=e.charAt(t))&&1==n.length&&/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/.test(n);var n}const So=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 Po(e,t){const n=String(e).matchAll(So);return Array.from(n).some((e=>e.index{this.refresh()})),this.on("execute",(e=>{this.isEnabled||e.stop()}),{priority:"high"}),this.listenTo(e,"change:isReadOnly",((e,t,n)=>{n&&this.affectsData?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}))}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",Ro,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",Ro),this.refresh())}execute(...e){}destroy(){this.stopListening()}}function Ro(e){e.return=!1,e.stop()}class No extends Oo{constructor(e){super(e),this._childCommandsDefinitions=[]}refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){b(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 Do extends(S()){constructor(e,t=[],n=[]){super(),this._context=e,this._plugins=new Map,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 n)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 w("plugincollection-plugin-not-loaded",this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}init(e,t=[],n=[]){const i=this,o=this._context;!function e(t,n=new Set){t.forEach((t=>{a(t)&&(n.has(t)||(n.add(t),t.pluginName&&!i._availablePlugins.has(t.pluginName)&&i._availablePlugins.set(t.pluginName,t),t.requires&&e(t.requires,n)))}))}(e),u(e);const r=[...function e(t,n=new Set){return t.map((e=>a(e)?e:i._availablePlugins.get(e))).reduce(((t,i)=>n.has(i)?t:(n.add(i),i.requires&&(u(i.requires,i),e(i.requires,n).forEach((e=>t.add(e)))),t.add(i))),new Set)}(e.filter((e=>!l(e,t))))];!function(e,t){for(const n of t){if("function"!=typeof n)throw new w("plugincollection-replace-plugin-invalid-type",null,{pluginItem:n});const t=n.pluginName;if(!t)throw new w("plugincollection-replace-plugin-missing-name",null,{pluginItem:n});if(n.requires&&n.requires.length)throw new w("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const o=i._availablePlugins.get(t);if(!o)throw new w("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:t});const r=e.indexOf(o);if(-1===r){if(i._contextPlugins.has(o))return;throw new w("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:t})}if(o.requires&&o.requires.length)throw new w("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:t});e.splice(r,1,n),i._availablePlugins.set(t,n)}}(r,n);const s=function(e){return e.map((e=>{let t=i._contextPlugins.get(e);return t=t||new e(o),i._add(e,t),t}))}(r);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,n=null){e.map((e=>a(e)?e:i._availablePlugins.get(e)||e)).forEach((e=>{!function(e,t){if(a(e))return;if(t)throw new w("plugincollection-soft-required",o,{missingPlugin:e,requiredBy:d(t)});throw new w("plugincollection-plugin-not-found",o,{plugin:e})}(e,n),function(e,t){if(!c(t))return;if(c(e))return;throw new w("plugincollection-context-required",o,{plugin:d(e),requiredBy:d(t)})}(e,n),function(e,n){if(!n)return;if(!l(e,t))return;throw new w("plugincollection-required",o,{plugin:d(e),requiredBy:d(n)})}(e,n)}))}function h(e,t){return e.reduce(((e,n)=>n[t]?i._contextPlugins.has(n)?e:e.then(n[t].bind(n)):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 n=e.pluginName;if(n){if(this._plugins.has(n))throw new w("plugincollection-plugin-name-conflict",null,{pluginName:n,plugin1:this._plugins.get(n).constructor,plugin2:e});this._plugins.set(n,t)}}}class Lo{constructor(e){this.config=new vi(e,this.constructor.defaultConfig);const t=this.constructor.builtinPlugins;this.config.define("plugins",t),this.plugins=new Do(this,t);const n=this.config.get("language")||{};this.locale=new _o({uiLanguage:"string"==typeof n?n:n.ui,contentLanguage:this.config.get("language.content")}),this.t=this.locale.t,this.editors=new vo,this._contextOwner=null}initPlugins(){const e=this.config.get("plugins")||[],t=this.config.get("substitutePlugins")||[];for(const n of e.concat(t)){if("function"!=typeof n)throw new w("context-initplugins-constructor-only",null,{Plugin:n});if(!0!==n.isContextPlugin)throw new w("context-initplugins-invalid-plugin",null,{Plugin:n})}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 w("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 n=new this(e);t(n.initPlugins().then((()=>n)))}))}}class Vo extends(H()){constructor(e){super(),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}var Bo=n(3379),jo=n.n(Bo),zo=n(5169),Fo={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(zo.Z,Fo);zo.Z.locals;const Uo=new WeakMap;function Ho(e){const{view:t,element:n,text:i,isDirectHost:o=!0,keepOnFocus:r=!1}=e,s=t.document;Uo.has(s)||(Uo.set(s,new Map),s.registerPostFixer((e=>qo(s,e))),s.on("change:isComposing",(()=>{t.change((e=>qo(s,e)))}),{priority:"high"})),Uo.get(s).set(n,{text:i,isDirectHost:o,keepOnFocus:r,hostElement:o?n:null}),t.change((e=>qo(s,e)))}function Wo(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function qo(e,t){const n=Uo.get(e),i=[];let o=!1;for(const[e,r]of n)r.isDirectHost&&(i.push(e),Zo(t,e,r)&&(o=!0));for(const[e,r]of n){if(r.isDirectHost)continue;const n=$o(e);n&&(i.includes(n)||(r.hostElement=n,Zo(t,e,r)&&(o=!0)))}return o}function Zo(e,t,n){const{text:i,isDirectHost:o,hostElement:r}=n;let s=!1;r.getAttribute("data-placeholder")!==i&&(e.setAttribute("data-placeholder",i,r),s=!0);return(o||1==t.childCount)&&function(e,t){if(!e.isAttached())return!1;const n=Array.from(e.getChildren()).some((e=>!e.is("uiElement")));if(n)return!1;const i=e.document,o=i.selection.anchor;return!(i.isComposing&&o&&o.parent===e||!t&&i.isFocused&&(!o||o.parent===e))}(r,n.keepOnFocus)?function(e,t){return!t.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",t),!0)}(e,r)&&(s=!0):Wo(e,r)&&(s=!0),s}function $o(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}class Ko{is(){throw new Error("is() method is abstract")}}const Go=function(e){return wi(e,4)};class Yo extends(S(Ko)){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 w("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 n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}getCommonAncestor(e,t={}){const n=this.getAncestors(t),i=e.getAncestors(t);let o=0;for(;n[o]==i[o]&&n[o];)o++;return 0===o?null:n[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),n=e.getPath(),i=Q(t,n);switch(i){case"prefix":return!0;case"extension":return!1;default:return t[i]e.data.length)throw new w("view-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.data.length)throw new w("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+n),this.offsetInText=t}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}getAncestors(e={}){const t=[];let n=e.includeSelf?this.textNode:this.parent;for(;null!==n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}}Jo.prototype.is=function(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e};class Xo{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 n=er(t,e);if(n)return{element:t,pattern:e,match:n}}return null}matchAll(...e){const t=[];for(const n of e)for(const e of this._patterns){const i=er(n,e);i&&t.push({element:n,pattern:e,match:i})}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 er(e,t){if("function"==typeof t)return t(e);const n={};return t.name&&(n.name=function(e,t){if(e instanceof RegExp)return!!t.match(e);return e===t}(t.name,e.name),!n.name)||t.attributes&&(n.attributes=function(e,t){const n=new Set(t.getAttributeKeys());xe(e)?(void 0!==e.style&&k("matcher-pattern-deprecated-attributes-style-key",e),void 0!==e.class&&k("matcher-pattern-deprecated-attributes-class-key",e)):(n.delete("style"),n.delete("class"));return tr(e,n,(e=>t.getAttribute(e)))}(t.attributes,e),!n.attributes)||t.classes&&(n.classes=function(e,t){return tr(e,t.getClassNames(),(()=>{}))}(t.classes,e),!n.classes)||t.styles&&(n.styles=function(e,t){return tr(e,t.getStyleNames(!0),(e=>t.getStyle(e)))}(t.styles,e),!n.styles)?null:n}function tr(e,t,n){const i=function(e){if(Array.isArray(e))return e.map((e=>xe(e)?(void 0!==e.key&&void 0!==e.value||k("matcher-pattern-missing-key-or-value",e),[e.key,e.value]):[e,!0]));if(xe(e))return Object.entries(e);return[[e,!0]]}(e),o=Array.from(t),r=[];if(i.forEach((([e,t])=>{o.forEach((i=>{(function(e,t){return!0===e||e===t||e instanceof RegExp&&t.match(e)})(e,i)&&function(e,t,n){if(!0===e)return!0;const i=n(t);return e===i||e instanceof RegExp&&!!String(i).match(e)}(t,i,n)&&r.push(i)}))})),i.length&&!(r.lengtho?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var r=Array(o);++i0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}};const Fr=zr(Br);const Ur=function(e,t){return Fr(Lr(e,t,Rr),e+"")};const Hr=function(e,t,n){if(!L(n))return!1;var i=typeof t;return!!("number"==i?rn(n)&&zt(t,n.length):"string"==i&&t in n)&&Ce(n[t],e)};const Wr=function(e){return Ur((function(t,n){var i=-1,o=n.length,r=o>1?n[o-1]:void 0,s=o>2?n[2]:void 0;for(r=e.length>3&&"function"==typeof r?(o--,r):void 0,s&&Hr(n[0],n[1],s)&&(r=o<3?void 0:r,o=1),t=Object(t);++it===e));return Array.isArray(t)}set(e,t){if(L(e))for(const[t,n]of Object.entries(e))this._styleProcessor.toNormalizedForm(t,n,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t=Yr(e);Ar(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]&&!L(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 n of t)e.push(...this._styleProcessor.getReducedForm(n,this._styles));return e}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const n=t.splice(0,t.length-1).join("."),i=Cr(this._styles,n);if(!i)return;!Array.from(Object.keys(i)).length&&this.remove(n)}}class Gr{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,n){if(L(t))Qr(n,Yr(e),t);else if(this._normalizers.has(e)){const i=this._normalizers.get(e),{path:o,value:r}=i(t);Qr(n,o,r)}else Qr(n,e,t)}getNormalized(e,t){if(!e)return qr({},t);if(void 0!==t[e])return t[e];if(this._extractors.has(e)){const n=this._extractors.get(e);if("string"==typeof n)return Cr(t,n);const i=n(e,t);if(i)return i}return Cr(t,Yr(e))}getReducedForm(e,t){const n=this.getNormalized(e,t);if(void 0===n)return[];if(this._reducers.has(e)){return this._reducers.get(e)(n)}return[[e,n]]}getStyleNames(e){const t=Array.from(this._consumables.keys()).filter((t=>{const n=this.getNormalized(t,e);return n&&"object"==typeof n?Object.keys(n).length:n})),n=new Set([...t,...Object.keys(e)]);return Array.from(n.values())}getRelatedStyles(e){return this._consumables.get(e)||[]}setNormalizer(e,t){this._normalizers.set(e,t)}setExtractor(e,t){this._extractors.set(e,t)}setReducer(e,t){this._reducers.set(e,t)}setStyleRelation(e,t){this._mapStyleNames(e,t);for(const n of t)this._mapStyleNames(n,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function Yr(e){return e.replace("-",".")}function Qr(e,t,n){let i=n;L(n)&&(i=qr({},Cr(e,t),n)),$r(e,t,i)}class Jr extends Yo{constructor(e,t,n,i){if(super(e),this.name=t,this._attrs=function(e){const t=Co(e);for(const[e,n]of t)null===n?t.delete(e):"string"!=typeof n&&t.set(e,String(n));return t}(n),this._children=[],i&&this._insertChild(0,i),this._classes=new Set,this._attrs.has("class")){const e=this._attrs.get("class");Xr(this._classes,e),this._attrs.delete("class")}this._styles=new Kr(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style")),this._customProperties=new Map,this._unsafeAttributesToRender=[]}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 Jr))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,n]of this._attrs)if(!e._attrs.has(t)||e._attrs.get(t)!==n)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 Xo(...e);let n=this.parent;for(;n&&!n.is("documentFragment");){if(t.match(n))return n;n=n.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=Array.from(this._classes).sort().join(","),t=this._styles.toString(),n=Array.from(this._attrs).map((e=>`${e[0]}="${e[1]}"`)).sort().join(" ");return this.name+(""==e?"":` class="${e}"`)+(t?` style="${t}"`:"")+(""==n?"":` ${n}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(e=!1){const t=[];if(e)for(const n of this.getChildren())t.push(n._clone(e));const n=new this.constructor(this.document,this.name,this._attrs,t);return n._classes=new Set(this._classes),n._styles.set(this._styles.getNormalized()),n._customProperties=new Map(this._customProperties),n.getFillerOffset=this.getFillerOffset,n._unsafeAttributesToRender=this._unsafeAttributesToRender,n}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this);let n=0;const i=function(e,t){if("string"==typeof t)return[new Qo(e,t)];J(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new Qo(e,t):t instanceof Jo?new Qo(e,t.data):t))}(this.document,t);for(const t of i)null!==t.parent&&t._remove(),t.parent=this,t.document=this.document,this._children.splice(e,0,t),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this);for(let n=e;n0&&(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 wo(e))this._classes.add(t)}_removeClass(e){this._fireChange("attributes",this);for(const t of wo(e))this._classes.delete(t)}_setStyle(e,t){this._fireChange("attributes",this),xe(e)?this._styles.set(e):this._styles.set(e,t)}_removeStyle(e){this._fireChange("attributes",this);for(const t of wo(e))this._styles.remove(t)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}}function Xr(e,t){const n=t.split(/\s+/);e.clear(),n.forEach((t=>e.add(t)))}Jr.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 es extends Jr{constructor(...e){super(...e),this.getFillerOffset=ts}}function ts(){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}es.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 ns extends(H(es)){constructor(...e){super(...e);const t=e[0];this.set("isReadOnly",!1),this.set("isFocused",!1),this.bind("isReadOnly").to(t),this.bind("isFocused").to(t,"isFocused",(e=>e&&t.selection.editableElement==this)),this.listenTo(t.selection,"change",(()=>{this.isFocused=t.isFocused&&t.selection.editableElement==this}))}destroy(){this.stopListening()}}ns.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 is=Symbol("rootName");class os extends ns{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(is)}set rootName(e){this._setCustomProperty(is,e)}set _name(e){this.name=e}}os.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 rs{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new w("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new w("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this.position=ss._createAt(e.startPosition):this.position=ss._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}skip(e){let t,n,i;do{i=this.position,({done:t,value:n}=this.next())}while(!t&&e(n));t||(this.position=i)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,n=e.parent;if(null===n.parent&&e.offset===n.childCount)return{done:!0,value:void 0};if(n===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let i;if(n instanceof Qo){if(e.isAtEnd)return this.position=ss._createAfter(n),this._next();i=n.data[e.offset]}else i=n.getChild(e.offset);if(i instanceof Jr)return this.shallow?e.offset++:e=new ss(i,0),this.position=e,this._formatReturnValue("elementStart",i,t,e,1);if(i instanceof Qo){if(this.singleCharacters)return e=new ss(i,0),this.position=e,this._next();{let n,o=i.data.length;return i==this._boundaryEndParent?(o=this.boundaries.end.offset,n=new Jo(i,0,o),e=ss._createAfter(n)):(n=new Jo(i,0,i.data.length),e.offset++),this.position=e,this._formatReturnValue("text",n,t,e,o)}}if("string"==typeof i){let i;if(this.singleCharacters)i=1;else{i=(n===this._boundaryEndParent?this.boundaries.end.offset:n.data.length)-e.offset}const o=new Jo(n,e.offset,i);return e.offset+=i,this.position=e,this._formatReturnValue("text",o,t,e,i)}return e=ss._createAfter(n),this.position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",n,t,e)}_previous(){let e=this.position.clone();const t=this.position,n=e.parent;if(null===n.parent&&0===e.offset)return{done:!0,value:void 0};if(n==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let i;if(n instanceof Qo){if(e.isAtStart)return this.position=ss._createBefore(n),this._previous();i=n.data[e.offset-1]}else i=n.getChild(e.offset-1);if(i instanceof Jr)return this.shallow?(e.offset--,this.position=e,this._formatReturnValue("elementStart",i,t,e,1)):(e=new ss(i,i.childCount),this.position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",i,t,e));if(i instanceof Qo){if(this.singleCharacters)return e=new ss(i,i.data.length),this.position=e,this._previous();{let n,o=i.data.length;if(i==this._boundaryStartParent){const t=this.boundaries.start.offset;n=new Jo(i,t,i.data.length-t),o=n.data.length,e=ss._createBefore(n)}else n=new Jo(i,0,i.data.length),e.offset--;return this.position=e,this._formatReturnValue("text",n,t,e,o)}}if("string"==typeof i){let i;if(this.singleCharacters)i=1;else{const t=n===this._boundaryStartParent?this.boundaries.start.offset:0;i=e.offset-t}e.offset-=i;const o=new Jo(n,e.offset,i);return this.position=e,this._formatReturnValue("text",o,t,e,i)}return e=ss._createBefore(n),this.position=e,this._formatReturnValue("elementStart",n,t,e,1)}_formatReturnValue(e,t,n,i,o){return t instanceof Jo&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?n=ss._createAfter(t.textNode):(i=ss._createAfter(t.textNode),this.position=i)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?n=ss._createBefore(t.textNode):(i=ss._createBefore(t.textNode),this.position=i))),{done:!1,value:{type:e,item:t,previousPosition:n,nextPosition:i,length:o}}}}class ss extends Ko{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 ns);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(e){const t=ss._createAt(this),n=t.offset+e;return t.offset=n<0?0:n,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const n=new rs(t);return n.skip(e),n.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),n=e.getAncestors();let i=0;for(;t[i]==n[i]&&t[i];)i++;return 0===i?null:t[i-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():[],n=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),n.push(e.offset);const i=Q(t,n);switch(i){case"prefix":return"before";case"extension":return"after";default:return t[i]0?new this(n,i):new this(i,n)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(ss._createBefore(e),t)}}function cs(e){return!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))}as.prototype.is=function(e){return"range"===e||"view:range"===e};class ls extends(S(Ko)){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 n=!1;for(const i of e._ranges)if(t.isEqual(i)){n=!0;break}if(!n)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=Y(this.getRanges());if(t!=Y(e.getRanges()))return!1;if(0==t)return!0;for(let t of this.getRanges()){t=t.getTrimmed();let n=!1;for(let i of e.getRanges())if(i=i.getTrimmed(),t.start.isEqual(i.start)&&t.end.isEqual(i.end)){n=!0;break}if(!n)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,n,i]=e;if("object"==typeof n&&(i=n,n=void 0),null===t)this._setRanges([]),this._setFakeOptions(i);else if(t instanceof ls||t instanceof ds)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof as)this._setRanges([t],i&&i.backward),this._setFakeOptions(i);else if(t instanceof ss)this._setRanges([new as(t)]),this._setFakeOptions(i);else if(t instanceof Yo){const e=!!i&&!!i.backward;let o;if(void 0===n)throw new w("view-selection-setto-required-second-parameter",this);o="in"==n?as._createIn(t):"on"==n?as._createOn(t):new as(ss._createAt(t,n)),this._setRanges([o],e),this._setFakeOptions(i)}else{if(!J(t))throw new w("view-selection-setto-not-selectable",this);this._setRanges(t,i&&i.backward),this._setFakeOptions(i)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new w("view-selection-setfocus-no-ranges",this);const n=ss._createAt(e,t);if("same"==n.compareWith(this.focus))return;const i=this.anchor;this._ranges.pop(),"before"==n.compareWith(i)?this._addRange(new as(n,i),!0):this._addRange(new as(i,n)),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 as))throw new w("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 w("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new as(e.start,e.end))}}ls.prototype.is=function(e){return"selection"===e||"view:selection"===e};class ds extends(S(Ko)){constructor(...e){super(),this._selection=new ls,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)}}ds.prototype.is=function(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e};class us extends m{constructor(e,t,n){super(e,t),this.startRange=n,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const hs=Symbol("bubbling contexts");function ms(e){return class extends e{fire(e,...t){try{const n=e instanceof m?e:new m(this,e),i=bs(this);if(!i.size)return;if(fs(n,"capturing",this),gs(i,"$capture",n,...t))return n.return;const o=n.startRange||this.selection.getFirstRange(),r=o?o.getContainedElement():null,s=!!r&&Boolean(ps(i,r));let a=r||function(e){if(!e)return null;const t=e.start.parent,n=e.end.parent,i=t.getPath(),o=n.getPath();return i.length>o.length?t:n}(o);if(fs(n,"atTarget",a),!s){if(gs(i,"$text",n,...t))return n.return;fs(n,"bubbling",a)}for(;a;){if(a.is("rootElement")){if(gs(i,"$root",n,...t))return n.return}else if(a.is("element")&&gs(i,a.name,n,...t))return n.return;if(gs(i,a,n,...t))return n.return;a=a.parent,fs(n,"bubbling",a)}return fs(n,"bubbling",this),gs(i,"$document",n,...t),n.return}catch(e){w.rethrowUnexpectedError(e,this)}}_addEventListener(e,t,n){const i=wo(n.context||"$document"),o=bs(this);for(const r of i){let i=o.get(r);i||(i=new(S()),o.set(r,i)),this.listenTo(i,e,t,n)}}_removeEventListener(e,t){const n=bs(this);for(const i of n.values())this.stopListening(i,e,t)}}}{const e=ms(Object);["fire","_addEventListener","_removeEventListener"].forEach((t=>{ms[t]=e.prototype[t]}))}function fs(e,t,n){e instanceof us&&(e._eventPhase=t,e._currentTarget=n)}function gs(e,t,n,...i){const o="string"==typeof t?e.get(t):ps(e,t);return!!o&&(o.fire(n,...i),n.stop.called)}function ps(e,t){for(const[n,i]of e)if("function"==typeof n&&n(t))return i;return null}function bs(e){return e[hs]||(e[hs]=new Map),e[hs]}class ws extends(ms(H())){constructor(e){super(),this.selection=new ds,this.roots=new vo({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("_isFocusChanging",!1),this.set("isSelecting",!1),this.set("isComposing",!1),this._postFixers=new Set}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.map((e=>e.destroy())),this.stopListening()}_callPostFixers(e){let t=!1;do{for(const n of this._postFixers)if(t=n(e),t)break}while(t)}}class ks extends Jr{constructor(...e){super(...e),this.getFillerOffset=_s,this._priority=10,this._id=null,this._clonesGroup=null}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new w("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 _s(){if(vs(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(vs(e)>1)return null;e=e.parent}return!e||vs(e)>1?null:this.childCount}function vs(e){return Array.from(e.getChildren()).filter((e=>!e.is("uiElement"))).length}ks.DEFAULT_PRIORITY=10,ks.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 ys extends Jr{constructor(e,t,n,i){super(e,t,n,i),this.getFillerOffset=xs}_insertChild(e,t){if(t&&(t instanceof Yo||Array.from(t).length>0))throw new w("view-emptyelement-cannot-add",[this,t]);return 0}}function xs(){return null}ys.prototype.is=function(e,t){return t?t===this.name&&("emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e):"emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class As extends Jr{constructor(...e){super(...e),this.getFillerOffset=Es}_insertChild(e,t){if(t&&(t instanceof Yo||Array.from(t).length>0))throw new w("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 Cs(e){e.document.on("arrowKey",((t,n)=>function(e,t,n){if(t.keyCode==lo.arrowright){const e=t.domTarget.ownerDocument.defaultView.getSelection(),i=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(i||t.shiftKey){const t=e.focusNode,o=e.focusOffset,r=n.domPositionToView(t,o);if(null===r)return;let s=!1;const a=r.getLastMatchingPosition((e=>(e.item.is("uiElement")&&(s=!0),!(!e.item.is("uiElement")&&!e.item.is("attributeElement")))));if(s){const t=n.viewPositionToDom(a);i?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}}(0,n,e.domConverter)),{priority:"low"})}function Es(){return null}As.prototype.is=function(e,t){return t?t===this.name&&("uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e):"uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class Ts extends Jr{constructor(...e){super(...e),this.getFillerOffset=Ss}_insertChild(e,t){if(t&&(t instanceof Yo||Array.from(t).length>0))throw new w("view-rawelement-cannot-add",[this,t]);return 0}render(){}}function Ss(){return null}Ts.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 Ps extends(S(Ko)){constructor(e,t){super(),this.document=e,this._children=[],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}_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 n=0;const i=function(e,t){if("string"==typeof t)return[new Qo(e,t)];J(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new Qo(e,t):t instanceof Jo?new Qo(e,t.data):t))}(this.document,t);for(const t of i)null!==t.parent&&t._remove(),t.parent=this,this._children.splice(e,0,t),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this);for(let n=e;n{const n=e[e.length-1],i=!t.is("uiElement");return n&&n.breakAttributes==i?n.nodes.push(t):e.push({breakAttributes:i,nodes:[t]}),e}),[]);let i=null,o=e;for(const{nodes:e,breakAttributes:t}of n){const n=this._insertNodes(o,e,t);i||(i=n.start),o=n.end}return i?new as(i,o):new as(e)}remove(e){const t=e instanceof as?e:as._createOn(e);if(js(t,this.document),t.isCollapsed)return new Ps(this.document);const{start:n,end:i}=this._breakAttributesRange(t,!0),o=n.parent,r=i.offset-n.offset,s=o._removeChildren(n.offset,r);for(const e of s)this._removeFromClonedElementsGroup(e);const a=this.mergeAttributes(n);return t.start=a,t.end=a.clone(),new Ps(this.document,s)}clear(e,t){js(e,this.document);const n=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const i of n){const n=i.item;let o;if(n.is("element")&&t.isSimilar(n))o=as._createOn(n);else if(!i.nextPosition.isAfter(e.start)&&n.is("$textProxy")){const e=n.getAncestors().find((e=>e.is("element")&&t.isSimilar(e)));e&&(o=as._createIn(e))}o&&(o.end.isAfter(e.end)&&(o.end=e.end),o.start.isBefore(e.start)&&(o.start=e.start),this.remove(o))}}move(e,t){let n;if(t.isAfter(e.end)){const i=(t=this._breakAttributes(t,!0)).parent,o=i.childCount;e=this._breakAttributesRange(e,!0),n=this.remove(e),t.offset+=i.childCount-o}else n=this.remove(e);return this.insert(t,n)}wrap(e,t){if(!(t instanceof ks))throw new w("view-writer-wrap-invalid-attribute",this.document);if(js(e,this.document),e.isCollapsed){let i=e.start;i.parent.is("element")&&(n=i.parent,!Array.from(n.getChildren()).some((e=>!e.is("uiElement"))))&&(i=i.getLastMatchingPosition((e=>e.item.is("uiElement")))),i=this._wrapPosition(i,t);const o=this.document.selection;return o.isCollapsed&&o.getFirstPosition().isEqual(e.start)&&this.setSelection(i),new as(i)}return this._wrapRange(e,t);var n}unwrap(e,t){if(!(t instanceof ks))throw new w("view-writer-unwrap-invalid-attribute",this.document);if(js(e,this.document),e.isCollapsed)return e;const{start:n,end:i}=this._breakAttributesRange(e,!0),o=n.parent,r=this._unwrapChildren(o,n.offset,i.offset,t),s=this.mergeAttributes(r.start);s.isEqual(r.start)||r.end.offset--;const a=this.mergeAttributes(r.end);return new as(s,a)}rename(e,t){const n=new es(this.document,e,t.getAttributes());return this.insert(ss._createAfter(t),n),this.move(as._createIn(t),ss._createAt(n,0)),this.remove(as._createOn(t)),n}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return ss._createAt(e,t)}createPositionAfter(e){return ss._createAfter(e)}createPositionBefore(e){return ss._createBefore(e)}createRange(...e){return new as(...e)}createRangeOn(e){return as._createOn(e)}createRangeIn(e){return as._createIn(e)}createSelection(...e){return new ls(...e)}createSlot(e){if(!this._slotFactory)throw new w("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,n){let i,o;if(i=n?Ms(e):e.parent.is("$text")?e.parent.parent:e.parent,!i)throw new w("view-writer-invalid-position-container",this.document);o=n?this._breakAttributes(e,!0):e.parent.is("$text")?Ns(e):e;const r=i._insertChild(o.offset,t);for(const e of t)this._addToClonedElementsGroup(e);const s=o.getShiftedBy(r),a=this.mergeAttributes(o);a.isEqual(o)||s.offset--;const c=this.mergeAttributes(s);return new as(a,c)}_wrapChildren(e,t,n,i){let o=t;const r=[];for(;o!1,e.parent._insertChild(e.offset,n);const i=new as(e,e.getShiftedBy(1));this.wrap(i,t);const o=new ss(n.parent,n.index);n._remove();const r=o.nodeBefore,s=o.nodeAfter;return r instanceof Qo&&s instanceof Qo?Ds(r,s):Rs(o)}_wrapAttributeElement(e,t){if(!zs(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const n of e.getAttributeKeys())if("class"!==n&&"style"!==n&&t.hasAttribute(n)&&t.getAttribute(n)!==e.getAttribute(n))return!1;for(const n of e.getStyleNames())if(t.hasStyle(n)&&t.getStyle(n)!==e.getStyle(n))return!1;for(const n of e.getAttributeKeys())"class"!==n&&"style"!==n&&(t.hasAttribute(n)||this.setAttribute(n,e.getAttribute(n),t));for(const n of e.getStyleNames())t.hasStyle(n)||this.setStyle(n,e.getStyle(n),t);for(const n of e.getClassNames())t.hasClass(n)||this.addClass(n,t);return!0}_unwrapAttributeElement(e,t){if(!zs(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const n of e.getAttributeKeys())if("class"!==n&&"style"!==n&&(!t.hasAttribute(n)||t.getAttribute(n)!==e.getAttribute(n)))return!1;if(!t.hasClass(...e.getClassNames()))return!1;for(const n of e.getStyleNames())if(!t.hasStyle(n)||t.getStyle(n)!==e.getStyle(n))return!1;for(const n of e.getAttributeKeys())"class"!==n&&"style"!==n&&this.removeAttribute(n,t);return this.removeClass(Array.from(e.getClassNames()),t),this.removeStyle(Array.from(e.getStyleNames()),t),!0}_breakAttributesRange(e,t=!1){const n=e.start,i=e.end;if(js(e,this.document),e.isCollapsed){const n=this._breakAttributes(e.start,t);return new as(n,n)}const o=this._breakAttributes(i,t),r=o.parent.childCount,s=this._breakAttributes(n,t);return o.offset+=o.parent.childCount-r,new as(s,o)}_breakAttributes(e,t=!1){const n=e.offset,i=e.parent;if(e.parent.is("emptyElement"))throw new w("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new w("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new w("view-writer-cannot-break-raw-element",this.document);if(!t&&i.is("$text")&&Bs(i.parent))return e.clone();if(Bs(i))return e.clone();if(i.is("$text"))return this._breakAttributes(Ns(e),t);if(n==i.childCount){const e=new ss(i.parent,i.index+1);return this._breakAttributes(e,t)}if(0===n){const e=new ss(i.parent,i.index);return this._breakAttributes(e,t)}{const e=i.index+1,o=i._clone();i.parent._insertChild(e,o),this._addToClonedElementsGroup(o);const r=i.childCount-n,s=i._removeChildren(n,r);o._appendChild(s);const a=new ss(i.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 n=this._cloneGroups.get(t);n||(n=new Set,this._cloneGroups.set(t,n)),n.add(e),e._clonesGroup=n}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const t of e.getChildren())this._removeFromClonedElementsGroup(t);const t=e.id;if(!t)return;const n=this._cloneGroups.get(t);n&&n.delete(e)}}function Ms(e){let t=e.parent;for(;!Bs(t);){if(!t)return;t=t.parent}return t}function Os(e,t){return e.priorityt.priority)&&e.getIdentity()n instanceof e)))throw new w("view-writer-insert-invalid-node-type",t);n.is("$text")||Vs(n.getChildren(),t)}}function Bs(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function js(e,t){const n=Ms(e.start),i=Ms(e.end);if(!n||!i||n!==i)throw new w("view-writer-invalid-range-container",t)}function zs(e,t){return null===e.id&&null===t.id}const Fs=e=>e.createTextNode(" "),Us=e=>{const t=e.createElement("span");return t.dataset.ckeFiller="true",t.innerText=" ",t},Hs=e=>{const t=e.createElement("br");return t.dataset.ckeFiller="true",t},Ws="⁠".repeat(7);function qs(e){return Ri(e)&&e.data.substr(0,7)===Ws}function Zs(e){return 7==e.data.length&&qs(e)}function $s(e){return qs(e)?e.data.slice(7):e.data}function Ks(e,t){if(t.keyCode==lo.arrowleft){const e=t.domTarget.ownerDocument.defaultView.getSelection();if(1==e.rangeCount&&e.getRangeAt(0).collapsed){const t=e.getRangeAt(0).startContainer,n=e.getRangeAt(0).startOffset;qs(t)&&n<=7&&e.collapse(t,0)}}}var Gs=n(1237),Ys={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Gs.Z,Ys);Gs.Z.locals;class Qs extends(H()){constructor(e,t){super(),this.domDocuments=new Set,this.domConverter=e,this.markedAttributes=new Set,this.markedChildren=new Set,this.markedTexts=new Set,this.selection=t,this.set("isFocused",!1),this.set("_isFocusChanging",!1),this.set("isSelecting",!1),r.isBlink&&!r.isAndroid&&this.on("change:isSelecting",(()=>{this.isSelecting||this.render()})),this.set("isComposing",!1),this.on("change:isComposing",(()=>{this.isComposing||this.render()})),this._inlineFiller=null,this._fakeSelectionContainer=null}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 w("view-renderer-unknown-type",this);this.markedChildren.add(t)}}}render(){if(this.isComposing&&!r.isAndroid)return;let e=null;const t=!(r.isBlink&&!r.isAndroid)||!this.isSelecting;for(const e of this.markedChildren)this._updateChildrenMappings(e);t?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?e=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(e=this.selection.getFirstPosition(),this.markedChildren.add(e.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(e=this.domConverter.domPositionToView(this._inlineFiller),e&&e.parent.is("$text")&&(e=ss._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),n=t.parent.ownerDocument;qs(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=Js(n,t.parent,t.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){if(!this.domConverter.mapViewToDom(e))return;const t=Array.from(this.domConverter.mapViewToDom(e).childNodes),n=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),i=this._diffNodeLists(t,n),o=this._findReplaceActions(i,t,n);if(-1!==o.indexOf("replace")){const i={equal:0,insert:0,delete:0};for(const r of o)if("replace"===r){const o=i.equal+i.insert,r=i.equal+i.delete,s=e.getChild(o);!s||s.is("uiElement")||s.is("rawElement")||this._updateElementMappings(s,t[r]),Qi(n[o]),i.equal++}else i[r]++}}_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")?ss._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&&Ri(t.parent)&&qs(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!qs(e))throw new w("view-renderer-filler-was-lost",this);Zs(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,n=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(n===t.getFillerOffset())return!1;const i=e.nodeBefore,o=e.nodeAfter;return!(i instanceof Qo||o instanceof Qo)&&(!r.isAndroid||!i&&!o)}_updateText(e,t){const n=this.domConverter.findCorrespondingDomText(e);let i=this.domConverter.viewToDom(e).data;const o=t.inlineFillerPosition;o&&o.parent==e.parent&&o.offset==e.index&&(i=Ws+i),na(n,i)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const n=Array.from(t.attributes).map((e=>e.name)),i=e.getAttributeKeys();for(const n of i)this.domConverter.setDomElementAttribute(t,n,e.getAttribute(n),e);for(const i of n)e.hasAttribute(i)||this.domConverter.removeDomElementAttribute(t,i)}_updateChildren(e,t){const n=this.domConverter.mapViewToDom(e);if(!n)return;if(r.isAndroid){let e=null;for(const t of Array.from(n.childNodes)){if(e&&Ri(e)&&Ri(t)){n.normalize();break}e=t}}const i=t.inlineFillerPosition,o=n.childNodes,s=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));i&&i.parent===e&&Js(n.ownerDocument,s,i.offset);const a=this._diffNodeLists(o,s),c=r.isAndroid?this._findReplaceActions(a,o,s,{replaceText:!0}):a;let l=0;const d=new Set;for(const e of c)"delete"===e?(d.add(o[l]),Qi(o[l])):"equal"!==e&&"replace"!==e||l++;l=0;for(const e of c)"insert"===e?(qi(n,l,s[l]),l++):"replace"===e?(na(o[l],s[l].data),l++):"equal"===e&&(this._markDescendantTextToSync(this.domConverter.domToView(s[l])),l++);for(const e of d)e.parentNode||this.domConverter.unbindDomElement(e)}_diffNodeLists(e,t){return d(e=function(e,t){const n=Array.from(e);if(0==n.length||!t)return n;n[n.length-1]==t&&n.pop();return n}(e,this._fakeSelectionContainer),t,ta.bind(null,this.domConverter))}_findReplaceActions(e,t,n,i={}){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let o=[],r=[],s=[];const a={equal:0,insert:0,delete:0};for(const c of e)"insert"===c?s.push(n[a.equal+a.insert]):"delete"===c?r.push(t[a.equal+a.delete]):(o=o.concat(d(r,s,i.replaceText?ea:Xs).map((e=>"equal"===e?"replace":e))),o.push("equal"),r=[],s=[]),a[c]++;return o.concat(d(r,s,i.replaceText?ea:Xs).map((e=>"equal"===e?"replace":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(r.isBlink&&!r.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(this._isFocusChanging)return;if(0===this.selection.rangeCount)return this._removeDomSelection(),void this._removeFakeSelection();const e=this.domConverter.mapViewToDom(this.selection.editableElement);this.isFocused&&e&&(this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&r.isAndroid||this._updateDomSelection(e))}_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 n=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(n,this.selection),!this._fakeSelectionNeedsUpdate(e))return;n.parentElement&&n.parentElement==e||e.appendChild(n),n.textContent=this.selection.fakeSelectionLabel||" ";const i=t.getSelection(),o=t.createRange();i.removeAllRanges(),o.selectNodeContents(n),i.addRange(o)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const n=this.domConverter.viewPositionToDom(this.selection.anchor),i=this.domConverter.viewPositionToDom(this.selection.focus);t.collapse(n.parent,n.offset),t.extend(i.parent,i.offset),r.isGecko&&function(e,t){const n=e.parent;if(n.nodeType!=Node.ELEMENT_NODE||e.offset!=n.childNodes.length-1)return;const i=n.childNodes[e.offset];i&&"BR"==i.tagName&&t.addRange(t.getRangeAt(0))}(i,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return(!t||!this.selection.isEqual(t))&&!(!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,n=e.ownerDocument.getSelection();return!t||t.parentElement!==e||(n.anchorNode!==t&&!t.contains(n.anchorNode)||t.textContent!==this.selection.fakeSelectionLabel)}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const n=e.activeElement,i=this.domConverter.mapDomToView(n);n&&i&&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 Js(e,t,n){const i=t instanceof Array?t:t.childNodes,o=i[n];if(Ri(o))return o.data=Ws+o.data,o;{const o=e.createTextNode(Ws);return Array.isArray(t)?i.splice(n,0,o):qi(t,n,o),o}}function Xs(e,t){return Ai(e)&&Ai(t)&&!Ri(e)&&!Ri(t)&&!Zi(e)&&!Zi(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function ea(e,t){return Ai(e)&&Ai(t)&&Ri(e)&&Ri(t)}function ta(e,t,n){return t===n||(Ri(t)&&Ri(n)?t.data===n.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(n)))}function na(e,t){const n=e.data;if(n==t)return;const i=a(n,t);for(const t of i)"insert"===t.type?e.insertData(t.index,t.values.join("")):e.deleteData(t.index,t.howMany)}const ia=Hs(Mi.document),oa=Fs(Mi.document),ra=Us(Mi.document),sa="data-ck-unsafe-attribute-",aa="data-ck-unsafe-element";class ca{constructor(e,t={}){this.document=e,this.renderingMode=t.renderingMode||"editing",this.blockFillerMode=t.blockFillerMode||("editing"===this.renderingMode?"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?Mi.document:Mi.document.implementation.createHTMLDocument(""),this._domToViewMapping=new WeakMap,this._viewToDomMapping=new WeakMap,this._fakeSelectionMapping=new WeakMap,this._rawContentElementMatcher=new Xo,this._encounteredRawContentDomNodes=new WeakSet}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new ls(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,n){return"data"===this.renderingMode||!(e=e.toLowerCase()).startsWith("on")&&(("srcdoc"!==e||!t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i))&&("img"===n&&("src"===e||"srcset"===e)||("source"===n&&"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 n=(new DOMParser).parseFromString(t,"text/html"),i=n.createDocumentFragment(),o=n.body.childNodes;for(;o.length>0;)i.appendChild(o[0]);const r=n.createTreeWalker(i,NodeFilter.SHOW_ELEMENT),s=[];let a;for(;a=r.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)&&(ua(t),e.replaceWith(this._createReplacementDomElement(t,e)))}for(;e.firstChild;)e.firstChild.remove();e.append(i)}viewToDom(e,t={}){if(e.is("$text")){const t=this._processDataFromViewText(e);return this._domDocument.createTextNode(t)}{if(this.mapViewToDom(e))return this.mapViewToDom(e);let n;if(e.is("documentFragment"))n=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(n,e);else{if(e.is("uiElement"))return n="$comment"===e.name?this._domDocument.createComment(e.getCustomProperty("$rawContent")):e.render(this._domDocument,this),t.bind&&this.bindElements(n,e),n;this._shouldRenameElement(e.name)?(ua(e.name),n=this._createReplacementDomElement(e.name)):n=e.hasAttribute("xmlns")?this._domDocument.createElementNS(e.getAttribute("xmlns"),e.name):this._domDocument.createElement(e.name),e.is("rawElement")&&e.render(n,this),t.bind&&this.bindElements(n,e);for(const t of e.getAttributeKeys())this.setDomElementAttribute(n,t,e.getAttribute(t),e)}if(!1!==t.withChildren)for(const i of this.viewChildrenToDom(e,t))n.appendChild(i);return n}}setDomElementAttribute(e,t,n,i){const o=this.shouldRenderAttribute(t,n,e.tagName.toLowerCase())||i&&i.shouldRenderUnsafeAttribute(t);o||k("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:n}),e.hasAttribute(t)&&!o?e.removeAttribute(t):e.hasAttribute(sa+t)&&o&&e.removeAttribute(sa+t),e.setAttribute(o?t:sa+t,n)}removeDomElementAttribute(e,t){t!=aa&&(e.removeAttribute(t),e.removeAttribute(sa+t))}*viewChildrenToDom(e,t={}){const n=e.getFillerOffset&&e.getFillerOffset();let i=0;for(const o of e.getChildren()){n===i&&(yield this._getBlockFiller());const e=o.is("element")&&o.getCustomProperty("dataPipeline:transparentRendering");e&&"data"==this.renderingMode?yield*this.viewChildrenToDom(o,t):(e&&k("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:o}),yield this.viewToDom(o,t)),i++}n===i&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),n=this.viewPositionToDom(e.end),i=this._domDocument.createRange();return i.setStart(t.parent,t.offset),i.setEnd(n.parent,n.offset),i}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const n=this.findCorrespondingDomText(t);if(!n)return null;let i=e.offset;return qs(n)&&(i+=7),{parent:n,offset:i}}{let n,i,o;if(0===e.offset){if(n=this.mapViewToDom(t),!n)return null;o=n.childNodes[0]}else{const t=e.nodeBefore;if(i=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(t),!i)return null;n=i.parentNode,o=i.nextSibling}if(Ri(o)&&qs(o))return{parent:o,offset:7};return{parent:n,offset:i?Wi(i)+1:0}}}domToView(e,t={}){if(this.isBlockFiller(e))return null;const n=this.getHostViewElement(e);if(n)return n;if(Zi(e)&&t.skipComments)return null;if(Ri(e)){if(Zs(e))return null;{const t=this._processDataFromDomText(e);return""===t?null:new Qo(this.document,t)}}{if(this.mapDomToView(e))return this.mapDomToView(e);let n;if(this.isDocumentFragment(e))n=new Ps(this.document),t.bind&&this.bindDocumentFragments(e,n);else{n=this._createViewElement(e,t),t.bind&&this.bindElements(e,n);const i=e.attributes;if(i)for(let e=i.length,t=0;t{const{scrollLeft:t,scrollTop:n}=e;i.push([t,n])})),t.focus(),la(t,(e=>{const[t,n]=i.shift();e.scrollLeft=t,e.scrollTop=n})),Mi.window.scrollTo(e,n)}}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(ia):!("BR"!==e.tagName||!da(e,this.blockElements)||1!==e.parentNode.childNodes.length)||(e.isEqualNode(ra)||function(e,t){return e.isEqualNode(oa)&&da(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 n=t.collapsed;return t.detach(),n}getHostViewElement(e){const t=Oi(e);for(t.pop();t.length;){const e=t.pop(),n=this._domToViewMapping.get(e);if(n&&(n.is("uiElement")||n.is("rawElement")))return n}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return Fs(this._domDocument);case"markedNbsp":return Us(this._domDocument);case"br":return Hs(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(Ri(e)&&qs(e)&&t<7)return!1;if(this.isElement(e)&&qs(e.childNodes[t]))return!1;const n=this.mapDomToView(e);return!n||!n.is("uiElement")&&!n.is("rawElement")}_processDataFromViewText(e){let t=e.data;if(e.getAncestors().some((e=>this.preElements.includes(e.name))))return t;if(" "==t.charAt(0)){const n=this._getTouchingInlineViewNode(e,!1);!(n&&n.is("$textProxy")&&this._nodeEndsWithSpace(n))&&n||(t=" "+t.substr(1))}if(" "==t.charAt(t.length-1)){const n=this._getTouchingInlineViewNode(e,!0),i=n&&n.is("$textProxy")&&" "==n.data.charAt(0);" "!=t.charAt(t.length-2)&&n&&!i||(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)}_processDataFromDomText(e){let t=e.data;if(function(e,t){return Oi(e).some((e=>e.tagName&&t.includes(e.tagName.toLowerCase())))}(e,this.preElements))return $s(e);t=t.replace(/[ \n\t\r]{1,}/g," ");const n=this._getTouchingInlineDomNode(e,!1),i=this._getTouchingInlineDomNode(e,!0),o=this._checkShouldLeftTrimDomText(e,n),r=this._checkShouldRightTrimDomText(e,i);o&&(t=t.replace(/^ /,"")),r&&(t=t.replace(/ $/,"")),t=$s(new Text(t)),t=t.replace(/ \u00A0/g," ");const s=i&&this.isElement(i)&&"BR"!=i.tagName,a=i&&Ri(i)&&" "==i.data.charAt(0);return(/( |\u00A0)\u00A0$/.test(t)||!i||s||a)&&(t=t.replace(/\u00A0$/," ")),(o||n&&this.isElement(n)&&"BR"!=n.tagName)&&(t=t.replace(/^\u00A0/," ")),t}_checkShouldLeftTrimDomText(e,t){return!t||(this.isElement(t)?"BR"===t.tagName:!this._encounteredRawContentDomNodes.has(e.previousSibling)&&/[^\S\u00A0]/.test(t.data.charAt(t.data.length-1)))}_checkShouldRightTrimDomText(e,t){return!t&&!qs(e)}_getTouchingInlineViewNode(e,t){const n=new rs({startPosition:t?ss._createAfter(e):ss._createBefore(e),direction:t?"forward":"backward"});for(const e of n){if(e.item.is("element")&&this.inlineObjectElements.includes(e.item.name))return e.item;if(e.item.is("containerElement"))return null;if(e.item.is("element","br"))return null;if(e.item.is("$textProxy"))return e.item}return null}_getTouchingInlineDomNode(e,t){if(!e.parentNode)return null;const n=t?"firstChild":"lastChild",i=t?"nextSibling":"previousSibling";let o=!0,r=e;do{if(!o&&r[n]?r=r[n]:r[i]?(r=r[i],o=!1):(r=r.parentNode,o=!0),!r||this._isBlockElement(r))return null}while(!Ri(r)&&"BR"!=r.tagName&&!this._isInlineObjectElement(r));return r}_isBlockElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isInlineObjectElement(e){return this.isElement(e)&&this.inlineObjectElements.includes(e.tagName.toLowerCase())}_createViewElement(e,t){if(Zi(e))return new As(this.document,"$comment");const n=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new Jr(this.document,n)}_isViewElementWithRawContent(e,t){return!1!==t.withChildren&&!!this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return"editing"===this.renderingMode&&this.unsafeElements.includes(t)}_createReplacementDomElement(e,t){const n=this._domDocument.createElement("span");if(n.setAttribute(aa,e),t){for(;t.firstChild;)n.appendChild(t.firstChild);for(const e of t.getAttributeNames())n.setAttribute(e,t.getAttribute(e))}return n}}function la(e,t){let n=e;for(;n;)t(n),n=n.parentElement}function da(e,t){const n=e.parentNode;return!!n&&!!n.tagName&&t.includes(n.tagName.toLowerCase())}function ua(e){"script"===e&&k("domconverter-unsafe-script-element-detected"),"style"===e&&k("domconverter-unsafe-style-element-detected")}class ha extends(Ti()){constructor(e){super(),this.view=e,this.document=e.document,this.isEnabled=!1}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 ma=Wr((function(e,t){Tt(t,un(t),e)}));class fa{constructor(e,t,n){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,ma(this,n)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class ga extends ha{constructor(e){super(e),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})}))}fire(e,t,n){this.isEnabled&&this.document.fire(e,new fa(this.view,t,n))}}class pa extends ga{constructor(e){super(e),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 ho(this)}};this.fire(e.type,e,t)}}const ba=function(){return te.Date.now()};var wa=/\s/;const ka=function(e){for(var t=e.length;t--&&wa.test(e.charAt(t)););return t};var _a=/^\s+/;const va=function(e){return e?e.slice(0,ka(e)+1).replace(_a,""):e};var ya=/^[-+]0x[0-9a-f]+$/i,xa=/^0b[01]+$/i,Aa=/^0o[0-7]+$/i,Ca=parseInt;const Ea=function(e){if("number"==typeof e)return e;if(nr(e))return NaN;if(L(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=L(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=va(e);var n=xa.test(e);return n||Aa.test(e)?Ca(e.slice(2),n?2:8):ya.test(e)?NaN:+e};var Ta=Math.max,Sa=Math.min;const Pa=function(e,t,n){var i,o,r,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 n=i,r=o;return i=o=void 0,l=t,s=e.apply(r,n)}function f(e){return l=e,a=setTimeout(p,t),d?m(e):s}function g(e){var n=e-c;return void 0===c||n>=t||n<0||u&&e-l>=r}function p(){var e=ba();if(g(e))return b(e);a=setTimeout(p,function(e){var n=t-(e-c);return u?Sa(n,r-(e-l)):n}(e))}function b(e){return a=void 0,h&&i?m(e):(i=o=void 0,s)}function w(){var e=ba(),n=g(e);if(i=arguments,o=this,c=e,n){if(void 0===a)return f(c);if(u)return clearTimeout(a),a=setTimeout(p,t),m(c)}return void 0===a&&(a=setTimeout(p,t)),s}return t=Ea(t)||0,L(n)&&(d=!!n.leading,r=(u="maxWait"in n)?Ta(Ea(n.maxWait)||0,t):r,h="trailing"in n?!!n.trailing:h),w.cancel=function(){void 0!==a&&clearTimeout(a),l=0,i=c=o=a=void 0},w.flush=function(){return void 0===a?s:b(ba())},w};class Ia extends ha{constructor(e){super(e),this._fireSelectionChangeDoneDebounced=Pa((e=>{this.document.fire("selectionChangeDone",e)}),200)}observe(){const e=this.document;e.on("arrowKey",((t,n)=>{e.selection.isFake&&this.isEnabled&&n.preventDefault()}),{context:"$capture"}),e.on("arrowKey",((t,n)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(n.keyCode)}),{priority:"lowest"})}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,n=new ls(t.getRanges(),{backward:t.isBackward,fake:!1});e!=lo.arrowleft&&e!=lo.arrowup||n.setTo(n.getFirstPosition()),e!=lo.arrowright&&e!=lo.arrowdown||n.setTo(n.getLastPosition());const i={oldSelection:t,newSelection:n,domSelection:null};this.document.fire("selectionChange",i),this._fireSelectionChangeDoneDebounced(i)}}const Ma=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this};const Oa=function(e){return this.__data__.has(e)};function Ra(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new wt;++ta))return!1;var l=r.get(e),d=r.get(t);if(l&&d)return l==t&&d==e;var u=-1,h=!0,m=2&n?new Na:void 0;for(r.set(e,t),r.set(t,e);++u{this.document.fire("selectionChangeDone",e)}),200),this._clearInfiniteLoopInterval=setInterval((()=>this._clearInfiniteLoop()),1e3),this._documentIsSelectingInactivityTimeoutDebounced=Pa((()=>this.document.isSelecting=!1),5e3),this._loopbackCounter=0}observe(e){const t=e.ownerDocument,n=()=>{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",n,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",n,{priority:"highest",useCapture:!0}),this._documents.has(t)||(this.listenTo(t,"mouseup",n,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",((e,n)=>{this.document.isComposing&&!r.isAndroid||(this._handleSelectionChange(n,t),this._documentIsSelectingInactivityTimeoutDebounced())})),this._documents.add(t))}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_handleSelectionChange(e,t){if(!this.isEnabled)return;const n=t.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(n.anchorNode))return;this.mutationObserver.flush();const i=this.domConverter.domSelectionToView(n);if(0!=i.rangeCount){if(this.view.hasDomSelection=!0,!(this.selection.isEqual(i)&&this.domConverter.isDomSelectionCorrect(n)||++this._loopbackCounter>60))if(this.selection.isSimilar(i))this.view.forceRender();else{const e={oldSelection:this.selection,newSelection:i,domSelection:n};this.document._isFocusChanging=!1,this.document.fire("selectionChange",e),this._fireSelectionChangeDoneDebounced(e)}}else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}}class tc extends ga{constructor(e){super(e),this.domEventType=["focus","blur"],this.useCapture=!0;const t=this.document;t.on("focus",(()=>{t.isFocused=!0,t._isFocusChanging=!0,this._renderTimeoutId=setTimeout((()=>{t._isFocusChanging=!1,e.change((()=>{}))}),50)})),t.on("blur",((n,i)=>{const o=t.selection.editableElement;null!==o&&o!==i.target||(t.isFocused=!1,e.change((()=>{})))}))}onDomEvent(e){this.fire(e.type,e)}destroy(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),super.destroy()}}class nc extends ga{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 ic{constructor(e){this.files=function(e){const t=Array.from(e.files||[]),n=Array.from(e.items||[]);if(t.length)return t;return n.filter((e=>"file"===e.kind)).map((e=>e.getAsFile()))}(e),this._native=e}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}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}class oc extends ga{constructor(e){super(e),this.domEventType=["beforeinput"]}onDomEvent(e){const t=e.getTargetRanges(),n=this.view,i=n.document;let o=null,s=null,a=[];if(e.dataTransfer&&(o=new ic(e.dataTransfer)),null!==e.data?s=e.data:o&&(s=o.getData("text/plain")),i.selection.isFake)a=Array.from(i.selection.getRanges());else if(t.length)a=t.map((e=>n.domConverter.domRangeToView(e)));else if(r.isAndroid){const t=e.target.ownerDocument.defaultView.getSelection();a=Array.from(n.domConverter.domSelectionToView(t).getRanges())}if(r.isAndroid&&"insertCompositionText"==e.inputType&&s&&s.endsWith("\n"))this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[n.createRange(a[0].end)]});else if("insertText"==e.inputType&&s&&s.includes("\n")){const t=s.split(/\n{1,2}/g);let n=a;for(let r=0;r{if(this.isEnabled&&((n=t.keyCode)==lo.arrowright||n==lo.arrowleft||n==lo.arrowup||n==lo.arrowdown)){const n=new us(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(n,t),n.stop.called&&e.stop()}var n}))}observe(){}}class sc extends ha{constructor(e){super(e);const t=this.document;t.on("keydown",((e,n)=>{if(!this.isEnabled||n.keyCode!=lo.tab||n.ctrlKey)return;const i=new us(t,"tab",t.selection.getFirstRange());t.fire(i,n),i.stop.called&&e.stop()}))}observe(){}}class ac extends(H()){constructor(e){super(),this.document=new ws(e),this.domConverter=new ca(this.document),this.domRoots=new Map,this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new Qs(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing","_isFocusChanging").to(this.document,"isFocused","isSelecting","isComposing","_isFocusChanging"),this._initialDomRootAttributes=new WeakMap,this._observers=new Map,this._ongoingChange=!1,this._postFixersInProgress=!1,this._renderingDisabled=!1,this._hasChangedSinceTheLastRendering=!1,this._writer=new Is(this.document),this.addObserver(Ja),this.addObserver(ec),this.addObserver(tc),this.addObserver(pa),this.addObserver(Ia),this.addObserver(nc),this.addObserver(rc),this.addObserver(oc),this.addObserver(sc),this.document.on("arrowKey",Ks,{priority:"low"}),Cs(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}))}attachDomRoot(e,t="main"){const n=this.document.getRoot(t);n._name=e.tagName.toLowerCase();const i={};for(const{name:t,value:o}of Array.from(e.attributes))i[t]=o,"class"===t?this._writer.addClass(o.split(" "),n):this._writer.setAttribute(t,o,n);this._initialDomRootAttributes.set(e,i);const o=()=>{this._writer.setAttribute("contenteditable",(!n.isReadOnly).toString(),n),n.isReadOnly?this._writer.addClass("ck-read-only",n):this._writer.removeClass("ck-read-only",n)};o(),this.domRoots.set(t,e),this.domConverter.bindElements(e,n),this._renderer.markToSync("children",n),this._renderer.markToSync("attributes",n),this._renderer.domDocuments.add(e.ownerDocument),n.on("change:children",((e,t)=>this._renderer.markToSync("children",t))),n.on("change:attributes",((e,t)=>this._renderer.markToSync("attributes",t))),n.on("change:text",((e,t)=>this._renderer.markToSync("text",t))),n.on("change:isReadOnly",(()=>this.change(o))),n.on("change",(()=>{this._hasChangedSinceTheLastRendering=!0}));for(const n of this._observers.values())n.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach((({name:e})=>t.removeAttribute(e)));const n=this._initialDomRootAttributes.get(t);for(const e in n)t.setAttribute(e,n[e]);this.domRoots.delete(e),this.domConverter.unbindDomElement(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,n]of this.domRoots)t.observe(n,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(){const e=this.document.selection.getFirstRange();e&&function({target:e,viewportOffset:t=0}){const n=oo(e);let i=n,o=null;for(;i;){let r;r=ro(i==n?e:o),Xi(r,(()=>so(e,i)));const s=so(e,i);if(Ji(i,s,t),i.parent!=i){if(o=i.frameElement,i=i.parent,!o)return}else i=null}}({target:this.domConverter.viewRangeToDom(e),viewportOffset:20})}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 w("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){w.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.document._isFocusChanging=!1,this.change((()=>{}))}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return ss._createAt(e,t)}createPositionAfter(e){return ss._createAfter(e)}createPositionBefore(e){return ss._createBefore(e)}createRange(...e){return new as(...e)}createRangeOn(e){return as._createOn(e)}createRangeIn(e){return as._createIn(e)}createSelection(...e){return new ls(...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 cc{is(){throw new Error("is() method is abstract")}}class lc extends cc{constructor(e){super(),this.parent=null,this._attrs=Co(e)}get document(){return null}get index(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildIndex(this)))throw new w("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 w("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 this.root.is("rootElement")}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={}){const t=[];let n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}getCommonAncestor(e,t={}){const n=this.getAncestors(t),i=e.getAncestors(t);let o=0;for(;n[o]==i[o]&&n[o];)o++;return 0===o?null:n[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),n=e.getPath(),i=Q(t,n);switch(i){case"prefix":return!0;case"extension":return!1;default:return t[i](e[t[0]]=t[1],e)),{})),e}_clone(e){return new lc(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,t){this._attrs.set(e,t)}_setAttributesTo(e){this._attrs=Co(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}lc.prototype.is=function(e){return"node"===e||"model:node"===e};class dc{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 w("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){let t=0;for(const n of this._nodes){if(e>=t&&e1e4)return e.slice(0,n).concat(t).concat(e.slice(n+i,e.length));{const o=Array.from(e);return o.splice(n,i,...t),o}}(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 uc extends lc{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 uc(this.data,this.getAttributes())}static fromJSON(e){return new uc(e.data,e.attributes)}}uc.prototype.is=function(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e};class hc extends cc{constructor(e,t,n){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new w("model-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.offsetSize)throw new w("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+n),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 n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}hc.prototype.is=function(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e};class mc extends lc{constructor(e,t,n){super(t),this.name=e,this._children=new dc,n&&this._insertChild(0,n)}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 n of e)t=t.getChild(t.offsetToIndex(n));return t}findAncestor(e,t={}){let n=t.includeSelf?this:this.parent;for(;n;){if(n.name===e)return n;n=n.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?Array.from(this._children).map((e=>e._clone(!0))):void 0;return new mc(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const n=function(e){if("string"==typeof e)return[new uc(e)];J(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new uc(e):e instanceof hc?new uc(e.data,e.getAttributes()):e))}(t);for(const e of n)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const e of n)e.parent=null;return n}static fromJSON(e){let t;if(e.children){t=[];for(const n of e.children)n.name?t.push(mc.fromJSON(n)):t.push(uc.fromJSON(n))}return new mc(e.name,e.attributes,t)}}mc.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 fc{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new w("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new w("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=pc._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}skip(e){let t,n,i,o;do{i=this.position,o=this._visitedParent,({done:t,value:n}=this.next())}while(!t&&e(n));t||(this.position=i,this._visitedParent=o)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),n=this._visitedParent;if(null===n.parent&&t.offset===n.maxOffset)return{done:!0,value:void 0};if(n===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const i=bc(t,n),o=i||wc(t,n,i);if(o instanceof mc)return this.shallow?t.offset++:(t.path.push(0),this._visitedParent=o),this.position=t,gc("elementStart",o,e,t,1);if(o instanceof uc){let i;if(this.singleCharacters)i=1;else{let e=o.endOffset;this._boundaryEndParent==n&&this.boundaries.end.offsete&&(e=this.boundaries.start.offset),i=t.offset-e}const o=t.offset-r.startOffset,s=new hc(r,o-i,i);return t.offset-=i,this.position=t,gc("text",s,e,t,i)}return t.path.pop(),this.position=t,this._visitedParent=n.parent,gc("elementStart",n,e,t,1)}}function gc(e,t,n,i,o){return{done:!1,value:{type:e,item:t,previousPosition:n,nextPosition:i,length:o}}}class pc extends cc{constructor(e,t,n="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new w("model-position-root-invalid",e);if(!(t instanceof Array)||0===t.length)throw new w("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=n}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;t1)return!1;if(1===t)return _c(e,this,n);if(-1===t)return _c(this,e,n)}return this.path.length===e.path.length||(this.path.length>e.path.length?vc(this.path,t):vc(e.path,t))}hasSameParentAs(e){if(this.root!==e.root)return!1;return"same"==Q(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=pc._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 n;return t.containsPosition(this)||t.start.isEqual(this)?(n=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(n=n._getTransformedByDeletion(e.deletionPosition,1))):n=this.isEqual(e.deletionPosition)?pc._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),n}_getTransformedByDeletion(e,t){const n=pc._createAt(this);if(this.root!=e.root)return n;if("same"==Q(e.getParentPath(),this.getParentPath())){if(e.offsetthis.offset)return null;n.offset-=t}}else if("prefix"==Q(e.getParentPath(),this.getParentPath())){const i=e.path.length-1;if(e.offset<=this.path[i]){if(e.offset+t>this.path[i])return null;n.path[i]-=t}}return n}_getTransformedByInsertion(e,t){const n=pc._createAt(this);if(this.root!=e.root)return n;if("same"==Q(e.getParentPath(),this.getParentPath()))(e.offset=t;){if(e.path[i]+o!==n.maxOffset)return!1;o=1,i--,n=n.parent}return!0}(e,n+1))}function vc(e,t){for(;tt+1;){const t=i.maxOffset-n.offset;0!==t&&e.push(new yc(n,n.getShiftedBy(t))),n.path=n.path.slice(0,-1),n.offset++,i=i.parent}for(;n.path.length<=this.end.path.length;){const t=this.end.path[n.path.length-1],i=t-n.offset;0!==i&&e.push(new yc(n,n.getShiftedBy(i))),n.offset=t,n.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new fc(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new fc(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new fc(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 yc(this.start,this.end)]}getTransformedByOperations(e){const t=[new yc(this.start,this.end)];for(const n of e)for(let e=0;e0?new this(n,i):new this(i,n)}static _createIn(e){return new this(pc._createAt(e,0),pc._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(pc._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new w("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 n=e.indexOf(t),i=new this(t.start,t.end);if(n>0)for(let t=n-1;e[t].end.isEqual(i.start);t++)i.start=pc._createAt(e[t].start);for(let t=n+1;t{if(t.viewPosition)return;const n=this._modelToViewMapping.get(t.modelPosition.parent);if(!n)throw new w("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(n,t.modelPosition.offset)}),{priority:"low"}),this.on("viewToModelPosition",((e,t)=>{if(t.modelPosition)return;const n=this.findMappedViewAncestor(t.viewPosition),i=this._viewToModelMapping.get(n),o=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,n);t.modelPosition=pc._createAt(i,o)}),{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const n=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const 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(n)==e&&this._modelToViewMapping.delete(n))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)}bindElementToMarker(e,t){const n=this._markerNameToElements.get(t)||new Set;n.add(e);const i=this._elementToMarkerNames.get(e)||new Set;i.add(t),this._markerNameToElements.set(t,n),this._elementToMarkerNames.set(e,i)}unbindElementFromMarkerName(e,t){const n=this._markerNameToElements.get(t);n&&(n.delete(e),0==n.size&&this._markerNameToElements.delete(t));const i=this._elementToMarkerNames.get(e);i&&(i.delete(t),0==i.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 yc(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new as(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){const t={viewPosition:e,mapper:this};return this.fire("viewToModelPosition",t),t.modelPosition}toViewPosition(e,t={}){const n={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",n),n.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const n=new Set;for(const e of t)if(e.is("attributeElement"))for(const t of e.getElementsWithSameId())n.add(t);else n.add(e);return n}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,n){if(n!=e){return this._toModelOffset(e.parent,e.index,n)+this._toModelOffset(e,t,e)}if(e.is("$text"))return t;let i=0;for(let n=0;n1?t[0]+":"+t[1]:t[0]}class Ec extends(S()){constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,n){const i=this._createConversionApi(n,e.getRefreshedItems());for(const t of e.getMarkersToRemove())this._convertMarkerRemove(t.name,t.range,i);const o=this._reduceChanges(e.getChanges());for(const e of o)"insert"===e.type?this._convertInsert(yc._createFromPositionAndShift(e.position,e.length),i):"reinsert"===e.type?this._convertReinsert(yc._createFromPositionAndShift(e.position,e.length),i):"remove"===e.type?this._convertRemove(e.position,e.length,e.name,i):this._convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,i);for(const e of i.mapper.flushUnboundMarkerNames()){const n=t.get(e).getRange();this._convertMarkerRemove(e,n,i),this._convertMarkerAdd(e,n,i)}for(const t of e.getMarkersToAdd())this._convertMarkerAdd(t.name,t.range,i);i.mapper.flushDeferredBindings(),i.consumable.verifyAllConsumed("insert")}convert(e,t,n,i={}){const o=this._createConversionApi(n,void 0,i);this._convertInsert(e,o);for(const[e,n]of t)this._convertMarkerAdd(e,n,o);o.consumable.verifyAllConsumed("insert")}convertSelection(e,t,n){const i=Array.from(t.getMarkersAtPosition(e.getFirstPosition())),o=this._createConversionApi(n);if(this._addConsumablesForSelection(o.consumable,e,i),this.fire("selection",{selection:e},o),e.isCollapsed){for(const t of i){const n=t.getRange();if(!Tc(e.getFirstPosition(),t,o.mapper))continue;const i={item:e,markerName:t.name,markerRange:n};o.consumable.test(e,"addMarker:"+t.name)&&this.fire(`addMarker:${t.name}`,i,o)}for(const t of e.getAttributeKeys()){const n={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};o.consumable.test(e,"attribute:"+n.attributeKey)&&this.fire(`attribute:${n.attributeKey}:$text`,n,o)}}}_convertInsert(e,t,n={}){n.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,Array.from(e));for(const n of Array.from(e.getWalker({shallow:!0})).map(Sc))this._testAndFire("insert",n,t)}_convertRemove(e,t,n,i){this.fire(`remove:${n}`,{position:e,length:t},i)}_convertAttribute(e,t,n,i,o){this._addConsumablesForRange(o.consumable,e,`attribute:${t}`);for(const r of e){const e={item:r.item,range:yc._createFromPositionAndShift(r.previousPosition,r.length),attributeKey:t,attributeOldValue:n,attributeNewValue:i};this._testAndFire(`attribute:${t}`,e,o)}}_convertReinsert(e,t){const n=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,n);for(const e of n.map(Sc))this._testAndFire("insert",{...e,reconversion:!0},t)}_convertMarkerAdd(e,t,n){if("$graveyard"==t.root.rootName)return;const i=`addMarker:${e}`;if(n.consumable.add(t,i),this.fire(i,{markerName:e,markerRange:t},n),n.consumable.consume(t,i)){this._addConsumablesForRange(n.consumable,t,i);for(const o of t.getItems()){if(!n.consumable.test(o,i))continue;const r={item:o,range:yc._createOn(o),markerName:e,markerRange:t};this.fire(i,r,n)}}}_convertMarkerRemove(e,t,n){"$graveyard"!=t.root.rootName&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},n)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.changes}_addConsumablesForInsert(e,t){for(const n of t){const t=n.item;if(null===e.test(t,"insert")){e.add(t,"insert");for(const n of t.getAttributeKeys())e.add(t,"attribute:"+n)}}return e}_addConsumablesForRange(e,t,n){for(const i of t.getItems())e.add(i,n);return e}_addConsumablesForSelection(e,t,n){e.add(t,"selection");for(const i of n)e.add(t,"addMarker:"+i.name);for(const n of t.getAttributeKeys())e.add(t,"attribute:"+n);return e}_testAndFire(e,t,n){const i=function(e,t){const n=t.item.is("element")?t.item.name:"$text";return`${e}:${n}`}(e,t),o=t.item.is("$textProxy")?n.consumable._getSymbolForTextProxy(t.item):t.item,r=this._firedEventsMap.get(n),s=r.get(o);if(s){if(s.has(i))return;s.add(i)}else r.set(o,new Set([i]));this.fire(i,t,n)}_testAndFireAddAttributes(e,t){const n={item:e,range:yc._createOn(e)};for(const e of n.item.getAttributeKeys())n.attributeKey=e,n.attributeOldValue=null,n.attributeNewValue=n.item.getAttribute(e),this._testAndFire(`attribute:${e}`,n,t)}_createConversionApi(e,t=new Set,n={}){const i={...this._conversionApi,consumable:new Ac,writer:e,options:n,convertItem:e=>this._convertInsert(yc._createOn(e),i),convertChildren:e=>this._convertInsert(yc._createIn(e),i,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,i),canReuseView:e=>!t.has(i.mapper.toModelElement(e))};return this._firedEventsMap.set(i,new Map),i}}function Tc(e,t,n){const i=t.getRange(),o=Array.from(e.getAncestors());o.shift(),o.reverse();return!o.some((e=>{if(i.containsItem(e)){return!!n.toViewElement(e).getCustomProperty("addHighlight")}}))}function Sc(e){return{item:e.item,range:yc._createFromPositionAndShift(e.previousPosition,e.length)}}class Pc extends(S(cc)){constructor(...e){super(),this._lastRangeBackward=!1,this._ranges=[],this._attrs=new Map,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 n=!1;for(const i of e._ranges)if(t.isEqual(i)){n=!0;break}if(!n)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new yc(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 yc(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 yc(e.start,e.end):null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}setTo(...e){let[t,n,i]=e;if("object"==typeof n&&(i=n,n=void 0),null===t)this._setRanges([]);else if(t instanceof Pc)this._setRanges(t.getRanges(),t.isBackward);else if(t&&"function"==typeof t.getRanges)this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof yc)this._setRanges([t],!!i&&!!i.backward);else if(t instanceof pc)this._setRanges([new yc(t)]);else if(t instanceof lc){const e=!!i&&!!i.backward;let o;if("in"==n)o=yc._createIn(t);else if("on"==n)o=yc._createOn(t);else{if(void 0===n)throw new w("model-selection-setto-required-second-parameter",[this,t]);o=new yc(pc._createAt(t,n))}this._setRanges([o],e)}else{if(!J(t))throw new w("model-selection-setto-not-selectable",[this,t]);this._setRanges(t,i&&!!i.backward)}}_setRanges(e,t=!1){const n=Array.from(e),i=n.some((t=>{if(!(t instanceof yc))throw new w("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every((e=>!e.isEqual(t)))}));(n.length!==this._ranges.length||i)&&(this._replaceAllRanges(n),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(null===this.anchor)throw new w("model-selection-setfocus-no-ranges",[this,e]);const n=pc._createAt(e,t);if("same"==n.compareWith(this.focus))return;const i=this.anchor;this._ranges.length&&this._popRange(),"before"==n.compareWith(i)?(this._pushRange(new yc(n,i)),this._lastRangeBackward=!0):(this._pushRange(new yc(i,n)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const n=Oc(t.start,e);n&&Rc(n,t)&&(yield n);for(const n of t.getWalker()){const i=n.item;"elementEnd"==n.type&&Mc(i,e,t)&&(yield i)}const i=Oc(t.end,e);i&&!t.end.isTouching(pc._createAt(i,0))&&Rc(i,t)&&(yield i)}}containsEntireContent(e=this.anchor.root){const t=pc._createAt(e,0),n=pc._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&n.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new yc(e.start,e.end))}_checkRange(e){for(let t=0;t0;)this._popRange()}_popRange(){this._ranges.pop()}}function Ic(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&!!e.parent)}function Mc(e,t,n){return Ic(e,t)&&Rc(e,n)}function Oc(e,t){const n=e.parent.root.document.model.schema,i=e.parent.getAncestors({parentFirst:!0,includeSelf:!0});let o=!1;const r=i.find((e=>!o&&(o=n.isLimit(e),!o&&Ic(e,t))));return i.forEach((e=>t.add(e))),r}function Rc(e,t){const n=function(e){const t=e.root.document.model.schema;let n=e.parent;for(;n;){if(t.isBlock(n))return n;n=n.parent}}(e);if(!n)return!0;return!t.containsRange(yc._createOn(n),!0)}Pc.prototype.is=function(e){return"selection"===e||"model:selection"===e};class Nc extends(S(yc)){constructor(e,t){super(e,t),Dc.call(this)}detach(){this.stopListening()}toRange(){return new yc(this.start,this.end)}static fromRange(e){return new Nc(e.start,e.end)}}function Dc(){this.listenTo(this.root.document.model,"applyOperation",((e,t)=>{const n=t[0];n.isDocumentOperation&&Lc.call(this,n)}),{priority:"low"})}function Lc(e){const t=this.getTransformedByOperation(e),n=yc._createFromRanges(t),i=!n.isEqual(this),o=function(e,t){switch(t.type){case"insert":return e.containsPosition(t.position);case"move":case"remove":case"reinsert":case"merge":return e.containsPosition(t.sourcePosition)||e.start.isEqual(t.sourcePosition)||e.containsPosition(t.targetPosition);case"split":return e.containsPosition(t.splitPosition)||e.containsPosition(t.insertionPosition)}return!1}(this,e);let r=null;if(i){"$graveyard"==n.root.rootName&&(r="remove"==e.type?e.sourcePosition:e.deletionPosition);const t=this.toRange();this.start=n.start,this.end=n.end,this.fire("change:range",t,{deletionPosition:r})}else o&&this.fire("change:content",this.toRange(),{deletionPosition:r})}Nc.prototype.is=function(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e};const Vc="selection:";class Bc extends(S(cc)){constructor(e){super(),this._selection=new jc(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 Vc+e}static _isStoreAttributeKey(e){return e.startsWith(Vc)}}Bc.prototype.is=function(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e};class jc extends Pc{constructor(e){super(),this.markers=new vo({idProperty:"name"}),this._model=e.model,this._document=e,this._attributePriority=new Map,this._selectionRestorePosition=null,this._hasChangedRange=!1,this._overriddenGravityRegister=new Set,this._observedMarkers=new Set,this.listenTo(this._model,"applyOperation",((e,t)=>{const n=t[0];n.isDocumentOperation&&"marker"!=n.type&&"rename"!=n.type&&"noop"!=n.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,n,i)=>{this._updateMarker(t,i)})),this.listenTo(this._document,"change",((e,t)=>{!function(e,t){const n=e.document.differ;for(const i of n.getChanges()){if("insert"!=i.type)continue;const n=i.position.parent;i.length===n.maxOffset&&e.enqueueChange(t,(e=>{const t=Array.from(n.getAttributeKeys()).filter((e=>e.startsWith(Vc)));for(const i of t)e.removeAttribute(i,n)}))}}(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=i.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 n=t.name.split(":",1)[0];if(!this._observedMarkers.has(n))continue;const i=t.getRange();for(const n of this.getRanges())i.containsRange(n,!n.isCollapsed)&&e.push(t)}const n=Array.from(this.markers);for(const n of e)this.markers.has(n)||(this.markers.add(n),t=!0);for(const n of Array.from(this.markers))e.includes(n)||(this.markers.remove(n),t=!0);t&&this.fire("change:marker",{oldMarkers:n,directChange:!1})}_updateMarker(e,t){const n=e.name.split(":",1)[0];if(!this._observedMarkers.has(n))return;let i=!1;const o=Array.from(this.markers),r=this.markers.has(e);if(t){let n=!1;for(const e of this.getRanges())if(t.containsRange(e,!e.isCollapsed)){n=!0;break}n&&!r?(this.markers.add(e),i=!0):!n&&r&&(this.markers.remove(e),i=!0)}else r&&(this.markers.remove(e),i=!0);i&&this.fire("change:marker",{oldMarkers:o,directChange:!1})}_updateAttributes(e){const t=Co(this._getSurroundingAttributes()),n=Co(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 i=[];for(const[e,t]of this.getAttributes())n.has(e)&&n.get(e)===t||i.push(e);for(const[e]of n)this.hasAttribute(e)||i.push(e);i.length>0&&this.fire("change:attribute",{attributeKeys:i,directChange:!1})}_setAttribute(e,t,n=!0){const i=n?"normal":"low";if("low"==i&&"normal"==this._attributePriority.get(e))return!1;return super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,i),!0)}_removeAttribute(e,t=!0){const n=t?"normal":"low";return("low"!=n||"normal"!=this._attributePriority.get(e))&&(this._attributePriority.set(e,n),!!super.hasAttribute(e)&&(this._attrs.delete(e),!0))}_setAttributesTo(e){const t=new Set;for(const[t,n]of this.getAttributes())e.get(t)!==n&&this._removeAttribute(t,!1);for(const[n,i]of e){this._setAttribute(n,i,!1)&&t.add(n)}return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())if(t.startsWith(Vc)){const n=t.substr(Vc.length);yield[n,e.getAttribute(t)]}}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;let n=null;if(this.isCollapsed){const i=e.textNode?e.textNode:e.nodeBefore,o=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(n=zc(i)),n||(n=zc(o)),!this.isGravityOverridden&&!n){let e=i;for(;e&&!t.isInline(e)&&!n;)e=e.previousSibling,n=zc(e)}if(!n){let e=o;for(;e&&!t.isInline(e)&&!n;)e=e.nextSibling,n=zc(e)}n||(n=this.getStoredAttributes())}else{const e=this.getFirstRange();for(const i of e){if(i.item.is("element")&&t.isObject(i.item))break;if("text"==i.type){n=i.item.getAttributes();break}}}return n}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function zc(e){return e instanceof hc||e instanceof uc?e.getAttributes():null}class Fc{constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}const Uc=function(e){return wi(e,5)};class Hc extends Fc{elementToElement(e){return this.add(function(e){const t=Zc(e.model),n=$c(e.view,"container");t.attributes.length&&(t.children=!0);return i=>{i.on(`insert:${t.name}`,function(e,t=tl){return(n,i,o)=>{if(!t(i.item,o.consumable,{preflight:!0}))return;const r=e(i.item,o,i);if(!r)return;t(i.item,o.consumable);const s=o.mapper.toViewPosition(i.range.start);o.mapper.bindElements(i.item,r),o.writer.insert(s,r),o.convertAttributes(i.item),Xc(r,i.item.getChildren(),o,{reconversion:i.reconversion})}}(n,Jc(t)),{priority:e.converterPriority||"normal"}),(t.children||t.attributes.length)&&i.on("reduceChanges",Qc(t),{priority:"low"})}}(e))}elementToStructure(e){return this.add(function(e){const t=Zc(e.model),n=$c(e.view,"container");return t.children=!0,i=>{if(i._conversionApi.schema.checkChild(t.name,"$text"))throw new w("conversion-element-to-structure-disallowed-text",i,{elementName:t.name});var o,r;i.on(`insert:${t.name}`,(o=n,r=Jc(t),(e,t,n)=>{if(!r(t.item,n.consumable,{preflight:!0}))return;const i=new Map;n.writer._registerSlotFactory(function(e,t,n){return(i,o="children")=>{const r=i.createContainerElement("$slot");let s=null;if("children"===o)s=Array.from(e.getChildren());else{if("function"!=typeof o)throw new w("conversion-slot-mode-unknown",n.dispatcher,{modeOrFilter:o});s=Array.from(e.getChildren()).filter((e=>o(e)))}return t.set(r,s),r}}(t.item,i,n));const s=o(t.item,n,t);if(n.writer._clearSlotFactory(),!s)return;!function(e,t,n){const i=Array.from(t.values()).flat(),o=new Set(i);if(o.size!=i.length)throw new w("conversion-slot-filter-overlap",n.dispatcher,{element:e});if(o.size!=e.childCount)throw new w("conversion-slot-filter-incomplete",n.dispatcher,{element:e})}(t.item,i,n),r(t.item,n.consumable);const a=n.mapper.toViewPosition(t.range.start);n.mapper.bindElements(t.item,s),n.writer.insert(a,s),n.convertAttributes(t.item),function(e,t,n,i){n.mapper.on("modelToViewPosition",s,{priority:"highest"});let o=null,r=null;for([o,r]of t)Xc(e,r,n,i),n.writer.move(n.writer.createRangeIn(o),n.writer.createPositionBefore(o)),n.writer.remove(o);function s(e,t){const n=t.modelPosition.nodeAfter,i=r.indexOf(n);i<0||(t.viewPosition=t.mapper.findPositionIn(o,i))}n.mapper.off("modelToViewPosition",s)}(s,i,n,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),i.on("reduceChanges",Qc(t),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){let t=(e=Uc(e)).model;"string"==typeof t&&(t={key:t});let n=`attribute:${t.key}`;t.name&&(n+=":"+t.name);if(t.values)for(const n of t.values)e.view[n]=$c(e.view[n],"attribute");else e.view=$c(e.view,"attribute");const i=Kc(e);return t=>{t.on(n,function(e){return(t,n,i)=>{if(!i.consumable.test(n.item,t.name))return;const o=e(n.attributeOldValue,i,n),r=e(n.attributeNewValue,i,n);if(!o&&!r)return;i.consumable.consume(n.item,t.name);const s=i.writer,a=s.document.selection;if(n.item instanceof Pc||n.item instanceof Bc)s.wrap(a.getFirstRange(),r);else{let e=i.mapper.toViewRange(n.range);null!==n.attributeOldValue&&o&&(e=s.unwrap(e,o)),null!==n.attributeNewValue&&r&&s.wrap(e,r)}}}(i),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){let t=(e=Uc(e)).model;"string"==typeof t&&(t={key:t});let n=`attribute:${t.key}`;t.name&&(n+=":"+t.name);if(t.values)for(const n of t.values)e.view[n]=Gc(e.view[n]);else e.view=Gc(e.view);const i=Kc(e);return t=>{var o;t.on(n,(o=i,(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;const i=o(t.attributeOldValue,n,t),r=o(t.attributeNewValue,n,t);if(!i&&!r)return;n.consumable.consume(t.item,e.name);const s=n.mapper.toViewElement(t.item),a=n.writer;if(!s)throw new w("conversion-attribute-to-attribute-on-text",n.dispatcher,t);if(null!==t.attributeOldValue&&i)if("class"==i.key){const e=wo(i.value);for(const t of e)a.removeClass(t,s)}else if("style"==i.key){const e=Object.keys(i.value);for(const t of e)a.removeStyle(t,s)}else a.removeAttribute(i.key,s);if(null!==t.attributeNewValue&&r)if("class"==r.key){const e=wo(r.value);for(const t of e)a.addClass(t,s)}else if("style"==r.key){const e=Object.keys(r.value);for(const t of e)a.setStyle(t,r.value[t],s)}else a.setAttribute(r.key,r.value,s)}),{priority:e.converterPriority||"normal"})}}(e))}markerToElement(e){return this.add(function(e){const t=$c(e.view,"ui");return n=>{var i;n.on(`addMarker:${e.model}`,(i=t,(e,t,n)=>{t.isOpening=!0;const o=i(t,n);t.isOpening=!1;const r=i(t,n);if(!o||!r)return;const s=t.markerRange;if(s.isCollapsed&&!n.consumable.consume(s,e.name))return;for(const t of s)if(!n.consumable.consume(t.item,e.name))return;const a=n.mapper,c=n.writer;c.insert(a.toViewPosition(s.start),o),n.mapper.bindElementToMarker(o,t.markerName),s.isCollapsed||(c.insert(a.toViewPosition(s.end),r),n.mapper.bindElementToMarker(r,t.markerName)),e.stop()}),{priority:e.converterPriority||"normal"}),n.on(`removeMarker:${e.model}`,((e,t,n)=>{const i=n.mapper.markerNameToElements(t.markerName);if(i){for(const e of i)n.mapper.unbindElementFromMarkerName(e,t.markerName),n.writer.clear(n.writer.createRangeOn(e),e);n.writer.clearClonedElementsGroup(t.markerName),e.stop()}}),{priority:e.converterPriority||"normal"})}}(e))}markerToHighlight(e){return this.add(function(e){return t=>{var n;t.on(`addMarker:${e.model}`,(n=e.view,(e,t,i)=>{if(!t.item)return;if(!(t.item instanceof Pc||t.item instanceof Bc||t.item.is("$textProxy")))return;const o=Yc(n,t,i);if(!o)return;if(!i.consumable.consume(t.item,e.name))return;const r=i.writer,s=Wc(r,o),a=r.document.selection;if(t.item instanceof Pc||t.item instanceof Bc)r.wrap(a.getFirstRange(),s);else{const e=i.mapper.toViewRange(t.range),n=r.wrap(e,s);for(const e of n.getItems())if(e.is("attributeElement")&&e.isSimilar(s)){i.mapper.bindElementToMarker(e,t.markerName);break}}}),{priority:e.converterPriority||"normal"}),t.on(`addMarker:${e.model}`,function(e){return(t,n,i)=>{if(!n.item)return;if(!(n.item instanceof mc))return;const o=Yc(e,n,i);if(!o)return;if(!i.consumable.test(n.item,t.name))return;const r=i.mapper.toViewElement(n.item);if(r&&r.getCustomProperty("addHighlight")){i.consumable.consume(n.item,t.name);for(const e of yc._createIn(n.item))i.consumable.consume(e.item,t.name);r.getCustomProperty("addHighlight")(r,o,i.writer),i.mapper.bindElementToMarker(r,n.markerName)}}}(e.view),{priority:e.converterPriority||"normal"}),t.on(`removeMarker:${e.model}`,function(e){return(t,n,i)=>{if(n.markerRange.isCollapsed)return;const o=Yc(e,n,i);if(!o)return;const r=Wc(i.writer,o),s=i.mapper.markerNameToElements(n.markerName);if(s){for(const e of s)if(i.mapper.unbindElementFromMarkerName(e,n.markerName),e.is("attributeElement"))i.writer.unwrap(i.writer.createRangeOn(e),r);else{e.getCustomProperty("removeHighlight")(e,o.id,i.writer)}i.writer.clearClonedElementsGroup(n.markerName),t.stop()}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}markerToData(e){return this.add(function(e){const t=(e=Uc(e)).model;let n=e.view;n||(n=n=>({group:t,name:n.substr(e.model.length+1)}));return i=>{var o;i.on(`addMarker:${t}`,(o=n,(e,t,n)=>{const i=o(t.markerName,n);if(!i)return;const r=t.markerRange;n.consumable.consume(r,e.name)&&(qc(r,!1,n,t,i),qc(r,!0,n,t,i),e.stop())}),{priority:e.converterPriority||"normal"}),i.on(`removeMarker:${t}`,function(e){return(t,n,i)=>{const o=e(n.markerName,i);if(!o)return;const r=i.mapper.markerNameToElements(n.markerName);if(r){for(const e of r)i.mapper.unbindElementFromMarkerName(e,n.markerName),e.is("containerElement")?(s(`data-${o.group}-start-before`,e),s(`data-${o.group}-start-after`,e),s(`data-${o.group}-end-before`,e),s(`data-${o.group}-end-after`,e)):i.writer.clear(i.writer.createRangeOn(e),e);i.writer.clearClonedElementsGroup(n.markerName),t.stop()}function s(e,t){if(t.hasAttribute(e)){const n=new Set(t.getAttribute(e).split(","));n.delete(o.name),0==n.size?i.writer.removeAttribute(e,t):i.writer.setAttribute(e,Array.from(n).join(","),t)}}}}(n),{priority:e.converterPriority||"normal"})}}(e))}}function Wc(e,t){const n=e.createAttributeElement("span",t.attributes);return t.classes&&n._addClass(t.classes),"number"==typeof t.priority&&(n._priority=t.priority),n._id=t.id,n}function qc(e,t,n,i,o){const r=t?e.start:e.end,s=r.nodeAfter&&r.nodeAfter.is("element")?r.nodeAfter:null,a=r.nodeBefore&&r.nodeBefore.is("element")?r.nodeBefore:null;if(s||a){let e,r;t&&s||!t&&!a?(e=s,r=!0):(e=a,r=!1);const c=n.mapper.toViewElement(e);if(c)return void function(e,t,n,i,o,r){const s=`data-${r.group}-${t?"start":"end"}-${n?"before":"after"}`,a=e.hasAttribute(s)?e.getAttribute(s).split(","):[];a.unshift(r.name),i.writer.setAttribute(s,a.join(","),e),i.mapper.bindElementToMarker(e,o.markerName)}(c,t,r,n,i,o)}!function(e,t,n,i,o){const r=`${o.group}-${t?"start":"end"}`,s=o.name?{name:o.name}:null,a=n.writer.createUIElement(r,s);n.writer.insert(e,a),n.mapper.bindElementToMarker(a,i.markerName)}(n.mapper.toViewPosition(r),t,n,i,o)}function Zc(e){return"string"==typeof e&&(e={name:e}),e.attributes?Array.isArray(e.attributes)||(e.attributes=[e.attributes]):e.attributes=[],e.children=!!e.children,e}function $c(e,t){return"function"==typeof e?e:(n,i)=>function(e,t,n){"string"==typeof e&&(e={name:e});let i;const o=t.writer,r=Object.assign({},e.attributes);if("container"==n)i=o.createContainerElement(e.name,r);else if("attribute"==n){const t={priority:e.priority||ks.DEFAULT_PRIORITY};i=o.createAttributeElement(e.name,r,t)}else i=o.createUIElement(e.name,r);if(e.styles){const t=Object.keys(e.styles);for(const n of t)o.setStyle(n,e.styles[n],i)}if(e.classes){const t=e.classes;if("string"==typeof t)o.addClass(t,i);else for(const e of t)o.addClass(e,i)}return i}(e,i,t)}function Kc(e){return e.model.values?(t,n,i)=>{const o=e.view[t];return o?o(t,n,i):null}:e.view}function Gc(e){return"string"==typeof e?t=>({key:e,value:t}):"object"==typeof e?e.value?()=>e:t=>({key:e.key,value:t}):e}function Yc(e,t,n){const i="function"==typeof e?e(t,n):e;return i?(i.priority||(i.priority=10),i.id||(i.id=t.markerName),i):null}function Qc(e){const t=function(e){return(t,n)=>{if(!t.is("element",e.name))return!1;if("attribute"==n.type){if(e.attributes.includes(n.attributeKey))return!0}else if(e.children)return!0;return!1}}(e);return(e,n)=>{const i=[];n.reconvertedElements||(n.reconvertedElements=new Set);for(const e of n.changes){const o="attribute"==e.type?e.range.start.nodeAfter:e.position.parent;if(o&&t(o,e)){if(!n.reconvertedElements.has(o)){n.reconvertedElements.add(o);const e=pc._createBefore(o);i.push({type:"remove",name:o.name,position:e,length:1},{type:"reinsert",name:o.name,position:e,length:1})}}else i.push(e)}n.changes=i}}function Jc(e){return(t,n,i={})=>{const o=["insert"];for(const n of e.attributes)t.hasAttribute(n)&&o.push(`attribute:${n}`);return!!o.every((e=>n.test(t,e)))&&(i.preflight||o.forEach((e=>n.consume(t,e))),!0)}}function Xc(e,t,n,i){for(const o of t)el(e.root,o,n,i)||n.convertItem(o)}function el(e,t,n,i){const{writer:o,mapper:r}=n;if(!i.reconversion)return!1;const s=r.toViewElement(t);return!(!s||s.root==e)&&(!!n.canReuseView(s)&&(o.move(o.createRangeOn(s),r.toViewPosition(pc._createBefore(t))),!0))}function tl(e,t,{preflight:n}={}){return n?t.test(e,"insert"):t.consume(e,"insert")}function nl(e){const{schema:t,document:n}=e.model;for(const i of n.getRootNames()){const o=n.getRoot(i);if(o.isEmpty&&!t.checkChild(o,"$text")&&t.checkChild(o,"paragraph"))return e.insertElement("paragraph",o),!0}return!1}function il(e,t,n){const i=n.createContext(e);return!!n.checkChild(i,"paragraph")&&!!n.checkChild(i.push("paragraph"),t)}function ol(e,t){const n=t.createElement("paragraph");return t.insert(n,e),t.createPositionAt(n,0)}class rl extends Fc{elementToElement(e){return this.add(sl(e))}elementToAttribute(e){return this.add(function(e){ll(e=Uc(e));const t=dl(e,!1),n=al(e.view),i=n?`element:${n}`:"element";return n=>{n.on(i,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=Uc(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 n;if("class"==t||"style"==t){n={["class"==t?"classes":"styles"]:e.view.value}}else{n={attributes:{[t]:void 0===e.view.value?/[\s\S]*/:e.view.value}}}e.view.name&&(n.name=e.view.name);return e.view=n,t}(e));ll(e,t);const n=dl(e,!0);return t=>{t.on("element",n,{priority:e.converterPriority||"low"})}}(e))}elementToMarker(e){return this.add(function(e){const t=function(e){return(t,n)=>{const i="string"==typeof e?e:e(t,n);return n.writer.createElement("$marker",{"data-name":i})}}(e.model);return sl({...e,model:t})}(e))}dataToMarker(e){return this.add(function(e){(e=Uc(e)).model||(e.model=t=>t?e.view+":"+t:e.view);const t={view:e.view,model:e.model},n=cl(ul(t,"start")),i=cl(ul(t,"end"));return o=>{o.on(`element:${e.view}-start`,n,{priority:e.converterPriority||"normal"}),o.on(`element:${e.view}-end`,i,{priority:e.converterPriority||"normal"});const r=p.get("low"),s=p.get("highest"),a=p.get(e.converterPriority)/s;o.on("element",function(e){return(t,n,i)=>{const o=`data-${e.view}`;function r(t,o){for(const r of o){const o=e.model(r,i),s=i.writer.createElement("$marker",{"data-name":o});i.writer.insert(s,t),n.modelCursor.isEqual(t)?n.modelCursor=n.modelCursor.getShiftedBy(1):n.modelCursor=n.modelCursor._getTransformedByInsertion(t,1),n.modelRange=n.modelRange._getTransformedByInsertion(t,1)[0]}}(i.consumable.test(n.viewItem,{attributes:o+"-end-after"})||i.consumable.test(n.viewItem,{attributes:o+"-start-after"})||i.consumable.test(n.viewItem,{attributes:o+"-end-before"})||i.consumable.test(n.viewItem,{attributes:o+"-start-before"}))&&(n.modelRange||Object.assign(n,i.convertChildren(n.viewItem,n.modelCursor)),i.consumable.consume(n.viewItem,{attributes:o+"-end-after"})&&r(n.modelRange.end,n.viewItem.getAttribute(o+"-end-after").split(",")),i.consumable.consume(n.viewItem,{attributes:o+"-start-after"})&&r(n.modelRange.end,n.viewItem.getAttribute(o+"-start-after").split(",")),i.consumable.consume(n.viewItem,{attributes:o+"-end-before"})&&r(n.modelRange.start,n.viewItem.getAttribute(o+"-end-before").split(",")),i.consumable.consume(n.viewItem,{attributes:o+"-start-before"})&&r(n.modelRange.start,n.viewItem.getAttribute(o+"-start-before").split(",")))}}(t),{priority:r+a})}}(e))}}function sl(e){const t=cl(e=Uc(e)),n=al(e.view),i=n?`element:${n}`:"element";return n=>{n.on(i,t,{priority:e.converterPriority||"normal"})}}function al(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}function cl(e){const t=new Xo(e.view);return(n,i,o)=>{const r=t.match(i.viewItem);if(!r)return;const s=r.match;if(s.name=!0,!o.consumable.test(i.viewItem,s))return;const a=function(e,t,n){return e instanceof Function?e(t,n):n.writer.createElement(e)}(e.model,i.viewItem,o);a&&o.safeInsert(a,i.modelCursor)&&(o.consumable.consume(i.viewItem,s),o.convertChildren(i.viewItem,a),o.updateConversionResult(a,i))}}function ll(e,t=null){const n=null===t||(e=>e.getAttribute(t)),i="object"!=typeof e.model?e.model:e.model.key,o="object"!=typeof e.model||void 0===e.model.value?n:e.model.value;e.model={key:i,value:o}}function dl(e,t){const n=new Xo(e.view);return(i,o,r)=>{if(!o.modelRange&&t)return;const s=n.match(o.viewItem);if(!s)return;if(!function(e,t){const n="function"==typeof e?e(t):e;if("object"==typeof n&&!al(n))return!1;return!n.classes&&!n.attributes&&!n.styles}(e.view,o.viewItem)?delete s.match.name:s.match.name=!0,!r.consumable.test(o.viewItem,s.match))return;const a=e.model.key,c="function"==typeof e.model.value?e.model.value(o.viewItem,r):e.model.value;if(null===c)return;o.modelRange||Object.assign(o,r.convertChildren(o.viewItem,o.modelCursor));const l=function(e,t,n,i){let o=!1;for(const r of Array.from(e.getItems({shallow:n})))i.schema.checkAttribute(r,t.key)&&(o=!0,r.hasAttribute(t.key)||i.writer.setAttribute(t.key,t.value,r));return o}(o.modelRange,{key:a,value:c},t,r);l&&(r.consumable.test(o.viewItem,{name:!0})&&(s.match.name=!0),r.consumable.consume(o.viewItem,s.match))}}function ul(e,t){return{view:`${e.view}-${t}`,model:(t,n)=>{const i=t.getAttribute("name"),o=e.model(i,n);return n.writer.createElement("$marker",{"data-name":o})}}}class hl extends(H()){constructor(e,t){super(),this.model=e,this.view=new ac(t),this.mapper=new xc,this.downcastDispatcher=new Ec({mapper:this.mapper,schema:e.schema});const n=this.model.document,i=n.selection,o=this.model.markers;this.listenTo(this.model,"_beforeChanges",(()=>{this.view._disableRendering(!0)}),{priority:"highest"}),this.listenTo(this.model,"_afterChanges",(()=>{this.view._disableRendering(!1)}),{priority:"lowest"}),this.listenTo(n,"change",(()=>{this.view.change((e=>{this.downcastDispatcher.convertChanges(n.differ,o,e),this.downcastDispatcher.convertSelection(i,o,e)}))}),{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(n,i)=>{const o=i.newSelection,r=[];for(const e of o.getRanges())r.push(t.toModelRange(e));const s=e.createSelection(r,{backward:o.isBackward});s.isEqual(e.document.selection)||e.change((e=>{e.setSelection(s)}))}}(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",((e,t,n)=>{if(!n.consumable.consume(t.item,e.name))return;const i=n.writer,o=n.mapper.toViewPosition(t.range.start),r=i.createText(t.item.data);i.insert(o,r)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,n)=>{n.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||n.convertChildren(t.item)}),{priority:"lowest"}),this.downcastDispatcher.on("remove",((e,t,n)=>{const i=n.mapper.toViewPosition(t.position),o=t.position.getShiftedBy(t.length),r=n.mapper.toViewPosition(o,{isPhantom:!0}),s=n.writer.createRange(i,r),a=n.writer.remove(s.getTrimmed());for(const e of n.writer.createRangeIn(a).getItems())n.mapper.unbindViewElement(e,{defer:!0})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,n)=>{const i=n.writer,o=i.document.selection;for(const e of o.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&n.writer.mergeAttributes(e.start);i.setSelection(null)}),{priority:"high"}),this.downcastDispatcher.on("selection",((e,t,n)=>{const i=t.selection;if(i.isCollapsed)return;if(!n.consumable.consume(i,"selection"))return;const o=[];for(const e of i.getRanges())o.push(n.mapper.toViewRange(e));n.writer.setSelection(o,{backward:i.isBackward})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,n)=>{const i=t.selection;if(!i.isCollapsed)return;if(!n.consumable.consume(i,"selection"))return;const o=n.writer,r=i.getFirstPosition(),s=n.mapper.toViewPosition(r),a=o.breakAttributes(s);o.setSelection(a)}),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using((e=>{if("$graveyard"==e.rootName)return null;const t=new os(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,n=this.model.markers.get(t);if(!n)throw new w("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change((()=>{this.model.markers._refresh(n)}))}reconvertItem(e){this.model.change((()=>{this.model.document.differ._refreshItem(e)}))}}class ml{constructor(){this._consumables=new Map}add(e,t){let n;e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):(this._consumables.has(e)?n=this._consumables.get(e):(n=new gl(e),this._consumables.set(e,n)),n.add(t))}test(e,t){const n=this._consumables.get(e);return void 0===n?null:e.is("$text")||e.is("documentFragment")?n:n.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 n=this._consumables.get(e);void 0!==n&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):n.revert(t))}static consumablesFromElement(e){const t={element:e,name:!0,attributes:[],classes:[],styles:[]},n=e.getAttributeKeys();for(const e of n)"style"!=e&&"class"!=e&&t.attributes.push(e);const i=e.getClassNames();for(const e of i)t.classes.push(e);const o=e.getStyleNames();for(const e of o)t.styles.push(e);return t}static createFrom(e,t){if(t||(t=new ml),e.is("$text"))return t.add(e),t;e.is("element")&&t.add(e,ml.consumablesFromElement(e)),e.is("documentFragment")&&t.add(e);for(const n of e.getChildren())t=ml.createFrom(n,t);return t}}const fl=["attributes","classes","styles"];class gl{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 fl)t in e&&this._add(t,e[t])}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const t of fl)if(t in e){const n=this._test(t,e[t]);if(!0!==n)return n}return!0}consume(e){e.name&&(this._canConsumeName=!1);for(const t of fl)t in e&&this._consume(t,e[t])}revert(e){e.name&&(this._canConsumeName=!0);for(const t of fl)t in e&&this._revert(t,e[t])}_add(e,t){const n=he(t)?t:[t],i=this._consumables[e];for(const t of n){if("attributes"===e&&("class"===t||"style"===t))throw new w("viewconsumable-invalid-attribute",this);if(i.set(t,!0),"styles"===e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))i.set(e,!0)}}_test(e,t){const n=he(t)?t:[t],i=this._consumables[e];for(const t of n)if("attributes"!==e||"class"!==t&&"style"!==t){const e=i.get(t);if(void 0===e)return null;if(!e)return!1}else{const e="class"==t?"classes":"styles",n=this._test(e,[...this._consumables[e].keys()]);if(!0!==n)return n}return!0}_consume(e,t){const n=he(t)?t:[t],i=this._consumables[e];for(const t of n)if("attributes"!==e||"class"!==t&&"style"!==t){if(i.set(t,!1),"styles"==e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))i.set(e,!1)}else{const e="class"==t?"classes":"styles";this._consume(e,[...this._consumables[e].keys()])}}_revert(e,t){const n=he(t)?t:[t],i=this._consumables[e];for(const t of n)if("attributes"!==e||"class"!==t&&"style"!==t){!1===i.get(t)&&i.set(t,!0)}else{const e="class"==t?"classes":"styles";this._revert(e,[...this._consumables[e].keys()])}}}class pl extends(H()){constructor(){super(),this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",((e,t)=>{t[0]=new bl(t[0])}),{priority:"highest"}),this.on("checkChild",((e,t)=>{t[0]=new bl(t[0]),t[1]=this.getDefinition(t[1])}),{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new w("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 w("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 n=this.getDefinition(e.last);return!!n&&n.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof pc){const t=e.nodeBefore,n=e.nodeAfter;if(!(t instanceof mc))throw new w("schema-check-merge-no-element-before",this);if(!(n instanceof mc))throw new w("schema-check-merge-no-element-after",this);return this.checkMerge(t,n)}for(const n of t.getChildren())if(!this.checkChild(e,n))return!1;return!0}addChildCheck(e){this.on("checkChild",((t,[n,i])=>{if(!i)return;const o=e(n,i);"boolean"==typeof o&&(t.stop(),t.return=o)}),{priority:"high"})}addAttributeCheck(e){this.on("checkAttribute",((t,[n,i])=>{const o=e(n,i);"boolean"==typeof o&&(t.stop(),t.return=o)}),{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 pc)t=e.parent;else{t=(e instanceof yc?[e]:Array.from(e.getRanges())).reduce(((e,t)=>{const n=t.getCommonAncestor();return e?e.getCommonAncestor(n,{includeSelf:!0}):n}),null)}for(;!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const n=[...e.getFirstPosition().getAncestors(),new uc("",e.getAttributes())];return this.checkAttribute(n,t)}{const n=e.getRanges();for(const e of n)for(const n of e)if(this.checkAttribute(n.item,t))return!0}return!1}*getValidRanges(e,t){e=function*(e){for(const t of e)yield*t.getMinimalFlatRanges()}(e);for(const n of e)yield*this._getValidRangesForRange(n,t)}getNearestSelectionRange(e,t="both"){if(this.checkChild(e,"$text"))return new yc(e);let n,i;const o=e.getAncestors().reverse().find((e=>this.isLimit(e)))||e.root;"both"!=t&&"backward"!=t||(n=new fc({boundaries:yc._createIn(o),startPosition:e,direction:"backward"})),"both"!=t&&"forward"!=t||(i=new fc({boundaries:yc._createIn(o),startPosition:e}));for(const e of function*(e,t){let n=!1;for(;!n;){if(n=!0,e){const t=e.next();t.done||(n=!1,yield{walker:e,value:t.value})}if(t){const e=t.next();e.done||(n=!1,yield{walker:t,value:e.value})}}}(n,i)){const t=e.walker==n?"elementEnd":"elementStart",i=e.value;if(i.type==t&&this.isObject(i.item))return yc._createOn(i.item);if(this.checkChild(i.nextPosition,"$text"))return new yc(i.nextPosition)}return null}findAllowedParent(e,t){let n=e.parent;for(;n;){if(this.checkChild(n,t))return n;if(this.isLimit(n))return null;n=n.parent}return null}setAllowedAttributes(e,t,n){const i=n.model;for(const[o,r]of Object.entries(t))i.schema.checkAttribute(e,o)&&n.setAttribute(o,r,e)}removeDisallowedAttributes(e,t){for(const n of e)if(n.is("$text"))Il(this,n,t);else{const e=yc._createIn(n).getPositions();for(const n of e){Il(this,n.nodeBefore||n.parent,t)}}}getAttributesWithProperty(e,t,n){const i={};for(const[o,r]of e.getAttributes()){const e=this.getAttributeProperties(o);void 0!==e[t]&&(void 0!==n&&n!==e[t]||(i[o]=r))}return i}createContext(e){return new bl(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,n=Object.keys(t);for(const i of n)e[i]=wl(t[i],i);for(const t of n)kl(e,t);for(const t of n)_l(e,t);for(const t of n)vl(e,t);for(const t of n)yl(e,t),xl(e,t);for(const t of n)Al(e,t),Cl(e,t),El(e,t);this._compiledDefinitions=e}_checkContextMatch(e,t,n=t.length-1){const i=t.getItem(n);if(e.allowIn.includes(i.name)){if(0==n)return!0;{const e=this.getDefinition(i);return this._checkContextMatch(e,t,n-1)}}return!1}*_getValidRangesForRange(e,t){let n=e.start,i=e.start;for(const o of e.getItems({shallow:!0}))o.is("element")&&(yield*this._getValidRangesForRange(yc._createIn(o),t)),this.checkAttribute(o,t)||(n.isEqual(i)||(yield new yc(n,i)),n=pc._createAfter(o)),i=pc._createAfter(o);n.isEqual(i)||(yield new yc(n,i))}}class bl{constructor(e){if(e instanceof bl)return e;let t;t="string"==typeof e?[e]:Array.isArray(e)?e:e.getAncestors({includeSelf:!0}),this._items=t.map(Pl)}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 bl([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 wl(e,t){const n={name:t,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],allowChildren:[],inheritTypesFrom:[]};return function(e,t){for(const n of e){const e=Object.keys(n).filter((e=>e.startsWith("is")));for(const i of e)t[i]=!!n[i]}}(e,n),Tl(e,n,"allowIn"),Tl(e,n,"allowContentOf"),Tl(e,n,"allowWhere"),Tl(e,n,"allowAttributes"),Tl(e,n,"allowAttributesOf"),Tl(e,n,"allowChildren"),Tl(e,n,"inheritTypesFrom"),function(e,t){for(const n of e){const e=n.inheritAllFrom;e&&(t.allowContentOf.push(e),t.allowWhere.push(e),t.allowAttributesOf.push(e),t.inheritTypesFrom.push(e))}}(e,n),n}function kl(e,t){const n=e[t];for(const i of n.allowChildren){const n=e[i];n&&n.allowIn.push(t)}n.allowChildren.length=0}function _l(e,t){for(const n of e[t].allowContentOf)if(e[n]){Sl(e,n).forEach((e=>{e.allowIn.push(t)}))}delete e[t].allowContentOf}function vl(e,t){for(const n of e[t].allowWhere){const i=e[n];if(i){const n=i.allowIn;e[t].allowIn.push(...n)}}delete e[t].allowWhere}function yl(e,t){for(const n of e[t].allowAttributesOf){const i=e[n];if(i){const n=i.allowAttributes;e[t].allowAttributes.push(...n)}}delete e[t].allowAttributesOf}function xl(e,t){const n=e[t];for(const t of n.inheritTypesFrom){const i=e[t];if(i){const e=Object.keys(i).filter((e=>e.startsWith("is")));for(const t of e)t in n||(n[t]=i[t])}}delete n.inheritTypesFrom}function Al(e,t){const n=e[t],i=n.allowIn.filter((t=>e[t]));n.allowIn=Array.from(new Set(i))}function Cl(e,t){const n=e[t];for(const i of n.allowIn){e[i].allowChildren.push(t)}}function El(e,t){const n=e[t];n.allowAttributes=Array.from(new Set(n.allowAttributes))}function Tl(e,t,n){for(const i of e){const e=i[n];"string"==typeof e?t[n].push(e):Array.isArray(e)&&t[n].push(...e)}}function Sl(e,t){const n=e[t];return(i=e,Object.keys(i).map((e=>i[e]))).filter((e=>e.allowIn.includes(n.name)));var i}function Pl(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 Il(e,t,n){for(const i of t.getAttributeKeys())e.checkAttribute(t,i)||n.removeAttribute(i,t)}class Ml extends(S()){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,n=["$root"]){this.fire("viewCleanup",e),this._modelCursor=function(e,t){let n;for(const i of new bl(e)){const e={};for(const t of i.getAttributeKeys())e[t]=i.getAttribute(t);const o=t.createElement(i.name,e);n&&t.insert(o,n),n=pc._createAt(o,0)}return n}(n,t),this.conversionApi.writer=t,this.conversionApi.consumable=ml.createFrom(e),this.conversionApi.store={};const{modelRange:i}=this._convertItem(e,this._modelCursor),o=t.createDocumentFragment();if(i){this._removeEmptyElements();for(const e of Array.from(this._modelCursor.parent.getChildren()))t.append(e,o);o.markers=function(e,t){const n=new Set,i=new Map,o=yc._createIn(e).getItems();for(const e of o)e.is("element","$marker")&&n.add(e);for(const e of n){const n=e.getAttribute("data-name"),o=t.createPositionBefore(e);i.has(n)?i.get(n).end=o.clone():i.set(n,new yc(o.clone())),t.remove(e)}return i}(o,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,o}_convertItem(e,t){const n={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,n,this.conversionApi):e.is("$text")?this.fire("text",n,this.conversionApi):this.fire("documentFragment",n,this.conversionApi),n.modelRange&&!(n.modelRange instanceof yc))throw new w("view-conversion-dispatcher-incorrect-result",this);return{modelRange:n.modelRange,modelCursor:n.modelCursor}}_convertChildren(e,t){let n=t.is("position")?t:pc._createAt(t,0);const i=new yc(n);for(const t of Array.from(e.getChildren())){const e=this._convertItem(t,n);e.modelRange instanceof yc&&(i.end=e.modelRange.end,n=e.modelCursor)}return{modelRange:i,modelCursor:n}}_safeInsert(e,t){const n=this._splitToAllowedParent(e,t);return!!n&&(this.conversionApi.writer.insert(e,n.position),!0)}_updateConversionResult(e,t){const n=this._getSplitParts(e),i=this.conversionApi.writer;t.modelRange||(t.modelRange=i.createRange(i.createPositionBefore(e),i.createPositionAfter(n[n.length-1])));const o=this._cursorParents.get(e);t.modelCursor=o?i.createPositionAt(o,0):t.modelRange.end}_splitToAllowedParent(e,t){const{schema:n,writer:i}=this.conversionApi;let o=n.findAllowedParent(t,e);if(o){if(o===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(o)&&(o=null)}if(!o)return il(t,e,n)?{position:ol(t,i)}:null;const r=this.conversionApi.writer.split(t,o),s=[];for(const e of r.range.getWalker())if("elementEnd"==e.type)s.push(e.item);else{const t=s.pop(),n=e.item;this._registerSplitPair(t,n)}const a=r.range.end.parent;return this._cursorParents.set(e,a),{position:r.position,cursorParent:a}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);const n=this._splitParts.get(e);this._splitParts.set(t,n),n.push(t)}_getSplitParts(e){let t;return 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 Ol{getHtml(e){const t=document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class Rl{constructor(e){this.skipComments=!0,this.domParser=new DOMParser,this.domConverter=new ca(e,{renderingMode:"data"}),this.htmlWriter=new Ol}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"),n=t.createDocumentFragment(),i=t.body.childNodes;for(;i.length>0;)n.appendChild(i[0]);return n}}class Nl extends(S()){constructor(e,t){super(),this.model=e,this.mapper=new xc,this.downcastDispatcher=new Ec({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",((e,t,n)=>{if(!n.consumable.consume(t.item,e.name))return;const i=n.writer,o=n.mapper.toViewPosition(t.range.start),r=i.createText(t.item.data);i.insert(o,r)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,n)=>{n.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||n.convertChildren(t.item)}),{priority:"lowest"}),this.upcastDispatcher=new Ml({schema:e.schema}),this.viewDocument=new ws(t),this.stylesProcessor=t,this.htmlProcessor=new Rl(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new Is(this.viewDocument),this.upcastDispatcher.on("text",((e,t,{schema:n,consumable:i,writer:o})=>{let r=t.modelCursor;if(!i.test(t.viewItem))return;if(!n.checkChild(r,"$text")){if(!il(r,"$text",n))return;if(0==t.viewItem.data.trim().length)return;r=ol(r,o)}i.consume(t.viewItem);const s=o.createText(t.viewItem.data);o.insert(s,r),t.modelRange=o.createRange(r,r.getShiftedBy(s.offsetSize)),t.modelCursor=t.modelRange.end}),{priority:"lowest"}),this.upcastDispatcher.on("element",((e,t,n)=>{if(!t.modelRange&&n.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:i}=n.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=i}}),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",((e,t,n)=>{if(!t.modelRange&&n.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:i}=n.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=i}}),{priority:"lowest"}),H().prototype.decorate.call(this,"init"),H().prototype.decorate.call(this,"set"),H().prototype.decorate.call(this,"get"),this.on("init",(()=>{this.fire("ready")}),{priority:"lowest"}),this.on("ready",(()=>{this.model.enqueueChange({isUndoable:!1},nl)}),{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:n="empty"}=e;if(!this._checkIfRootsExists([t]))throw new w("datacontroller-get-non-existent-root",this);const i=this.model.document.getRoot(t);return"empty"!==n||this.model.hasContent(i,{ignoreWhitespaces:!0})?this.stringify(i,e):""}stringify(e,t={}){const n=this.toView(e,t);return this.processor.toData(n)}toView(e,t={}){const n=this.viewDocument,i=this._viewWriter;this.mapper.clearBindings();const o=yc._createIn(e),r=new Ps(n);this.mapper.bindElements(e,r);const s=e.is("documentFragment")?e.markers:function(e){const t=[],n=e.root.document;if(!n)return new Map;const i=yc._createIn(e);for(const e of n.model.markers){const n=e.getRange(),o=n.isCollapsed,r=n.start.isEqual(i.start)||n.end.isEqual(i.end);if(o&&r)t.push([e.name,n]);else{const o=i.getIntersection(n);o&&t.push([e.name,o])}}return t.sort((([e,t],[n,i])=>{if("after"!==t.end.compareWith(i.start))return 1;if("before"!==t.start.compareWith(i.end))return-1;switch(t.start.compareWith(i.start)){case"before":return 1;case"after":return-1;default:switch(t.end.compareWith(i.end)){case"before":return 1;case"after":return-1;default:return n.localeCompare(e)}}})),new Map(t)}(e);return this.downcastDispatcher.convert(o,s,i,t),r}init(e){if(this.model.document.version)throw new w("datacontroller-init-document-not-empty",this);let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new w("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},(e=>{for(const n of Object.keys(t)){const i=this.model.document.getRoot(n);e.insert(this.parse(t[n],i),i,0)}})),Promise.resolve()}set(e,t={}){let n={};if("string"==typeof e?n.main=e:n=e,!this._checkIfRootsExists(Object.keys(n)))throw new w("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(n)){const i=this.model.document.getRoot(t);e.remove(e.createRangeIn(i)),e.insert(this.parse(n[t],i),i,0)}}))}parse(e,t="$root"){const n=this.processor.toView(e);return this.toModel(n,t)}toModel(e,t="$root"){return this.model.change((n=>this.upcastDispatcher.convert(e,n,t)))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const t of e)if(!this.model.document.getRootNames().includes(t))return!1;return!0}}class Dl{constructor(e,t){this._helpers=new Map,this._downcast=wo(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=wo(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const n=this._downcast.includes(t);if(!this._upcast.includes(t)&&!n)throw new w("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:n})}for(e){if(!this._helpers.has(e))throw new w("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:n}of Ll(e))this.for("upcast").elementToElement({model:t,view:n,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:n}of Ll(e))this.for("upcast").elementToAttribute({view:n,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:n}of Ll(e))this.for("upcast").attributeToAttribute({view:n,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:n}){if(this._helpers.has(e))throw new w("conversion-group-exists",this);const i=n?new Hc(t):new rl(t);this._helpers.set(e,i)}}function*Ll(e){if(e.model.values)for(const t of e.model.values){const n={key:e.model.key,value:t},i=e.view[t],o=e.upcastAlso?e.upcastAlso[t]:void 0;yield*Vl(n,i,o)}else yield*Vl(e.model,e.view,e.upcastAlso)}function*Vl(e,t,n){if(yield{model:e,view:t},n)for(const t of wo(n))yield{model:e,view:t}}class Bl{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 jl(e,t){const n=Ul(t),i=n.reduce(((e,t)=>e+t.offsetSize),0),o=e.parent;Wl(e);const r=e.index;return o._insertChild(r,n),Hl(o,r+n.length),Hl(o,r),new yc(e,e.getShiftedBy(i))}function zl(e){if(!e.isFlat)throw new w("operation-utils-remove-range-not-flat",this);const t=e.start.parent;Wl(e.start),Wl(e.end);const n=t._removeChildren(e.start.index,e.end.index-e.start.index);return Hl(t,e.start.index),n}function Fl(e,t){if(!e.isFlat)throw new w("operation-utils-move-range-not-flat",this);const n=zl(e);return jl(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),n)}function Ul(e){const t=[];!function e(n){if("string"==typeof n)t.push(new uc(n));else if(n instanceof hc)t.push(new uc(n.data,n.getAttributes()));else if(n instanceof lc)t.push(n);else if(J(n))for(const t of n)e(t)}(e);for(let e=1;ee.maxOffset)throw new w("move-operation-nodes-do-not-exist",this);if(e===t&&n=n&&this.targetPosition.path[e]e._clone(!0)))),t=new $l(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new pc(e,[0]);return new Zl(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffsete._clone(!0)))),jl(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){const n=[];for(const t of e.nodes)t.name?n.push(mc.fromJSON(t)):n.push(uc.fromJSON(t));const i=new $l(pc.fromJSON(e.position,t),n,e.baseVersion);return i.shouldReceiveAttributes=e.shouldReceiveAttributes,i}}class Kl extends Bl{constructor(e,t,n,i,o,r){super(r),this.name=e,this.oldRange=t?t.clone():null,this.newRange=n?n.clone():null,this.affectsData=o,this._markers=i}get type(){return"marker"}clone(){return new Kl(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new Kl(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){this.newRange?this._markers._set(this.name,this.newRange,!0,this.affectsData):this._markers._remove(this.name)}toJSON(){const e=super.toJSON();return this.oldRange&&(e.oldRange=this.oldRange.toJSON()),this.newRange&&(e.newRange=this.newRange.toJSON()),delete e._markers,e}static get className(){return"MarkerOperation"}static fromJSON(e,t){return new Kl(e.name,e.oldRange?yc.fromJSON(e.oldRange,t):null,e.newRange?yc.fromJSON(e.newRange,t):null,t.model.markers,e.affectsData,e.baseVersion)}}const Gl=function(e,t){return Ya(e,t)};class Yl extends Bl{constructor(e,t,n,i,o){super(o),this.range=e.clone(),this.key=t,this.oldValue=void 0===n?null:n,this.newValue=void 0===i?null:i}get type(){return null===this.oldValue?"addAttribute":null===this.newValue?"removeAttribute":"changeAttribute"}clone(){return new Yl(this.range,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new Yl(this.range,this.key,this.newValue,this.oldValue,this.baseVersion+1)}toJSON(){const e=super.toJSON();return e.range=this.range.toJSON(),e}_validate(){if(!this.range.isFlat)throw new w("attribute-operation-range-not-flat",this);for(const e of this.range.getItems({shallow:!0})){if(null!==this.oldValue&&!Gl(e.getAttribute(this.key),this.oldValue))throw new w("attribute-operation-wrong-old-value",this,{item:e,key:this.key,value:this.oldValue});if(null===this.oldValue&&null!==this.newValue&&e.hasAttribute(this.key))throw new w("attribute-operation-attribute-exists",this,{node:e,key:this.key})}}_execute(){Gl(this.oldValue,this.newValue)||function(e,t,n){Wl(e.start),Wl(e.end);for(const i of e.getItems({shallow:!0})){const e=i.is("$textProxy")?i.textNode:i;null!==n?e._setAttribute(t,n):e._removeAttribute(t),Hl(e.parent,e.index)}Hl(e.end.parent,e.end.index)}(this.range,this.key,this.newValue)}static get className(){return"AttributeOperation"}static fromJSON(e,t){return new Yl(yc.fromJSON(e.range,t),e.key,e.oldValue,e.newValue,e.baseVersion)}}class Ql extends Bl{get type(){return"noop"}clone(){return new Ql(this.baseVersion)}getReversed(){return new Ql(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}class Jl extends Bl{constructor(e,t,n,i){super(i),this.position=e,this.position.stickiness="toNext",this.oldName=t,this.newName=n}get type(){return"rename"}clone(){return new Jl(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new Jl(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const e=this.position.nodeAfter;if(!(e instanceof mc))throw new w("rename-operation-wrong-position",this);if(e.name!==this.oldName)throw new w("rename-operation-wrong-name",this)}_execute(){this.position.nodeAfter.name=this.newName}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e}static get className(){return"RenameOperation"}static fromJSON(e,t){return new Jl(pc.fromJSON(e.position,t),e.oldName,e.newName,e.baseVersion)}}class Xl extends Bl{constructor(e,t,n,i,o){super(o),this.root=e,this.key=t,this.oldValue=n,this.newValue=i}get type(){return null===this.oldValue?"addRootAttribute":null===this.newValue?"removeRootAttribute":"changeRootAttribute"}clone(){return new Xl(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new Xl(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new w("rootattribute-operation-not-a-root",this,{root:this.root,key:this.key});if(null!==this.oldValue&&this.root.getAttribute(this.key)!==this.oldValue)throw new w("rootattribute-operation-wrong-old-value",this,{root:this.root,key:this.key});if(null===this.oldValue&&null!==this.newValue&&this.root.hasAttribute(this.key))throw new w("rootattribute-operation-attribute-exists",this,{root:this.root,key:this.key})}_execute(){null!==this.newValue?this.root._setAttribute(this.key,this.newValue):this.root._removeAttribute(this.key)}toJSON(){const e=super.toJSON();return e.root=this.root.toJSON(),e}static get className(){return"RootAttributeOperation"}static fromJSON(e,t){if(!t.getRoot(e.root))throw new w("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new Xl(t.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}}class ed extends Bl{constructor(e,t,n,i,o){super(o),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=t,this.targetPosition=n.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=i.clone()}get type(){return"merge"}get deletionPosition(){return new pc(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const e=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new yc(this.sourcePosition,e)}clone(){return new ed(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.targetPosition._getTransformedByMergeOperation(this),t=this.sourcePosition.path.slice(0,-1),n=new pc(this.sourcePosition.root,t)._getTransformedByMergeOperation(this);return new td(e,this.howMany,n,this.graveyardPosition,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent;if(!e.parent)throw new w("merge-operation-source-position-invalid",this);if(!t.parent)throw new w("merge-operation-target-position-invalid",this);if(this.howMany!=e.maxOffset)throw new w("merge-operation-how-many-invalid",this)}_execute(){const e=this.sourcePosition.parent;Fl(yc._createIn(e),this.targetPosition),Fl(yc._createOn(e),this.graveyardPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=e.sourcePosition.toJSON(),e.targetPosition=e.targetPosition.toJSON(),e.graveyardPosition=e.graveyardPosition.toJSON(),e}static get className(){return"MergeOperation"}static fromJSON(e,t){const n=pc.fromJSON(e.sourcePosition,t),i=pc.fromJSON(e.targetPosition,t),o=pc.fromJSON(e.graveyardPosition,t);return new this(n,e.howMany,i,o,e.baseVersion)}}class td extends Bl{constructor(e,t,n,i,o){super(o),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=n,this.graveyardPosition=i?i.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new pc(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new yc(this.splitPosition,e)}clone(){return new td(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new pc(e,[0]);return new ed(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 i=e.range.getDifference(t.range).map((t=>new Yl(t,e.key,e.oldValue,e.newValue,0))),o=e.range.getIntersection(t.range);return o&&n.aIsStrong&&i.push(new Yl(o,t.key,t.newValue,e.newValue,0)),0==i.length?[new Ql(0)]:i}return[e]})),od(Yl,$l,((e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){const n=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map((t=>new Yl(t,e.key,e.oldValue,e.newValue,e.baseVersion)));if(t.shouldReceiveAttributes){const i=ud(t,e.key,e.oldValue);i&&n.unshift(i)}return n}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]})),od(Yl,ed,((e,t)=>{const n=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&n.push(yc._createFromPositionAndShift(t.graveyardPosition,1));const i=e.range._getTransformedByMergeOperation(t);return i.isCollapsed||n.push(i),n.map((t=>new Yl(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),od(Yl,Zl,((e,t)=>{const n=function(e,t){const n=yc._createFromPositionAndShift(t.sourcePosition,t.howMany);let i=null,o=[];n.containsRange(e,!0)?i=e:e.start.hasSameParentAs(n.start)?(o=e.getDifference(n),i=e.getIntersection(n)):o=[e];const r=[];for(let e of o){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const n=t.getMovedRangeStart(),i=e.start.hasSameParentAs(n),o=e._getTransformedByInsertion(n,t.howMany,i);r.push(...o)}i&&r.push(i._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]);return r}(e.range,t);return n.map((t=>new Yl(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),od(Yl,td,((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 n=e.clone();return n.range=new yc(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness="toPrevious",[e,n]}return e.range=e.range._getTransformedBySplitOperation(t),[e]})),od($l,Yl,((e,t)=>{const n=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const i=ud(e,t.key,t.newValue);i&&n.push(i)}return n})),od($l,$l,((e,t,n)=>(e.position.isEqual(t.position)&&n.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e]))),od($l,Zl,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),od($l,td,((e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e]))),od($l,ed,((e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e]))),od(Kl,$l,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e]))),od(Kl,Kl,((e,t,n)=>{if(e.name==t.name){if(!n.aIsStrong)return[new Ql(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]})),od(Kl,ed,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e]))),od(Kl,Zl,((e,t,n)=>{if(e.oldRange&&(e.oldRange=yc._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){if(n.abRelation){const i=yc._createFromRanges(e.newRange._getTransformedByMoveOperation(t));if("left"==n.abRelation.side&&t.targetPosition.isEqual(e.newRange.start))return e.newRange.end=i.end,e.newRange.start.path=n.abRelation.path,[e];if("right"==n.abRelation.side&&t.targetPosition.isEqual(e.newRange.end))return e.newRange.start=i.start,e.newRange.end.path=n.abRelation.path,[e]}e.newRange=yc._createFromRanges(e.newRange._getTransformedByMoveOperation(t))}return[e]})),od(Kl,td,((e,t,n)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(n.abRelation){const i=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)&&n.abRelation.wasStartBeforeMergedElement?e.newRange.start=pc._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!n.abRelation.wasInLeftElement&&(e.newRange.start=pc._createAt(t.moveTargetPosition)),e.newRange.end.isEqual(t.splitPosition)&&n.abRelation.wasInRightElement?e.newRange.end=pc._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&n.abRelation.wasEndBeforeMergedElement?e.newRange.end=pc._createAt(t.insertionPosition):e.newRange.end=i.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]})),od(ed,$l,((e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e]))),od(ed,ed,((e,t,n)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition)){if(n.bWasUndone){const n=t.graveyardPosition.path.slice();return n.push(0),e.sourcePosition=new pc(t.graveyardPosition.root,n),e.howMany=0,[e]}return[new Ql(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!n.bWasUndone&&"splitAtSource"!=n.abRelation){const i="$graveyard"==e.targetPosition.root.rootName,o="$graveyard"==t.targetPosition.root.rootName,r=i&&!o;if(o&&!i||!r&&n.aIsStrong){const n=t.targetPosition._getTransformedByMergeOperation(t),i=e.targetPosition._getTransformedByMergeOperation(t);return[new Zl(n,e.howMany,i,0)]}return[new Ql(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)&&n.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),od(ed,Zl,((e,t,n)=>{const i=yc._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!n.bWasUndone&&!n.forceWeakRemove&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.sourcePosition)?[new Ql(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])})),od(ed,td,((e,t,n)=>{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 i=0!=t.howMany,o=t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition);if(i||o||"mergeTargetNotMoved"==n.abRelation)return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e]}if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==n.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==n.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]})),od(Zl,$l,((e,t)=>{const n=yc._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=n.start,e.howMany=n.end.offset-n.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]})),od(Zl,Zl,((e,t,n)=>{const i=yc._createFromPositionAndShift(e.sourcePosition,e.howMany),o=yc._createFromPositionAndShift(t.sourcePosition,t.howMany);let r,s=n.aIsStrong,a=!n.aIsStrong;if("insertBefore"==n.abRelation||"insertAfter"==n.baRelation?a=!0:"insertAfter"!=n.abRelation&&"insertBefore"!=n.baRelation||(a=!1),r=e.targetPosition.isEqual(t.targetPosition)&&a?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),hd(e,t)&&hd(t,e))return[t.getReversed()];if(i.containsPosition(t.targetPosition)&&i.containsRange(o,!0))return i.start=i.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),i.end=i.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),md([i],r);if(o.containsPosition(e.targetPosition)&&o.containsRange(i,!0))return i.start=i.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),i.end=i.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),md([i],r);const c=Q(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==c||"extension"==c)return i.start=i.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),i.end=i.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),md([i],r);"remove"!=e.type||"remove"==t.type||n.aWasUndone||n.forceWeakRemove?"remove"==e.type||"remove"!=t.type||n.bWasUndone||n.forceWeakRemove||(s=!1):s=!0;const l=[],d=i.getDifference(o);for(const e of d){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const n="same"==Q(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),i=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,n);l.push(...i)}const u=i.getIntersection(o);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?o.start.isBefore(i.start)||o.start.isEqual(i.start)?l.unshift(u):l.push(u):l.splice(1,0,u)),0===l.length?[new Ql(e.baseVersion)]:md(l,r)})),od(Zl,td,((e,t,n)=>{let i=e.targetPosition.clone();e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=n.abRelation||(i=e.targetPosition._getTransformedBySplitOperation(t));const o=yc._createFromPositionAndShift(e.sourcePosition,e.howMany);if(o.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.howMany++,e.targetPosition=i,[e];if(o.start.hasSameParentAs(t.splitPosition)&&o.containsPosition(t.splitPosition)){let e=new yc(t.splitPosition,o.end);e=e._getTransformedBySplitOperation(t);return md([new yc(o.start,t.splitPosition),e],i)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==n.abRelation&&(i=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==n.abRelation&&(i=e.targetPosition);const r=[o._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const i=o.start.isEqual(t.graveyardPosition)||o.containsPosition(t.graveyardPosition);e.howMany>1&&i&&!n.aWasUndone&&r.push(yc._createFromPositionAndShift(t.insertionPosition,1))}return md(r,i)})),od(Zl,ed,((e,t,n)=>{const i=yc._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&i.containsPosition(t.sourcePosition))if("remove"!=e.type||n.forceWeakRemove){if(1==e.howMany)return n.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new Ql(0)]}else if(!n.aWasUndone){const n=[];let i=t.graveyardPosition.clone(),o=t.targetPosition._getTransformedByMergeOperation(t);e.howMany>1&&(n.push(new Zl(e.sourcePosition,e.howMany-1,e.targetPosition,0)),i=i._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1),o=o._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1));const r=t.deletionPosition._getCombined(e.sourcePosition,e.targetPosition),s=new Zl(i,1,r,0),a=s.getMovedRangeStart().path.slice();a.push(0);const c=new pc(s.targetPosition.root,a);o=o._getTransformedByMove(i,r,1);const l=new Zl(o,t.howMany,c,0);return n.push(s),n.push(l),n}const o=yc._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByMergeOperation(t);return e.sourcePosition=o.start,e.howMany=o.end.offset-o.start.offset,e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]})),od(Jl,$l,((e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e]))),od(Jl,ed,((e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e]))),od(Jl,Zl,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),od(Jl,Jl,((e,t,n)=>{if(e.position.isEqual(t.position)){if(!n.aIsStrong)return[new Ql(0)];e.oldName=t.newName}return[e]})),od(Jl,td,((e,t)=>{if("same"==Q(e.position.path,t.splitPosition.getParentPath())&&!t.graveyardPosition){const t=new Jl(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]})),od(Xl,Xl,((e,t,n)=>{if(e.root===t.root&&e.key===t.key){if(!n.aIsStrong||e.newValue===t.newValue)return[new Ql(0)];e.oldValue=t.newValue}return[e]})),od(td,$l,((e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset{if(!e.graveyardPosition&&!n.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const n=t.graveyardPosition.path.slice();n.push(0);const i=new pc(t.graveyardPosition.root,n),o=td.getInsertionPosition(new pc(t.graveyardPosition.root,n)),r=new td(i,0,o,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=td.getInsertionPosition(e.splitPosition),e.graveyardPosition=r.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[r,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=td.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),od(td,Zl,((e,t,n)=>{const i=yc._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const o=i.start.isEqual(e.graveyardPosition)||i.containsPosition(e.graveyardPosition);if(!n.bWasUndone&&o){const n=e.splitPosition._getTransformedByMoveOperation(t),i=e.graveyardPosition._getTransformedByMoveOperation(t),o=i.path.slice();o.push(0);const r=new pc(i.root,o);return[new Zl(n,e.howMany,r,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const o=e.splitPosition.isEqual(t.targetPosition);if(o&&("insertAtSource"==n.baRelation||"splitBefore"==n.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=td.getInsertionPosition(e.splitPosition),[e];if(o&&n.abRelation&&n.abRelation.howMany){const{howMany:t,offset:i}=n.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(i),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.splitPosition)){const n=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=n,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new Ql(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new Ql(0)];if("splitBefore"==n.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){const i="$graveyard"==e.splitPosition.root.rootName,o="$graveyard"==t.splitPosition.root.rootName,r=i&&!o;if(o&&!i||!r&&n.aIsStrong){const n=[];return t.howMany&&n.push(new Zl(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&n.push(new Zl(e.splitPosition,e.howMany,e.moveTargetPosition,0)),n}return[new Ql(0)]}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==n.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==n.baRelation){const n=t.insertionPosition.path.slice();n.push(0);const i=new pc(t.insertionPosition.root,n);return[e,new Zl(e.insertionPosition,1,i,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset{const n=t[0];n.isDocumentOperation&&pd.call(this,n)}),{priority:"low"})}function pd(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)}}fd.prototype.is=function(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e};class bd{constructor(e={}){"string"==typeof e&&(e="transparent"===e?{isUndoable:!1}:{},k("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:n=!0,isUndo:i=!1,isTyping:o=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=n,this.isUndo=i,this.isTyping=o}get type(){return k("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 wd{constructor(e){this._markerCollection=e,this._changesInElement=new Map,this._elementSnapshots=new Map,this._changedMarkers=new Map,this._changeCount=0,this._cachedChanges=null,this._cachedChangesWithGraveyard=null,this._refreshedItems=new Set}get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.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),n=this._isInInsertedElement(t.targetPosition.parent);e||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),n||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=yc._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 n=t.graveyardPosition.parent;this._markInsert(n,t.graveyardPosition.offset,1);const i=t.targetPosition.parent;this._isInInsertedElement(i)||this._markInsert(i,t.targetPosition.offset,e.maxOffset);break}}this._cachedChanges=null}bufferMarkerChange(e,t,n){const i=this._changedMarkers.get(e);i?(i.newMarkerData=n,null==i.oldMarkerData.range&&null==n.range&&this._changedMarkers.delete(e)):this._changedMarkers.set(e,{newMarkerData:n,oldMarkerData:t})}getMarkersToRemove(){const e=[];for(const[t,n]of this._changedMarkers)null!=n.oldMarkerData.range&&e.push({name:t,range:n.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,n]of this._changedMarkers)null!=n.newMarkerData.range&&e.push({name:t,range:n.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map((([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}})))}hasDataChanges(){if(this._changesInElement.size>0)return!0;for(const{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){const n=e.range&&!t.range,i=!e.range&&t.range,o=e.range&&t.range&&!e.range.isEqual(t.range);if(n||i||o)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const e of this._changesInElement.keys()){const n=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(vd),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementSnapshots.clear(),this._changedMarkers.clear(),this._refreshedItems=new Set,this._cachedChanges=null}_refreshItem(e){if(this._isInInsertedElement(e.parent))return;this._markRemove(e.parent,e.startOffset,e.offsetSize),this._markInsert(e.parent,e.startOffset,e.offsetSize),this._refreshedItems.add(e);const t=yc._createOn(e);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getData();this.bufferMarkerChange(e.name,t,t)}this._cachedChanges=null}_markInsert(e,t,n){const i={type:"insert",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,i)}_markRemove(e,t,n){const i={type:"remove",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,i),this._removeAllNestedChanges(e,t,n)}_markAttribute(e){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 n=this._getChangesForElement(e);this._handleChange(t,n),n.push(t);for(let e=0;en.offset){if(i>o){const e={type:"attribute",offset:o,howMany:i-o,count:this._changeCount++};this._handleChange(e,t),t.push(e)}e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=n.offset&&e.offseto?(e.nodesToHandle=i-o,e.offset=o):e.nodesToHandle=0);if("remove"==n.type&&e.offsetn.offset){const o={type:"attribute",offset:n.offset,howMany:i-n.offset,count:this._changeCount++};this._handleChange(o,t),t.push(o),e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==n.type&&(e.offset>=n.offset&&i<=o?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=n.offset&&i>=o&&(n.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,n){return{type:"insert",position:pc._createAt(e,t),name:n.name,attributes:new Map(n.attributes),length:1,changeCount:this._changeCount++}}_getRemoveDiff(e,t,n){return{type:"remove",position:pc._createAt(e,t),name:n.name,attributes:new Map(n.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,n){const i=[];n=new Map(n);for(const[o,r]of t){const t=n.has(o)?n.get(o):null;t!==r&&i.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:o,attributeOldValue:r,attributeNewValue:t,changeCount:this._changeCount++}),n.delete(o)}for(const[t,o]of n)i.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:o,changeCount:this._changeCount++});return i}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const n=this._changesInElement.get(t),i=e.startOffset;if(n)for(const e of n)if("insert"==e.type&&i>=e.offset&&ii){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 w("model-document-history-addoperation-incorrect-version",this,{operation:e,historyVersion:this.version});this._operations.push(e),this._version++,this._baseVersionToOperationIndex.set(e.baseVersion,this._operations.length-1)}getOperations(e,t=this.version){if(!this._operations.length)return[];const n=this._operations[0];void 0===e&&(e=n.baseVersion);let i=t-1;for(const[t,n]of this._gaps)e>t&&et&&ithis.lastOperation.baseVersion)return[];let o=this._baseVersionToOperationIndex.get(e);void 0===o&&(o=0);let r=this._baseVersionToOperationIndex.get(i);return void 0===r&&(r=this._operations.length-1),this._operations.slice(o,r+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 xd extends mc{constructor(e,t,n="main"){super(t),this._document=e,this.rootName=n}get document(){return this._document}toJSON(){return this.rootName}}xd.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 Ad="$graveyard";class Cd extends(S()){constructor(e){super(),this.model=e,this.history=new yd,this.selection=new Bc(this),this.roots=new vo({idProperty:"rootName"}),this.differ=new wd(e.markers),this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",Ad),this.listenTo(e,"applyOperation",((e,t)=>{const n=t[0];n.isDocumentOperation&&this.differ.bufferOperation(n)}),{priority:"high"}),this.listenTo(e,"applyOperation",((e,t)=>{const n=t[0];n.isDocumentOperation&&this.history.addOperation(n)}),{priority:"low"}),this.listenTo(this.selection,"change",(()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0})),this.listenTo(e.markers,"update",((e,t,n,i,o)=>{const r={...t.getData(),range:i};this.differ.bufferMarkerChange(t.name,o,r),null===n&&t.on("change",((e,n)=>{const i=t.getData();this.differ.bufferMarkerChange(t.name,{...i,range:n},i)}))}))}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(Ad)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new w("model-document-createroot-name-exists",this,{name:t});const n=new xd(this,e,t);return this.roots.add(n),n}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(){return Array.from(this.roots,(e=>e.rootName)).filter((e=>e!=Ad))}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=Go(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(){for(const e of this.roots)if(e!==this.graveyard)return e;return this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,n=t.schema,i=t.createPositionFromPath(e,[0]);return n.getNearestSelectionRange(i)||t.createRange(i)}_validateSelectionRange(e){return Ed(e.start)&&Ed(e.end)}_callPostFixers(e){let t=!1;do{for(const n of this._postFixers)if(this.selection.refresh(),t=n(e),t)break}while(t)}}function Ed(e){const t=e.textNode;if(t){const n=t.data,i=e.offset-t.startOffset;return!Eo(n,i)&&!To(n,i)}return!0}class Td extends(S()){constructor(){super(),this._markers=new Map}[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof Sd?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,n=!1,i=!1){const o=e instanceof Sd?e.name:e;if(o.includes(","))throw new w("markercollection-incorrect-marker-name",this);const r=this._markers.get(o);if(r){const e=r.getData(),s=r.getRange();let a=!1;return s.isEqual(t)||(r._attachLiveRange(Nc.fromRange(t)),a=!0),n!=r.managedUsingOperations&&(r._managedUsingOperations=n,a=!0),"boolean"==typeof i&&i!=r.affectsData&&(r._affectsData=i,a=!0),a&&this.fire(`update:${o}`,r,s,t,e),r}const s=Nc.fromRange(t),a=new Sd(o,s,n,i);return this._markers.set(o,a),this.fire(`update:${o}`,a,null,t,{...a.getData(),range:null}),a}_remove(e){const t=e instanceof Sd?e.name:e,n=this._markers.get(t);return!!n&&(this._markers.delete(t),this.fire(`update:${t}`,n,n.getRange(),null,n.getData()),this._destroyMarker(n),!0)}_refresh(e){const t=e instanceof Sd?e.name:e,n=this._markers.get(t);if(!n)throw new w("markercollection-refresh-marker-not-exists",this);const i=n.getRange();this.fire(`update:${t}`,n,i,i,n.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 Sd extends(S(cc)){constructor(e,t,n,i){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=n,this._affectsData=i}get managedUsingOperations(){if(!this._liveRange)throw new w("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new w("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new w("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new w("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new w("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}}Sd.prototype.is=function(e){return"marker"===e||"model:marker"===e};class Pd extends Bl{constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}get type(){return"detach"}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new w("detach-operation-on-document-node",this)}_execute(){zl(yc._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class Id extends cc{constructor(e){super(),this.markers=new Map,this._children=new dc,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}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 n of e)t=t.getChild(t.offsetToIndex(n));return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const n of e)n.name?t.push(mc.fromJSON(n)):t.push(uc.fromJSON(n));return new Id(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const n=function(e){if("string"==typeof e)return[new uc(e)];J(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new uc(e):e instanceof hc?new uc(e.data,e.getAttributes()):e))}(t);for(const e of n)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const e of n)e.parent=null;return n}}Id.prototype.is=function(e){return"documentFragment"===e||"model:documentFragment"===e};class Md{constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new uc(e,t)}createElement(e,t){return new mc(e,t)}createDocumentFragment(){return new Id}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,n=0){if(this._assertWriterUsedCorrectly(),e instanceof uc&&""==e.data)return;const i=pc._createAt(t,n);if(e.parent){if(Ld(e.root,i.root))return void this.move(yc._createOn(e),i);if(e.root.document)throw new w("model-writer-insert-forbidden-move",this);this.remove(e)}const o=i.root.document?i.root.document.version:null,r=new $l(i,e,o);if(e instanceof uc&&(r.shouldReceiveAttributes=!0),this.batch.addOperation(r),this.model.applyOperation(r),e instanceof Id)for(const[t,n]of e.markers){const e=pc._createAt(n.root,0),o={range:new yc(n.start._getCombined(e,i),n.end._getCombined(e,i)),usingOperation:!0,affectsData:!0};this.model.markers.has(t)?this.updateMarker(t,o):this.addMarker(t,o)}}insertText(e,t,n,i){t instanceof Id||t instanceof mc||t instanceof pc?this.insert(this.createText(e),t,n):this.insert(this.createText(e,t),n,i)}insertElement(e,t,n,i){t instanceof Id||t instanceof mc||t instanceof pc?this.insert(this.createElement(e),t,n):this.insert(this.createElement(e,t),n,i)}append(e,t){this.insert(e,t,"end")}appendText(e,t,n){t instanceof Id||t instanceof mc?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),n,"end")}appendElement(e,t,n){t instanceof Id||t instanceof mc?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),n,"end")}setAttribute(e,t,n){if(this._assertWriterUsedCorrectly(),n instanceof yc){const i=n.getMinimalFlatRanges();for(const n of i)Od(this,e,t,n)}else Rd(this,e,t,n)}setAttributes(e,t){for(const[n,i]of Co(e))this.setAttribute(n,i,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof yc){const n=t.getMinimalFlatRanges();for(const t of n)Od(this,e,null,t)}else Rd(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=e=>{for(const t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof yc)for(const n of e.getItems())t(n);else t(e)}move(e,t,n){if(this._assertWriterUsedCorrectly(),!(e instanceof yc))throw new w("writer-move-invalid-range",this);if(!e.isFlat)throw new w("writer-move-range-not-flat",this);const i=pc._createAt(t,n);if(i.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!Ld(e.root,i.root))throw new w("writer-move-different-document",this);const o=e.root.document?e.root.document.version:null,r=new Zl(e.start,e.end.offset-e.start.offset,i,o);this.batch.addOperation(r),this.model.applyOperation(r)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof yc?e:yc._createOn(e)).getMinimalFlatRanges().reverse();for(const e of t)this._addOperationForAffectedMarkers("move",e),Dd(e.start,e.end.offset-e.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,n=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof mc))throw new w("writer-merge-no-element-before",this);if(!(n instanceof mc))throw new w("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,n){return this.model.createPositionFromPath(e,t,n)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(...e){return this.model.createSelection(...e)}_mergeDetached(e){const t=e.nodeBefore,n=e.nodeAfter;this.move(yc._createIn(n),pc._createAt(t,"end")),this.remove(n)}_merge(e){const t=pc._createAt(e.nodeBefore,"end"),n=pc._createAt(e.nodeAfter,0),i=e.root.document.graveyard,o=new pc(i,[0]),r=e.root.document.version,s=new ed(n,e.nodeAfter.maxOffset,t,o,r);this.batch.addOperation(s),this.model.applyOperation(s)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof mc))throw new w("writer-rename-not-element-instance",this);const n=e.root.document?e.root.document.version:null,i=new Jl(pc._createBefore(e),e.name,t,n);this.batch.addOperation(i),this.model.applyOperation(i)}split(e,t){this._assertWriterUsedCorrectly();let n,i,o=e.parent;if(!o.parent)throw new w("writer-split-element-no-parent",this);if(t||(t=o.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new w("writer-split-invalid-limit-element",this);do{const t=o.root.document?o.root.document.version:null,r=o.maxOffset-e.offset,s=td.getInsertionPosition(e),a=new td(e,r,s,null,t);this.batch.addOperation(a),this.model.applyOperation(a),n||i||(n=o,i=e.parent.nextSibling),o=(e=this.createPositionAfter(e.parent)).parent}while(o!==t);return{position:e,range:new yc(pc._createAt(n,"end"),pc._createAt(i,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new w("writer-wrap-range-not-flat",this);const n=t instanceof mc?t:new mc(t);if(n.childCount>0)throw new w("writer-wrap-element-not-empty",this);if(null!==n.parent)throw new w("writer-wrap-element-attached",this);this.insert(n,e.start);const i=new yc(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(i,pc._createAt(n,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new w("writer-unwrap-element-no-parent",this);this.move(yc._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new w("writer-addmarker-no-usingoperation",this);const n=t.usingOperation,i=t.range,o=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new w("writer-addmarker-marker-exists",this);if(!i)throw new w("writer-addmarker-no-range",this);return n?(Nd(this,e,null,i,o),this.model.markers.get(e)):this.model.markers._set(e,i,n,o)}updateMarker(e,t){this._assertWriterUsedCorrectly();const n="string"==typeof e?e:e.name,i=this.model.markers.get(n);if(!i)throw new w("writer-updatemarker-marker-not-exists",this);if(!t)return k("writer-updatemarker-reconvert-using-editingcontroller",{markerName:n}),void this.model.markers._refresh(i);const o="boolean"==typeof t.usingOperation,r="boolean"==typeof t.affectsData,s=r?t.affectsData:i.affectsData;if(!o&&!t.range&&!r)throw new w("writer-updatemarker-wrong-options",this);const a=i.getRange(),c=t.range?t.range:a;o&&t.usingOperation!==i.managedUsingOperations?t.usingOperation?Nd(this,n,null,c,s):(Nd(this,n,a,null,s),this.model.markers._set(n,c,void 0,s)):i.managedUsingOperations?Nd(this,n,a,c,s):this.model.markers._set(n,c,void 0,s)}removeMarker(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new w("writer-removemarker-no-marker",this);const n=this.model.markers.get(t);if(!n.managedUsingOperations)return void this.model.markers._remove(t);Nd(this,t,n.getRange(),null,n.affectsData)}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,n]of Co(e))this._setSelectionAttribute(t,n)}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 n=this.model.document.selection;if(n.isCollapsed&&n.anchor.parent.isEmpty){const i=Bc._getStoreAttributeKey(e);this.setAttribute(i,t,n.anchor.parent)}n._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const n=Bc._getStoreAttributeKey(e);this.removeAttribute(n,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new w("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const n of this.model.markers){if(!n.managedUsingOperations)continue;const i=n.getRange();let o=!1;if("move"===e){const e=t;o=e.containsPosition(i.start)||e.start.isEqual(i.start)||e.containsPosition(i.end)||e.end.isEqual(i.end)}else{const e=t,n=e.nodeBefore,r=e.nodeAfter,s=i.start.parent==n&&i.start.isAtEnd,a=i.end.parent==r&&0==i.end.offset,c=i.end.nodeAfter==r,l=i.start.nodeAfter==r;o=s||a||c||l}o&&this.updateMarker(n.name,{range:i})}}}function Od(e,t,n,i){const o=e.model,r=o.document;let s,a,c,l=i.start;for(const e of i.getWalker({shallow:!0}))c=e.item.getAttribute(t),s&&a!=c&&(a!=n&&d(),l=s),s=e.nextPosition,a=c;function d(){const i=new yc(l,s),c=i.root.document?r.version:null,d=new Yl(i,t,a,n,c);e.batch.addOperation(d),o.applyOperation(d)}s instanceof pc&&s!=l&&a!=n&&d()}function Rd(e,t,n,i){const o=e.model,r=o.document,s=i.getAttribute(t);let a,c;if(s!=n){if(i.root===i){const e=i.document?r.version:null;c=new Xl(i,t,s,n,e)}else{a=new yc(pc._createBefore(i),e.createPositionAfter(i));const o=a.root.document?r.version:null;c=new Yl(a,t,s,n,o)}e.batch.addOperation(c),o.applyOperation(c)}}function Nd(e,t,n,i,o){const r=e.model,s=r.document,a=new Kl(t,n,i,r.markers,!!o,s.version);e.batch.addOperation(a),r.applyOperation(a)}function Dd(e,t,n,i){let o;if(e.root.document){const n=i.document,r=new pc(n.graveyard,[0]);o=new Zl(e,t,r,n.version)}else o=new Pd(e,t);n.addOperation(o),i.applyOperation(o)}function Ld(e,t){return e===t||e instanceof xd&&t instanceof xd}function Vd(e){e.document.registerPostFixer((t=>function(e,t){const n=t.document.selection,i=t.schema,o=[];let r=!1;for(const e of n.getRanges()){const t=Bd(e,i);t&&!t.isEqual(e)?(o.push(t),r=!0):o.push(e)}r&&e.setSelection(function(e){const t=[...e],n=new Set;let i=1;for(;i!n.has(t)))}(o),{backward:n.isBackward});return!1}(t,e)))}function Bd(e,t){return e.isCollapsed?function(e,t){const n=e.start,i=t.getNearestSelectionRange(n);if(!i){const e=n.getAncestors().reverse().find((e=>t.isObject(e)));return e?yc._createOn(e):null}if(!i.isCollapsed)return i;const o=i.start;if(n.isEqual(o))return null;return new yc(o)}(e,t):function(e,t){const{start:n,end:i}=e,o=t.checkChild(n,"$text"),r=t.checkChild(i,"$text"),s=t.getLimitElement(n),a=t.getLimitElement(i);if(s===a){if(o&&r)return null;if(function(e,t,n){const i=e.nodeAfter&&!n.isLimit(e.nodeAfter)||n.checkChild(e,"$text"),o=t.nodeBefore&&!n.isLimit(t.nodeBefore)||n.checkChild(t,"$text");return i||o}(n,i,t)){const e=n.nodeAfter&&t.isSelectable(n.nodeAfter)?null:t.getNearestSelectionRange(n,"forward"),o=i.nodeBefore&&t.isSelectable(i.nodeBefore)?null:t.getNearestSelectionRange(i,"backward"),r=e?e.start:n,s=o?o.end:i;return new yc(r,s)}}const c=s&&!s.is("rootElement"),l=a&&!a.is("rootElement");if(c||l){const e=n.nodeAfter&&i.nodeBefore&&n.nodeAfter.parent===i.nodeBefore.parent,o=c&&(!e||!zd(n.nodeAfter,t)),r=l&&(!e||!zd(i.nodeBefore,t));let d=n,u=i;return o&&(d=pc._createBefore(jd(s,t))),r&&(u=pc._createAfter(jd(a,t))),new yc(d,u)}return null}(e,t)}function jd(e,t){let n=e,i=n;for(;t.isLimit(i)&&i.parent;)n=i,i=i.parent;return n}function zd(e,t){return e&&t.isSelectable(e)}function Fd(e,t,n={}){if(t.isCollapsed)return;const i=t.getFirstRange();if("$graveyard"==i.root.rootName)return;const o=e.schema;e.change((e=>{if(!n.doNotResetEntireContent&&function(e,t){const n=e.getLimitElement(t);if(!t.containsEntireContent(n))return!1;const i=t.getFirstRange();if(i.start.parent==i.end.parent)return!1;return e.checkChild(n,"paragraph")}(o,t))return void function(e,t){const n=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(n)),qd(e,e.createPositionAt(n,0),t)}(e,t);const r={};if(!n.doNotAutoparagraph){const e=t.getSelectedElement();e&&Object.assign(r,o.getAttributesWithProperty(e,"copyOnReplace",!0))}const[s,a]=function(e){const t=e.root.document.model,n=e.start;let i=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){const n=function(e){const t=e.parent,n=t.root.document.model.schema,i=t.getAncestors({parentFirst:!0,includeSelf:!0});for(const e of i){if(n.isLimit(e))return null;if(n.isBlock(e))return e}}(i);if(n&&i.isTouching(t.createPositionAt(n,0))){const n=t.createSelection(e);t.modifySelection(n,{direction:"backward"});const o=n.getLastPosition(),r=t.createRange(o,i);t.hasContent(r,{ignoreMarkers:!0})||(i=o)}}return[fd.fromPosition(n,"toPrevious"),fd.fromPosition(i,"toNext")]}(i);s.isTouching(a)||e.remove(e.createRange(s,a)),n.leaveUnmerged||(!function(e,t,n){const i=e.model;if(!Wd(e.model.schema,t,n))return;const[o,r]=function(e,t){const n=e.getAncestors(),i=t.getAncestors();let o=0;for(;n[o]&&n[o]==i[o];)o++;return[n[o],i[o]]}(t,n);if(!o||!r)return;!i.hasContent(o,{ignoreMarkers:!0})&&i.hasContent(r,{ignoreMarkers:!0})?Hd(e,t,n,o.parent):Ud(e,t,n,o.parent)}(e,s,a),o.removeDisallowedAttributes(s.parent.getChildren(),e)),Zd(e,t,s),!n.doNotAutoparagraph&&function(e,t){const n=e.checkChild(t,"$text"),i=e.checkChild(t,"paragraph");return!n&&i}(o,s)&&qd(e,s,t,r),s.detach(),a.detach()}))}function Ud(e,t,n,i){const o=t.parent,r=n.parent;if(o!=i&&r!=i){for(t=e.createPositionAfter(o),(n=e.createPositionBefore(r)).isEqual(t)||e.insert(r,t),e.merge(t);n.parent.isEmpty;){const t=n.parent;n=e.createPositionBefore(t),e.remove(t)}Wd(e.model.schema,t,n)&&Ud(e,t,n,i)}}function Hd(e,t,n,i){const o=t.parent,r=n.parent;if(o!=i&&r!=i){for(t=e.createPositionAfter(o),(n=e.createPositionBefore(r)).isEqual(t)||e.insert(o,n);t.parent.isEmpty;){const n=t.parent;t=e.createPositionBefore(n),e.remove(n)}n=e.createPositionBefore(r),function(e,t){const n=t.nodeBefore,i=t.nodeAfter;n.name!=i.name&&e.rename(n,i.name);e.clearAttributes(n),e.setAttributes(Object.fromEntries(i.getAttributes()),n),e.merge(t)}(e,n),Wd(e.model.schema,t,n)&&Hd(e,t,n,i)}}function Wd(e,t,n){const i=t.parent,o=n.parent;return i!=o&&(!e.isLimit(i)&&!e.isLimit(o)&&function(e,t,n){const i=new yc(e,t);for(const e of i.getWalker())if(n.isLimit(e.item))return!1;return!0}(t,n,e))}function qd(e,t,n,i={}){const o=e.createElement("paragraph");e.model.schema.setAllowedAttributes(o,i,e),e.insert(o,t),Zd(e,n,e.createPositionAt(o,0))}function Zd(e,t,n){t instanceof Bc?e.setSelection(n):t.setTo(n)}function $d(e,t){const n=[];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=>{n.push(e.start.parent),t.remove(e)})),n.forEach((e=>{let n=e;for(;n.parent&&n.isEmpty;){const e=t.createRangeOn(n);n=n.parent,t.remove(e)}}))}class Kd{constructor(e,t,n){this.model=e,this.writer=t,this.position=n,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0),this._firstNode=null,this._lastNode=null,this._lastAutoParagraph=null,this._filterAttributesOf=[],this._affectedStart=null,this._affectedEnd=null}handleNodes(e){for(const t of Array.from(e))this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),n=this.writer.createPositionAfter(e);if(n.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new w("insertcontent-invalid-insertion-position",this);this.position=n,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?yc._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new yc(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=fd.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 w("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=fd.fromPosition(e,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(e)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=fd.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof mc))return;if(!this._canMergeLeft(e))return;const t=fd._createBefore(e);t.stickiness="toNext";const n=fd.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=fd._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=fd._createAt(t.nodeBefore,"end","toNext")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof mc))return;if(!this._canMergeRight(e))return;const t=fd._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new w("insertcontent-invalid-insertion-position",this);this.position=pc._createAt(t.nodeBefore,"end");const n=fd.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=fd._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=fd._createAt(t.nodeBefore,0,"toPrevious")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof mc&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof mc&&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 Gd(e,t,n="auto"){const i=e.getSelectedElement();if(i&&t.schema.isObject(i)&&!t.schema.isInline(i))return"before"==n||"after"==n?t.createRange(t.createPositionAt(i,n)):t.createRangeOn(i);const o=yo(e.getSelectedBlocks());if(!o)return t.createRange(e.focus);if(o.isEmpty)return t.createRange(t.createPositionAt(o,0));const r=t.createPositionAfter(o);return e.focus.isTouching(r)?t.createRange(r):t.createRange(t.createPositionBefore(o))}function Yd(e,t,n,i,o={}){if(!e.schema.isObject(t))throw new w("insertobject-element-not-an-object",e,{object:t});let r;r=n?n instanceof Pc||n instanceof Bc?n:e.createSelection(n,i):e.document.selection;let s=r;o.findOptimalPosition&&e.schema.isBlock(t)&&(s=e.createSelection(Gd(r,e,o.findOptimalPosition)));const a=yo(r.getSelectedBlocks()),c={};return a&&Object.assign(c,e.schema.getAttributesWithProperty(a,"copyOnReplace",!0)),e.change((n=>{s.isCollapsed||e.deleteContent(s,{doNotAutoparagraph:!0});let i=t;const r=s.anchor.parent;!e.schema.checkChild(r,t)&&e.schema.checkChild(r,"paragraph")&&e.schema.checkChild("paragraph",t)&&(i=n.createElement("paragraph"),n.insert(t,i)),e.schema.setAllowedAttributes(i,c,n);const a=e.insertContent(i,s);return a.isCollapsed||o.setSelection&&function(e,t,n,i){const o=e.model;if("on"==n)return void e.setSelection(t,"on");if("after"!=n)throw new w("insertobject-invalid-place-parameter-value",o);let r=t.nextSibling;if(o.schema.isInline(t))return void e.setSelection(t,"after");r&&o.schema.checkChild(r,"$text")||!o.schema.checkChild(t.parent,"paragraph")||(r=e.createElement("paragraph"),o.schema.setAllowedAttributes(r,i,e),o.insertContent(r,e.createPositionAfter(t)));r&&e.setSelection(r,0)}(n,t,o.setSelection,c),a}))}function Qd(e,t){const{isForward:n,walker:i,unit:o,schema:r,treatEmojiAsSingleUnit:s}=e,{type:a,item:c,nextPosition:l}=t;if("text"==a)return"word"===e.unit?function(e,t){let n=e.position.textNode;n||(n=t?e.position.nodeAfter:e.position.nodeBefore);for(;n&&n.is("$text");){const i=e.position.offset-n.startOffset;if(eu(n,i,t))n=t?e.position.nodeAfter:e.position.nodeBefore;else{if(Xd(n.data,i,t))break;e.next()}}return e.position}(i,n):function(e,t,n){const i=e.position.textNode;if(i){const o=i.data;let r=e.position.offset-i.startOffset;for(;Eo(o,r)||"character"==t&&To(o,r)||n&&Po(o,r);)e.next(),r=e.position.offset-i.startOffset}return e.position}(i,o,s);if(a==(n?"elementStart":"elementEnd")){if(r.isSelectable(c))return pc._createAt(c,n?"after":"before");if(r.checkChild(l,"$text"))return l}else{if(r.isLimit(c))return void i.skip((()=>!0));if(r.checkChild(l,"$text"))return l}}function Jd(e,t){const n=e.root,i=pc._createAt(n,t?"end":0);return t?new yc(e,i):new yc(i,e)}function Xd(e,t,n){const i=t+(n?0:-1);return' ,.?!:;"-()'.includes(e.charAt(i))}function eu(e,t,n){return t===(n?e.offsetSize:0)}class tu extends(H()){constructor(){super(),this.markers=new Td,this.document=new Cd(this),this.schema=new pl,this._pendingChanges=[],this._currentWriter=null,["insertContent","insertObject","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})),Vd(this),this.document.registerPostFixer(nl)}change(e){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new bd,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(e){w.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{e?"function"==typeof e?(t=e,e=new bd):e instanceof bd||(e=new bd(e)):e=new bd,this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(e){w.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,n){return function(e,t,n,i){return e.change((o=>{let r;r=n?n instanceof Pc||n instanceof Bc?n:o.createSelection(n,i):e.document.selection,r.isCollapsed||e.deleteContent(r,{doNotAutoparagraph:!0});const s=new Kd(e,o,r.anchor),a=[];let c;if(t.is("documentFragment")){if(t.markers.size){const e=[];for(const[n,i]of t.markers){const{start:t,end:o}=i,r=t.isEqual(o);e.push({position:t,name:n,isCollapsed:r},{position:o,name:n,isCollapsed:r})}e.sort((({position:e},{position:t})=>e.isBefore(t)?1:-1));for(const{position:n,name:i,isCollapsed:r}of e){let e=null,s=null;const c=n.parent===t&&n.isAtStart,l=n.parent===t&&n.isAtEnd;c||l?r&&(s=c?"start":"end"):(e=o.createElement("$marker"),o.insert(e,n)),a.push({name:i,element:e,collapsed:s})}}c=t.getChildren()}else c=[t];s.handleNodes(c);let l=s.getSelectionRange();if(t.is("documentFragment")&&a.length){const e=l?Nc.fromRange(l):null,t={};for(let e=a.length-1;e>=0;e--){const{name:n,element:i,collapsed:r}=a[e],c=!t[n];if(c&&(t[n]=[]),i){const e=o.createPositionAt(i,"before");t[n].push(e),o.remove(i)}else{const e=s.getAffectedRange();if(!e){r&&t[n].push(s.position);continue}r?t[n].push(e[r]):t[n].push(c?e.start:e.end)}}for(const[e,[n,i]]of Object.entries(t))n&&i&&n.root===i.root&&o.addMarker(e,{usingOperation:!0,affectsData:!0,range:new yc(n,i)});e&&(l=e.toRange(),e.detach())}l&&(r instanceof Bc?o.setSelection(l):r.setTo(l));const d=s.getAffectedRange()||e.createRange(r.anchor);return s.destroy(),d}))}(this,e,t,n)}insertObject(e,t,n,i){return Yd(this,e,t,n,i)}deleteContent(e,t){Fd(this,e,t)}modifySelection(e,t){!function(e,t,n={}){const i=e.schema,o="backward"!=n.direction,r=n.unit?n.unit:"character",s=!!n.treatEmojiAsSingleUnit,a=t.focus,c=new fc({boundaries:Jd(a,o),singleCharacters:!0,direction:o?"forward":"backward"}),l={walker:c,schema:i,isForward:o,unit:r,treatEmojiAsSingleUnit:s};let d;for(;d=c.next();){if(d.done)return;const n=Qd(l,d.value);if(n)return void(t instanceof Bc?e.change((e=>{e.setSelectionFocus(n)})):t.setFocus(n))}}(this,e,t)}getSelectedContent(e){return function(e,t){return e.change((e=>{const n=e.createDocumentFragment(),i=t.getFirstRange();if(!i||i.isCollapsed)return n;const o=i.start.root,r=i.start.getCommonPath(i.end),s=o.getNodeByPath(r);let a;a=i.start.parent==i.end.parent?i:e.createRange(e.createPositionAt(s,i.start.path[r.length]),e.createPositionAt(s,i.end.path[r.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(),n):e.append(e.cloneElement(t,!0),n);if(a!=i){const t=i._getTransformedByMove(a.start,e.createPositionAt(n,0),c)[0],o=e.createRange(e.createPositionAt(n,0),t.start);$d(e.createRange(t.end,e.createPositionAt(n,"end")),e),$d(o,e)}return n}))}(this,e)}hasContent(e,t={}){const n=e instanceof yc?e:yc._createIn(e);if(n.isCollapsed)return!1;const{ignoreWhitespaces:i=!1,ignoreMarkers:o=!1}=t;if(!o)for(const e of this.markers.getMarkersIntersectingRange(n))if(e.affectsData)return!0;for(const e of n.getItems())if(this.schema.isContent(e)){if(!e.is("$textProxy"))return!0;if(!i)return!0;if(-1!==e.data.search(/\S/))return!0}return!1}createPositionFromPath(e,t,n){return new pc(e,t,n)}createPositionAt(e,t){return pc._createAt(e,t)}createPositionAfter(e){return pc._createAfter(e)}createPositionBefore(e){return pc._createBefore(e)}createRange(e,t){return new yc(e,t)}createRangeIn(e){return yc._createIn(e)}createRangeOn(e){return yc._createOn(e)}createSelection(...e){return new Pc(...e)}createBatch(e){return new bd(e)}createOperationFromJSON(e){return class{static fromJSON(e,t){return nd[e.__className].fromJSON(e,t)}}.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 Md(this,t);const n=this._pendingChanges[0].callback(this._currentWriter);e.push(n),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}return e}}class nu extends ga{constructor(e){super(e),this.domEventType="click"}onDomEvent(e){this.fire(e.type,e)}}class iu extends ga{constructor(e){super(e),this.domEventType=["mousedown","mouseup","mouseover","mouseout"]}onDomEvent(e){this.fire(e.type,e)}}class ou{constructor(e){this.document=e}createDocumentFragment(e){return new Ps(this.document,e)}createElement(e,t,n){return new Jr(this.document,e,t,n)}createText(e){return new Qo(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,n){return n._insertChild(e,t)}removeChildren(e,t,n){return n._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const n=e.parent;if(n){const i=n.getChildIndex(e);return this.removeChildren(i,1,n),this.insertChild(i,t,n),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const n=t.getChildIndex(e);this.remove(e),this.insertChild(n,e.getChildren(),t)}}rename(e,t){const n=new Jr(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,n)?n:null}setAttribute(e,t,n){n._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){xe(e)&&void 0===n?t._setStyle(e):n._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,n){n._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return ss._createAt(e,t)}createPositionAfter(e){return ss._createAfter(e)}createPositionBefore(e){return ss._createBefore(e)}createRange(e,t){return new as(e,t)}createRangeOn(e){return as._createOn(e)}createRangeIn(e){return as._createIn(e)}createSelection(...e){return new ls(...e)}}const ru=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,su=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,au=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,cu=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,lu=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,du=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 uu(e){return e.startsWith("#")?ru.test(e):e.startsWith("rgb")?su.test(e)||au.test(e):e.startsWith("hsl")?cu.test(e)||lu.test(e):du.has(e.toLowerCase())}const hu=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;const mu=/^[+-]?[0-9]*([.][0-9]+)?%$/;const fu=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function gu(e){return fu.includes(e)}const pu=["center","top","bottom","left","right"];function bu(e){return pu.includes(e)}const wu=["fixed","scroll","local"];function ku(e){return wu.includes(e)}const _u=/^url\(/;function vu(e){return _u.test(e)}function yu(e=""){if(""===e)return{top:void 0,right:void 0,bottom:void 0,left:void 0};const t=Au(e),n=t[0],i=t[2]||n,o=t[1]||n;return{top:n,bottom:i,right:o,left:t[3]||o}}function xu({top:e,right:t,bottom:n,left:i}){const o=[];return i!==t?o.push(e,t,n,i):n!==e?o.push(e,t,n):t!==e?o.push(e,t):o.push(e),o.join(" ")}function Au(e){return e.replace(/, /g,",").split(" ").map((e=>e.replace(/,/g,", ")))}function Cu(e){e.setNormalizer("background",(e=>{const t={},n=Au(e);for(const e of n)gu(e)?(t.repeat=t.repeat||[],t.repeat.push(e)):bu(e)?(t.position=t.position||[],t.position.push(e)):ku(e)?t.attachment=e:uu(e)?t.color=e:vu(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 Eu(e){var t,n;e.setNormalizer("margin",(t="margin",e=>({path:t,value:yu(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",(n="margin",e=>{const{top:t,right:i,bottom:o,left:r}=e,s=[];return[t,i,r,o].every((e=>!!e))?s.push([n,xu(e)]):(t&&s.push([n+"-top",t]),i&&s.push([n+"-right",i]),o&&s.push([n+"-bottom",o]),r&&s.push([n+"-left",r])),s})),e.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}class Tu{constructor(){this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){const n=this.get(e);if(!n)throw new w("commandcollection-command-not-found",this,{commandName:e});return n.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 Su extends Ao{constructor(e){super(),this.editor=e}set(e,t,n={}){if("string"==typeof t){const e=t;t=(t,n)=>{this.editor.execute(e),n()}}super.set(e,t,n)}}class Pu extends(H()){constructor(e={}){super();const t=this.constructor,n=e.language||t.defaultConfig&&t.defaultConfig.language;this._context=e.context||new Lo({language:n}),this._context._addEditor(this,!e.context);const i=Array.from(t.builtinPlugins||[]);this.config=new vi(e,t.defaultConfig),this.config.define("plugins",i),this.config.define(this._context._getEditorConfig()),this.plugins=new Do(this,i,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new Tu,this.set("state","initializing"),this.once("ready",(()=>this.state="ready"),{priority:"high"}),this.once("destroy",(()=>this.state="destroyed"),{priority:"high"}),this.model=new tu;const o=new Gr;this.data=new Nl(this.model,o),this.editing=new hl(this.model,o),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new Dl([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 Su(this),this.keystrokes.listenTo(this.editing.view.document)}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new w("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new w("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 w("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"),n=e.get("removePlugins")||[],i=e.get("extraPlugins")||[],o=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(i),n,o)}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){w.rethrowUnexpectedError(e,this)}}focus(){this.editing.view.focus()}}class Iu{constructor(e){this.editor=e,this._components=new Map}*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set(Mu(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new w("componentfactory-item-missing",this,{name:e});return this._components.get(Mu(e)).callback(this.editor.locale)}has(e){return this._components.has(Mu(e))}}function Mu(e){return String(e).toLowerCase()}class Ou extends vo{constructor(e=[]){super(e,{idProperty:"viewUid"}),this.on("add",((e,t,n)=>{this._renderViewIntoCollectionParent(t,n)})),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 w("ui-viewcollection-delegate-wrong-events",this);return{to:t=>{for(const n of this)for(const i of e)n.delegate(i).to(t);this.on("add",((n,i)=>{for(const n of e)i.delegate(n).to(t)})),this.on("remove",((n,i)=>{for(const n of e)i.stopDelegating(n,t)}))}}}_renderViewIntoCollectionParent(e,t){e.isRendered||e.render(),e.element&&this._parentElement&&this._parentElement.insertBefore(e.element,this._parentElement.children[t])}}class Ru extends(S()){constructor(e){super(),Object.assign(this,Hu(Uu(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 w("ui-template-revert-not-applied",[this,e]);this._revertTemplateFromNode(e,this._revertData)}*getViews(){yield*function*e(t){if(t.children)for(const n of t.children)Gu(n)?yield n:Yu(n)&&(yield*e(n))}(this)}static bind(e,t){return{to:(n,i)=>new Du({eventNameOrFunction:n,attribute:n,observable:e,emitter:t,callback:i}),if:(n,i,o)=>new Lu({observable:e,emitter:t,attribute:n,valueIfTrue:i,callback:o})}}static extend(e,t){if(e._isRendered)throw new w("template-extend-render",[this,e]);$u(e,Hu(Uu(t)))}_renderNode(e){let t;if(t=e.node?this.tag&&this.text:this.tag?this.text:!this.text,t)throw new w("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(""),Vu(this.text)?this._bindToObservable({schema:this.text,updater:ju(t),data:e}):t.textContent=this.text.join(""),t}_renderAttributes(e){if(!this.attributes)return;const t=e.node,n=e.revertData;for(const i in this.attributes){const o=t.getAttribute(i),r=this.attributes[i];n&&(n.attributes[i]=o);const s=Ju(r)?r[0].ns:null;if(Vu(r)){const a=Ju(r)?r[0].value:r;n&&Xu(i)&&a.unshift(o),this._bindToObservable({schema:a,updater:zu(t,i,s),data:e})}else if("style"==i&&"string"!=typeof r[0])this._renderStyleAttribute(r[0],e);else{n&&o&&Xu(i)&&r.unshift(o);const e=r.map((e=>e&&e.value||e)).reduce(((e,t)=>e.concat(t)),[]).reduce(qu,"");Ku(e)||t.setAttributeNS(s,i,e)}}}_renderStyleAttribute(e,t){const n=t.node;for(const i in e){const o=e[i];Vu(o)?this._bindToObservable({schema:[o],updater:Fu(n,i),data:t}):n.style[i]=o}}_renderElementChildren(e){const t=e.node,n=e.intoFragment?document.createDocumentFragment():t,i=e.isApplying;let o=0;for(const r of this.children)if(Qu(r)){if(!i){r.setParent(t);for(const e of r)n.appendChild(e.element)}}else if(Gu(r))i||(r.isRendered||r.render(),n.appendChild(r.element));else if(Ai(r))n.appendChild(r);else if(i){const t={children:[],bindings:[],attributes:{}};e.revertData.children.push(t),r._renderNode({intoFragment:!1,node:n.childNodes[o++],isApplying:!0,revertData:t})}else n.appendChild(r.render());e.intoFragment&&t.appendChild(n)}_setUpListeners(e){if(this.eventListeners)for(const t in this.eventListeners){const n=this.eventListeners[t].map((n=>{const[i,o]=t.split("@");return n.activateDomEventListener(i,o,e)}));e.revertData&&e.revertData.bindings.push(n)}}_bindToObservable({schema:e,updater:t,data:n}){const i=n.revertData;Bu(e,t,n);const o=e.filter((e=>!Ku(e))).filter((e=>e.observable)).map((i=>i.activateAttributeListener(e,t,n)));i&&i.bindings.push(o)}_revertTemplateFromNode(e,t){for(const e of t.bindings)for(const t of e)t();if(t.text)return void(e.textContent=t.text);const n=e;for(const e in t.attributes){const i=t.attributes[e];null===i?n.removeAttribute(e):n.setAttribute(e,i)}for(let e=0;eBu(e,t,n);return this.emitter.listenTo(this.observable,`change:${this.attribute}`,i),()=>{this.emitter.stopListening(this.observable,`change:${this.attribute}`,i)}}}class Du extends Nu{constructor(e){super(e),this.eventNameOrFunction=e.eventNameOrFunction}activateDomEventListener(e,t,n){const i=(e,n)=>{t&&!n.target.matches(t)||("function"==typeof this.eventNameOrFunction?this.eventNameOrFunction(n):this.observable.fire(this.eventNameOrFunction,n))};return this.emitter.listenTo(n.node,e,i),()=>{this.emitter.stopListening(n.node,e,i)}}}class Lu extends Nu{constructor(e){super(e),this.valueIfTrue=e.valueIfTrue}getValue(e){return!Ku(super.getValue(e))&&(this.valueIfTrue||!0)}}function Vu(e){return!!e&&(e.value&&(e=e.value),Array.isArray(e)?e.some(Vu):e instanceof Nu)}function Bu(e,t,{node:n}){const i=function(e,t){return e.map((e=>e instanceof Nu?e.getValue(t):e))}(e,n);let o;o=1==e.length&&e[0]instanceof Lu?i[0]:i.reduce(qu,""),Ku(o)?t.remove():t.set(o)}function ju(e){return{set(t){e.textContent=t},remove(){e.textContent=""}}}function zu(e,t,n){return{set(i){e.setAttributeNS(n,t,i)},remove(){e.removeAttributeNS(n,t)}}}function Fu(e,t){return{set(n){e.style[t]=n},remove(){e.style[t]=null}}}function Uu(e){return ki(e,(e=>{if(e&&(e instanceof Nu||Yu(e)||Gu(e)||Qu(e)))return e}))}function Hu(e){if("string"==typeof e?e=function(e){return{text:[e]}}(e):e.text&&function(e){e.text=wo(e.text)}(e),e.on&&(e.eventListeners=function(e){for(const t in e)Wu(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=wo(e[t].value)),Wu(e,t)}(e.attributes);const t=[];if(e.children)if(Qu(e.children))t.push(e.children);else for(const n of e.children)Yu(n)||Gu(n)||Ai(n)?t.push(n):t.push(new Ru(n));e.children=t}return e}function Wu(e,t){e[t]=wo(e[t])}function qu(e,t){return Ku(t)?e:Ku(e)?t:`${e} ${t}`}function Zu(e,t){for(const n in t)e[n]?e[n].push(...t[n]):e[n]=t[n]}function $u(e,t){if(t.attributes&&(e.attributes||(e.attributes={}),Zu(e.attributes,t.attributes)),t.eventListeners&&(e.eventListeners||(e.eventListeners={}),Zu(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 w("ui-template-extend-children-mismatch",e);let n=0;for(const i of t.children)$u(e.children[n++],i)}}function Ku(e){return!e&&0!==e}function Gu(e){return e instanceof nh}function Yu(e){return e instanceof Ru}function Qu(e){return e instanceof Ou}function Ju(e){return L(e[0])&&e[0].ns}function Xu(e){return"class"==e||"style"==e}var eh=n(972),th={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(eh.Z,th);eh.Z.locals;class nh extends(Ti(H())){constructor(e){super(),this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new vo,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",((t,n)=>{n.locale=e,n.t=e&&e.t})),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=Ru.bind(this,this)}createCollection(e){const t=new Ou(e);return this._viewCollections.add(t),t}registerChild(e){J(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){J(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new Ru(e)}extendTemplate(e){Ru.extend(this.template,e)}render(){if(this.isRendered)throw new w("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)}}var ih=n(9029),oh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(ih.Z,oh);ih.Z.locals;const rh=Hi("px"),sh=Mi.document.body;class ah extends nh{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",rh),left:t.to("left",rh)}},children:this.content})}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){this.show();const t=ah.defaultPositions,n=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:sh,fitInViewport:!0},e),i=ah._getOptimalPosition(n),o=parseInt(i.left),r=parseInt(i.top),s=i.name,a=i.config||{},{withArrow:c=!0}=a;this.top=r,this.left=o,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=ch(e.target),n=e.limiter?ch(e.limiter):sh;this.listenTo(Mi.document,"scroll",((i,o)=>{const r=o.target,s=t&&r.contains(t),a=n&&r.contains(n);!s&&!a&&t&&n||this.attachTo(e)}),{useCapture:!0}),this.listenTo(Mi.window,"resize",(()=>{this.attachTo(e)}))}_stopPinning(){this.stopListening(Mi.document,"scroll"),this.stopListening(Mi.window,"resize")}}function ch(e){return _i(e)?e:Ni(e)?e.commonAncestorContainer:"function"==typeof e?ch(e()):null}function lh(e={}){const{sideOffset:t=ah.arrowSideOffset,heightOffset:n=ah.arrowHeightOffset,stickyVerticalOffset:i=ah.stickyVerticalOffset,config:o}=e;return{northWestArrowSouthWest:(e,n)=>({top:r(e,n),left:e.left-t,name:"arrow_sw",...o&&{config:o}}),northWestArrowSouthMiddleWest:(e,n)=>({top:r(e,n),left:e.left-.25*n.width-t,name:"arrow_smw",...o&&{config:o}}),northWestArrowSouth:(e,t)=>({top:r(e,t),left:e.left-t.width/2,name:"arrow_s",...o&&{config:o}}),northWestArrowSouthMiddleEast:(e,n)=>({top:r(e,n),left:e.left-.75*n.width+t,name:"arrow_sme",...o&&{config:o}}),northWestArrowSouthEast:(e,n)=>({top:r(e,n),left:e.left-n.width+t,name:"arrow_se",...o&&{config:o}}),northArrowSouthWest:(e,n)=>({top:r(e,n),left:e.left+e.width/2-t,name:"arrow_sw",...o&&{config:o}}),northArrowSouthMiddleWest:(e,n)=>({top:r(e,n),left:e.left+e.width/2-.25*n.width-t,name:"arrow_smw",...o&&{config:o}}),northArrowSouth:(e,t)=>({top:r(e,t),left:e.left+e.width/2-t.width/2,name:"arrow_s",...o&&{config:o}}),northArrowSouthMiddleEast:(e,n)=>({top:r(e,n),left:e.left+e.width/2-.75*n.width+t,name:"arrow_sme",...o&&{config:o}}),northArrowSouthEast:(e,n)=>({top:r(e,n),left:e.left+e.width/2-n.width+t,name:"arrow_se",...o&&{config:o}}),northEastArrowSouthWest:(e,n)=>({top:r(e,n),left:e.right-t,name:"arrow_sw",...o&&{config:o}}),northEastArrowSouthMiddleWest:(e,n)=>({top:r(e,n),left:e.right-.25*n.width-t,name:"arrow_smw",...o&&{config:o}}),northEastArrowSouth:(e,t)=>({top:r(e,t),left:e.right-t.width/2,name:"arrow_s",...o&&{config:o}}),northEastArrowSouthMiddleEast:(e,n)=>({top:r(e,n),left:e.right-.75*n.width+t,name:"arrow_sme",...o&&{config:o}}),northEastArrowSouthEast:(e,n)=>({top:r(e,n),left:e.right-n.width+t,name:"arrow_se",...o&&{config:o}}),southWestArrowNorthWest:e=>({top:s(e),left:e.left-t,name:"arrow_nw",...o&&{config:o}}),southWestArrowNorthMiddleWest:(e,n)=>({top:s(e),left:e.left-.25*n.width-t,name:"arrow_nmw",...o&&{config:o}}),southWestArrowNorth:(e,t)=>({top:s(e),left:e.left-t.width/2,name:"arrow_n",...o&&{config:o}}),southWestArrowNorthMiddleEast:(e,n)=>({top:s(e),left:e.left-.75*n.width+t,name:"arrow_nme",...o&&{config:o}}),southWestArrowNorthEast:(e,n)=>({top:s(e),left:e.left-n.width+t,name:"arrow_ne",...o&&{config:o}}),southArrowNorthWest:e=>({top:s(e),left:e.left+e.width/2-t,name:"arrow_nw",...o&&{config:o}}),southArrowNorthMiddleWest:(e,n)=>({top:s(e),left:e.left+e.width/2-.25*n.width-t,name:"arrow_nmw",...o&&{config:o}}),southArrowNorth:(e,t)=>({top:s(e),left:e.left+e.width/2-t.width/2,name:"arrow_n",...o&&{config:o}}),southArrowNorthMiddleEast:(e,n)=>({top:s(e),left:e.left+e.width/2-.75*n.width+t,name:"arrow_nme",...o&&{config:o}}),southArrowNorthEast:(e,n)=>({top:s(e),left:e.left+e.width/2-n.width+t,name:"arrow_ne",...o&&{config:o}}),southEastArrowNorthWest:e=>({top:s(e),left:e.right-t,name:"arrow_nw",...o&&{config:o}}),southEastArrowNorthMiddleWest:(e,n)=>({top:s(e),left:e.right-.25*n.width-t,name:"arrow_nmw",...o&&{config:o}}),southEastArrowNorth:(e,t)=>({top:s(e),left:e.right-t.width/2,name:"arrow_n",...o&&{config:o}}),southEastArrowNorthMiddleEast:(e,n)=>({top:s(e),left:e.right-.75*n.width+t,name:"arrow_nme",...o&&{config:o}}),southEastArrowNorthEast:(e,n)=>({top:s(e),left:e.right-n.width+t,name:"arrow_ne",...o&&{config:o}}),westArrowEast:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.left-t.width-n,name:"arrow_e",...o&&{config:o}}),eastArrowWest:(e,t)=>({top:e.top+e.height/2-t.height/2,left:e.right+n,name:"arrow_w",...o&&{config:o}}),viewportStickyNorth:(e,t,n)=>e.getIntersection(n)?{top:n.top+i,left:e.left+e.width/2-t.width/2,name:"arrowless",config:{withArrow:!1,...o}}:null};function r(e,t){return e.top-t.height-n}function s(e){return e.bottom+n}}ah.arrowSideOffset=25,ah.arrowHeightOffset=10,ah.stickyVerticalOffset=20,ah._getOptimalPosition=Ki,ah.defaultPositions=lh();var dh=n(9721),uh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(dh.Z,uh);dh.Z.locals;const hh="ck-tooltip";class mh extends(Ti()){constructor(e){if(super(),mh._editors.add(e),mh._instance)return mh._instance;mh._instance=this,this.tooltipTextView=new nh(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 ah(e.locale),this.balloonPanelView.class=hh,this.balloonPanelView.content.add(this.tooltipTextView),this._resizeObserver=null,this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this._pinTooltipDebounced=Pa(this._pinTooltip,600),this.listenTo(Mi.document,"mouseenter",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(Mi.document,"mouseleave",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(Mi.document,"focus",this._onEnterOrFocus.bind(this),{useCapture:!0}),this.listenTo(Mi.document,"blur",this._onLeaveOrBlur.bind(this),{useCapture:!0}),this.listenTo(Mi.document,"scroll",this._onScroll.bind(this),{useCapture:!0}),this._watchdogExcluded=!0}destroy(e){const t=e.ui.view&&e.ui.view.body;mh._editors.delete(e),this.stopListening(e.ui),t&&t.has(this.balloonPanelView)&&t.remove(this.balloonPanelView),mh._editors.size||(this._unpinTooltip(),this.balloonPanelView.destroy(),this.stopListening(),mh._instance=null)}static getPositioningFunctions(e){const t=mh.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 n=fh(t);var i;n&&(n!==this._currentElementWithTooltip&&(this._unpinTooltip(),this._pinTooltipDebounced(n,{text:(i=n).dataset.ckeTooltipText,position:i.dataset.ckeTooltipPosition||"s",cssClass:i.dataset.ckeTooltipClass||""})))}_onLeaveOrBlur(e,{target:t,relatedTarget:n}){if("mouseleave"===e.name){if(!_i(t))return;if(this._currentElementWithTooltip&&t!==this._currentElementWithTooltip)return;const e=fh(t),i=fh(n);e&&e!==i&&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:n,cssClass:i}){const o=yo(mh._editors.values()).ui.view.body;o.has(this.balloonPanelView)||o.add(this.balloonPanelView),this.tooltipTextView.text=t,this.balloonPanelView.pin({target:e,positions:mh.getPositioningFunctions(n)}),this._resizeObserver=new Fi(e,(()=>{$i(e)||this._unpinTooltip()})),this.balloonPanelView.class=[hh,i].filter((e=>e)).join(" ");for(const e of mh._editors)this.listenTo(e.ui,"update",this._updateTooltipPosition.bind(this),{priority:"low"});this._currentElementWithTooltip=e,this._currentTooltipPosition=n}_unpinTooltip(){this._pinTooltipDebounced.cancel(),this.balloonPanelView.unpin();for(const e of mh._editors)this.stopListening(e.ui,"update");this._currentElementWithTooltip=null,this._currentTooltipPosition=null,this._resizeObserver&&this._resizeObserver.destroy()}_updateTooltipPosition(){$i(this._currentElementWithTooltip)?this.balloonPanelView.pin({target:this._currentElementWithTooltip,positions:mh.getPositioningFunctions(this._currentTooltipPosition)}):this._unpinTooltip()}}function fh(e){return _i(e)?e.closest("[data-cke-tooltip-text]:not([data-cke-tooltip-disabled])"):null}mh.defaultBalloonPositions=lh({heightOffset:5,sideOffset:13}),mh._editors=new Set,mh._instance=null;class gh extends(H()){constructor(e){super(),this.editor=e,this.componentFactory=new Iu(e),this.focusTracker=new xo,this.tooltipManager=new mh(e),this.set("viewportOffset",this._readViewportOffsetFromConfig()),this.isReady=!1,this.once("ready",(()=>{this.isReady=!0})),this._editableElementsMap=new Map,this._focusableToolbarDefinitions=[],this.listenTo(e.editing.view.document,"layoutChanged",(()=>this.update())),this._initFocusTracking()}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy(),this.tooltipManager.destroy(this.editor);for(const e of this._editableElementsMap.values())e.ckeditorInstance=null;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 n=()=>{this.editor.editing.view.getDomRoot(e)||this.editor.keystrokes.listenTo(t)};this.isReady?n():this.once("ready",n)}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 n=e.config.get("toolbar.viewportTopOffset");return n?(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:n}):{top:0}}_initFocusTracking(){const e=this.editor,t=e.editing.view;let n,i;e.keystrokes.set("Alt+F10",((e,o)=>{const r=this.focusTracker.focusedElement;Array.from(this._editableElementsMap.values()).includes(r)&&!Array.from(t.domRoots.values()).includes(r)&&(n=r);const s=this._getCurrentFocusedToolbarDefinition();s&&i||(i=this._getFocusableCandidateToolbarDefinitions());for(let e=0;e{const o=this._getCurrentFocusedToolbarDefinition();o&&(n?(n.focus(),n=null):e.editing.view.focus(),o.options.afterBlur&&o.options.afterBlur(),i())}))}_getFocusableCandidateToolbarDefinitions(){const e=[];for(const t of this._focusableToolbarDefinitions){const{toolbarView:n,options:i}=t;($i(n.element)||i.beforeFocus)&&e.push(t)}return e.sort(((e,t)=>ph(e)-ph(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:n}}=e;return n&&n(),!!$i(t.element)&&(t.focus(),!0)}}function ph(e){const{toolbarView:t,options:n}=e;let i=10;return $i(t.element)&&i--,n.isContextual&&i--,i}function bh(e){return class extends e{setData(e){this.data.set(e)}getData(e){return this.data.get(e)}}}{const e=bh(Object);bh.setData=e.prototype.setData,bh.getData=e.prototype.getData}function wh(e){return class extends e{updateSourceElement(e=this.data.get()){if(!this.sourceElement)throw new w("editor-missing-sourceelement",this);const t=this.config.get("updateSourceElementOnDestroy"),n=this.sourceElement instanceof HTMLTextAreaElement;Ui(this.sourceElement,t||n?e:"")}}}wh.updateSourceElement=wh(Object).prototype.updateSourceElement;class kh extends Vo{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new vo({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new w("pendingactions-add-invalid-message",this);const t=new(H());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 _h='',vh='',yh={bold:'',cancel:_h,caption:'',check:vh,cog:'',eraser:'',image:'',lowVision:'',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:''};function xh({emitter:e,activator:t,callback:n,contextElements:i}){e.listenTo(document,"mousedown",((e,o)=>{if(!t())return;const r="function"==typeof o.composedPath?o.composedPath():[];for(const e of i)if(e.contains(o.target)||r.includes(e))return;n()}))}function Ah(e){const t=e;t.set("_isCssTransitionsDisabled",!1),t.disableCssTransitions=()=>{t._isCssTransitionsDisabled=!0},t.enableCssTransitions=()=>{t._isCssTransitionsDisabled=!1},t.extendTemplate({attributes:{class:[t.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}function Ch({view:e}){e.listenTo(e.element,"submit",((t,n)=>{n.preventDefault(),e.fire("submit")}),{useCapture:!0})}function Eh({keystrokeHandler:e,focusTracker:t,gridItems:n,numberOfColumns:i,uiLanguageDirection:o}){const r="number"==typeof i?()=>i:i;function s(e){return i=>{const o=n.find((e=>e.element===t.focusedElement)),r=n.getIndex(o),s=e(r,n);n.get(s).focus(),i.stopPropagation(),i.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"===o?c(e,t.length):a(e,t.length)))),e.set("arrowleft",s(((e,t)=>"rtl"===o?a(e,t.length):c(e,t.length)))),e.set("arrowup",s(((e,t)=>{let n=e-r();return n<0&&(n=e+r()*Math.floor(t.length/r()),n>t.length-1&&(n-=r())),n}))),e.set("arrowdown",s(((e,t)=>{let n=e+r();return n>t.length-1&&(n=e%r()),n})))}class Th extends Ou{constructor(e,t=[]){super(t),this.locale=e}attachToDom(){this._bodyCollectionContainer=new Ru({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=ge(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 Sh=n(3872),Ph={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Sh.Z,Ph);Sh.Z.locals;class Ih extends nh{constructor(){super();const e=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.set("isColorInherited",!0),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon","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:n}of Array.from(e.attributes))Ih.presentationalAttributeNames.includes(t)&&this.element.setAttribute(t,n);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}))}}Ih.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"];var Mh=n(9377),Oh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Mh.Z,Oh);Mh.Z.locals;class Rh extends nh{constructor(e){super(e);const t=this.bindTemplate,n=g();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("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._createLabelView(n),this.iconView=new Ih,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 i={tag:"button",attributes:{class:["ck","ck-button",t.to("class"),t.if("isEnabled","ck-disabled",(e=>!e)),t.if("isVisible","ck-hidden",(e=>!e)),t.to("isOn",(e=>e?"ck-on":"ck-off")),t.if("withText","ck-button_with-text"),t.if("withKeystroke","ck-button_with-keystroke")],type:t.to("type",(e=>e||"button")),tabindex:t.to("tabindex"),"aria-labelledby":`ck-editor__aria-label_${n}`,"aria-disabled":t.if("isEnabled",!0,(e=>!e)),"aria-pressed":t.to("isOn",(e=>!!this.isToggleable&&String(!!e))),"data-cke-tooltip-text":t.to("_tooltipString"),"data-cke-tooltip-position":t.to("tooltipPosition")},children:this.children,on:{click:t.to((e=>{this.isEnabled?this.fire("execute"):e.preventDefault()}))}};r.isSafari&&(i.on.mousedown=t.to((e=>{this.focus(),e.preventDefault()}))),this.setTemplate(i)}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()}_createLabelView(e){const t=new nh,n=this.bindTemplate;return t.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:n.to("labelStyle"),id:`ck-editor__aria-label_${e}`},children:[{text:this.bindTemplate.to("label")}]}),t}_createKeystrokeView(){const e=new nh;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",(e=>fo(e)))}]}),e}_getTooltipString(e,t,n){return e?"string"==typeof e?e:(n&&(n=fo(n)),e instanceof Function?e(t,n):`${t}${n?` (${n})`:""}`):""}}var Nh=n(9547),Dh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Nh.Z,Dh);Nh.Z.locals;class Lh extends Rh{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 nh;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}}function Vh(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 Bh extends Rh{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-table__color-tile_bordered")]}})}render(){super.render(),this.iconView.fillColor="hsl(0, 0%, 100%)"}}var jh=n(6601),zh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(jh.Z,zh);jh.Z.locals;class Fh extends nh{constructor(e,t){super(e);const n=t&&t.colorDefinitions||[];this.columns=t&&t.columns?t.columns:5;const i={gridTemplateColumns:`repeat( ${this.columns}, 1fr)`};this.set("selectedColor",void 0),this.items=this.createCollection(),this.focusTracker=new xo,this.keystrokes=new Ao,this.items.on("add",((e,t)=>{t.isOn=t.color===this.selectedColor})),n.forEach((e=>{const t=new Bh;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:i}}),this.on("change:selectedColor",((e,t,n)=>{for(const e of this.items)e.isOn=e.color===n}))}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),Eh({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()}}const Uh='';class Hh extends Rh{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 Ih;return e.content=Uh,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}}var Wh=n(8418),qh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Wh.Z,qh);Wh.Z.locals;class Zh extends nh{constructor(e){super(e);const t=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(),this.arrowView=this._createArrowView(),this.keystrokes=new Ao,this.focusTracker=new xo,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",t.to("class"),t.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(){const e=new Rh;return e.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),e.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),e.delegate("execute").to(this),e}_createArrowView(){const e=new Rh,t=e.bindTemplate;return e.icon=Uh,e.extendTemplate({attributes:{class:["ck-splitbutton__arrow"],"data-cke-tooltip-disabled":t.to("isOn"),"aria-haspopup":!0,"aria-expanded":t.to("isOn",(e=>String(e)))}}),e.bind("isEnabled").to(this),e.bind("label").to(this),e.bind("tooltip").to(this),e.delegate("execute").to(this,"open"),e}}class $h extends nh{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")]},children:this.children,on:{selectstart:t.to((e=>e.preventDefault()))}})}focus(){if(this.children.length){const e=this.children.first;"function"==typeof e.focus?e.focus():k("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 Kh=n(5457),Gh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Kh.Z,Gh);Kh.Z.locals;class Yh extends nh{constructor(e,t,n){super(e);const i=this.bindTemplate;this.buttonView=t,this.panelView=n,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class",void 0),this.set("id",void 0),this.set("panelPosition","auto"),this.keystrokes=new Ao,this.focusTracker=new xo,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",i.to("class"),i.if("isEnabled","ck-disabled",(e=>!e))],id:i.to("id"),"aria-describedby":i.to("ariaDescribedById")},children:[t,n]}),t.extendTemplate({attributes:{class:["ck-dropdown__button"],"data-cke-tooltip-disabled":i.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.panelView.bind("isVisible").to(this,"isOpen"),this.on("change:isOpen",((e,t,n)=>{n&&("auto"===this.panelPosition?this.panelView.position=Yh._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions}).name: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:n,southWest:i,northEast:o,northWest:r,southMiddleEast:s,southMiddleWest:a,northMiddleEast:c,northMiddleWest:l}=Yh.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[n,i,s,a,e,o,r,c,l,t]:[i,n,a,s,e,r,o,l,c,t]}}Yh.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"})},Yh._getOptimalPosition=Ki;class Qh{constructor(e){if(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 n=e.actions[t];"string"==typeof n&&(n=[n]);for(const i of n)e.keystrokeHandler.set(i,((e,n)=>{this[t](),n()}))}}get first(){return this.focusables.find(Jh)||null}get last(){return this.focusables.filter(Jh).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,n)=>{const i=t.element===this.focusTracker.focusedElement;return i&&(e=n),i})),e)}focusFirst(){this._focus(this.first)}focusLast(){this._focus(this.last)}focusNext(){this._focus(this.next)}focusPrevious(){this._focus(this.previous)}_focus(e){e&&e.focus()}_getFocusableItem(e){const t=this.current,n=this.focusables.length;if(!n)return null;if(null===t)return this[1===e?"first":"last"];let i=(t+n+e)%n;do{const t=this.focusables.get(i);if(Jh(t))return t;i=(i+n+e)%n}while(i!==t);return null}}function Jh(e){return!(!e.focus||!$i(e.element))}class Xh extends nh{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}class em extends nh{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}function tm(e){return Array.isArray(e)?{items:e,removeItems:[]}:e?Object.assign({items:[],removeItems:[]},e):{items:[],removeItems:[]}}var nm=n(7343),im={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(nm.Z,im);nm.Z.locals;const{threeVerticalDots:om}=yh,rm={alignLeft:yh.alignLeft,bold:yh.bold,importExport:yh.importExport,paragraph:yh.paragraph,plus:yh.plus,text:yh.text,threeVerticalDots:yh.threeVerticalDots};class sm extends nh{constructor(e,t){super(e);const n=this.bindTemplate,i=this.t;this.options=t||{},this.set("ariaLabel",i("Editor toolbar")),this.set("maxWidth","auto"),this.items=this.createCollection(),this.focusTracker=new xo,this.keystrokes=new Ao,this.set("class",void 0),this.set("isCompact",!1),this.itemsView=new am(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const o="rtl"===e.uiLanguageDirection;this._focusCycler=new Qh({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[o?"arrowright":"arrowleft","arrowup"],focusNext:[o?"arrowleft":"arrowright","arrowdown"]}});const r=["ck","ck-toolbar",n.to("class"),n.if("isCompact","ck-toolbar_compact")];var s;this.options.shouldGroupWhenFull&&this.options.isFloating&&r.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:r,role:"toolbar","aria-label":n.to("ariaLabel"),style:{maxWidth:n.to("maxWidth")}},children:this.children,on:{mousedown:(s=this,s.bindTemplate.to((e=>{e.target===s.element&&e.preventDefault()})))}}),this._behavior=this.options.shouldGroupWhenFull?new lm(this):new cm(this)}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),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,n){const i=tm(e),o=n||i.removeItems,r=this._cleanItemsConfiguration(i.items,t,o).map((e=>L(e)?this._createNestedToolbarDropdown(e,t,o):"|"===e?new Xh:"-"===e?new em:t.create(e))).filter((e=>!!e));this.items.addMany(r)}_cleanItemsConfiguration(e,t,n){const i=e.filter(((e,i,o)=>"|"===e||-1===n.indexOf(e)&&("-"===e?!this.options.shouldGroupWhenFull||(k("toolbarview-line-break-ignored-when-grouping-items",o),!1):!(!L(e)&&!t.has(e))||(k("toolbarview-item-unavailable",{item:e}),!1))));return this._cleanSeparatorsAndLineBreaks(i)}_cleanSeparatorsAndLineBreaks(e){const t=e=>"-"!==e&&"|"!==e,n=e.length,i=e.findIndex(t);if(-1===i)return[];const o=n-e.slice().reverse().findIndex(t);return e.slice(i,o).filter(((e,n,i)=>{if(t(e))return!0;return!(n>0&&i[n-1]===e)}))}_createNestedToolbarDropdown(e,t,n){let{label:i,icon:o,items:r,tooltip:s=!0,withText:a=!1}=e;if(r=this._cleanItemsConfiguration(r,t,n),!r.length)return null;const c=km(this.locale);return i||k("toolbarview-nested-toolbar-dropdown-missing-label",e),c.class="ck-toolbar__nested-toolbar-dropdown",c.buttonView.set({label:i,tooltip:s,withText:!!a}),!1!==o?c.buttonView.icon=rm[o]||o||om:c.buttonView.withText=!0,_m(c,[]),c.toolbarView.fillFromConfig(r,t,n),c}}class am extends nh{constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class cm{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 lm{constructor(e){this.view=e,this.viewChildren=e.children,this.viewFocusables=e.focusables,this.viewItemsView=e.itemsView,this.viewFocusTracker=e.focusTracker,this.viewLocale=e.locale,this.ungroupedItems=e.createCollection(),this.groupedItems=e.createCollection(),this.groupedItemsDropdown=this._createGroupedItemsDropdown(),this.resizeObserver=null,this.cachedPadding=null,this.shouldUpdateGroupingOnNextResize=!1,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 n=t.index,i=Array.from(t.added);for(const e of t.removed)n>=this.ungroupedItems.length?this.groupedItems.remove(e):this.ungroupedItems.remove(e);for(let e=n;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(!$i(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,n=new Vi(e.lastChild),i=new Vi(e);if(!this.cachedPadding){const n=Mi.window.getComputedStyle(e),i="ltr"===t?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(n[i])}return"ltr"===t?n.right>i.right-this.cachedPadding:n.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 Xh),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,n=km(e);return n.class="ck-toolbar__grouped-dropdown",n.panelPosition="ltr"===e.uiLanguageDirection?"sw":"se",_m(n,[]),n.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:"rtl"===e.uiLanguageDirection?"se":"sw",icon:om}),n.toolbarView.items.bindTo(this.groupedItems).using((e=>e)),n}_updateFocusCycleableItems(){this.viewFocusables.clear(),this.ungroupedItems.map((e=>{this.viewFocusables.add(e)})),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}var dm=n(9647),um={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(dm.Z,um);dm.Z.locals;class hm extends nh{constructor(e){super(e),this.items=this.createCollection(),this.focusTracker=new xo,this.keystrokes=new Ao,this._focusCycler=new Qh({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.setTemplate({tag:"ul",attributes:{class:["ck","ck-reset","ck-list"]},children:this.items})}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)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}class mm extends nh{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))]},children:this.children})}focus(){this.children.first.focus()}}class fm extends nh{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}var gm=n(3505),pm={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(gm.Z,pm);gm.Z.locals;var bm=n(6371),wm={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(bm.Z,wm);bm.Z.locals;function km(e,t=Hh){const n=new t(e),i=new $h(e),o=new Yh(e,n,i);return n.bind("isEnabled").to(o),n instanceof Zh?n.arrowView.bind("isOn").to(o,"isOpen"):n.bind("isOn").to(o,"isOpen"),function(e){(function(e){e.on("render",(()=>{xh({emitter:e,activator:()=>e.isOpen,callback:()=>{e.isOpen=!1},contextElements:[e.element]})}))})(e),function(e){e.on("execute",(t=>{t.source instanceof Lh||(e.isOpen=!1)}))}(e),function(e){e.focusTracker.on("change:isFocused",((t,n,i)=>{e.isOpen&&!i&&(e.isOpen=!1)}))}(e),function(e){e.keystrokes.set("arrowdown",((t,n)=>{e.isOpen&&(e.panelView.focus(),n())})),e.keystrokes.set("arrowup",((t,n)=>{e.isOpen&&(e.panelView.focusLast(),n())}))}(e),function(e){e.on("change:isOpen",((t,n,i)=>{i||e.panelView.element.contains(Mi.document.activeElement)&&e.buttonView.focus()}))}(e),function(e){e.on("change:isOpen",((t,n,i)=>{i&&e.panelView.focus()}),{priority:"low"})}(e)}(o),o}function _m(e,t,n={}){const i=e.locale,o=i.t,r=e.toolbarView=new sm(i);r.set("ariaLabel",o("Dropdown toolbar")),e.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),t.map((e=>r.items.add(e))),n.enableActiveItemFocusOnDropdownOpen&&ym(e,(()=>r.items.find((e=>e.isOn)))),e.panelView.children.add(r),r.items.delegate("execute").to(e)}function vm(e,t){const n=e.locale,i=e.listView=new hm(n);i.items.bindTo(t).using((e=>{if("separator"===e.type)return new fm(n);if("button"===e.type||"switchbutton"===e.type){const t=new mm(n);let i;return i="button"===e.type?new Rh(n):new Lh(n),i.bind(...Object.keys(e.model)).to(e.model),i.delegate("execute").to(t),t.children.add(i),t}return null})),e.panelView.children.add(i),i.items.delegate("execute").to(e),ym(e,(()=>i.items.find((e=>e instanceof mm&&e.children.first.isOn))))}function ym(e,t){e.on("change:isOpen",(()=>{if(!e.isOpen)return;const n=t();n&&("function"==typeof n.focus?n.focus():k("ui-dropdown-focus-child-on-open-child-missing-focus",{view:n}))}),{priority:p.low-10})}var xm=n(7456),Am={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(xm.Z,Am);xm.Z.locals;class Cm extends nh{constructor(e){super(e),this.body=new Th(e)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}var Em=n(3320),Tm={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Em.Z,Tm);Em.Z.locals;class Sm extends nh{constructor(e){super(e),this.set("text",void 0),this.set("for",void 0),this.id=`ck-editor__label_${g()}`;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")}]})}}class Pm extends Cm{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 Sm;return t.text=e("Rich Text Editor"),t.extendTemplate({attributes:{class:"ck-voice-label"}}),t}}class Im extends nh{constructor(e,t,n){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:e.contentLanguage,dir:e.contentLanguageDirection}}),this.name=null,this.set("isFocused",!1),this._editableElement=n,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()}_updateIsFocusedClasses(){const e=this._editingView;function t(t){e.change((n=>{const i=e.document.getRoot(t.name);n.addClass(t.isFocused?"ck-focused":"ck-blurred",i),n.removeClass(t.isFocused?"ck-blurred":"ck-focused",i)}))}e.isRenderingInProgress?function n(i){e.once("change:isRenderingInProgress",((e,o,r)=>{r?n(i):t(i)}))}(this):t(this)}}class Mm extends Im{constructor(e,t,n,i={}){super(e,t,n);const o=e.t;this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}}),this._generateLabel=i.label||(()=>o("Editor editing area: %0",this.name))}render(){super.render();const e=this._editingView;e.change((t=>{const n=e.document.getRoot(this.name);t.setAttribute("aria-label",this._generateLabel(this),n)}))}}var Om=n(7641),Rm={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Om.Z,Rm);Om.Z.locals;var Nm=n(7138),Dm={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Nm.Z,Dm);Nm.Z.locals;class Lm extends nh{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 xo,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0),this.set("inputMode","text");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"),inputmode:t.to("inputMode"),"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,n)=>{this._setDomElementValue(n),this._updateIsEmpty()}))}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}_updateIsEmpty(){this.isEmpty=!this.element.value}_setDomElementValue(e){this.element.value=e||0===e?e:""}}class Vm extends Lm{constructor(e){super(e),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}var Bm=n(7546),jm={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Bm.Z,jm);Bm.Z.locals;class zm extends nh{constructor(e,t){super(e);const n=`ck-labeled-field-view-${g()}`,i=`ck-labeled-field-view-status-${g()}`;this.fieldView=t(this,n,i),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(n),this.statusView=this._createStatusView(i),this.fieldWrapperChildren=this.createCollection([this.fieldView,this.labelView]),this.bind("_statusText").to(this,"errorText",this,"infoText",((e,t)=>e||t));const o=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",o.to("class"),o.if("isEnabled","ck-disabled",(e=>!e)),o.if("isEmpty","ck-labeled-field-view_empty"),o.if("isFocused","ck-labeled-field-view_focused"),o.if("placeholder","ck-labeled-field-view_placeholder"),o.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:this.fieldWrapperChildren},this.statusView]})}_createLabelView(e){const t=new Sm(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new nh(this.locale),n=this.bindTemplate;return t.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",n.if("errorText","ck-labeled-field-view__status_error"),n.if("_statusText","ck-hidden",(e=>!e))],id:e,role:n.if("errorText","alert")},children:[{text:n.to("_statusText")}]}),t}focus(){this.fieldView.focus()}}function Fm(e,t,n){const i=new Vm(e.locale);return i.set({id:t,ariaDescribedById:n}),i.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),i.bind("hasError").to(e,"errorText",(e=>!!e)),i.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(i),i}class Um extends Vo{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 Hm extends(H()){constructor(e,t){super(),t&&ma(this,t),e&&this.set(e)}}var Wm=n(395),qm={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Wm.Z,qm);Wm.Z.locals;var Zm=n(5078),$m={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Zm.Z,$m);Zm.Z.locals;const Km=Hi("px");class Gm extends Io{static get pluginName(){return"ContextualBalloon"}constructor(e){super(e),this.positionLimiter=()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},this.set("visibleView",null),this.view=new ah(e.locale),e.ui.view.body.add(this.view),e.ui.focusTracker.add(this.view.element),this._viewToStack=new Map,this._idToStack=new Map,this.set("_numberOfStacks",0),this.set("_singleViewMode",!1),this._rotatorView=this._createRotatorView(),this._fakePanelsView=this._createFakePanelsView()}destroy(){super.destroy(),this.view.destroy(),this._rotatorView.destroy(),this._fakePanelsView.destroy()}hasView(e){return Array.from(this._viewToStack.keys()).includes(e)}add(e){if(this.hasView(e.view))throw new w("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 n=this._idToStack.get(t);e.singleViewMode&&this.showStack(t),n.set(e.view,e),this._viewToStack.set(e.view,n),n===this._visibleStack&&this._showView(e)}remove(e){if(!this.hasView(e))throw new w("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 w("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}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 Ym(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,n)=>{if(n<2)return"";const i=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[i,n])})),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 Qm(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:n=!0,singleViewMode:i=!1}){this.view.class=t,this.view.withArrow=n,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),i&&(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 Ym extends nh{constructor(e){super(e);const t=e.t,n=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new xo,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",n.to("isNavigationVisible",(e=>e?"":"ck-hidden"))]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:n.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 n=new Rh(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n}}class Qm extends nh{constructor(e,t){super(e);const n=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",n.to("numberOfPanels",(e=>e?"":"ck-hidden"))],style:{top:n.to("top",Km),left:n.to("left",Km),width:n.to("width",Km),height:n.to("height",Km)}},children:this.content}),this.on("change:numberOfPanels",((e,t,n,i)=>{n>i?this._addPanels(n-i):this._removePanels(i-n),this.updatePosition()}))}_addPanels(e){for(;e--;){const e=new nh;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:n,height:i}=new Vi(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:n,height:i})}}}var Jm=n(3846),Xm={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Jm.Z,Xm);Jm.Z.locals;const ef=Hi("px");class tf extends nh{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("_isStickyToTheLimiter",!1),this.set("_hasViewportTopOffset",!1),this.content=this.createCollection(),this._contentPanelPlaceholder=new Ru({tag:"div",attributes:{class:["ck","ck-sticky-panel__placeholder"],style:{display:t.to("isSticky",(e=>e?"block":"none")),height:t.to("isSticky",(e=>e?ef(this._panelRect.height):null))}}}).render(),this._contentPanel=new Ru({tag:"div",attributes:{class:["ck","ck-sticky-panel__content",t.if("isSticky","ck-sticky-panel__content_sticky"),t.if("_isStickyToTheLimiter","ck-sticky-panel__content_sticky_bottom-limit")],style:{width:t.to("isSticky",(e=>e?ef(this._contentPanelPlaceholder.getBoundingClientRect().width):null)),top:t.to("_hasViewportTopOffset",(e=>e?ef(this.viewportTopOffset):null)),bottom:t.to("_isStickyToTheLimiter",(e=>e?ef(this.limiterBottomOffset):null)),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(Mi.window,"scroll",(()=>{this._checkIfShouldBeSticky()})),this.listenTo(this,"change:isActive",(()=>{this._checkIfShouldBeSticky()}))}_checkIfShouldBeSticky(){const e=this._panelRect=this._contentPanel.getBoundingClientRect();let t;this.limiterElement?(t=this._limiterRect=this.limiterElement.getBoundingClientRect(),this.isSticky=this.isActive&&t.tope)),e.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(e.toolbar)}_initPlaceholder(){const e=this.editor,t=e.editing.view,n=t.document.getRoot(),i=e.sourceElement,o=e.config.get("placeholder")||i&&"textarea"===i.tagName.toLowerCase()&&i.getAttribute("placeholder");o&&Ho({view:t,element:n,text:o,isDirectHost:!1,keepOnFocus:!0})}}var af=n(4090),cf={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(af.Z,cf);af.Z.locals;class lf extends Pm{constructor(e,t,n={}){super(e),this.stickyPanel=new tf(e),this.toolbar=new sm(e,{shouldGroupWhenFull:n.shouldToolbarGroupWhenFull}),this.editable=new Mm(e,t)}render(){super.render(),this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}class df extends Pu{constructor(e,t={}){if(!_i(e)&&void 0!==t.initialData)throw new w("editor-create-initial-data",null);super(t),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return _i(e)?(t=e,t instanceof HTMLTextAreaElement?t.value:t.innerHTML):e;var t}(e)),_i(e)&&(this.sourceElement=e),this.model.document.createRoot();const n=!this.config.get("toolbar.shouldNotGroupWhenFull"),i=new lf(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:n});this.ui=new sf(this,i),function(e){if(!Be(e.updateSourceElement))throw new w("attachtoform-missing-elementapi-interface",e);const t=e.sourceElement;if(function(e){return!!e&&"textarea"===e.tagName.toLowerCase()}(t)&&t.form){let n;const i=t.form,o=()=>e.updateSourceElement();Be(i.submit)&&(n=i.submit,i.submit=()=>{o(),n.apply(i)}),i.addEventListener("submit",o),e.on("destroy",(()=>{i.removeEventListener("submit",o),n&&(i.submit=n)}))}}(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise((n=>{const i=new this(e,t);n(i.initPlugins().then((()=>i.ui.init(_i(e)?e:null))).then((()=>i.data.init(i.config.get("initialData")))).then((()=>i.fire("ready"))).then((()=>i)))}))}}u(df,bh),u(df,wh);class uf{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 hf extends Oo{constructor(e,t){super(e),this._buffer=new uf(e.model,t)}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,n=t.document,i=e.text||"",o=i.length;let r=n.selection;e.selection?r=e.selection:e.range&&(r=t.createSelection(e.range));const s=e.resultRange;t.enqueueChange(this._buffer.batch,(e=>{this._buffer.lock(),t.deleteContent(r),i&&t.insertContent(e.createText(i,n.selection.getAttributes()),r),s?e.setSelection(s):r.is("documentSelection")||e.setSelection(r),this._buffer.unlock(),this._buffer.input(o)}))}}const mf=["insertText","insertReplacementText"];class ff extends ha{constructor(e){super(e),r.isAndroid&&mf.push("insertCompositionText");const t=e.document;t.on("beforeinput",((n,i)=>{if(!this.isEnabled)return;const{data:o,targetRanges:r,inputType:s,domEvent:a}=i;if(!mf.includes(s))return;const c=new m(t,"insertText");t.fire(c,new fa(e,a,{text:o,selection:e.createSelection(r)})),c.stop.called&&n.stop()})),t.on("compositionend",((n,{data:i,domEvent:o})=>{this.isEnabled&&!r.isAndroid&&i&&t.fire("insertText",new fa(e,o,{text:i,selection:t.selection}))}),{priority:"lowest"})}observe(){}}class gf extends Io{static get pluginName(){return"Input"}init(){const e=this.editor,t=e.model,n=e.editing.view,i=t.document.selection;n.addObserver(ff);const o=new hf(e,e.config.get("typing.undoStep")||20);e.commands.add("insertText",o),e.commands.add("input",o),this.listenTo(n.document,"insertText",((i,o)=>{n.document.isComposing||o.preventDefault();const{text:s,selection:a,resultRange:c}=o,l=Array.from(a.getRanges()).map((t=>e.editing.mapper.toModelRange(t)));let d=s;if(r.isAndroid){const e=Array.from(l[0].getItems()).reduce(((e,t)=>e+(t.is("$textProxy")?t.data:"")),"");e&&(e.length<=d.length?d.startsWith(e)&&(d=d.substring(e.length),l[0].start=l[0].start.getShiftedBy(e.length)):e.startsWith(d)&&(l[0].start=l[0].start.getShiftedBy(d.length),d=""))}const u={text:d,selection:t.createSelection(l)};c&&(u.resultRange=e.editing.mapper.toModelRange(c)),e.execute("insertText",u)})),r.isAndroid?this.listenTo(n.document,"keydown",((e,r)=>{!i.isCollapsed&&229==r.keyCode&&n.document.isComposing&&pf(t,o)})):this.listenTo(n.document,"compositionstart",(()=>{i.isCollapsed||pf(t,o)}))}}function pf(e,t){if(!t.isEnabled)return;const n=t.buffer;n.lock(),e.enqueueChange(n.batch,(()=>{e.deleteContent(e.document.selection)})),n.unlock()}class bf extends Oo{constructor(e,t){super(e),this.direction=t,this._buffer=new uf(e.model,e.config.get("typing.undoStep"))}get buffer(){return this._buffer}execute(e={}){const t=this.editor.model,n=t.document;t.enqueueChange(this._buffer.batch,(i=>{this._buffer.lock();const o=i.createSelection(e.selection||n.selection),r=e.sequence||1,s=o.isCollapsed;if(o.isCollapsed&&t.modifySelection(o,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(r))return void this._replaceEntireContentWithParagraph(i);if(this._shouldReplaceFirstBlockWithParagraph(o,r))return void this.editor.execute("paragraph",{selection:o});if(o.isCollapsed)return;let a=0;o.getFirstRange().getMinimalFlatRanges().forEach((e=>{a+=Y(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),t.deleteContent(o,{doNotResetEntireContent:s,direction:this.direction}),this._buffer.input(a),i.setSelection(o),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,n=t.document.selection,i=t.schema.getLimitElement(n);if(!(n.isCollapsed&&n.containsEntireContent(i)))return!1;if(!t.schema.checkChild(i,"paragraph"))return!1;const o=i.getChild(0);return!o||!o.is("element","paragraph")}_replaceEntireContentWithParagraph(e){const t=this.editor.model,n=t.document.selection,i=t.schema.getLimitElement(n),o=e.createElement("paragraph");e.remove(e.createRangeIn(i)),e.insert(o,i),e.setSelection(o,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const n=this.editor.model;if(t>1||"backward"!=this.direction)return!1;if(!e.isCollapsed)return!1;const i=e.getFirstPosition(),o=n.schema.getLimitElement(i),r=o.getChild(0);return i.parent==r&&(!!e.containsEntireContent(r)&&(!!n.schema.checkChild(o,"paragraph")&&"paragraph"!=r.name))}}const wf="word",kf="selection",_f="backward",vf="forward",yf={deleteContent:{unit:kf,direction:_f},deleteContentBackward:{unit:"codePoint",direction:_f},deleteWordBackward:{unit:wf,direction:_f},deleteHardLineBackward:{unit:kf,direction:_f},deleteSoftLineBackward:{unit:kf,direction:_f},deleteContentForward:{unit:"character",direction:vf},deleteWordForward:{unit:wf,direction:vf},deleteHardLineForward:{unit:kf,direction:vf},deleteSoftLineForward:{unit:kf,direction:vf}};class xf extends ha{constructor(e){super(e);const t=e.document;let n=0;t.on("keydown",(()=>{n++})),t.on("keyup",(()=>{n=0})),t.on("beforeinput",((i,o)=>{if(!this.isEnabled)return;const{targetRanges:s,domEvent:a,inputType:c}=o,l=yf[c];if(!l)return;const d={direction:l.direction,unit:l.unit,sequence:n};d.unit==kf&&(d.selectionToRemove=e.createSelection(s[0])),r.isAndroid&&"deleteContentBackward"===c&&(d.sequence=1,1!=s.length||s[0].start.parent==s[0].end.parent&&s[0].start.offset+1==s[0].end.offset||(d.unit=kf,d.selectionToRemove=e.createSelection(s)));const u=new us(t,"delete",s[0]);t.fire(u,new fa(e,a,d)),u.stop.called&&i.stop()})),r.isBlink&&function(e){const t=e.view,n=t.document;let i=null,o=!1;function r(e){return e==lo.backspace||e==lo.delete}function s(e){return e==lo.backspace?_f:vf}n.on("keydown",((e,{keyCode:t})=>{i=t,o=!1})),n.on("keyup",((a,{keyCode:c,domEvent:l})=>{const d=n.selection,u=e.isEnabled&&c==i&&r(c)&&!d.isCollapsed&&!o;if(i=null,u){const e=d.getFirstRange(),i=new us(n,"delete",e),o={unit:kf,direction:s(c),selectionToRemove:d};n.fire(i,new fa(t,l,o))}})),n.on("beforeinput",((e,{inputType:t})=>{const n=yf[t];r(i)&&n&&n.direction==s(i)&&(o=!0)}),{priority:"high"}),n.on("beforeinput",((e,{inputType:t,data:n})=>{i==lo.delete&&"insertText"==t&&""==n&&e.stop()}),{priority:"high"})}(this)}observe(){}}class Af extends Io{static get pluginName(){return"Delete"}init(){const e=this.editor,t=e.editing.view,n=t.document,i=e.model.document;t.addObserver(xf),this._undoOnBackspace=!1;const o=new bf(e,"forward");e.commands.add("deleteForward",o),e.commands.add("forwardDelete",o),e.commands.add("delete",new bf(e,"backward")),this.listenTo(n,"delete",((i,o)=>{n.isComposing||o.preventDefault();const{direction:r,sequence:s,selectionToRemove:a,unit:c}=o,l="forward"===r?"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(n,"delete",((t,n)=>{this._undoOnBackspace&&"backward"==n.direction&&1==n.sequence&&"codePoint"==n.unit&&(this._undoOnBackspace=!1,e.execute("undo"),n.preventDefault(),t.stop())}),{context:"$capture"}),this.listenTo(i,"change",(()=>{this._undoOnBackspace=!1})))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class Cf extends Io{static get requires(){return[gf,Af]}static get pluginName(){return"Typing"}}function Ef(e,t){let n=e.start;return{text:Array.from(e.getItems()).reduce(((e,i)=>i.is("$text")||i.is("$textProxy")?e+i.data:(n=t.createPositionAfter(i),"")),""),range:t.createRange(n,e.end)}}class Tf extends(H()){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:n})=>{n&&(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 n=this.model,i=n.document.selection,o=n.createRange(n.createPositionAt(i.focus.parent,0),i.focus),{text:r,range:s}=Ef(o,n),a=this.testCallback(r);if(!a&&this.hasMatch&&this.fire("unmatched"),this._hasMatch=!!a,a){const n=Object.assign(t,{text:r,range:s});"object"==typeof a&&Object.assign(n,a),this.fire(`matched:${e}`,n)}}}class Sf extends Io{static get pluginName(){return"TwoStepCaretMovement"}constructor(e){super(e),this.attributes=new Set,this._overrideUid=null}init(){const e=this.editor,t=e.model,n=e.editing.view,i=e.locale,o=t.document.selection;this.listenTo(n.document,"arrowKey",((e,t)=>{if(!o.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const n=t.keyCode==lo.arrowright,r=t.keyCode==lo.arrowleft;if(!n&&!r)return;const s=i.contentLanguageDirection;let a=!1;a="ltr"===s&&n||"rtl"===s&&r?this._handleForwardMovement(t):this._handleBackwardMovement(t),!0===a&&e.stop()}),{context:"$text",priority:"highest"}),this._isNextGravityRestorationSkipped=!1,this.listenTo(o,"change:range",((e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&Of(o.getFirstPosition(),this.attributes)||this._restoreGravity())}))}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,n=this.editor.model.document.selection,i=n.getFirstPosition();return!this._isGravityOverridden&&((!i.isAtStart||!Pf(n,t))&&(!!Of(i,t)&&(Mf(e),this._overrideGravity(),!0)))}_handleBackwardMovement(e){const t=this.attributes,n=this.editor.model,i=n.document.selection,o=i.getFirstPosition();return this._isGravityOverridden?(Mf(e),this._restoreGravity(),If(n,t,o),!0):o.isAtStart?!!Pf(i,t)&&(Mf(e),If(n,t,o),!0):!!function(e,t){return Of(e.getShiftedBy(-1),t)}(o,t)&&(o.isAtEnd&&!Pf(i,t)&&Of(o,t)?(Mf(e),If(n,t,o),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1))}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 Pf(e,t){for(const n of t)if(e.hasAttribute(n))return!0;return!1}function If(e,t,n){const i=n.nodeBefore;e.change((e=>{i?e.setSelectionAttribute(i.getAttributes()):e.removeSelectionAttribute(t)}))}function Mf(e){e.preventDefault()}function Of(e,t){const{nodeBefore:n,nodeAfter:i}=e;for(const e of t){const t=n?n.getAttribute(e):void 0;if((i?i.getAttribute(e):void 0)!==t)return!0}return!1}Rf('"'),Rf("'"),Rf("'"),Rf('"'),Rf('"'),Rf("'");function Rf(e){return new RegExp(`(^|\\s)(${e})([^${e}]*)(${e})$`)}function Nf(e,t,n,i){return i.createRange(Df(e,t,n,!0,i),Df(e,t,n,!1,i))}function Df(e,t,n,i,o){let r=e.textNode||(i?e.nodeBefore:e.nodeAfter),s=null;for(;r&&r.getAttribute(t)==n;)s=r,r=i?r.previousSibling:r.nextSibling;return s?o.createPositionAt(s,i?"before":"after"):e}function Lf(e,t,n,i){const o=e.editing.view,r=new Set;o.document.registerPostFixer((o=>{const s=e.model.document.selection;let a=!1;if(s.hasAttribute(t)){const c=Nf(s.getFirstPosition(),t,s.getAttribute(t),e.model),l=e.editing.mapper.toViewRange(c);for(const e of l.getItems())e.is("element",n)&&!e.hasClass(i)&&(o.addClass(i,e),r.add(e),a=!0)}return a})),e.conversion.for("editingDowncast").add((e=>{function t(){o.change((e=>{for(const t of r.values())e.removeClass(i,t),r.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*Vf(e,t){for(const n of t)n&&e.getAttributeProperties(n[0]).copyOnEnter&&(yield n)}class Bf extends Oo{execute(){this.editor.model.change((e=>{this.enterBlock(e),this.fire("afterExecute",{writer:e})}))}enterBlock(e){const t=this.editor.model,n=t.document.selection,i=t.schema,o=n.isCollapsed,r=n.getFirstRange(),s=r.start.parent,a=r.end.parent;if(i.isLimit(s)||i.isLimit(a))return o||s!=a||t.deleteContent(n),!1;if(o){const t=Vf(e.model.schema,n.getAttributes());return jf(e,r.start),e.setSelectionAttribute(t),!0}{const i=!(r.start.isAtStart&&r.end.isAtEnd),o=s==a;if(t.deleteContent(n,{leaveUnmerged:i}),i){if(o)return jf(e,n.focus),!0;e.setSelection(a,0)}}return!1}}function jf(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}const zf={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class Ff extends ha{constructor(e){super(e);const t=this.document;t.on("beforeinput",((n,i)=>{if(!this.isEnabled)return;const o=i.domEvent,r=zf[i.inputType];if(!r)return;const s=new us(t,"enter",i.targetRanges[0]);t.fire(s,new fa(e,o,{isSoft:r.isSoft})),s.stop.called&&n.stop()}))}observe(){}}class Uf extends Io{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,n=t.document;t.addObserver(Ff),e.commands.add("enter",new Bf(e)),this.listenTo(n,"enter",((i,o)=>{n.isComposing||o.preventDefault(),o.isSoft||(e.execute("enter"),t.scrollToTheSelection())}),{priority:"low"})}}class Hf extends Oo{execute(){const e=this.editor.model,t=e.document;e.change((n=>{!function(e,t,n){const i=n.isCollapsed,o=n.getFirstRange(),r=o.start.parent,s=o.end.parent,a=r==s;if(i){const i=Vf(e.schema,n.getAttributes());Wf(e,t,o.end),t.removeSelectionAttribute(n.getAttributeKeys()),t.setSelectionAttribute(i)}else{const i=!(o.start.isAtStart&&o.end.isAtEnd);e.deleteContent(n,{leaveUnmerged:i}),a?Wf(e,t,n.focus):i&&t.setSelection(s,0)}}(e,n,t.selection),this.fire("afterExecute",{writer:n})}))}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=function(e,t){if(t.rangeCount>1)return!1;const n=t.anchor;if(!n||!e.checkChild(n,"softBreak"))return!1;const i=t.getFirstRange(),o=i.start.parent,r=i.end.parent;if((qf(o,e)||qf(r,e))&&o!==r)return!1;return!0}(e.schema,t.selection)}}function Wf(e,t,n){const i=t.createElement("softBreak");e.insertContent(i,n),t.setSelection(i,"after")}function qf(e,t){return!e.is("rootElement")&&(t.isLimit(e)||qf(e.parent,t))}class Zf extends Io{static get pluginName(){return"ShiftEnter"}init(){const e=this.editor,t=e.model.schema,n=e.conversion,i=e.editing.view,o=i.document;t.register("softBreak",{allowWhere:"$text",isInline:!0}),n.for("upcast").elementToElement({model:"softBreak",view:"br"}),n.for("downcast").elementToElement({model:"softBreak",view:(e,{writer:t})=>t.createEmptyElement("br")}),i.addObserver(Ff),e.commands.add("shiftEnter",new Hf(e)),this.listenTo(o,"enter",((t,n)=>{o.isComposing||n.preventDefault(),n.isSoft&&(e.execute("shiftEnter"),i.scrollToTheSelection())}),{priority:"low"})}}class $f extends(S()){constructor(){super(),this._stack=[]}add(e,t){const n=this._stack,i=n[0];this._insertDescriptor(e);const o=n[0];i===o||Kf(i,o)||this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:t})}remove(e,t){const n=this._stack,i=n[0];this._removeDescriptor(e);const o=n[0];i===o||Kf(i,o)||this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:t})}_insertDescriptor(e){const t=this._stack,n=t.findIndex((t=>t.id===e.id));if(Kf(e,t[n]))return;n>-1&&t.splice(n,1);let i=0;for(;t[i]&&Gf(t[i],e);)i++;t.splice(i,0,e)}_removeDescriptor(e){const t=this._stack,n=t.findIndex((t=>t.id===e));n>-1&&t.splice(n,1)}}function Kf(e,t){return e&&t&&e.priority==t.priority&&Yf(e.classes)==Yf(t.classes)}function Gf(e,t){return e.priority>t.priority||!(e.priorityYf(t.classes)}function Yf(e){return Array.isArray(e)?e.sort().join(","):e}const Qf='',Jf="ck-widget_selected";function Xf(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function eg(e,t,n={}){if(!e.is("containerElement"))throw new w("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=sg,t.setCustomProperty("widgetLabel",[],e),n.label&&function(e,t){e.getCustomProperty("widgetLabel").push(t)}(e,n.label),n.hasSelectionHandle&&function(e,t){const n=t.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(e){const t=this.toDomElement(e),n=new Ih;return n.set("content",Qf),n.render(),t.appendChild(n.element),t}));t.insert(t.createPositionAt(e,0),n),t.addClass(["ck-widget_with-selection-handle"],e)}(e,t),ig(e,t),e}function tg(e,t,n){if(t.classes&&n.addClass(wo(t.classes),e),t.attributes)for(const i in t.attributes)n.setAttribute(i,t.attributes[i],e)}function ng(e,t,n){if(t.classes&&n.removeClass(wo(t.classes),e),t.attributes)for(const i in t.attributes)n.removeAttribute(i,e)}function ig(e,t,n=tg,i=ng){const o=new $f;o.on("change:top",((t,o)=>{o.oldDescriptor&&i(e,o.oldDescriptor,o.writer),o.newDescriptor&&n(e,o.newDescriptor,o.writer)}));t.setCustomProperty("addHighlight",((e,t,n)=>o.add(t,n)),e),t.setCustomProperty("removeHighlight",((e,t,n)=>o.remove(t,n)),e)}function og(e,t,n={}){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),t.setAttribute("role","textbox",e),n.label&&t.setAttribute("aria-label",n.label,e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",((n,i,o)=>{t.setAttribute("contenteditable",o?"false":"true",e)})),e.on("change:isFocused",((n,i,o)=>{o?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)})),ig(e,t),e}function rg(e,t){const n=e.getSelectedElement();if(n){const i=lg(e);if(i)return t.createRange(t.createPositionAt(n,i))}return Gd(e,t)}function sg(){return null}const ag="widget-type-around";function cg(e,t,n){return!!e&&Xf(e)&&!n.isInline(t)}function lg(e){return e.getAttribute(ag)}var dg=n(5485),ug={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(dg.Z,ug);dg.Z.locals;const hg=["before","after"],mg=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,fg="ck-widget__type-around_disabled";class gg extends Io{static get pluginName(){return"WidgetTypeAround"}static get requires(){return[Uf,Af]}constructor(e){super(e),this._currentFakeCaretModelElement=null}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",((n,i,o)=>{t.change((e=>{for(const n of t.document.roots)o?e.removeClass(fg,n):e.addClass(fg,n)})),o||e.model.change((e=>{e.removeSelectionAttribute(ag)}))})),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 n=this.editor,i=n.editing.view,o=n.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);n.execute("insertParagraph",{position:n.model.createPositionAt(e,t),attributes:o}),i.focus(),i.scrollToTheSelection()}_listenToIfEnabled(e,t,n,i){this.listenTo(e,t,((...e)=>{this.isEnabled&&n(...e)}),i)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=lg(e);if(!t)return!1;const n=e.getSelectedElement();return this._insertParagraph(n,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,n=e.locale.t,i={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",((e,o,r)=>{const s=r.mapper.toViewElement(o.item);if(s&&cg(s,o.item,t)){!function(e,t,n){const i=e.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(e){const n=this.toDomElement(e);return function(e,t){for(const n of hg){const i=new Ru({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${n}`],title:t[n],"aria-hidden":"true"},children:[e.ownerDocument.importNode(mg,!0)]});e.appendChild(i.render())}}(n,t),function(e){const t=new Ru({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(n),n}));e.insert(e.createPositionAt(n,"end"),i)}(r.writer,i,s);s.getCustomProperty("widgetLabel").push((()=>this.isEnabled?n("Press Enter to type after or press Shift + Enter to type before the widget"):""))}}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,n=t.document.selection,i=t.schema,o=e.editing.view;function r(e){return`ck-widget_type-around_show-fake-caret_${e}`}this._listenToIfEnabled(o.document,"arrowKey",((e,t)=>{this._handleArrowKeyPress(e,t)}),{context:[Xf,"$text"],priority:"high"}),this._listenToIfEnabled(n,"change:range",((t,n)=>{n.directChange&&e.model.change((e=>{e.removeSelectionAttribute(ag)}))})),this._listenToIfEnabled(t.document,"change:data",(()=>{const t=n.getSelectedElement();if(t){if(cg(e.editing.mapper.toViewElement(t),t,i))return}e.model.change((e=>{e.removeSelectionAttribute(ag)}))})),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",((e,t,n)=>{const o=n.writer;if(this._currentFakeCaretModelElement){const e=n.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(o.removeClass(hg.map(r),e),this._currentFakeCaretModelElement=null)}const s=t.selection.getSelectedElement();if(!s)return;const a=n.mapper.toViewElement(s);if(!cg(a,s,i))return;const c=lg(t.selection);c&&(o.addClass(r(c),a),this._currentFakeCaretModelElement=s)})),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",((t,n,i)=>{i||e.model.change((e=>{e.removeSelectionAttribute(ag)}))}))}_handleArrowKeyPress(e,t){const n=this.editor,i=n.model,o=i.document.selection,r=i.schema,s=n.editing.view,a=function(e,t){const n=go(e,t);return"down"===n||"right"===n}(t.keyCode,n.locale.contentLanguageDirection),c=s.document.selection.getSelectedElement();let l;cg(c,n.editing.mapper.toModelElement(c),r)?l=this._handleArrowKeyPressOnSelectedWidget(a):o.isCollapsed?l=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):t.shiftKey||(l=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),l&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,n=lg(t.document.selection);return t.change((t=>{if(!n)return t.setSelectionAttribute(ag,e?"after":"before"),!0;if(!(n===(e?"after":"before")))return t.removeSelectionAttribute(ag),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,n=t.model,i=n.schema,o=t.plugins.get("Widget"),r=o._getObjectElementNextToSelection(e);return!!cg(t.editing.mapper.toViewElement(r),r,i)&&(n.change((t=>{o._setSelectionOverElement(r),t.setSelectionAttribute(ag,e?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,n=t.model,i=n.schema,o=t.editing.mapper,r=n.document.selection,s=e?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter;return!!cg(o.toViewElement(s),s,i)&&(n.change((t=>{t.setSelection(s,"on"),t.setSelectionAttribute(ag,e?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",((n,i)=>{const o=i.domTarget.closest(".ck-widget__type-around__button");if(!o)return;const r=function(e){return e.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(o),s=function(e,t){const n=e.closest(".ck-widget");return t.mapDomToView(n)}(o,t.domConverter),a=e.editing.mapper.toModelElement(s);this._insertParagraph(a,r),i.preventDefault(),n.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,n=e.editing.view;this._listenToIfEnabled(n.document,"enter",((n,i)=>{if("atTarget"!=n.eventPhase)return;const o=t.getSelectedElement(),r=e.editing.mapper.toViewElement(o),s=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:cg(r,o,s)&&(this._insertParagraph(o,i.isSoft?"before":"after"),a=!0),a&&(i.preventDefault(),n.stop())}),{context:Xf})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view.document;this._listenToIfEnabled(e,"insertText",((t,n)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(n.selection=e.selection)}),{priority:"high"}),r.isAndroid?this._listenToIfEnabled(e,"keydown",((e,t)=>{229==t.keyCode&&this._insertParagraphAccordingToFakeCaretPosition()})):this._listenToIfEnabled(e,"compositionstart",(()=>{this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,n=e.model,i=n.schema;this._listenToIfEnabled(t.document,"delete",((t,o)=>{if("atTarget"!=t.eventPhase)return;const r=lg(n.document.selection);if(!r)return;const s=o.direction,a=n.document.selection.getSelectedElement(),c="forward"==s;if("before"===r===c)e.execute("delete",{selection:n.createSelection(a,"on")});else{const t=i.getNearestSelectionRange(n.createPositionAt(a,r),s);if(t)if(t.isCollapsed){const o=n.createSelection(t.start);if(n.modifySelection(o,{direction:s}),o.focus.isEqual(t.start)){const e=function(e,t){let n=t;for(const i of t.getAncestors({parentFirst:!0})){if(i.childCount>1||e.isLimit(i))break;n=i}return n}(i,t.start.parent);n.deleteContent(n.createSelection(e,"on"),{doNotAutoparagraph:!0})}else n.change((n=>{n.setSelection(t),e.execute(c?"deleteForward":"delete")}))}else n.change((n=>{n.setSelection(t),e.execute(c?"deleteForward":"delete")}))}o.preventDefault(),t.stop()}),{context:Xf})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,n=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",((e,[i,o])=>{if(o&&!o.is("documentSelection"))return;const r=lg(n);return r?(e.stop(),t.change((e=>{const o=n.getSelectedElement(),s=t.createPositionAt(o,r),a=e.createSelection(s),c=t.insertContent(i,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,n)=>{const[,i,,o={}]=n;if(i&&!i.is("documentSelection"))return;const r=lg(t);r&&(o.findOptimalPosition=r,n[3]=o)}),{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",((e,[n])=>{if(n&&!n.is("documentSelection"))return;lg(t)&&e.stop()}),{priority:"high"})}}function pg(e){const t=e.model;return(n,i)=>{const o=i.keyCode==lo.arrowup,r=i.keyCode==lo.arrowdown,s=i.shiftKey,a=t.document.selection;if(!o&&!r)return;const c=r;if(s&&function(e,t){return!e.isCollapsed&&e.isBackward==t}(a,c))return;const l=function(e,t,n){const i=e.model;if(n){const e=t.isCollapsed?t.focus:t.getLastPosition(),n=bg(i,e,"forward");if(!n)return null;const o=i.createRange(e,n),r=wg(i.schema,o,"backward");return r?i.createRange(e,r):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),n=bg(i,e,"backward");if(!n)return null;const o=i.createRange(n,e),r=wg(i.schema,o,"forward");return r?i.createRange(r,e):null}}(e,a,c);if(l){if(l.isCollapsed){if(a.isCollapsed)return;if(s)return}(l.isCollapsed||function(e,t,n){const i=e.model,o=e.view.domConverter;if(n){const e=i.createSelection(t.start);i.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=i.createRange(e.focus,t.end))}const r=e.mapper.toViewRange(t),s=o.viewRangeToDom(r),a=Vi.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 n=c?l.end:l.start;if(s){const i=t.createSelection(a.anchor);i.setFocus(n),e.setSelection(i)}else e.setSelection(n)})),n.stop(),i.preventDefault(),i.stopPropagation())}}}function bg(e,t,n){const i=e.schema,o=e.createRangeIn(t.root),r="forward"==n?"elementStart":"elementEnd";for(const{previousPosition:e,item:s,type:a}of o.getWalker({startPosition:t,direction:n})){if(i.isLimit(s)&&!i.isInline(s))return e;if(a==r&&i.isBlock(s))return null}return null}function wg(e,t,n){const i="backward"==n?t.end:t.start;if(e.checkChild(i,"$text"))return i;for(const{nextPosition:i}of t.getWalker({direction:n}))if(e.checkChild(i,"$text"))return i;return null}var kg=n(1014),_g={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(kg.Z,_g);kg.Z.locals;class vg extends Io{static get pluginName(){return"Widget"}static get requires(){return[gg,Af]}init(){const e=this.editor,t=e.editing.view,n=t.document;this._previouslySelected=new Set,this.editor.editing.downcastDispatcher.on("selection",((t,n,i)=>{const o=i.writer,r=n.selection;if(r.isCollapsed)return;const s=r.getSelectedElement();if(!s)return;const a=e.editing.mapper.toViewElement(s);var c;Xf(a)&&(i.consumable.consume(r,"selection")&&o.setSelection(o.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,n)=>{this._clearPreviouslySelectedWidgets(n.writer);const i=n.writer,o=i.document.selection;let r=null;for(const e of o.getRanges())for(const t of e){const e=t.item;Xf(e)&&!yg(e,r)&&(i.addClass(Jf,e),this._previouslySelected.add(e),r=e)}}),{priority:"low"}),t.addObserver(iu),this.listenTo(n,"mousedown",((...e)=>this._onMousedown(...e))),this.listenTo(n,"arrowKey",((...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)}),{context:[Xf,"$text"]}),this.listenTo(n,"arrowKey",((...e)=>{this._preventDefaultOnArrowKeyPress(...e)}),{context:"$root"}),this.listenTo(n,"arrowKey",pg(this.editor.editing),{context:"$text"}),this.listenTo(n,"delete",((e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())}),{context:"$root"})}_onMousedown(e,t){const n=this.editor,i=n.editing.view,o=i.document;let s=t.target;if(function(e){let t=e;for(;t;){if(t.is("editableElement")&&!t.is("rootElement"))return!0;if(Xf(t))return!1;t=t.parent}return!1}(s)){if((r.isSafari||r.isGecko)&&t.domEvent.detail>=3){const e=n.editing.mapper,i=s.is("attributeElement")?s.findAncestor((e=>!e.is("attributeElement"))):s,o=e.toModelElement(i);t.preventDefault(),this.editor.model.change((e=>{e.setSelection(o,"in")}))}return}if(!Xf(s)&&(s=s.findAncestor(Xf),!s))return;r.isAndroid&&t.preventDefault(),o.isFocused||i.focus();const a=n.editing.mapper.toModelElement(s);this._setSelectionOverElement(a)}_handleSelectionChangeOnArrowKeyPress(e,t){const n=t.keyCode,i=this.editor.model,o=i.schema,r=i.document.selection,s=r.getSelectedElement(),a=go(n,this.editor.locale.contentLanguageDirection),c="down"==a||"right"==a,l="up"==a||"down"==a;if(s&&o.isObject(s)){const n=c?r.getLastPosition():r.getFirstPosition(),s=o.getNearestSelectionRange(n,c?"forward":"backward");return void(s&&(i.change((e=>{e.setSelection(s)})),t.preventDefault(),e.stop()))}if(!r.isCollapsed&&!t.shiftKey){const n=r.getFirstPosition(),s=r.getLastPosition(),a=n.nodeAfter,l=s.nodeBefore;return void((a&&o.isObject(a)||l&&o.isObject(l))&&(i.change((e=>{e.setSelection(c?s:n)})),t.preventDefault(),e.stop()))}if(!r.isCollapsed)return;const d=this._getObjectElementNextToSelection(c);if(d&&o.isObject(d)){if(o.isInline(d)&&l)return;this._setSelectionOverElement(d),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const n=this.editor.model,i=n.schema,o=n.document.selection.getSelectedElement();o&&i.isObject(o)&&(t.preventDefault(),e.stop())}_handleDelete(e){if(this.editor.isReadOnly)return;const t=this.editor.model.document.selection;if(!t.isCollapsed)return;const n=this._getObjectElementNextToSelection(e);return n?(this.editor.model.change((e=>{let i=t.anchor.parent;for(;i.isEmpty;){const t=i;i=t.parent,e.remove(t)}this._setSelectionOverElement(n)})),!0):void 0}_setSelectionOverElement(e){this.editor.model.change((t=>{t.setSelection(t.createRangeOn(e))}))}_getObjectElementNextToSelection(e){const t=this.editor.model,n=t.schema,i=t.document.selection,o=t.createSelection(i);if(t.modifySelection(o,{direction:e?"forward":"backward"}),o.isEqual(i))return null;const r=e?o.focus.nodeBefore:o.focus.nodeAfter;return r&&n.isObject(r)?r:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(Jf,t);this._previouslySelected.clear()}}function yg(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}class xg extends Io{static get requires(){return[Gm]}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||!Xf(t))})(e.editing.view.document.selection)&&t.stop()}),{priority:"high"})}this._toolbarDefinitions=new Map,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:n,getRelatedElement:i,balloonClassName:o="ck-toolbar-container"}){if(!n.length)return void k("widget-toolbar-no-items",{toolbarId:e});const r=this.editor,s=r.t,a=new sm(r.locale);if(a.ariaLabel=t||s("Widget toolbar"),this._toolbarDefinitions.has(e))throw new w("widget-toolbar-duplicated",this,{toolbarId:e});a.fillFromConfig(n,r.ui.componentFactory);const c={view:a,getRelatedElement:i,balloonClassName:o};r.ui.addToolbar(a,{isContextual:!0,beforeFocus:()=>{const e=i(r.editing.view.document.selection);e&&this._showToolbar(c,e)},afterBlur:()=>{this._hideToolbar(c)}}),this._toolbarDefinitions.set(e,c)}_updateToolbarsVisibility(){let e=0,t=null,n=null;for(const i of this._toolbarDefinitions.values()){const o=i.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&o)if(this.editor.ui.focusTracker.isFocused){const r=o.getAncestors().length;r>e&&(e=r,t=o,n=i)}else this._isToolbarVisible(i)&&this._hideToolbar(i);else this._isToolbarInBalloon(i)&&this._hideToolbar(i)}n&&this._showToolbar(n,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?Ag(this.editor,t):this._isToolbarInBalloon(e)||(this._balloon.add({view:e.view,position:Cg(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);Ag(this.editor,t)}})))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function Ag(e,t){const n=e.plugins.get("ContextualBalloon"),i=Cg(e,t);n.updatePosition(i)}function Cg(e,t){const n=e.editing.view,i=ah.defaultPositions;return{target:n.domConverter.mapViewToDom(t),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}H();H();var Eg=n(6036),Tg={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Eg.Z,Tg);Eg.Z.locals;class Sg extends Oo{refresh(){const e=this.editor.model,t=e.schema,n=e.document.selection;this.isEnabled=function(e,t,n){const i=function(e,t){const n=rg(e,t).start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(e,n);return t.checkChild(i,"horizontalLine")}(n,t,e)}execute(){const e=this.editor.model;e.change((t=>{const n=t.createElement("horizontalLine");e.insertObject(n,null,null,{setSelection:"after"})}))}}var Pg=n(4383),Ig={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Pg.Z,Ig);Pg.Z.locals;class Mg extends Io{static get pluginName(){return"HorizontalLineEditing"}init(){const e=this.editor,t=e.model.schema,n=e.t,i=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),i.for("dataDowncast").elementToElement({model:"horizontalLine",view:(e,{writer:t})=>t.createEmptyElement("hr")}),i.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(e,{writer:t})=>{const i=n("Horizontal line"),o=t.createContainerElement("div",null,t.createEmptyElement("hr"));return t.addClass("ck-horizontal-line",o),t.setCustomProperty("hr",!0,o),function(e,t,n){return t.setCustomProperty("horizontalLine",!0,e),eg(e,t,{label:n})}(o,t,i)}}),i.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new Sg(e))}}class Og extends Io{static get pluginName(){return"HorizontalLineUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("horizontalLine",(n=>{const i=e.commands.get("horizontalLine"),o=new Rh(n);return o.set({label:t("Horizontal line"),icon:'',tooltip:!0}),o.bind("isEnabled").to(i,"isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("horizontalLine"),e.editing.view.focus()})),o}))}}class Rg extends Io{static get requires(){return[Mg,Og,vg]}static get pluginName(){return"HorizontalLine"}}function Ng(e){const t=e.getSelectedElement();return t&&Lg(t)?t:null}function Dg(e){const t=e.getFirstPosition();if(!t)return null;let n=t.parent;for(;n;){if(n.is("element")&&Lg(n))return n;n=n.parent}return null}function Lg(e){return!!e.getCustomProperty("table")&&Xf(e)}class Vg extends Io{static get requires(){return[xg]}static get pluginName(){return"TableToolbar"}afterInit(){const e=this.editor,t=e.t,n=e.plugins.get(xg),i=e.config.get("table.contentToolbar"),o=e.config.get("table.tableToolbar");i&&n.register("tableContent",{ariaLabel:t("Table toolbar"),items:i,getRelatedElement:Dg}),o&&n.register("table",{ariaLabel:t("Table toolbar"),items:o,getRelatedElement:Ng})}}function Bg(e,t,n,i,o=1){t>o?i.setAttribute(e,t,n):i.removeAttribute(e,n)}function jg(e,t,n={}){const i=e.createElement("tableCell",n);return e.insertElement("paragraph",i),e.insert(i,t),i}function zg(e,t){const n=t.parent.parent,i=parseInt(n.getAttribute("headingColumns")||0),{column:o}=e.getCellLocation(t);return!!i&&o{e.on("element:table",((e,t,n)=>{const i=t.viewItem;if(!n.consumable.test(i,{name:!0}))return;const{rows:o,headingRows:r,headingColumns:s}=function(e){const t={headingRows:0,headingColumns:0},n=[],i=[];let o;for(const r of Array.from(e.getChildren()))if("tbody"===r.name||"thead"===r.name||"tfoot"===r.name){"thead"!==r.name||o||(o=r);const e=Array.from(r.getChildren()).filter((e=>e.is("element","tr")));for(const r of e)if("thead"===r.parent.name&&r.parent===o)t.headingRows++,n.push(r);else{i.push(r);const e=Hg(r);e>t.headingColumns&&(t.headingColumns=e)}}return t.rows=[...n,...i],t}(i),a={};s&&(a.headingColumns=s),r&&(a.headingRows=r);const c=n.writer.createElement("table",a);if(n.safeInsert(c,t.modelCursor)){if(n.consumable.consume(i,{name:!0}),o.forEach((e=>n.convertItem(e,n.writer.createPositionAt(c,"end")))),n.convertChildren(i,n.writer.createPositionAt(c,"end")),c.isEmpty){const e=n.writer.createElement("tableRow");n.writer.insert(e,n.writer.createPositionAt(c,"end")),jg(n.writer,n.writer.createPositionAt(e,"end"))}n.updateConversionResult(c,t)}}))}}function Ug(e){return t=>{t.on(`element:${e}`,((e,t,n)=>{if(t.modelRange&&t.viewItem.isEmpty){const e=t.modelRange.start.nodeAfter,i=n.writer.createPositionAt(e,0);n.writer.insertElement("paragraph",i)}}),{priority:"low"})}}function Hg(e){let t=0,n=0;const i=Array.from(e.getChildren()).filter((e=>"th"===e.name||"td"===e.name));for(;n1||o>1)&&this._recordSpans(n,o,i),this._shouldSkipSlot()||(t=this._formatOutValue(n)),this._nextCellAtColumn=this._column+i}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,n=this._column){return{done:!1,value:new qg(this,e,t,n)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._rowthis._endColumn;return e||t||n||i}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,n){const i={cell:e,row:this._row,column:this._column};for(let e=this._row;e{const o=n.getAttribute("headingRows")||0,r=[];o>0&&r.push(i.createContainerElement("thead",null,i.createSlot((e=>e.is("element","tableRow")&&e.indexe.is("element","tableRow")&&e.index>=o))));const s=i.createContainerElement("figure",{class:"table"},[i.createContainerElement("table",null,r),i.createSlot((e=>!e.is("element","tableRow")))]);return t.asWidget?function(e,t){return t.setCustomProperty("table",!0,e),eg(e,t,{hasSelectionHandle:!0})}(s,i):s}}function $g(e={}){return(t,{writer:n})=>{const i=t.parent,o=i.parent,r=o.getChildIndex(i),s=new Wg(o,{row:r}),a=o.getAttribute("headingRows")||0,c=o.getAttribute("headingColumns")||0;for(const i of s)if(i.cell==t){const t=i.row{if(t.parent.is("element","tableCell")&&Gg(t))return e.asWidget?n.createContainerElement("span",{class:"ck-table-bogus-paragraph"}):(i.consume(t,"insert"),void o.bindElements(t,o.toViewElement(t.parent)))}}function Gg(e){return 1==e.parent.childCount&&![...e.getAttributeKeys()].length}class Yg extends Oo{refresh(){const e=this.editor.model,t=e.document.selection,n=e.schema;this.isEnabled=function(e,t){const n=e.getFirstPosition().parent,i=n===n.root?n:n.parent;return t.checkChild(i,"table")}(t,n)}execute(e={}){const t=this.editor.model,n=this.editor.plugins.get("TableUtils"),i=this.editor.config.get("table"),o=i.defaultHeadings.rows,r=i.defaultHeadings.columns;void 0===e.headingRows&&o&&(e.headingRows=o),void 0===e.headingColumns&&r&&(e.headingColumns=r),t.change((i=>{const o=n.createTable(i,e);t.insertObject(o,null,null,{findOptimalPosition:"auto"}),i.setSelection(i.createPositionAt(o.getNodeByPath([0,0,0]),0))}))}}class Qg extends Oo{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,n=e.plugins.get("TableUtils"),i="above"===this.order,o=n.getSelectionAffectedTableCells(t),r=n.getRowIndexes(o),s=i?r.first:r.last,a=o[0].findAncestor("table");n.insertRows(a,{at:i?s:s+1,copyStructureFromAbove:!i})}}class Jg extends Oo{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,n=e.plugins.get("TableUtils"),i="left"===this.order,o=n.getSelectionAffectedTableCells(t),r=n.getColumnIndexes(o),s=i?r.first:r.last,a=o[0].findAncestor("table");n.insertColumns(a,{columns:1,at:i?s:s+1})}}class Xg extends Oo{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 ep(e,t,n){const{startRow:i,startColumn:o,endRow:r,endColumn:s}=t,a=n.createElement("table"),c=r-i+1;for(let e=0;e0){Bg("headingRows",r-n,e,o,0)}const s=parseInt(t.getAttribute("headingColumns")||0);if(s>0){Bg("headingColumns",s-i,e,o,0)}}(a,e,i,o,n),a}function tp(e,t,n=0){const i=[],o=new Wg(e,{startRow:n,endRow:t-1});for(const e of o){const{row:n,cellHeight:o}=e,r=n+o-1;n1&&(a.rowspan=c);const l=parseInt(e.getAttribute("colspan")||1);l>1&&(a.colspan=l);const d=r+s,u=[...new Wg(o,{startRow:r,endRow:d,includeAllSlots:!0})];let h,m=null;for(const t of u){const{row:i,column:o,cell:r}=t;r===e&&void 0===h&&(h=o),void 0!==h&&h===o&&i===d&&(m=jg(n,t.getPositionBefore(),a))}return Bg("rowspan",s,e,n),m}function ip(e,t){const n=[],i=new Wg(e);for(const e of i){const{column:i,cellWidth:o}=e,r=i+o-1;i1&&(r.colspan=s);const a=parseInt(e.getAttribute("rowspan")||1);a>1&&(r.rowspan=a);const c=jg(i,i.createPositionAfter(e),r);return Bg("colspan",o,e,i),c}function rp(e,t,n,i,o,r){const s=parseInt(e.getAttribute("colspan")||1),a=parseInt(e.getAttribute("rowspan")||1);if(n+s-1>o){Bg("colspan",o-n+1,e,r,1)}if(t+a-1>i){Bg("rowspan",i-t+1,e,r,1)}}function sp(e,t){const n=t.getColumns(e),i=new Array(n).fill(0);for(const{column:t}of new Wg(e))i[t]++;const o=i.reduce(((e,t,n)=>t?e:[...e,n]),[]);if(o.length>0){const n=o[o.length-1];return t.removeColumns(e,{at:n}),!0}return!1}function ap(e,t){const n=[],i=t.getRows(e);for(let t=0;t0){const i=n[n.length-1];return t.removeRows(e,{at:i}),!0}return!1}function cp(e,t){sp(e,t)||ap(e,t)}function lp(e,t){const n=Array.from(new Wg(e,{startColumn:t.firstColumn,endColumn:t.lastColumn,row:t.lastRow}));if(n.every((({cellHeight:e})=>1===e)))return t.lastRow;const i=n[0].cellHeight-1;return t.lastRow+i}function dp(e,t){const n=Array.from(new Wg(e,{startRow:t.firstRow,endRow:t.lastRow,column:t.lastColumn}));if(n.every((({cellWidth:e})=>1===e)))return t.lastColumn;const i=n[0].cellWidth-1;return t.lastColumn+i}class up extends Oo{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,n=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(t.selection)[0],i=this.value,o=this.direction;e.change((e=>{const t="right"==o||"down"==o,r=t?n:i,s=t?i:n,a=s.parent;!function(e,t,n){hp(e)||(hp(t)&&n.remove(n.createRangeIn(t)),n.move(n.createRangeIn(e),n.createPositionAt(t,"end")));n.remove(e)}(s,r,e);const c=this.isHorizontal?"colspan":"rowspan",l=parseInt(n.getAttribute(c)||1),d=parseInt(i.getAttribute(c)||1);e.setAttribute(c,l+d,r),e.setSelection(e.createRangeIn(r));const u=this.editor.plugins.get("TableUtils");cp(a.findAncestor("table"),u)}))}_getMergeableCell(){const e=this.editor.model.document,t=this.editor.plugins.get("TableUtils"),n=t.getTableCellsContainingSelection(e.selection)[0];if(!n)return;const i=this.isHorizontal?function(e,t,n){const i=e.parent.parent,o="right"==t?e.nextSibling:e.previousSibling,r=(i.getAttribute("headingColumns")||0)>0;if(!o)return;const s="right"==t?e:o,a="right"==t?o:e,{column:c}=n.getCellLocation(s),{column:l}=n.getCellLocation(a),d=parseInt(s.getAttribute("colspan")||1),u=zg(n,s),h=zg(n,a);if(r&&u!=h)return;return c+d===l?o:void 0}(n,this.direction,t):function(e,t,n){const i=e.parent,o=i.parent,r=o.getChildIndex(i);if("down"==t&&r===n.getRows(o)-1||"up"==t&&0===r)return;const s=parseInt(e.getAttribute("rowspan")||1),a=o.getAttribute("headingRows")||0,c="down"==t&&r+s===a,l="up"==t&&r===a;if(a&&(c||l))return;const d=parseInt(e.getAttribute("rowspan")||1),u="down"==t?r+d:r,h=[...new Wg(o,{endRow:u})],m=h.find((t=>t.cell===e)).column,f=h.find((({row:e,cellHeight:n,column:i})=>i===m&&("down"==t?e===u:u===e+n)));return f&&f.cell}(n,this.direction,t);if(!i)return;const o=this.isHorizontal?"rowspan":"colspan",r=parseInt(n.getAttribute(o)||1);return parseInt(i.getAttribute(o)||1)===r?i:void 0}}function hp(e){return 1==e.childCount&&e.getChild(0).is("element","paragraph")&&e.getChild(0).isEmpty}class mp extends Oo{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),n=t[0];if(n){const i=n.findAncestor("table"),o=this.editor.plugins.get("TableUtils").getRows(i)-1,r=e.getRowIndexes(t),s=0===r.first&&r.last===o;this.isEnabled=!s}else this.isEnabled=!1}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),n=t.getSelectionAffectedTableCells(e.document.selection),i=t.getRowIndexes(n),o=n[0],r=o.findAncestor("table"),s=t.getCellLocation(o).column;e.change((e=>{const n=i.last-i.first+1;t.removeRows(r,{at:i.first,rows:n});const o=function(e,t,n,i){const o=e.getChild(Math.min(t,i-1));let r=o.getChild(0),s=0;for(const e of o.getChildren()){if(s>n)return r;r=e,s+=parseInt(e.getAttribute("colspan")||1)}return r}(r,i.first,s,t.getRows(r));e.setSelection(e.createPositionAt(o,0))}))}}class fp extends Oo{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),n=t[0];if(n){const i=n.findAncestor("table"),o=e.getColumns(i),{first:r,last:s}=e.getColumnIndexes(t);this.isEnabled=s-re.cell===t)).column,last:o.find((e=>e.cell===n)).column},s=function(e,t,n,i){return parseInt(n.getAttribute("colspan")||1)>1?n:t.previousSibling||n.nextSibling?n.nextSibling||t.previousSibling:i.first?e.reverse().find((({column:e})=>ee>i.last)).cell}(o,t,n,r);this.editor.model.change((e=>{const t=r.last-r.first+1;this.editor.plugins.get("TableUtils").removeColumns(i,{at:r.first,columns:t}),e.setSelection(e.createPositionAt(s,0))}))}}class gp extends Oo{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,n=e.getSelectionAffectedTableCells(t.document.selection),i=n.length>0;this.isEnabled=i,this.value=i&&n.every((e=>this._isInHeading(e,e.parent.parent)))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),n=this.editor.model,i=t.getSelectionAffectedTableCells(n.document.selection),o=i[0].findAncestor("table"),{first:r,last:s}=t.getRowIndexes(i),a=this.value?r:s+1,c=o.getAttribute("headingRows")||0;n.change((e=>{if(a){const t=tp(o,a,a>c?c:0);for(const{cell:n}of t)np(n,a,e)}Bg("headingRows",a,o,e,0)}))}_isInHeading(e,t){const n=parseInt(t.getAttribute("headingRows")||0);return!!n&&e.parent.index0;this.isEnabled=i,this.value=i&&n.every((e=>zg(t,e)))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),n=this.editor.model,i=t.getSelectionAffectedTableCells(n.document.selection),o=i[0].findAncestor("table"),{first:r,last:s}=t.getColumnIndexes(i),a=this.value?r:s+1;n.change((e=>{if(a){const t=ip(o,a);for(const{cell:n,column:i}of t)op(n,i,a,e)}Bg("headingColumns",a,o,e,0)}))}}class bp extends Io{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,n=t.parent,i=n.getChildIndex(t),o=new Wg(n,{row:i});for(const{cell:t,row:n,column:i}of o)if(t===e)return{row:n,column:i}}createTable(e,t){const n=e.createElement("table"),i=parseInt(t.rows)||2,o=parseInt(t.columns)||2;return wp(e,n,0,i,o),t.headingRows&&Bg("headingRows",Math.min(t.headingRows,i),n,e,0),t.headingColumns&&Bg("headingColumns",Math.min(t.headingColumns,o),n,e,0),n}insertRows(e,t={}){const n=this.editor.model,i=t.at||0,o=t.rows||1,r=void 0!==t.copyStructureFromAbove,s=t.copyStructureFromAbove?i-1:i,a=this.getRows(e),c=this.getColumns(e);if(i>a)throw new w("tableutils-insertrows-insert-out-of-range",this,{options:t});n.change((t=>{const n=e.getAttribute("headingRows")||0;if(n>i&&Bg("headingRows",n+o,e,t,0),!r&&(0===i||i===a))return void wp(t,e,i,o,c);const l=r?Math.max(i,s):i,d=new Wg(e,{endRow:l}),u=new Array(c).fill(1);for(const{row:e,column:n,cellHeight:a,cellWidth:c,cell:l}of d){const d=e+a-1,h=e<=s&&s<=d;e0&&jg(t,o,i>1?{colspan:i}:null),e+=Math.abs(i)-1}}}))}insertColumns(e,t={}){const n=this.editor.model,i=t.at||0,o=t.columns||1;n.change((t=>{const n=e.getAttribute("headingColumns");io-1)throw new w("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});n.change((t=>{const{cellsToMove:n,cellsToTrim:i}=function(e,t,n){const i=new Map,o=[];for(const{row:r,column:s,cellHeight:a,cell:c}of new Wg(e,{endRow:n})){const e=r+a-1;if(r>=t&&r<=n&&e>n){const e=a-(n-r+1);i.set(s,{cell:c,rowspan:e})}if(r=t){let i;i=e>=n?n-t+1:e-t+1,o.push({cell:c,rowspan:a-i})}}return{cellsToMove:i,cellsToTrim:o}}(e,r,s);if(n.size){!function(e,t,n,i){const o=[...new Wg(e,{includeAllSlots:!0,row:t})],r=e.getChild(t);let s;for(const{column:e,cell:t,isAnchor:a}of o)if(n.has(e)){const{cell:t,rowspan:o}=n.get(e),a=s?i.createPositionAfter(s):i.createPositionAt(r,0);i.move(i.createRangeOn(t),a),Bg("rowspan",o,t,i),s=t}else a&&(s=t)}(e,s+1,n,t)}for(let n=s;n>=r;n--)t.remove(e.getChild(n));for(const{rowspan:e,cell:n}of i)Bg("rowspan",e,n,t);!function(e,t,n,i){const o=e.getAttribute("headingRows")||0;if(t{!function(e,t,n){const i=e.getAttribute("headingColumns")||0;if(i&&t.first=i;n--)for(const{cell:i,column:o,cellWidth:r}of[...new Wg(e)])o<=n&&r>1&&o+r>n?Bg("colspan",r-1,i,t):o===n&&t.remove(i);ap(e,this)||sp(e,this)}))}splitCellVertically(e,t=2){const n=this.editor.model,i=e.parent.parent,o=parseInt(e.getAttribute("rowspan")||1),r=parseInt(e.getAttribute("colspan")||1);n.change((n=>{if(r>1){const{newCellsSpan:i,updatedSpan:s}=_p(r,t);Bg("colspan",s,e,n);const a={};i>1&&(a.colspan=i),o>1&&(a.rowspan=o);kp(r>t?t-1:r-1,n,n.createPositionAfter(e),a)}if(rt===e)),l=a.filter((({cell:t,cellWidth:n,column:i})=>t!==e&&i===c||ic));for(const{cell:e,cellWidth:t}of l)n.setAttribute("colspan",t+s,e);const d={};o>1&&(d.rowspan=o),kp(s,n,n.createPositionAfter(e),d);const u=i.getAttribute("headingColumns")||0;u>c&&Bg("headingColumns",u+s,i,n)}}))}splitCellHorizontally(e,t=2){const n=this.editor.model,i=e.parent,o=i.parent,r=o.getChildIndex(i),s=parseInt(e.getAttribute("rowspan")||1),a=parseInt(e.getAttribute("colspan")||1);n.change((n=>{if(s>1){const i=[...new Wg(o,{startRow:r,endRow:r+s-1,includeAllSlots:!0})],{newCellsSpan:c,updatedSpan:l}=_p(s,t);Bg("rowspan",l,e,n);const{column:d}=i.find((({cell:t})=>t===e)),u={};c>1&&(u.rowspan=c),a>1&&(u.colspan=a);for(const e of i){const{column:t,row:i}=e,o=t===d,s=(i+r+l)%c==0;i>=r+l&&o&&s&&kp(1,n,e.getPositionBefore(),u)}}if(sr){const e=o+i;n.setAttribute("rowspan",e,t)}const l={};a>1&&(l.colspan=a),wp(n,o,r+1,i,1,l);const d=o.getAttribute("headingRows")||0;d>r&&Bg("headingRows",d+i,o,n)}}))}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 Wg(e,t)}getSelectedTableCells(e){const t=[];for(const n of this.sortRanges(e.getRanges())){const e=n.getContainedElement();e&&e.is("element","tableCell")&&t.push(e)}return t}getTableCellsContainingSelection(e){const t=[];for(const n of e.getRanges()){const e=n.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"),n=[...new Wg(t)].filter((t=>e.includes(t.cell))).map((e=>e.column));return this._getFirstLastIndexesObject(n)}isSelectionRectangular(e){if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;const t=new Set,n=new Set;let i=0;for(const o of e){const{row:e,column:r}=this.getCellLocation(o),s=parseInt(o.getAttribute("rowspan")||1),a=parseInt(o.getAttribute("colspan")||1);t.add(e),n.add(r),s>1&&t.add(e+s-1),a>1&&n.add(r+a-1),i+=s*a}const o=function(e,t){const n=Array.from(e.values()),i=Array.from(t.values()),o=Math.max(...n),r=Math.min(...n),s=Math.max(...i),a=Math.min(...i);return(o-r+1)*(s-a+1)}(t,n);return o==i}sortRanges(e){return Array.from(e).sort(vp)}_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"),n=this.getRowIndexes(e),i=parseInt(t.getAttribute("headingRows")||0);if(!this._areIndexesInSameSection(n,i))return!1;const o=parseInt(t.getAttribute("headingColumns")||0),r=this.getColumnIndexes(e);return this._areIndexesInSameSection(r,o)}_areIndexesInSameSection({first:e,last:t},n){return e{const i=t.getSelectedTableCells(e.document.selection),o=i.shift(),{mergeWidth:r,mergeHeight:s}=function(e,t,n){let i=0,o=0;for(const e of t){const{row:t,column:r}=n.getCellLocation(e);i=Cp(e,r,i,"colspan"),o=Cp(e,t,o,"rowspan")}const{row:r,column:s}=n.getCellLocation(e);return{mergeWidth:i-s,mergeHeight:o-r}}(o,i,t);Bg("colspan",r,o,n),Bg("rowspan",s,o,n);for(const e of i)xp(e,o,n);cp(o.findAncestor("table"),t),n.setSelection(o,"in")}))}}function xp(e,t,n){Ap(e)||(Ap(t)&&n.remove(n.createRangeIn(t)),n.move(n.createRangeIn(e),n.createPositionAt(t,"end"))),n.remove(e)}function Ap(e){return 1==e.childCount&&e.getChild(0).is("element","paragraph")&&e.getChild(0).isEmpty}function Cp(e,t,n,i){const o=parseInt(e.getAttribute(i)||1);return Math.max(n,t+o)}class Ep extends Oo{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"),n=t.getSelectionAffectedTableCells(e.document.selection),i=t.getRowIndexes(n),o=n[0].findAncestor("table"),r=[];for(let t=i.first;t<=i.last;t++)for(const n of o.getChild(t).getChildren())r.push(e.createRangeOn(n));e.change((e=>{e.setSelection(r)}))}}class Tp extends Oo{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,n=e.getSelectionAffectedTableCells(t.document.selection),i=n[0],o=n.pop(),r=i.findAncestor("table"),s=e.getCellLocation(i),a=e.getCellLocation(o),c=Math.min(s.column,a.column),l=Math.max(s.column,a.column),d=[];for(const e of new Wg(r,{startColumn:c,endColumn:l}))d.push(t.createRangeOn(e.cell));t.change((e=>{e.setSelection(d)}))}}function Sp(e){e.document.registerPostFixer((t=>function(e,t){const n=t.document.differ.getChanges();let i=!1;const o=new Set;for(const t of n){let n;"table"==t.name&&"insert"==t.type&&(n=t.position.nodeAfter),"tableRow"!=t.name&&"tableCell"!=t.name||(n=t.position.findAncestor("table")),Mp(t)&&(n=t.range.start.findAncestor("table")),n&&!o.has(n)&&(i=Pp(n,e)||i,i=Ip(n,e)||i,o.add(n))}return i}(t,e)))}function Pp(e,t){let n=!1;const i=function(e){const t=parseInt(e.getAttribute("headingRows")||0),n=Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0),i=[];for(const{row:o,cell:r,cellHeight:s}of new Wg(e)){if(s<2)continue;const e=oe){const t=e-o;i.push({cell:r,rowspan:t})}}return i}(e);if(i.length){n=!0;for(const e of i)Bg("rowspan",e.rowspan,e.cell,t,1)}return n}function Ip(e,t){let n=!1;const i=function(e){const t=new Array(e.childCount).fill(0);for(const{rowIndex:n}of new Wg(e,{includeAllSlots:!0}))t[n]++;return t}(e),o=[];for(const[t,n]of i.entries())!n&&e.getChild(t).is("element","tableRow")&&o.push(t);if(o.length){n=!0;for(const n of o.reverse())t.remove(e.getChild(n)),i.splice(n,1)}const r=i.filter(((t,n)=>e.getChild(n).is("element","tableRow"))),s=r[0];if(!r.every((e=>e===s))){const i=r.reduce(((e,t)=>t>e?t:e),0);for(const[o,s]of r.entries()){const r=i-s;if(r){for(let n=0;nfunction(e,t){const n=t.document.differ.getChanges();let i=!1;for(const t of n)"insert"==t.type&&"table"==t.name&&(i=Rp(t.position.nodeAfter,e)||i),"insert"==t.type&&"tableRow"==t.name&&(i=Np(t.position.nodeAfter,e)||i),"insert"==t.type&&"tableCell"==t.name&&(i=Dp(t.position.nodeAfter,e)||i),Lp(t)&&(i=Dp(t.position.parent,e)||i);return i}(t,e)))}function Rp(e,t){let n=!1;for(const i of e.getChildren())i.is("element","tableRow")&&(n=Np(i,t)||n);return n}function Np(e,t){let n=!1;for(const i of e.getChildren())n=Dp(i,t)||n;return n}function Dp(e,t){if(0==e.childCount)return t.insertElement("paragraph",e),!0;const n=Array.from(e.getChildren()).filter((e=>e.is("$text")));for(const e of n)t.wrap(t.createRangeOn(e),"paragraph");return!!n.length}function Lp(e){return!(!e.position||!e.position.parent.is("element","tableCell"))&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)}function Vp(e,t){if(!e.is("element","paragraph"))return!1;const n=t.toViewElement(e);return!!n&&Gg(e)!==n.is("element","span")}var Bp=n(3137),jp={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Bp.Z,jp);Bp.Z.locals;class zp extends Io{static get pluginName(){return"TableEditing"}static get requires(){return[bp]}init(){const e=this.editor,t=e.model,n=t.schema,i=e.conversion,o=e.plugins.get(bp);n.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),n.register("tableRow",{allowIn:"table",isLimit:!0}),n.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),i.for("upcast").add((e=>{e.on("element:figure",((e,t,n)=>{if(!n.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const i=function(e){for(const t of e.getChildren())if(t.is("element","table"))return t}(t.viewItem);if(!i||!n.consumable.test(i,{name:!0}))return;n.consumable.consume(t.viewItem,{name:!0,classes:"table"});const o=yo(n.convertItem(i,t.modelCursor).modelRange.getItems());o?(n.convertChildren(t.viewItem,n.writer.createPositionAt(o,"end")),n.updateConversionResult(o,t)):n.consumable.revert(t.viewItem,{name:!0,classes:"table"})}))})),i.for("upcast").add(Fg()),i.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Zg(o,{asWidget:!0})}),i.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Zg(o)}),i.for("upcast").elementToElement({model:"tableRow",view:"tr"}),i.for("upcast").add((e=>{e.on("element:tr",((e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()}),{priority:"high"})})),i.for("downcast").elementToElement({model:"tableRow",view:(e,{writer:t})=>e.isEmpty?t.createEmptyElement("tr"):t.createContainerElement("tr")}),i.for("upcast").elementToElement({model:"tableCell",view:"td"}),i.for("upcast").elementToElement({model:"tableCell",view:"th"}),i.for("upcast").add(Ug("td")),i.for("upcast").add(Ug("th")),i.for("editingDowncast").elementToElement({model:"tableCell",view:$g({asWidget:!0})}),i.for("dataDowncast").elementToElement({model:"tableCell",view:$g()}),i.for("editingDowncast").elementToElement({model:"paragraph",view:Kg({asWidget:!0}),converterPriority:"high"}),i.for("dataDowncast").elementToElement({model:"paragraph",view:Kg(),converterPriority:"high"}),i.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),i.for("upcast").attributeToAttribute({model:{key:"colspan",value:Fp("colspan")},view:"colspan"}),i.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),i.for("upcast").attributeToAttribute({model:{key:"rowspan",value:Fp("rowspan")},view:"rowspan"}),e.data.mapper.on("modelToViewPosition",((e,t)=>{const n=t.modelPosition.parent,i=t.modelPosition.nodeBefore;if(!n.is("element","tableCell"))return;if(!i||!i.is("element","paragraph"))return;const o=t.mapper.toViewElement(i),r=t.mapper.toViewElement(n);o===r&&(t.viewPosition=t.mapper.findPositionIn(r,i.maxOffset))})),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new Yg(e)),e.commands.add("insertTableRowAbove",new Qg(e,{order:"above"})),e.commands.add("insertTableRowBelow",new Qg(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new Jg(e,{order:"left"})),e.commands.add("insertTableColumnRight",new Jg(e,{order:"right"})),e.commands.add("removeTableRow",new mp(e)),e.commands.add("removeTableColumn",new fp(e)),e.commands.add("splitTableCellVertically",new Xg(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new Xg(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new yp(e)),e.commands.add("mergeTableCellRight",new up(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new up(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new up(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new up(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new pp(e)),e.commands.add("setTableRowHeader",new gp(e)),e.commands.add("selectTableRow",new Ep(e)),e.commands.add("selectTableColumn",new Tp(e)),Sp(t),Op(t),this.listenTo(t.document,"change:data",(()=>{!function(e,t){const n=e.document.differ;for(const e of n.getChanges()){let n,i=!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;n=t,i="headingRows"==e.attributeKey}else"tableRow"!=e.name&&"tableCell"!=e.name||(n=e.position.findAncestor("table"),i="tableRow"==e.name);if(!n)continue;const o=n.getAttribute("headingRows")||0,r=n.getAttribute("headingColumns")||0,s=new Wg(n);for(const e of s){const n=e.rowVp(e,t.mapper)));for(const e of n)t.reconvertItem(e)}}(t,e.editing)}))}}function Fp(e){return t=>{const n=parseInt(t.getAttribute(e));return Number.isNaN(n)||n<=0?null:n}}var Up=n(6516),Hp={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Up.Z,Hp);Up.Z.locals;class Wp extends nh{constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new Ao,this.focusTracker=new xo,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:n,column:i}=t.target.dataset;this.items.get(10*(parseInt(n,10)-1)+(parseInt(i,10)-1)).focus()})),this.focusTracker.on("change:focusedElement",((e,t,n)=>{if(!n)return;const{row:i,column:o}=n.dataset;this.set({rows:parseInt(i),columns:parseInt(o)})})),this.on("change:columns",(()=>this._highlightGridBoxes())),this.on("change:rows",(()=>this._highlightGridBoxes()))}render(){super.render(),Eh({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10});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(((n,i)=>{const o=Math.floor(i/10){const i=e.commands.get("insertTable"),o=km(n);let r;return o.bind("isEnabled").to(i),o.buttonView.set({icon:'',label:t("Insert table"),tooltip:!0}),o.on("change:isOpen",(()=>{r||(r=new Wp(n),o.panelView.children.add(r),r.delegate("execute").to(o),o.on("execute",(()=>{e.execute("insertTable",{rows:r.rows,columns:r.columns}),e.editing.view.focus()})))})),o})),e.ui.componentFactory.add("tableColumn",(e=>{const i=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:n?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:n?"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"),'',i,e)})),e.ui.componentFactory.add("tableRow",(e=>{const n=[{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"),'',n,e)})),e.ui.componentFactory.add("mergeTableCells",(e=>{const i=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:n?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:n?"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"),'',i,e)}))}_prepareDropdown(e,t,n,i){const o=this.editor,r=km(i),s=this._fillDropdownWithListOptions(r,n);return r.buttonView.set({label:e,icon:t,tooltip:!0}),r.bind("isEnabled").toMany(s,"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(r,"execute",(e=>{o.execute(e.source.commandName),e.source instanceof Lh||o.editing.view.focus()})),r}_prepareMergeSplitButtonDropdown(e,t,n,i){const o=this.editor,r=km(i,Zh),s="mergeTableCells",a=o.commands.get(s),c=this._fillDropdownWithListOptions(r,n);return r.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),r.bind("isEnabled").toMany([a,...c],"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(r.buttonView,"execute",(()=>{o.execute(s),o.editing.view.focus()})),this.listenTo(r,"execute",(e=>{o.execute(e.source.commandName),o.editing.view.focus()})),r}_fillDropdownWithListOptions(e,t){const n=this.editor,i=[],o=new vo;for(const e of t)Zp(e,n,i,o);return vm(e,o,n.ui.componentFactory),i}}function Zp(e,t,n,i){const o=e.model=new Hm(e.model),{commandName:r,bindIsOn:s}=e.model;if("button"===e.type||"switchbutton"===e.type){const e=t.commands.get(r);n.push(e),o.set({commandName:r}),o.bind("isEnabled").to(e),s&&o.bind("isOn").to(e,"value")}o.set({withText:!0}),i.add(e)}var $p=n(2794),Kp={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()($p.Z,Kp);$p.Z.locals;class Gp extends Io{static get pluginName(){return"TableSelection"}static get requires(){return[bp,bp]}init(){const e=this.editor.model;this.listenTo(e,"deleteContent",((e,t)=>this._handleDeleteContent(e,t)),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=this.editor.plugins.get(bp),t=this.editor.model.document.selection,n=e.getSelectedTableCells(t);return 0==n.length?null:n}getSelectionAsFragment(){const e=this.editor.plugins.get(bp),t=this.getSelectedTableCells();return t?this.editor.model.change((n=>{const i=n.createDocumentFragment(),{first:o,last:r}=e.getColumnIndexes(t),{first:s,last:a}=e.getRowIndexes(t),c=t[0].findAncestor("table");let l=a,d=r;if(e.isSelectionRectangular(t)){const e={firstColumn:o,lastColumn:r,firstRow:s,lastRow:a};l=lp(c,e),d=dp(c,e)}const u=ep(c,{startRow:s,startColumn:o,endRow:l,endColumn:d},n);return n.insert(u,i,0),i})):null}setCellSelection(e,t){const n=this._getCellsToSelect(e,t);this.editor.model.change((e=>{e.setSelection(n.cells.map((t=>e.createRangeOn(t))),{backward:n.backward})}))}getFocusCell(){const e=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return e&&e.is("element","tableCell")?e:null}getAnchorCell(){const e=yo(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,n,i)=>{const o=i.writer;!function(e){for(const n of t)e.removeClass("ck-editor__editable_selected",n);t.clear()}(o);const r=this.getSelectedTableCells();if(!r)return;for(const e of r){const n=i.mapper.toViewElement(e);o.addClass("ck-editor__editable_selected",n),t.add(n)}const s=i.mapper.toViewElement(r[r.length-1]);o.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((n=>{const i=n.createPositionAt(t[0],0),o=e.model.schema.getNearestSelectionRange(i);n.setSelection(o)}))}}))}_handleDeleteContent(e,t){const n=this.editor.plugins.get(bp),[i,o]=t,r=this.editor.model,s=!o||"backward"==o.direction,a=n.getSelectedTableCells(i);a.length&&(e.stop(),r.change((e=>{const t=a[s?a.length-1:0];r.change((e=>{for(const t of a)r.deleteContent(e.createSelection(t,"in"))}));const n=r.schema.getNearestSelectionRange(e.createPositionAt(t,0));i.is("documentSelection")?e.setSelection(n):i.setTo(n)})))}_getCellsToSelect(e,t){const n=this.editor.plugins.get("TableUtils"),i=n.getCellLocation(e),o=n.getCellLocation(t),r=Math.min(i.row,o.row),s=Math.max(i.row,o.row),a=Math.min(i.column,o.column),c=Math.max(i.column,o.column),l=new Array(s-r+1).fill(null).map((()=>[])),d={startRow:r,endRow:s,startColumn:a,endColumn:c};for(const{row:t,cell:n}of new Wg(e.findAncestor("table"),d))l[t-r].push(n);const u=o.rowe.reverse())),{cells:l.flat(),backward:u||h}}}class Yp extends Io{static get pluginName(){return"TableClipboard"}static get requires(){return[Gp,bp]}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)=>this._onInsertContent(e,...t)),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(e,t){const n=this.editor.plugins.get(Gp);if(!n.getSelectedTableCells())return;if("cut"==e.name&&this.editor.isReadOnly)return;t.preventDefault(),e.stop();const i=this.editor.data,o=this.editor.editing.view.document,r=i.toView(n.getSelectionAsFragment());o.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:r,method:e.name})}_onInsertContent(e,t,n){if(n&&!n.is("documentSelection"))return;const i=this.editor.model,o=this.editor.plugins.get(bp);let r=Qp(t,i);if(!r)return;const s=o.getSelectionAffectedTableCells(i.document.selection);s.length?(e.stop(),i.change((e=>{const t={width:o.getColumns(r),height:o.getRows(r)},n=function(e,t,n,i){const o=e[0].findAncestor("table"),r=i.getColumnIndexes(e),s=i.getRowIndexes(e),a={firstColumn:r.first,lastColumn:r.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,n,i){const o=i.getColumns(e),r=i.getRows(e);n>o&&i.insertColumns(e,{at:o,columns:n-o});t>r&&i.insertRows(e,{at:r,rows:t-r})}(o,a.lastRow+1,a.lastColumn+1,i));c||!i.isSelectionRectangular(e)?function(e,t,n){const{firstRow:i,lastRow:o,firstColumn:r,lastColumn:s}=t,a={first:i,last:o},c={first:r,last:s};Xp(e,r,a,n),Xp(e,s+1,a,n),Jp(e,i,c,n),Jp(e,o+1,c,n,i)}(o,a,n):(a.lastRow=lp(o,a),a.lastColumn=dp(o,a));return a}(s,t,e,o),i=n.lastRow-n.firstRow+1,a=n.lastColumn-n.firstColumn+1,c={startRow:0,startColumn:0,endRow:Math.min(i,t.height)-1,endColumn:Math.min(a,t.width)-1};r=ep(r,c,e);const l=s[0].findAncestor("table"),d=this._replaceSelectedCellsWithPasted(r,t,l,n,e);if(this.editor.plugins.get("TableSelection").isEnabled){const t=o.sortRanges(d.map((t=>e.createRangeOn(t))));e.setSelection(t)}else e.setSelection(d[0],0)}))):cp(r,o)}_replaceSelectedCellsWithPasted(e,t,n,i,o){const{width:r,height:s}=t,a=function(e,t,n){const i=new Array(n).fill(null).map((()=>new Array(t).fill(null)));for(const{column:t,row:n,cell:o}of new Wg(e))i[n][t]=o;return i}(e,r,s),c=[...new Wg(n,{startRow:i.firstRow,endRow:i.lastRow,startColumn:i.firstColumn,endColumn:i.lastColumn,includeAllSlots:!0})],l=[];let d;for(const e of c){const{row:t,column:n}=e;n===i.firstColumn&&(d=e.getPositionBefore());const c=t-i.firstRow,u=n-i.firstColumn,h=a[c%s][u%r],m=h?o.cloneElement(h):null,f=this._replaceTableSlotCell(e,m,d,o);f&&(rp(f,t,n,i.lastRow,i.lastColumn,o),l.push(f),d=o.createPositionAfter(f))}const u=parseInt(n.getAttribute("headingRows")||0),h=parseInt(n.getAttribute("headingColumns")||0),m=i.firstRoweb(e,t,n))).map((({cell:e})=>np(e,t,i)))}function Xp(e,t,n,i){if(t<1)return;return ip(e,t).filter((({row:e,cellHeight:t})=>eb(e,t,n))).map((({cell:e,column:n})=>op(e,n,t,i)))}function eb(e,t,n){const i=e+t-1,{first:o,last:r}=n;return e>=o&&e<=r||e=o}class tb extends Io{static get pluginName(){return"TableKeyboard"}static get requires(){return[Gp,bp]}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 n=this.editor,i=n.model.document.selection.getSelectedElement();i&&i.is("element","table")&&(t.preventDefault(),t.stopPropagation(),e.stop(),n.model.change((e=>{e.setSelection(e.createRangeIn(i.getChild(0).getChild(0)))})))}_handleTab(e,t){const n=this.editor,i=this.editor.plugins.get(bp),o=n.model.document.selection,r=!t.shiftKey;let s=i.getTableCellsContainingSelection(o)[0];if(s||(s=this.editor.plugins.get("TableSelection").getFocusCell()),!s)return;t.preventDefault(),t.stopPropagation(),e.stop();const a=s.parent,c=a.parent,l=c.getChildIndex(a),d=a.getChildIndex(s),u=0===d;if(!r&&u&&0===l)return void n.model.change((e=>{e.setSelection(e.createRangeOn(c))}));const h=d===a.childCount-1,m=l===i.getRows(c)-1;if(r&&m&&h&&(n.execute("insertTableRowBelow"),l===i.getRows(c)-1))return void n.model.change((e=>{e.setSelection(e.createRangeOn(c))}));let f;if(r&&h){const e=c.getChild(l+1);f=e.getChild(0)}else if(!r&&u){const e=c.getChild(l-1);f=e.getChild(e.childCount-1)}else f=a.getChild(d+(r?1:-1));n.model.change((e=>{e.setSelection(e.createRangeIn(f))}))}_onArrowKey(e,t){const n=this.editor,i=go(t.keyCode,n.locale.contentLanguageDirection);this._handleArrowKeys(i,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const n=this.editor.plugins.get(bp),i=this.editor.model,o=i.document.selection,r=["right","down"].includes(e),s=n.getSelectedTableCells(o);if(s.length){let n;return n=t?this.editor.plugins.get("TableSelection").getFocusCell():r?s[s.length-1]:s[0],this._navigateFromCellInDirection(n,e,t),!0}const a=o.focus.findAncestor("tableCell");if(!a)return!1;if(!o.isCollapsed)if(t){if(o.isBackward==r&&!o.containsEntireContent(a))return!1}else{const e=o.getSelectedElement();if(!e||!i.schema.isObject(e))return!1}return!!this._isSelectionAtCellEdge(o,a,r)&&(this._navigateFromCellInDirection(a,e,t),!0)}_isSelectionAtCellEdge(e,t,n){const i=this.editor.model,o=this.editor.model.schema,r=n?e.getLastPosition():e.getFirstPosition();if(!o.getLimitElement(r).is("element","tableCell")){return i.createPositionAt(t,n?"end":0).isTouching(r)}const s=i.createSelection(r);return i.modifySelection(s,{direction:n?"forward":"backward"}),r.isEqual(s.focus)}_navigateFromCellInDirection(e,t,n=!1){const i=this.editor.model,o=e.findAncestor("table"),r=[...new Wg(o,{includeAllSlots:!0})],{row:s,column:a}=r[r.length-1],c=r.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 i.change((e=>{e.setSelection(e.createRangeOn(o))}));d<0?(d=n?0:a,l--):d>a&&(d=n?a:0,l++);const u=r.find((e=>e.row==l&&e.column==d)).cell,h=["right","down"].includes(t),m=this.editor.plugins.get("TableSelection");if(n&&m.isEnabled){const t=m.getAnchorCell()||e;m.setCellSelection(t,u)}else{const e=i.createPositionAt(u,h?0:"end");i.change((t=>{t.setSelection(e)}))}}}class nb extends ga{constructor(e){super(e),this.domEventType=["mousemove","mouseleave"]}onDomEvent(e){this.fire(e.type,e)}}class ib extends Io{static get pluginName(){return"TableMouse"}static get requires(){return[Gp,bp]}init(){this.editor.editing.view.addObserver(nb),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(bp);let n=!1;const i=e.plugins.get(Gp);this.listenTo(e.editing.view.document,"mousedown",((o,r)=>{const s=e.model.document.selection;if(!this.isEnabled||!i.isEnabled)return;if(!r.domEvent.shiftKey)return;const a=i.getAnchorCell()||t.getTableCellsContainingSelection(s)[0];if(!a)return;const c=this._getModelTableCellFromDomEvent(r);c&&ob(a,c)&&(n=!0,i.setCellSelection(a,c),r.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{n=!1})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{n&&e.stop()}),{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,n,i=!1,o=!1;const r=e.plugins.get(Gp);this.listenTo(e.editing.view.document,"mousedown",((e,n)=>{this.isEnabled&&r.isEnabled&&(n.domEvent.shiftKey||n.domEvent.ctrlKey||n.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(n)))})),this.listenTo(e.editing.view.document,"mousemove",((e,s)=>{if(!s.domEvent.buttons)return;if(!t)return;const a=this._getModelTableCellFromDomEvent(s);a&&ob(t,a)&&(n=a,i||n==t||(i=!0)),i&&(o=!0,r.setCellSelection(t,n),s.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{i=!1,o=!1,t=null,n=null})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{o&&e.stop()}),{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,n=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(n).parent.findAncestor("tableCell",{includeSelf:!0})}}function ob(e,t){return e.parent.parent==t.parent.parent}var rb=n(4418),sb={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(rb.Z,sb);rb.Z.locals;class ab extends Io{static get requires(){return[zp,qp,Gp,ib,tb,Yp,vg]}static get pluginName(){return"Table"}}function cb(e,t,n,i){let o,r=null;"function"==typeof i?o=i:(r=e.commands.get(i),o=()=>{e.execute(i)}),e.model.document.on("change:data",((s,a)=>{if(r&&!r.isEnabled||!t.isEnabled)return;const c=yo(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 i&&!["numberedList","bulletedList","todoList"].includes(i))return;if(r&&!0===r.value)return;const h=u.getChild(0),m=e.model.createRangeOn(h);if(!m.containsRange(c)&&!c.end.isEqual(m.end))return;const f=n.exec(h.data.substr(0,c.end.offset));f&&e.model.enqueueChange((t=>{const n=t.createPositionAt(u,0),i=t.createPositionAt(u,f[0].length),r=new Nc(n,i);if(!1!==o({match:f})){t.remove(r);const n=e.model.document.selection.getFirstRange(),i=t.createRangeIn(u);!u.isEmpty||i.isEqual(n)||i.containsRange(n,!0)||t.remove(u)}r.detach(),e.model.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}))}))}function lb(e,t,n,i){let o,r;n instanceof RegExp?o=n:r=n,r=r||(e=>{let t;const n=[],i=[];for(;null!==(t=o.exec(e))&&!(t&&t.length<4);){let{index:e,1:o,2:r,3:s}=t;const a=o+r+s;e+=t[0].length-a.length;const c=[e,e+o.length],l=[e+o.length+r.length,e+o.length+r.length+s.length];n.push(c),n.push(l),i.push([e+o.length,e+o.length+r.length])}return{remove:n,format:i}}),e.model.document.on("change:data",((n,o)=>{if(o.isUndo||!o.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 n=e.start;return{text:Array.from(e.getItems()).reduce(((e,i)=>!i.is("$text")&&!i.is("$textProxy")||i.getAttribute("code")?(n=t.createPositionAfter(i),""):e+i.data),""),range:t.createRange(n,e.end)}}(s.createRange(s.createPositionAt(u,0),d),s),f=r(h),g=db(m.start,f.format,s),p=db(m.start,f.remove,s);g.length&&p.length&&s.enqueueChange((t=>{if(!1!==i(t,g)){for(const e of p.reverse())t.remove(e);s.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}}))}))}function db(e,t,n){return t.filter((e=>void 0!==e[0]&&void 0!==e[1])).map((t=>n.createRange(e.getShiftedBy(t[0]),e.getShiftedBy(t[1]))))}class ub extends Io{static get requires(){return[Af]}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")&&cb(this.editor,this,/^[*-]\s$/,"bulletedList"),e.get("numberedList")&&cb(this.editor,this,/^1[.|)]\s$/,"numberedList"),e.get("todoList")&&cb(this.editor,this,/^\[\s?\]\s$/,"todoList"),e.get("checkTodoList")&&cb(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=hb(this.editor,"bold");lb(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,e),lb(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,e)}if(e.get("italic")){const e=hb(this.editor,"italic");lb(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,e),lb(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,e)}if(e.get("code")){const e=hb(this.editor,"code");lb(this.editor,this,/(`)([^`]+)(`)$/g,e)}if(e.get("strikethrough")){const e=hb(this.editor,"strikethrough");lb(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 n=t[7],i=new RegExp(`^(#{${n}})\\s$`);cb(this.editor,this,i,(()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute("heading",{value:t})}))}))}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&cb(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const e=this.editor,t=e.model.document.selection;e.commands.get("codeBlock")&&cb(e,this,/^```$/,(()=>{if(t.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})}))}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&cb(this.editor,this,/^---$/,"horizontalLine")}}function hb(e,t){return(n,i)=>{if(!e.commands.get(t).isEnabled)return!1;const o=e.model.schema.getValidRanges(i,t);for(const e of o)n.setAttribute(t,!0,e);n.removeSelectionAttribute(t)}}class mb extends ga{constructor(e){super(e);const t=this.document;function n(e){return(n,i)=>{i.preventDefault();const o=i.dropRange?[i.dropRange]:null,r=new m(t,e);t.fire(r,{dataTransfer:i.dataTransfer,method:n.name,targetRanges:o,target:i.target}),r.stop.called&&i.stopPropagation()}}this.domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"],this.listenTo(t,"paste",n("clipboardInput"),{priority:"low"}),this.listenTo(t,"drop",n("clipboardInput"),{priority:"low"}),this.listenTo(t,"dragover",n("dragging"),{priority:"low"})}onDomEvent(e){const t={dataTransfer:new ic("clipboardData"in e?e.clipboardData:e.dataTransfer)};"drop"!=e.type&&"dragover"!=e.type||(t.dropRange=function(e,t){const n=t.target.ownerDocument,i=t.clientX,o=t.clientY;let r;n.caretRangeFromPoint&&n.caretRangeFromPoint(i,o)?r=n.caretRangeFromPoint(i,o):t.rangeParent&&(r=n.createRange(),r.setStart(t.rangeParent,t.rangeOffset),r.collapse(!0));if(r)return e.domConverter.domRangeToView(r);return null}(this.view,e)),this.fire(e.type,e,t)}}const fb=["figcaption","li"];function gb(e){let t="";if(e.is("$text")||e.is("$textProxy"))t=e.data;else if(e.is("element","img")&&e.hasAttribute("alt"))t=e.getAttribute("alt");else if(e.is("element","br"))t="\n";else{let n=null;for(const i of e.getChildren()){const e=gb(i);n&&(n.is("containerElement")||i.is("containerElement"))&&(fb.includes(n.name)||fb.includes(i.name)?t+="\n":t+="\n\n"),t+=e,n=i}}return t}class pb extends Io{static get pluginName(){return"ClipboardPipeline"}init(){this.editor.editing.view.addObserver(mb),this._setupPasteDrop(),this._setupCopyCut()}_setupPasteDrop(){const e=this.editor,t=e.model,n=e.editing.view,i=n.document;this.listenTo(i,"clipboardInput",(t=>{e.isReadOnly&&t.stop()}),{priority:"highest"}),this.listenTo(i,"clipboardInput",((e,t)=>{const i=t.dataTransfer;let o;if(t.content)o=t.content;else{let e="";i.getData("text/html")?e=function(e){return e.replace(/(\s+)<\/span>/g,((e,t)=>1==t.length?" ":t)).replace(//g,"")}(i.getData("text/html")):i.getData("text/plain")&&(((r=(r=i.getData("text/plain")).replace(//g,">").replace(/\r?\n\r?\n/g,"

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

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

${r}

`),e=r),o=this.editor.data.htmlProcessor.toView(e)}var r;const s=new m(this,"inputTransformation");this.fire(s,{content:o,dataTransfer:i,targetRanges:t.targetRanges,method:t.method}),s.stop.called&&e.stop(),n.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,n)=>{if(n.content.isEmpty)return;const i=this.editor.data.toModel(n.content,"$clipboardHolder");0!=i.childCount&&(e.stop(),t.change((()=>{this.fire("contentInsertion",{content:i,method:n.method,dataTransfer:n.dataTransfer,targetRanges:n.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,n)=>{n.resultRange=t.insertContent(n.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,n=e.editing.view.document,i=(i,o)=>{const r=o.dataTransfer;o.preventDefault();const s=e.data.toView(e.model.getSelectedContent(t.selection));n.fire("clipboardOutput",{dataTransfer:r,content:s,method:i.name})};this.listenTo(n,"copy",i,{priority:"low"}),this.listenTo(n,"cut",((t,n)=>{e.isReadOnly?n.preventDefault():i(t,n)}),{priority:"low"}),this.listenTo(n,"clipboardOutput",((n,i)=>{i.content.isEmpty||(i.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(i.content)),i.dataTransfer.setData("text/plain",gb(i.content))),"cut"==i.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}const bb=function(e,t,n){var i=!0,o=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return L(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),Pa(e,t,{leading:i,maxWait:t,trailing:o})};var wb=n(3352),kb={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(wb.Z,kb);wb.Z.locals;class _b extends Io{static get pluginName(){return"DragDrop"}static get requires(){return[pb,vg]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=bb((e=>this._updateDropMarker(e)),40),this._removeDropMarkerDelayed=xb((()=>this._removeDropMarker()),40),this._clearDraggableAttributesDelayed=xb((()=>this._clearDraggableAttributes()),40),t.addObserver(mb),t.addObserver(iu),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",((e,t,n)=>{n?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((e,t,n)=>{n||this._finalizeDragging(!1)})),r.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._updateDropMarkerThrottled.cancel(),this._removeDropMarkerDelayed.cancel(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,n=t.document,i=e.editing.view,o=i.document;this.listenTo(o,"dragstart",((i,r)=>{const s=n.selection;if(r.target&&r.target.is("editableElement"))return void r.preventDefault();const a=r.target?Ab(r.target):null;if(a){const n=e.editing.mapper.toModelElement(a);this._draggedRange=Nc.fromRange(t.createRangeOn(n)),e.plugins.has("WidgetToolbarRepository")&&e.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}else if(!o.selection.isCollapsed){const e=o.selection.getSelectedElement();e&&Xf(e)||(this._draggedRange=Nc.fromRange(s.getFirstRange()))}if(!this._draggedRange)return void r.preventDefault();this._draggingUid=g(),r.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",r.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const c=t.createSelection(this._draggedRange.toRange()),l=e.data.toView(t.getSelectedContent(c));o.fire("clipboardOutput",{dataTransfer:r.dataTransfer,content:l,method:"dragstart"}),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(o,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this.listenTo(o,"dragenter",(()=>{this.isEnabled&&i.focus()})),this.listenTo(o,"dragleave",(()=>{this._removeDropMarkerDelayed()})),this.listenTo(o,"dragging",((t,n)=>{if(!this.isEnabled)return void(n.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const i=vb(e,n.targetRanges,n.target);this._draggedRange||(n.dataTransfer.dropEffect="copy"),r.isGecko||("copy"==n.dataTransfer.effectAllowed?n.dataTransfer.dropEffect="copy":["all","copyMove"].includes(n.dataTransfer.effectAllowed)&&(n.dataTransfer.dropEffect="move")),i&&this._updateDropMarkerThrottled(i)}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"clipboardInput",((t,n)=>{if("drop"!=n.method)return;const i=vb(e,n.targetRanges,n.target);if(this._removeDropMarker(),!i)return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==yb(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(i,!0))return this._finalizeDragging(!1),void t.stop();n.targetRanges=[e.editing.mapper.toViewRange(i)]}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(pb);e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const n=t.targetRanges.map((e=>this.editor.editing.mapper.toModelRange(e)));this.editor.model.change((e=>e.setSelection(n)))}),{priority:"high"}),e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const n="move"==yb(t.dataTransfer),i=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(i&&n)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,n=t.document;this.listenTo(n,"mousedown",((i,o)=>{if(r.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let s=Ab(o.target);if(r.isBlink&&!e.isReadOnly&&!s&&!n.selection.isCollapsed){const e=n.selection.getSelectedElement();e&&Xf(e)||(s=n.selection.editableElement)}s&&(t.change((e=>{e.setAttribute("draggable","true",s)})),this._draggableElement=e.editing.mapper.toModelElement(s))})),this.listenTo(n,"mouseup",(()=>{r.isAndroid||this._clearDraggableAttributesDelayed()}))}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change((t=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null}))}_setupDropMarker(){const e=this.editor;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:n})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return n.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(e){const t=this.toDomElement(e);return t.append("⁠",e.createElement("span"),"⁠"),t}))}})}_updateDropMarker(e){const t=this.editor,n=t.model.markers;t.model.change((t=>{n.has("drop-target")?n.get("drop-target").getRange().isEqual(e)||t.updateMarker("drop-target",{range:e}):t.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})}))}_removeDropMarker(){const e=this.editor.model;this._removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),e.markers.has("drop-target")&&e.change((e=>{e.removeMarker("drop-target")}))}_finalizeDragging(e){const t=this.editor,n=t.model;this._removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._draggedRange&&(e&&this.isEnabled&&n.deleteContent(n.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function vb(e,t,n){const i=e.model,o=e.editing.mapper;let s=null;const a=t?t[0].start:null;if(n.is("uiElement")&&(n=n.parent),s=function(e,t){const n=e.model,i=e.editing.mapper;if(Xf(t))return n.createRangeOn(i.toModelElement(t));if(!t.is("editableElement")){const e=t.findAncestor((e=>Xf(e)||e.is("editableElement")));if(Xf(e))return n.createRangeOn(i.toModelElement(e))}return null}(e,n),s)return s;const c=function(e,t){const n=e.editing.mapper,i=e.editing.view,o=n.toModelElement(t);if(o)return o;const r=i.createPositionBefore(t),s=n.findMappedViewAncestor(r);return n.toModelElement(s)}(e,n),l=a?o.toModelPosition(a):null;return l?(s=function(e,t,n){const i=e.model;if(!i.schema.checkChild(n,"$block"))return null;const o=i.createPositionAt(n,0),r=t.path.slice(0,o.path.length),s=i.createPositionFromPath(t.root,r).nodeAfter;if(s&&i.schema.isObject(s))return i.createRangeOn(s);return null}(e,l,c),s||(s=i.schema.getNearestSelectionRange(l,r.isGecko?"forward":"backward"),s||function(e,t){const n=e.model;let i=t;for(;i;){if(n.schema.isObject(i))return n.createRangeOn(i);i=i.parent}return null}(e,l.parent))):function(e,t){const n=e.model,i=n.schema,o=n.createPositionAt(t,0);return i.getNearestSelectionRange(o,"forward")}(e,c)}function yb(e){return r.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function xb(e,t){let n;function i(...o){i.cancel(),n=setTimeout((()=>e(...o)),t)}return i.cancel=()=>{clearTimeout(n)},i}function Ab(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(Xf);if(Xf(e))return e;const t=e.findAncestor((e=>Xf(e)||e.is("editableElement")));return Xf(t)?t:null}class Cb extends Io{static get pluginName(){return"PastePlainText"}static get requires(){return[pb]}init(){const e=this.editor,t=e.model,n=e.editing.view,i=n.document,o=t.document.selection;let r=!1;n.addObserver(mb),this.listenTo(i,"keydown",((e,t)=>{r=t.shiftKey})),e.plugins.get(pb).on("contentInsertion",((e,n)=>{(r||function(e,t){if(e.childCount>1)return!1;const n=e.getChild(0);if(t.isObject(n))return!1;return 0==Array.from(n.getAttributeKeys()).length}(n.content,t.schema))&&t.change((e=>{const i=Array.from(o.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0}),i.push(...o.getAttributes());const r=e.createRangeIn(n.content);for(const t of r.getItems())t.is("$textProxy")&&e.setAttributes(i,t)}))}))}}class Eb extends Io{static get pluginName(){return"Clipboard"}static get requires(){return[pb,_b,Cb]}}class Tb extends Oo{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let n=e.schema.getLimitElement(t);if(t.containsEntireContent(n)||!Sb(e.schema,n))do{if(n=n.parent,!n)return}while(!Sb(e.schema,n));e.change((e=>{e.setSelection(n,"in")}))}}function Sb(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const Pb=mo("Ctrl+A");class Ib extends Io{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new Tb(e)),this.listenTo(t,"keydown",((t,n)=>{ho(n)===Pb&&(e.execute("selectAll"),n.preventDefault())}))}}class Mb extends Io{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(t=>{const n=e.commands.get("selectAll"),i=new Rh(t),o=t.t;return i.set({label:o("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),i.bind("isEnabled").to(n,"isEnabled"),this.listenTo(i,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),i}))}}class Ob extends Io{static get requires(){return[Ib,Mb]}static get pluginName(){return"SelectAll"}}class Rb extends Oo{constructor(e){super(e),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),this.listenTo(e.data,"set",((e,t)=>{t[1]={...t[1]};const n=t[1];n.batchType||(n.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}addBatch(e){const t=this.editor.model.document.selection,n={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:n}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,n){const i=this.editor.model,o=i.document,r=[],s=e.map((e=>e.getTransformedByOperations(n))),a=s.flat();for(const e of s){const t=e.filter((e=>e.root!=o.graveyard)).filter((e=>!Db(e,a)));t.length&&(Nb(t),r.push(t[0]))}r.length&&i.change((e=>{e.setSelection(r,{backward:t})}))}_undo(e,t){const n=this.editor.model,i=n.document;this._createdBatches.add(t);const o=e.operations.slice().filter((e=>e.isDocumentOperation));o.reverse();for(const e of o){const o=e.baseVersion+1,r=Array.from(i.history.getOperations(o)),s=ad([e.getReversed()],r,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(const o of s)t.addOperation(o),n.applyOperation(o),i.history.setOperationAsUndone(e,o)}}}function Nb(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}class Lb extends Rb{execute(e=null){const t=e?this._stack.findIndex((t=>t.batch==e)):this._stack.length-1,n=this._stack.splice(t,1)[0],i=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(i,(()=>{this._undo(n.batch,i);const e=this.editor.model.document.history.getOperations(n.batch.baseVersion);this._restoreSelection(n.selection.ranges,n.selection.isBackward,e),this.fire("revert",n.batch,i)})),this.refresh()}}class Vb extends Rb{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(t,(()=>{const n=e.batch.operations[e.batch.operations.length-1].baseVersion+1,i=this.editor.model.document.history.getOperations(n);this._restoreSelection(e.selection.ranges,e.selection.isBackward,i),this._undo(e.batch,t)})),this.refresh()}}class Bb extends Io{static get pluginName(){return"UndoEditing"}constructor(e){super(e),this._batchRegistry=new WeakSet}init(){const e=this.editor;this._undoCommand=new Lb(e),this._redoCommand=new Vb(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",((e,t)=>{const n=t[0];if(!n.isDocumentOperation)return;const i=n.batch,o=this._redoCommand._createdBatches.has(i),r=this._undoCommand._createdBatches.has(i);this._batchRegistry.has(i)||(this._batchRegistry.add(i),i.isUndoable&&(o?this._undoCommand.addBatch(i):r||(this._undoCommand.addBatch(i),this._redoCommand.clearStack())))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((e,t,n)=>{this._redoCommand.addBatch(n)})),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo")}}const jb='',zb='';class Fb extends Io{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,n=e.t,i="ltr"==t.uiLanguageDirection?jb:zb,o="ltr"==t.uiLanguageDirection?zb:jb;this._addButton("undo",n("Undo"),"CTRL+Z",i),this._addButton("redo",n("Redo"),"CTRL+Y",o)}_addButton(e,t,n,i){const o=this.editor;o.ui.componentFactory.add(e,(r=>{const s=o.commands.get(e),a=new Rh(r);return a.set({label:t,icon:i,keystroke:n,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",(()=>{o.execute(e),o.editing.view.focus()})),a}))}}class Ub extends Io{static get requires(){return[Bb,Fb]}static get pluginName(){return"Undo"}}class Hb extends Io{static get requires(){return[Eb,Uf,Ob,Zf,Cf,Ub]}static get pluginName(){return"Essentials"}}class Wb extends Oo{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,n=t.schema,i=t.document.selection,o=Array.from(i.getSelectedBlocks()),r=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(r){const t=o.filter((e=>qb(e)||$b(n,e)));this._applyQuote(e,t)}else this._removeQuote(e,o.filter(qb))}))}_getValue(){const e=yo(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!qb(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,n=yo(e.getSelectedBlocks());return!!n&&$b(t,n)}_removeQuote(e,t){Zb(e,t).reverse().forEach((t=>{if(t.start.isAtStart&&t.end.isAtEnd)return void e.unwrap(t.start.parent);if(t.start.isAtStart){const n=e.createPositionBefore(t.start.parent);return void e.move(t,n)}t.end.isAtEnd||e.split(t.end);const n=e.createPositionAfter(t.end.parent);e.move(t,n)}))}_applyQuote(e,t){const n=[];Zb(e,t).reverse().forEach((t=>{let i=qb(t.start);i||(i=e.createElement("blockQuote"),e.wrap(t,i)),n.push(i)})),n.reverse().reduce(((t,n)=>t.nextSibling==n?(e.merge(e.createPositionAfter(t)),t):n))}}function qb(e){return"blockQuote"==e.parent.name?e.parent:null}function Zb(e,t){let n,i=0;const o=[];for(;i{const i=e.model.document.differ.getChanges();for(const e of i)if("insert"==e.type){const i=e.position.nodeAfter;if(!i)continue;if(i.is("element","blockQuote")&&i.isEmpty)return n.remove(i),!0;if(i.is("element","blockQuote")&&!t.checkChild(e.position,i))return n.unwrap(i),!0;if(i.is("element")){const e=n.createRangeIn(i);for(const i of e.getItems())if(i.is("element","blockQuote")&&!t.checkChild(n.createPositionBefore(i),i))return n.unwrap(i),!0}}else if("remove"==e.type){const t=e.position.parent;if(t.is("element","blockQuote")&&t.isEmpty)return n.remove(t),!0}return!1}));const n=this.editor.editing.view.document,i=e.model.document.selection,o=e.commands.get("blockQuote");this.listenTo(n,"enter",((t,n)=>{if(!i.isCollapsed||!o.value)return;i.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())}),{context:"blockquote"}),this.listenTo(n,"delete",((t,n)=>{if("backward"!=n.direction||!i.isCollapsed||!o.value)return;const r=i.getLastPosition().parent;r.isEmpty&&!r.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())}),{context:"blockquote"})}}var Gb=n(5558),Yb={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Gb.Z,Yb);Gb.Z.locals;class Qb extends Io{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",(n=>{const i=e.commands.get("blockQuote"),o=new Rh(n);return o.set({label:t("Block quote"),icon:yh.quote,tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),o}))}}class Jb extends Io{static get requires(){return[Kb,Qb]}static get pluginName(){return"BlockQuote"}}function Xb(e){const t=e.t,n=e.config.get("codeBlock.languages");for(const e of n)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class=`language-${e.language}`);return n}function ew(e,t,n){const i={};for(const o of e)"class"===t?i[o[t].split(" ").shift()]=o[n]:i[o[t]]=o[n];return i}function tw(e){return e.data.match(/^(\s*)/)[0]}function nw(e){const t=e.document.selection,n=[];if(t.isCollapsed)n.push(t.anchor);else{const i=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:t}of i)if(t.is("$textProxy")&&t.parent.is("element","codeBlock")){const i=tw(t.textNode),{parent:o,startOffset:r}=t.textNode,s=e.createPositionAt(o,r+i.length);n.push(s)}}return n}function iw(e){const t=yo(e.getSelectedBlocks());return t&&t.is("element","codeBlock")}function ow(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}class rw extends Oo{constructor(e){super(e),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,n=t.model,i=n.document.selection,o=Xb(t)[0],r=Array.from(i.getSelectedBlocks()),s=void 0===e.forceValue?!this.value:e.forceValue,a=function(e,t,n){if(e.language)return e.language;if(e.usePreviousLanguageChoice&&t)return t;return n}(e,this._lastLanguage,o.language);n.change((e=>{s?this._applyCodeBlock(e,r,a):this._removeCodeBlock(e,r)}))}_getValue(){const e=yo(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,n=yo(e.getSelectedBlocks());return!!n&&ow(t,n)}_applyCodeBlock(e,t,n){this._lastLanguage=n;const i=this.editor.model.schema,o=t.filter((e=>ow(i,e)));for(const t of o)e.rename(t,"codeBlock"),e.setAttribute("language",n,t),i.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter((e=>!i.checkChild(t,e))).forEach((t=>e.remove(t)));o.reverse().forEach(((t,n)=>{const i=o[n+1];t.previousSibling===i&&(e.appendElement("softBreak",i),e.merge(e.createPositionBefore(t)))}))}_removeCodeBlock(e,t){const n=t.filter((e=>e.is("element","codeBlock")));for(const t of n){const n=e.createRangeOn(t);for(const t of Array.from(n.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:n}=e.split(e.createPositionBefore(t));e.rename(n.nodeAfter,"paragraph"),e.removeAttribute("language",n.nodeAfter),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}class sw extends Oo{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 n=nw(e);for(const i of n){const n=t.createText(this._indentSequence);e.insertContent(n,i)}}))}_checkEnabled(){return!!this._indentSequence&&iw(this.editor.model.document.selection)}}class aw extends Oo{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=nw(e);for(const n of t){const t=cw(e,n,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!iw(e.document.selection)&&nw(e).some((t=>cw(e,t,this._indentSequence)))}}function cw(e,t,n){const i=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(!i)return null;const o=tw(i),r=o.lastIndexOf(n);if(r+n.length!==o.length)return null;if(-1===r)return null;const{parent:s,startOffset:a}=i;return e.createRange(e.createPositionAt(s,a+r),e.createPositionAt(s,a+r+n.length))}function lw(e,t,n=!1){const i=ew(t,"language","class"),o=ew(t,"language","label");return(t,r,s)=>{const{writer:a,mapper:c,consumable:l}=s;if(!l.consume(r.item,"insert"))return;const d=r.item.getAttribute("language"),u=c.toViewPosition(e.createPositionBefore(r.item)),h={};n&&(h["data-language"]=o[d],h.spellcheck="false");const m=a.createContainerElement("code",{class:i[d]||null}),f=a.createContainerElement("pre",h,m);a.insert(u,f),c.bindElements(r.item,m)}}const dw="paragraph";class uw extends Io{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[Zf]}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,n=e.model,i=e.editing.view,o=e.plugins.has("DocumentListEditing"),r=Xb(e);e.commands.add("codeBlock",new rw(e)),e.commands.add("indentCodeBlock",new sw(e)),e.commands.add("outdentCodeBlock",new aw(e)),this.listenTo(i.document,"tab",((t,n)=>{const i=n.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(i).isEnabled&&(e.execute(i),n.stopPropagation(),n.preventDefault(),t.stop())}),{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",isBlock:!0,allowAttributes:["language"]}),t.addAttributeCheck(((e,t)=>{const n=e.endsWith("codeBlock")&&t.startsWith("list")&&"list"!==t;return!(!o||!n)||!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",lw(n,r,!0)),e.data.downcastDispatcher.on("insert:codeBlock",lw(n,r)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,n,i)=>{if("codeBlock"!==n.item.parent.name)return;const{writer:o,mapper:r,consumable:s}=i;if(!s.consume(n.item,"insert"))return;const a=r.toViewPosition(e.createPositionBefore(n.item));o.insert(a,o.createText("\n"))}}(n),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const n=ew(t,"class","language"),i=t[0].language;return(e,t,o)=>{const r=t.viewItem,s=r.parent;if(!s||!s.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:c}=o;if(!a.test(r,{name:!0}))return;const l=c.createElement("codeBlock"),d=[...r.getClassNames()];d.length||d.push("");for(const e of d){const t=n[e];if(t){c.setAttribute("language",t,l);break}}l.hasAttribute("language")||c.setAttribute("language",i,l),o.convertChildren(r,l),o.safeInsert(l,t.modelCursor)&&(a.consume(r,{name:!0}),o.updateConversionResult(l,t))}}(0,r)),e.data.upcastDispatcher.on("text",((e,t,{consumable:n,writer:i})=>{let o=t.modelCursor;if(!n.test(t.viewItem))return;if(!o.findAncestor("codeBlock"))return;n.consume(t.viewItem);const r=t.viewItem.data.split("\n").map((e=>i.createText(e))),s=r[r.length-1];for(const e of r)if(i.insert(e,o),o=o.getShiftedBy(e.offsetSize),e!==s){const e=i.createElement("softBreak");i.insert(e,o),o=i.createPositionAfter(e)}t.modelRange=i.createRange(t.modelCursor,o),t.modelCursor=o})),e.data.upcastDispatcher.on("element:pre",((e,t,{consumable:n})=>{const i=t.viewItem;if(i.findAncestor("pre"))return;const o=Array.from(i.getChildren()),r=o.find((e=>e.is("element","code")));if(r)for(const e of o)e!==r&&e.is("$text")&&n.consume(e,{name:!0})}),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,i)=>{let o=n.createRange(n.document.selection.anchor);if(i.targetRanges&&(o=e.editing.mapper.toModelRange(i.targetRanges[0])),!o.start.parent.is("element","codeBlock"))return;const r=i.dataTransfer.getData("text/plain"),s=new ou(e.editing.view.document);i.content=function(e,t){const n=e.createDocumentFragment(),i=t.split("\n"),o=i.reduce(((t,n,o)=>(t.push(n),o{const o=i.anchor;!i.isCollapsed&&o.parent.is("element","codeBlock")&&o.hasSameParentAs(i.focus)&&n.change((n=>{const r=e.return;if(r.childCount>1||i.containsEntireContent(o.parent)){const t=n.createElement("codeBlock",o.parent.getAttributes());n.append(r,t);const i=n.createDocumentFragment();n.append(t,i),e.return=i}else{const e=r.getChild(0);t.checkAttribute(e,"code")&&n.setAttribute("code",!0,e)}}))}))}afterInit(){const e=this.editor,t=e.commands,n=t.get("indent"),i=t.get("outdent");n&&n.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),i&&i.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",((t,n)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const n=e.model.document,i=e.editing.view,o=n.selection.getLastPosition(),r=o.nodeAfter;if(t||!n.selection.isCollapsed||!o.isAtStart)return!1;if(!mw(r))return!1;return e.model.change((t=>{e.execute("enter");const i=n.selection.anchor.parent.previousSibling;t.rename(i,dw),t.setSelection(i,"in"),e.model.schema.removeDisallowedAttributes([i],t),t.remove(r)})),i.scrollToTheSelection(),!0}(e,n.isSoft)||function(e,t){const n=e.model,i=n.document,o=e.editing.view,r=i.selection.getLastPosition(),s=r.nodeBefore;let a;if(t||!i.selection.isCollapsed||!r.isAtEnd||!s||!s.previousSibling)return!1;if(mw(s)&&mw(s.previousSibling))a=n.createRange(n.createPositionBefore(s.previousSibling),n.createPositionAfter(s));else if(hw(s)&&mw(s.previousSibling)&&mw(s.previousSibling.previousSibling))a=n.createRange(n.createPositionBefore(s.previousSibling.previousSibling),n.createPositionAfter(s));else{if(!(hw(s)&&mw(s.previousSibling)&&hw(s.previousSibling.previousSibling)&&mw(s.previousSibling.previousSibling.previousSibling)))return!1;a=n.createRange(n.createPositionBefore(s.previousSibling.previousSibling.previousSibling),n.createPositionAfter(s))}return e.model.change((t=>{t.remove(a),e.execute("enter");const n=i.selection.anchor.parent;t.rename(n,dw),e.model.schema.removeDisallowedAttributes([n],t)})),o.scrollToTheSelection(),!0}(e,n.isSoft)||function(e){const t=e.model.document,n=t.selection.getLastPosition(),i=n.nodeBefore||n.textNode;let o;i&&i.is("$text")&&(o=tw(i));e.model.change((n=>{e.execute("shiftEnter"),o&&n.insertText(o,t.selection.anchor)}))}(e),n.preventDefault(),t.stop())}),{context:"pre"})}}function hw(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function mw(e){return e&&e.is("element","softBreak")}var fw=n(348),gw={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(fw.Z,gw);fw.Z.locals;class pw extends Io{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,n=e.ui.componentFactory,i=Xb(e);n.add("codeBlock",(n=>{const o=e.commands.get("codeBlock"),r=km(n,Zh),s=r.buttonView;return s.set({label:t("Insert code block"),tooltip:!0,icon:'',isToggleable:!0}),s.bind("isOn").to(o,"value",(e=>!!e)),s.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()})),r.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),r.class="ck-code-block-dropdown",r.bind("isEnabled").to(o),vm(r,this._getLanguageListItemDefinitions(i)),r}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),n=new vo;for(const i of e){const e={type:"button",model:new Hm({_codeBlockLanguage:i.language,label:i.label,withText:!0})};e.model.bind("isOn").to(t,"value",(t=>t===e.model._codeBlockLanguage)),n.add(e)}return n}}class bw extends Io{static get requires(){return[uw,pw]}static get pluginName(){return"CodeBlock"}}class ww extends Oo{refresh(){const e=this.editor.model,t=yo(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&kw(t,e.schema)}execute(e={}){const t=this.editor.model,n=t.document;t.change((i=>{const o=(e.selection||n.selection).getSelectedBlocks();for(const e of o)!e.is("element","paragraph")&&kw(e,t.schema)&&i.rename(e,"paragraph")}))}}function kw(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class _w extends Oo{execute(e){const t=this.editor.model,n=e.attributes;let i=e.position;t.change((e=>{const o=e.createElement("paragraph");if(n&&t.schema.setAllowedAttributes(o,n,e),!t.schema.checkChild(i.parent,o)){const n=t.schema.findAllowedParent(i,o);if(!n)return;i=e.split(i,n).position}t.insertContent(o,i),e.setSelection(o,"in")}))}}class vw extends Io{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new ww(e)),e.commands.add("insertParagraph",new _w(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>vw.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}vw.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class yw extends Oo{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=yo(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>xw(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,n=t.document,i=e.value;t.change((e=>{const o=Array.from(n.selection.getSelectedBlocks()).filter((e=>xw(e,i,t.schema)));for(const t of o)t.is("element",i)||e.rename(t,i)}))}}function xw(e,t,n){return n.checkChild(e.parent,t)&&!n.isObject(e)}const Aw="paragraph";class Cw extends Io{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[vw]}init(){const e=this.editor,t=e.config.get("heading.options"),n=[];for(const i of t)i.model!==Aw&&(e.model.schema.register(i.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(i),n.push(i.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new yw(e,n))}afterInit(){const e=this.editor,t=e.commands.get("enter"),n=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,i)=>{const o=e.model.document.selection.getFirstPosition().parent;n.some((e=>o.is("element",e.model)))&&!o.is("element",Aw)&&0===o.childCount&&i.writer.rename(o,Aw)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:p.get("low")+1})}}var Ew=n(4684),Tw={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Ew.Z,Tw);Ew.Z.locals;class Sw extends Io{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,n=function(e){const t=e.t,n={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=n[e.title];return t&&t!=e.title&&(e.title=t),e}))}(e),i=t("Choose heading"),o=t("Heading");e.ui.componentFactory.add("heading",(t=>{const r={},s=new vo,a=e.commands.get("heading"),c=e.commands.get("paragraph"),l=[a];for(const e of n){const t={type:"button",model:new Hm({label:e.title,class:e.class,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),r[e.model]=e.title}const d=km(t);return vm(d,s),d.buttonView.set({isOn:!1,withText:!0,tooltip:o}),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 n=e||t&&"paragraph";return r[n]?r[n]:i})),this.listenTo(d,"execute",(t=>{e.execute(t.source.commandName,t.source.commandValue?{value:t.source.commandValue}:void 0),e.editing.view.focus()})),d}))}}class Pw extends Io{static get requires(){return[Cw,Sw]}static get pluginName(){return"Heading"}}class Iw extends Oo{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,n=t.document,i=Array.from(n.selection.getSelectedBlocks()).filter((e=>Ow(e,t.schema))),o=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(o){let t=i[i.length-1].nextSibling,n=Number.POSITIVE_INFINITY,o=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=n;)r>o.getAttribute("listIndent")&&(r=o.getAttribute("listIndent")),o.getAttribute("listIndent")==r&&e[t?"unshift":"push"](o),o=o[t?"previousSibling":"nextSibling"]}}function Ow(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class Rw extends Oo{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 n=Array.from(t.selection.getSelectedBlocks());e.change((e=>{const t=n[n.length-1];let i=t.nextSibling;for(;i&&"listItem"==i.name&&i.getAttribute("listIndent")>t.getAttribute("listIndent");)n.push(i),i=i.nextSibling;this._indentBy<0&&(n=n.reverse());for(const t of n){const n=t.getAttribute("listIndent")+this._indentBy;n<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",n,t)}this.fire("_executeCleanup",n)}))}_checkEnabled(){const e=yo(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("element","listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),n=e.getAttribute("listType");let i=e.previousSibling;for(;i&&i.is("element","listItem")&&i.getAttribute("listIndent")>=t;){if(i.getAttribute("listIndent")==t)return i.getAttribute("listType")==n;i=i.previousSibling}return!1}return!0}}function Nw(e,t){const n=t.mapper,i=t.writer,o="numbered"==e.getAttribute("listType")?"ol":"ul",r=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=zw,t}(i),s=i.createContainerElement(o,null);return i.insert(i.createPositionAt(s,0),r),n.bindElements(e,r),r}function Dw(e,t,n,i){const o=t.parent,r=n.mapper,s=n.writer;let a=r.toViewPosition(i.createPositionBefore(e));const c=Bw(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),l=e.previousSibling;if(c&&c.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=r.toViewElement(c);a=s.breakContainer(s.createPositionAfter(e))}else if(l&&"listItem"==l.name){a=r.toViewPosition(i.createPositionAt(l,"end"));const e=r.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=r.toViewPosition(i.createPositionBefore(e));if(a=Vw(a),s.insert(a,o),l&&"listItem"==l.name){const e=r.toViewElement(l),n=s.createRange(s.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of n)if(e.item.is("element","li")){const i=s.breakContainer(s.createPositionBefore(e.item)),o=e.item.parent,r=s.createPositionAt(t,"end");Lw(s,r.nodeBefore,r.nodeAfter),s.move(s.createRangeOn(o),r),n.position=i}}else{const n=o.nextSibling;if(n&&(n.is("element","ul")||n.is("element","ol"))){let i=null;for(const t of n.getChildren()){const n=r.toModelElement(t);if(!(n&&n.getAttribute("listIndent")>e.getAttribute("listIndent")))break;i=t}i&&(s.breakContainer(s.createPositionAfter(i)),s.move(s.createRangeOn(i.parent),s.createPositionAt(t,"end")))}}Lw(s,o,o.nextSibling),Lw(s,o.previousSibling,o)}function Lw(e,t,n){return!t||!n||"ul"!=t.name&&"ol"!=t.name||t.name!=n.name||t.getAttribute("class")!==n.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function Vw(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function Bw(e,t){const n=!!t.sameIndent,i=!!t.smallerIndent,o=t.listIndent;let r=e;for(;r&&"listItem"==r.name;){const e=r.getAttribute("listIndent");if(n&&o==e||i&&o>e)return r;r="forward"===t.direction?r.nextSibling:r.previousSibling}return null}function jw(e,t,n,i){e.ui.componentFactory.add(t,(o=>{const r=e.commands.get(t),s=new Rh(o);return s.set({label:n,icon:i,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),s}))}function zw(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:ts.call(this)}function Fw(e){return(t,n,i)=>{const o=i.consumable;if(!o.test(n.item,"insert")||!o.test(n.item,"attribute:listType")||!o.test(n.item,"attribute:listIndent"))return;o.consume(n.item,"insert"),o.consume(n.item,"attribute:listType"),o.consume(n.item,"attribute:listIndent");const r=n.item;Dw(r,Nw(r,i),i,e)}}function Uw(e,t,n){if(!n.consumable.test(t.item,e.name))return;const i=n.mapper.toViewElement(t.item),o=n.writer;o.breakContainer(o.createPositionBefore(i)),o.breakContainer(o.createPositionAfter(i));const r=i.parent,s="numbered"==t.attributeNewValue?"ol":"ul";o.rename(s,r)}function Hw(e,t,n){n.consumable.consume(t.item,e.name);const i=n.mapper.toViewElement(t.item).parent,o=n.writer;Lw(o,i,i.nextSibling),Lw(o,i.previousSibling,i)}function Ww(e,t,n){if(n.consumable.test(t.item,e.name)&&"listItem"!=t.item.name){let e=n.mapper.toViewPosition(t.range.start);const i=n.writer,o=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=i.breakContainer(e),"li"==e.parent.name);){const t=e,n=i.createPositionAt(e.parent,"end");if(!t.isEqual(n)){const e=i.remove(i.createRange(t,n));o.push(e)}e=i.createPositionAfter(e.parent)}if(o.length>0){for(let t=0;t0){const t=Lw(i,n,n.nextSibling);t&&t.parent==n&&e.offset--}}Lw(i,e.nodeBefore,e.nodeAfter)}}}function qw(e,t,n){const i=n.mapper.toViewPosition(t.position),o=i.nodeBefore,r=i.nodeAfter;Lw(n.writer,o,r)}function Zw(e,t,n){if(n.consumable.consume(t.viewItem,{name:!0})){const e=n.writer,i=e.createElement("listItem"),o=function(e){let t=0,n=e.parent;for(;n;){if(n.is("element","li"))t++;else{const e=n.previousSibling;e&&e.is("element","li")&&t++}n=n.parent}return t}(t.viewItem);e.setAttribute("listIndent",o,i);const r=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",r,i),!n.safeInsert(i,t.modelCursor))return;const s=function(e,t,n){const{writer:i,schema:o}=n;let r=i.createPositionAfter(e);for(const s of t)if("ul"==s.name||"ol"==s.name)r=n.convertItem(s,r).modelCursor;else{const t=n.convertItem(s,i.createPositionAt(e,"end")),a=t.modelRange.start.nodeAfter;a&&a.is("element")&&!o.checkChild(e,a.name)&&(e=t.modelCursor.parent.is("element","listItem")?t.modelCursor.parent:Qw(t.modelCursor),r=i.createPositionAfter(e))}return r}(i,t.viewItem.getChildren(),n);t.modelRange=e.createRange(t.modelCursor,s),n.updateConversionResult(i,t)}}function $w(e,t,n){if(n.consumable.test(t.viewItem,{name:!0})){const e=Array.from(t.viewItem.getChildren());for(const t of e){!(t.is("element","li")||Xw(t))&&t._remove()}}}function Kw(e,t,n){if(n.consumable.test(t.viewItem,{name:!0})){if(0===t.viewItem.childCount)return;const e=[...t.viewItem.getChildren()];let n=!1;for(const t of e)n&&!Xw(t)&&t._remove(),Xw(t)&&(n=!0)}}function Gw(e){return(t,n)=>{if(n.isPhantom)return;const i=n.modelPosition.nodeBefore;if(i&&i.is("element","listItem")){const t=n.mapper.toViewElement(i),o=t.getAncestors().find(Xw),r=e.createPositionAt(t,0).getWalker();for(const e of r){if("elementStart"==e.type&&e.item.is("element","li")){n.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==o){n.viewPosition=e.nextPosition;break}}}}}function Yw(e,[t,n]){let i,o=t.is("documentFragment")?t.getChild(0):t;if(i=n?this.createSelection(n):this.document.selection,o&&o.is("element","listItem")){const e=i.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 Qw(e){const t=new fc({startPosition:e});let n;do{n=t.next()}while(!n.value.item.is("element","listItem"));return n.value.item}function Jw(e,t,n,i,o,r){const s=Bw(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e,foo:"b"}),a=o.mapper,c=o.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=r.createPositionAt(s,"end");d=a.toViewPosition(e)}else d=n;d=Vw(d);for(const e of[...i.getChildren()])Xw(e)&&(d=c.move(c.createRangeOn(e),d).end,Lw(c,e,e.nextSibling),Lw(c,e.previousSibling,e))}function Xw(e){return e.is("element","ol")||e.is("element","ul")}class ek extends Io{static get pluginName(){return"ListEditing"}static get requires(){return[Uf,Af]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,n=e.editing;var i;e.model.document.registerPostFixer((t=>function(e,t){const n=e.document.differ.getChanges(),i=new Map;let o=!1;for(const i of n)if("insert"==i.type&&"listItem"==i.name)r(i.position);else if("insert"==i.type&&"listItem"!=i.name){if("$text"!=i.name){const n=i.position.nodeAfter;n.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",n),o=!0),n.hasAttribute("listType")&&(t.removeAttribute("listType",n),o=!0),n.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",n),o=!0),n.hasAttribute("listReversed")&&(t.removeAttribute("listReversed",n),o=!0),n.hasAttribute("listStart")&&(t.removeAttribute("listStart",n),o=!0);for(const t of Array.from(e.createRangeIn(n)).filter((e=>e.item.is("element","listItem"))))r(t.previousPosition)}r(i.position.getShiftedBy(i.length))}else"remove"==i.type&&"listItem"==i.name?r(i.position):("attribute"==i.type&&"listIndent"==i.attributeKey||"attribute"==i.type&&"listType"==i.attributeKey)&&r(i.range.start);for(const e of i.values())s(e),a(e);return o;function r(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(i.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,i.has(e))return;i.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&i.set(t,t)}}function s(e){let n=0,i=null;for(;e&&e.is("element","listItem");){const r=e.getAttribute("listIndent");if(r>n){let s;null===i?(i=r-n,s=n):(i>r&&(i=r),s=r-i),t.setAttribute("listIndent",s,e),o=!0}else i=null,n=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let n=[],i=null;for(;e&&e.is("element","listItem");){const r=e.getAttribute("listIndent");if(i&&i.getAttribute("listIndent")>r&&(n=n.slice(0,r+1)),0!=r)if(n[r]){const i=n[r];e.getAttribute("listType")!=i&&(t.setAttribute("listType",i,e),o=!0)}else n[r]=e.getAttribute("listType");i=e,e=e.nextSibling}}}(e.model,t))),n.mapper.registerViewToModelLength("li",tk),t.mapper.registerViewToModelLength("li",tk),n.mapper.on("modelToViewPosition",Gw(n.view)),n.mapper.on("viewToModelPosition",(i=e.model,(e,t)=>{const n=t.viewPosition,o=n.parent,r=t.mapper;if("ul"==o.name||"ol"==o.name){if(n.isAtEnd){const e=r.toModelElement(n.nodeBefore),o=r.getModelLength(n.nodeBefore);t.modelPosition=i.createPositionBefore(e).getShiftedBy(o)}else{const e=r.toModelElement(n.nodeAfter);t.modelPosition=i.createPositionBefore(e)}e.stop()}else if("li"==o.name&&n.nodeBefore&&("ul"==n.nodeBefore.name||"ol"==n.nodeBefore.name)){const s=r.toModelElement(o);let a=1,c=n.nodeBefore;for(;c&&Xw(c);)a+=r.getModelLength(c),c=c.previousSibling;t.modelPosition=i.createPositionBefore(s).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",Gw(n.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",Ww,{priority:"high"}),t.on("insert:listItem",Fw(e.model)),t.on("attribute:listType:listItem",Uw,{priority:"high"}),t.on("attribute:listType:listItem",Hw,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,n,i)=>{if(!i.consumable.consume(n.item,"attribute:listIndent"))return;const o=i.mapper.toViewElement(n.item),r=i.writer;r.breakContainer(r.createPositionBefore(o)),r.breakContainer(r.createPositionAfter(o));const s=o.parent,a=s.previousSibling,c=r.createRangeOn(s);r.remove(c),a&&a.nextSibling&&Lw(r,a,a.nextSibling),Jw(n.attributeOldValue+1,n.range.start,c.start,o,i,e),Dw(n.item,o,i,e);for(const e of n.item.getChildren())i.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,n,i)=>{const o=i.mapper.toViewPosition(n.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,r=i.writer;r.breakContainer(r.createPositionBefore(o)),r.breakContainer(r.createPositionAfter(o));const s=o.parent,a=s.previousSibling,c=r.createRangeOn(s),l=r.remove(c);a&&a.nextSibling&&Lw(r,a,a.nextSibling),Jw(i.mapper.toModelElement(o).getAttribute("listIndent")+1,n.position,c.start,o,i,e);for(const e of r.createRangeIn(l).getItems())i.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",qw,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",Ww,{priority:"high"}),t.on("insert:listItem",Fw(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",$w,{priority:"high"}),e.on("element:ol",$w,{priority:"high"}),e.on("element:li",Kw,{priority:"high"}),e.on("element:li",Zw)})),e.model.on("insertContent",Yw,{priority:"high"}),e.commands.add("numberedList",new Iw(e,"numbered")),e.commands.add("bulletedList",new Iw(e,"bulleted")),e.commands.add("indentList",new Rw(e,"forward")),e.commands.add("outdentList",new Rw(e,"backward"));const o=n.view.document;this.listenTo(o,"enter",((e,t)=>{const n=this.editor.model.document,i=n.selection.getLastPosition().parent;n.selection.isCollapsed&&"listItem"==i.name&&i.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(o,"delete",((e,t)=>{if("backward"!==t.direction)return;const n=this.editor.model.document.selection;if(!n.isCollapsed)return;const i=n.getFirstPosition();if(!i.isAtStart)return;const o=i.parent;if("listItem"!==o.name)return;o.previousSibling&&"listItem"===o.previousSibling.name||(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(e.editing.view.document,"tab",((t,n)=>{const i=n.shiftKey?"outdentList":"indentList";this.editor.commands.get(i).isEnabled&&(e.execute(i),n.stopPropagation(),n.preventDefault(),t.stop())}),{context:"li"})}afterInit(){const e=this.editor.commands,t=e.get("indent"),n=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),n&&n.registerChildCommand(e.get("outdentList"))}}function tk(e){let t=1;for(const n of e.getChildren())if("ul"==n.name||"ol"==n.name)for(const e of n.getChildren())t+=tk(e);return t}class nk extends Io{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;jw(this.editor,"numberedList",e("Numbered List"),''),jw(this.editor,"bulletedList",e("Bulleted List"),'')}}class ik extends Io{static get requires(){return[ek,nk]}static get pluginName(){return"List"}}function ok(e,t){return`${e}:${t=t||bo(e)}`}class rk extends Oo{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 n=this.editor.model,i=n.document.selection,o=!!e&&ok(e,t);n.change((e=>{if(i.isCollapsed)o?e.setSelectionAttribute("language",o):e.removeSelectionAttribute("language");else{const t=n.schema.getValidRanges(i.getRanges(),"language");for(const n of t)o?e.setAttribute("language",o,n):e.removeAttribute("language",n)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,n=e.document.selection;if(n.isCollapsed)return n.getAttribute("language")||!1;for(const e of n.getRanges())for(const n of e.getItems())if(t.checkAttribute(n,"language"))return n.getAttribute("language")||!1;return!1}}class sk extends Io{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 rk(e))}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToAttribute({model:{key:"language",value:e=>ok(e.getAttribute("lang"),e.getAttribute("dir"))},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),e.for("downcast").attributeToElement({model:"language",view:(e,{writer:t},n)=>{if(!e)return;if(!n.item.is("$textProxy")&&!n.item.is("documentSelection"))return;const{languageCode:i,textDirection:o}=function(e){const[t,n]=e.split(":");return{languageCode:t,textDirection:n}}(e);return t.createAttributeElement("span",{lang:i,dir:o})}})}}var ak=n(858),ck={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(ak.Z,ck);ak.Z.locals;class lk extends Io{static get pluginName(){return"TextPartLanguageUI"}init(){const e=this.editor,t=e.t,n=e.config.get("language.textPartLanguage"),i=t("Choose language"),o=t("Remove language"),r=t("Language");e.ui.componentFactory.add("textPartLanguage",(t=>{const s=new vo,a={},c=e.commands.get("textPartLanguage");s.add({type:"button",model:new Hm({label:o,languageCode:!1,withText:!0})}),s.add({type:"separator"});for(const e of n){const t={type:"button",model:new Hm({label:e.title,languageCode:e.languageCode,textDirection:e.textDirection,withText:!0})},n=ok(e.languageCode,e.textDirection);t.model.bind("isOn").to(c,"value",(e=>e===n)),s.add(t),a[n]=e.title}const l=km(t);return vm(l,s),l.buttonView.set({isOn:!1,withText:!0,tooltip:r}),l.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),l.bind("isEnabled").to(c,"isEnabled"),l.buttonView.bind("label").to(c,"value",(e=>a[e]||i)),this.listenTo(l,"execute",(t=>{c.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()})),l}))}}class dk extends Io{static get requires(){return[sk,lk]}static get pluginName(){return"TextPartLanguage"}}class uk extends Oo{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,n=t.document.selection,i=e.value;t.change((e=>{if(n.isCollapsed)i?e.setSelectionAttribute(this.attributeKey,i):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(n.getRanges(),this.attributeKey);for(const t of o)i?e.setAttribute(this.attributeKey,i,t):e.removeAttribute(this.attributeKey,t)}}))}}class hk extends vo{constructor(e){super(e),this.set("isEmpty",!0),this.on("change",(()=>{this.set("isEmpty",0===this.length)}))}add(e,t){this.find((t=>t.color===e.color))||super.add(e,t)}hasColor(e){return!!this.find((t=>t.color===e))}}u(hk,H);var mk=n(4590),fk={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(mk.Z,fk);mk.Z.locals;class gk extends nh{constructor(e,{colors:t,columns:n,removeButtonLabel:i,documentColorsLabel:o,documentColorsCount:r}){super(e),this.items=this.createCollection(),this.colorDefinitions=t,this.focusTracker=new xo,this.keystrokes=new Ao,this.set("selectedColor"),this.removeButtonLabel=i,this.columns=n,this.documentColors=new hk,this.documentColorsCount=r,this._focusables=new Ou,this._focusCycler=new Qh({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this._documentColorsLabel=o,this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-table"]},children:this.items}),this.items.add(this._createRemoveColorButton())}updateDocumentColors(e,t){const n=e.document,i=this.documentColorsCount;this.documentColors.clear();for(const o of n.getRootNames()){const r=n.getRoot(o),s=e.createRangeIn(r);for(const e of s.getItems())if(e.is("$textProxy")&&e.hasAttribute(t)&&(this._addColorToDocumentColors(e.getAttribute(t)),this.documentColors.length>=i))return}}updateSelectedColors(){const e=this.documentColorsGrid,t=this.staticColorsGrid,n=this.selectedColor;t.selectedColor=n,e&&(e.selectedColor=n)}render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}appendGrids(){if(!this.staticColorsGrid&&(this.staticColorsGrid=this._createStaticColorsGrid(),this.items.add(this.staticColorsGrid),this.focusTracker.add(this.staticColorsGrid.element),this._focusables.add(this.staticColorsGrid),this.documentColorsCount)){const e=Ru.bind(this.documentColors,this.documentColors),t=new Sm(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.focusTracker.add(this.documentColorsGrid.element),this._focusables.add(this.documentColorsGrid)}}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_createRemoveColorButton(){const e=new Rh;return e.set({withText:!0,icon:yh.eraser,label:this.removeButtonLabel}),e.class="ck-color-table__remove-color",e.on("execute",(()=>{this.fire("execute",{value:null})})),e.render(),this.focusTracker.add(e.element),this._focusables.add(e),e}_createStaticColorsGrid(){const e=new Fh(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return e.delegate("execute").to(this),e}_createDocumentColorsGrid(){const e=Ru.bind(this.documentColors,this.documentColors),t=new Fh(this.locale,{columns:this.columns});return t.delegate("execute").to(this),t.extendTemplate({attributes:{class:e.if("isEmpty","ck-hidden")}}),t.items.bindTo(this.documentColors).using((e=>{const t=new Bh;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})})),t})),this.documentColors.on("change:isEmpty",((e,n,i)=>{i&&(t.selectedColor=null)})),t}_addColorToDocumentColors(e){const t=this.colorDefinitions.find((t=>t.color===e));t?this.documentColors.add(Object.assign({},t)):this.documentColors.add({color:e,label:e,options:{hasBorder:!1}})}}const pk="fontSize",bk="fontFamily",wk="fontColor",kk="fontBackgroundColor";function _k(e,t){const n={model:{key:e,values:[]},view:{},upcastAlso:{}};for(const e of t)n.model.values.push(e.model),n.view[e.model]=e.view,e.upcastAlso&&(n.upcastAlso[e.model]=e.upcastAlso);return n}function vk(e){return t=>t.getStyle(e).replace(/\s/g,"")}function yk(e){return(t,{writer:n})=>n.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class xk extends uk{constructor(e){super(e,bk)}}function Ak(e){return e.map(Ck).filter((e=>!!e))}function Ck(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=e.replace(/"|'/g,"").split(","),n=t[0],i=t.map(Ek).join(", ");return{title:n,model:i,view:{name:"span",styles:{"font-family":i},priority:7}}}(e):void 0}function Ek(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class Tk extends Io{static get pluginName(){return"FontFamilyEditing"}constructor(e){super(e),e.config.define(bk,{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:bk}),e.model.schema.setAttributeProperties(bk,{isFormatting:!0,copyOnEnter:!0});const t=Ak(e.config.get("fontFamily.options")).filter((e=>e.model)),n=_k(bk,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(bk,new xk(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:bk,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:bk,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:bk,value:e=>e.getAttribute("face")}})}}class Sk extends Io{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,n=this._getLocalizedOptions(),i=e.commands.get(bk);e.ui.componentFactory.add(bk,(o=>{const r=km(o);return vm(r,function(e,t){const n=new vo;for(const i of e){const e={type:"button",model:new Hm({commandName:bk,commandParam:i.model,label:i.title,withText:!0})};e.model.bind("isOn").to(t,"value",(e=>e===i.model||!(!e||!i.model)&&e.split(",")[0].replace(/'/g,"").toLowerCase()===i.model.toLowerCase())),i.view&&i.view.styles&&e.model.set("labelStyle",`font-family: ${i.view.styles["font-family"]}`),n.add(e)}return n}(n,i)),r.buttonView.set({label:t("Font Family"),icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),r.bind("isEnabled").to(i),this.listenTo(r,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),r}))}_getLocalizedOptions(){const e=this.editor,t=e.t;return Ak(e.config.get(bk).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class Pk extends Io{static get requires(){return[Tk,Sk]}static get pluginName(){return"FontFamily"}}class Ik extends uk{constructor(e){super(e,pk)}}function Mk(e){return e.map((e=>function(e){if(t=e,"object"==typeof t&&t.title&&t.model&&t.view)return Rk(e);var t;const n=function(e){return Ok[e]||Ok[e.model]}(e);if(n)return Rk(n);if("default"===e)return{model:void 0,title:"Default"};if(function(e){let t;if("object"==typeof e){if(!e.model)throw new w("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}(e))return;return function(e){"number"!=typeof e&&"string"!=typeof e||(e={title:String(e),model:`${parseFloat(e)}px`});return e.view={name:"span",styles:{"font-size":e.model}},Rk(e)}(e)}(e))).filter((e=>!!e))}const Ok={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 Rk(e){return e.view.priority||(e.view.priority=7),e}const Nk=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class Dk extends Io{static get pluginName(){return"FontSizeEditing"}constructor(e){super(e),e.config.define(pk,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:pk}),e.model.schema.setAttributeProperties(pk,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),n=Mk(this.editor.config.get("fontSize.options")).filter((e=>e.model)),i=_k(pk,n);t?(this._prepareAnyValueConverters(i),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(pk,new Ik(e))}_prepareAnyValueConverters(e){const t=this.editor,n=e.model.values.filter((e=>{return!(t=String(e),hu.test(t)||function(e){return mu.test(e)}(String(e)));var t}));if(n.length)throw new w("font-size-invalid-use-of-named-presets",null,{presets:n});t.conversion.for("downcast").attributeToElement({model:pk,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:pk,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:pk,value:e=>{const t=e.getAttribute("size"),n="-"===t[0]||"+"===t[0];let i=parseInt(t,10);n&&(i=3+i);const o=Nk.length-1,r=Math.min(Math.max(i,0),o);return Nk[r]}}})}}var Lk=n(9875),Vk={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};jo()(Lk.Z,Vk);Lk.Z.locals;class Bk extends Io{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,n=this._getLocalizedOptions(),i=e.commands.get(pk);e.ui.componentFactory.add(pk,(o=>{const r=km(o);return vm(r,function(e,t){const n=new vo;for(const i of e){const e={type:"button",model:new Hm({commandName:pk,commandParam:i.model,label:i.title,class:"ck-fontsize-option",withText:!0})};i.view&&i.view.styles&&e.model.set("labelStyle",`font-size:${i.view.styles["font-size"]}`),i.view&&i.view.classes&&e.model.set("class",`${e.model.class} ${i.view.classes}`),e.model.bind("isOn").to(t,"value",(e=>e===i.model)),n.add(e)}return n}(n,i)),r.buttonView.set({label:t("Font Size"),icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),r.bind("isEnabled").to(i),this.listenTo(r,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),r}))}_getLocalizedOptions(){const e=this.editor,t=e.t,n={Default:t("Default"),Tiny:t("Tiny"),Small:t("Small"),Big:t("Big"),Huge:t("Huge")};return Mk(e.config.get(pk).options).map((e=>{const t=n[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class jk extends Io{static get requires(){return[Dk,Bk]}static get pluginName(){return"FontSize"}normalizeSizeOptions(e){return Mk(e)}}class zk extends uk{constructor(e){super(e,wk)}}class Fk extends Io{static get pluginName(){return"FontColorEditing"}constructor(e){super(e),e.config.define(wk,{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:wk,value:vk("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:wk,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:wk,view:yk("color")}),e.commands.add(wk,new zk(e)),e.model.schema.extend("$text",{allowAttributes:wk}),e.model.schema.setAttributeProperties(wk,{isFormatting:!0,copyOnEnter:!0})}}class Uk extends Io{constructor(e,{commandName:t,icon:n,componentName:i,dropdownLabel:o}){super(e),this.commandName=t,this.componentName=i,this.icon=n,this.dropdownLabel=o,this.columns=e.config.get(`${this.componentName}.columns`),this.colorTableView=void 0}init(){const e=this.editor,t=e.locale,n=t.t,i=e.commands.get(this.commandName),o=function(e){return e.map(Vh).filter((e=>!!e))}(e.config.get(this.componentName).colors),r=function(e,t){const n=e.t,i={Black:n("Black"),"Dim grey":n("Dim grey"),Grey:n("Grey"),"Light grey":n("Light grey"),White:n("White"),Red:n("Red"),Orange:n("Orange"),Yellow:n("Yellow"),"Light green":n("Light green"),Green:n("Green"),Aquamarine:n("Aquamarine"),Turquoise:n("Turquoise"),"Light blue":n("Light blue"),Blue:n("Blue"),Purple:n("Purple")};return t.map((e=>{const t=i[e.label];return t&&t!=e.label&&(e.label=t),e}))}(t,o),s=e.config.get(`${this.componentName}.documentColors`);e.ui.componentFactory.add(this.componentName,(t=>{const o=km(t);return this.colorTableView=function({dropdownView:e,colors:t,columns:n,removeButtonLabel:i,documentColorsLabel:o,documentColorsCount:r}){const s=e.locale,a=new gk(s,{colors:t,columns:n,removeButtonLabel:i,documentColorsLabel:o,documentColorsCount:r});return e.colorTableView=a,e.panelView.children.add(a),a.delegate("execute").to(e,"execute"),a}({dropdownView:o,colors:r.map((e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}}))),columns:this.columns,removeButtonLabel:n("Remove color"),documentColorsLabel:0!==s?n("Document colors"):void 0,documentColorsCount:void 0===s?this.columns:s}),this.colorTableView.bind("selectedColor").to(i,"value"),o.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),o.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),o.bind("isEnabled").to(i),o.on("execute",((t,n)=>{e.execute(this.commandName,n),e.editing.view.focus()})),o.on("change:isOpen",((t,n,i)=>{o.colorTableView.appendGrids(),i&&(0!==s&&this.colorTableView.updateDocumentColors(e.model,this.componentName),this.colorTableView.updateSelectedColors())})),ym(o,(()=>o.colorTableView.staticColorsGrid.items.find((e=>e.isOn)))),o}))}}class Hk extends Uk{constructor(e){const t=e.locale.t;super(e,{commandName:wk,componentName:wk,icon:'',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class Wk extends Io{static get requires(){return[Fk,Hk]}static get pluginName(){return"FontColor"}}class qk extends uk{constructor(e){super(e,kk)}}class Zk extends Io{static get pluginName(){return"FontBackgroundColorEditing"}constructor(e){super(e),e.config.define(kk,{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(Cu),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:kk,value:vk("background-color")}}),e.conversion.for("downcast").attributeToElement({model:kk,view:yk("background-color")}),e.commands.add(kk,new qk(e)),e.model.schema.extend("$text",{allowAttributes:kk}),e.model.schema.setAttributeProperties(kk,{isFormatting:!0,copyOnEnter:!0})}}class $k extends Uk{constructor(e){const t=e.locale.t;super(e,{commandName:kk,componentName:kk,icon:'',dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class Kk extends Io{static get requires(){return[Zk,$k]}static get pluginName(){return"FontBackgroundColor"}}class Gk extends Io{static get requires(){return[Pk,jk,Wk,Kk]}static get pluginName(){return"Font"}}function Yk(e,t,n,{blockElements:i,inlineObjectElements:o}){let r=n.createPositionAt(e,"forward"==t?"after":"before");return r=r.getLastMatchingPosition((({item:e})=>e.is("element")&&!i.includes(e.name)&&!o.includes(e.name)),{direction:t}),"forward"==t?r.nodeAfter:r.nodeBefore}function Qk(e,t){return!!e&&e.is("element")&&t.includes(e.name)}function Jk(e,t){if(!e.childCount)return;const n=new ou(e.document),i=function(e,t){const n=t.createRangeIn(e),i=new Xo({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),o=[];for(const e of n)if("elementStart"===e.type&&i.match(e.item)){const t=t_(e.item);o.push({element:e.item,id:t.id,order:t.order,indent:t.indent})}return o}(e,n);if(!i.length)return;let o=null,r=1;i.forEach(((e,s)=>{const a=function(e,t){if(!e)return!0;if(e.id!==t.id)return t.indent-e.indent!=1;const n=t.element.previousSibling;if(!n)return!0;return i=n,!(i.is("element","ol")||i.is("element","ul"));var i}(i[s-1],e),c=a?null:i[s-1],l=(u=e,(d=c)?u.indent-d.indent:u.indent-1);var d,u;if(a&&(o=null,r=1),!o||0!==l){const i=function(e,t){const n=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),i=/mso-level-number-format:([^;]{0,100});/gi,o=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,r=n.exec(t);let s="decimal",a="ol",c=null;if(r&&r[1]){const t=i.exec(r[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);return e.is("$text")?e:e.getChild(0)}}(e);if(!t)return null;const n=t._data;if("o"===n)return"circle";if("·"===n)return"disc";if("§"===n)return"square";return null}(e.element);t&&(s=t)}else{const e=o.exec(r[1]);e&&e[1]&&(c=parseInt(e[1]))}}return{type:a,startIndex:c,style:Xk(s)}}(e,t);if(o){if(e.indent>r){const e=o.getChild(o.childCount-1),t=e.getChild(e.childCount-1);o=e_(i,t,n),r+=1}else if(e.indent1&&n.setAttribute("start",e.startIndex,o),o}function t_(e){const t={},n=e.getStyle("mso-list");if(n){const e=n.match(/(^|\s{1,100})l(\d+)/i),i=n.match(/\s{0,100}lfo(\d+)/i),o=n.match(/\s{0,100}level(\d+)/i);e&&i&&o&&(t.id=e[2],t.order=i[1],t.indent=o[1])}return t}const n_=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class i_{constructor(e){this.document=e}isActive(e){return n_.test(e)}execute(e){const t=new ou(this.document),{body:n}=e._parsedData;!function(e,t){for(const n of e.getChildren())if(n.is("element","b")&&"normal"===n.getStyle("font-weight")){const i=e.getChildIndex(n);t.remove(n),t.insertChild(i,n.getChildren(),e)}}(n,t),function(e,t){for(const n of t.createRangeIn(e)){const e=n.item;if(e.is("element","li")){const n=e.getChild(0);n&&n.is("element","p")&&t.unwrapElement(n)}}}(n,t),function(e,t){const n=new ws(t.document.stylesProcessor),i=new ca(n,{renderingMode:"data"}),o=i.blockElements,r=i.inlineObjectElements,s=[];for(const n of t.createRangeIn(e)){const e=n.item;if(e.is("element","br")){const n=Yk(e,"forward",t,{blockElements:o,inlineObjectElements:r}),i=Yk(e,"backward",t,{blockElements:o,inlineObjectElements:r}),a=Qk(n,o);(Qk(i,o)||a)&&s.push(e)}}for(const e of s)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(n,t),e.content=n}}function o_(e,t){if(!e.childCount)return;const n=new ou,i=function(e,t){const n=t.createRangeIn(e),i=new Xo({name:/v:(.+)/}),o=[];for(const e of n){if("elementStart"!=e.type)continue;const t=e.item,n=t.previousSibling&&t.previousSibling.name||null;i.match(t)&&t.getAttribute("o:gfxdata")&&"v:shapetype"!==n&&o.push(e.item.getAttribute("id"))}return o}(e,n);!function(e,t,n){const i=n.createRangeIn(t),o=new Xo({name:"img"}),r=[];for(const t of i)if(o.match(t.item)){const n=t.item,i=n.getAttribute("v:shapes")?n.getAttribute("v:shapes").split(" "):[];i.length&&i.every((t=>e.indexOf(t)>-1))?r.push(n):n.getAttribute("src")||r.push(n)}for(const e of r)n.remove(e)}(i,e,n),function(e,t){const n=t.createRangeIn(e),i=new Xo({name:/v:(.+)/}),o=[];for(const e of n)"elementStart"==e.type&&i.match(e.item)&&o.push(e.item);for(const e of o)t.remove(e)}(e,n);const o=function(e,t){const n=t.createRangeIn(e),i=new Xo({name:"img"}),o=[];for(const e of n)i.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&o.push(e.item);return o}(e,n);o.length&&function(e,t,n){if(e.length===t.length)for(let i=0;iString.fromCharCode(parseInt(e,16)))).join(""))}const s_=//i,a_=/xmlns:o="urn:schemas-microsoft-com/i;class c_{constructor(e){this.document=e}isActive(e){return s_.test(e)||a_.test(e)}execute(e){const{body:t,stylesString:n}=e._parsedData;Jk(t,n),o_(t,e.dataTransfer.getData("text/rtf")),e.content=t}}function l_(e){return e.replace(/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length)))}function d_(e,t){const n=new DOMParser,i=function(e){return l_(l_(e)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/ <\//g," <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(e){const t="",n="",i=e.indexOf(t);if(i<0)return e;const o=e.indexOf(n,i+t.length);return e.substring(0,i+t.length)+(o>=0?e.substring(o):"")}(e=e.replace(//g,"")}(i.getData("text/html")):i.getData("text/plain")&&(((r=(r=i.getData("text/plain")).replace(//g,">").replace(/\r?\n\r?\n/g,"

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

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

${r}

`),e=r),o=this.editor.data.htmlProcessor.toView(e)}var r;const s=new f(this,"inputTransformation");this.fire(s,{content:o,dataTransfer:i,targetRanges:t.targetRanges,method:t.method}),s.stop.called&&e.stop(),n.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,n)=>{if(n.content.isEmpty)return;const i=this.editor.data.toModel(n.content,"$clipboardHolder");0!=i.childCount&&(e.stop(),t.change((()=>{this.fire("contentInsertion",{content:i,method:n.method,dataTransfer:n.dataTransfer,targetRanges:n.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,n)=>{n.resultRange=t.insertContent(n.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,n=e.editing.view.document,i=(i,o)=>{const r=o.dataTransfer;o.preventDefault();const s=e.data.toView(e.model.getSelectedContent(t.selection));n.fire("clipboardOutput",{dataTransfer:r,content:s,method:i.name})};this.listenTo(n,"copy",i,{priority:"low"}),this.listenTo(n,"cut",((t,n)=>{e.isReadOnly?n.preventDefault():i(t,n)}),{priority:"low"}),this.listenTo(n,"clipboardOutput",((n,i)=>{i.content.isEmpty||(i.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(i.content)),i.dataTransfer.setData("text/plain",xb(i.content))),"cut"==i.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}const Cb=function(e,t,n){var i=!0,o=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return V(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),Oa(e,t,{leading:i,maxWait:t,trailing:o})};var Eb=n(3352),Tb={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};zo()(Eb.Z,Tb);Eb.Z.locals;class Sb extends Oo{static get pluginName(){return"DragDrop"}static get requires(){return[Ab,Tg]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=Cb((e=>this._updateDropMarker(e)),40),this._removeDropMarkerDelayed=Ob((()=>this._removeDropMarker()),40),this._clearDraggableAttributesDelayed=Ob((()=>this._clearDraggableAttributes()),40),t.addObserver(vb),t.addObserver(au),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",((e,t,n)=>{n?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((e,t,n)=>{n||this._finalizeDragging(!1)})),r.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._updateDropMarkerThrottled.cancel(),this._removeDropMarkerDelayed.cancel(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,n=t.document,i=e.editing.view,o=i.document;this.listenTo(o,"dragstart",((i,r)=>{const s=n.selection;if(r.target&&r.target.is("editableElement"))return void r.preventDefault();const a=r.target?Mb(r.target):null;if(a){const n=e.editing.mapper.toModelElement(a);this._draggedRange=Lc.fromRange(t.createRangeOn(n)),e.plugins.has("WidgetToolbarRepository")&&e.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}else if(!o.selection.isCollapsed){const e=o.selection.getSelectedElement();e&&rg(e)||(this._draggedRange=Lc.fromRange(s.getFirstRange()))}if(!this._draggedRange)return void r.preventDefault();this._draggingUid=g(),r.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",r.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const c=t.createSelection(this._draggedRange.toRange()),l=e.data.toView(t.getSelectedContent(c));o.fire("clipboardOutput",{dataTransfer:r.dataTransfer,content:l,method:"dragstart"}),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(o,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this.listenTo(o,"dragenter",(()=>{this.isEnabled&&i.focus()})),this.listenTo(o,"dragleave",(()=>{this._removeDropMarkerDelayed()})),this.listenTo(o,"dragging",((t,n)=>{if(!this.isEnabled)return void(n.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const i=Pb(e,n.targetRanges,n.target);this._draggedRange||(n.dataTransfer.dropEffect="copy"),r.isGecko||("copy"==n.dataTransfer.effectAllowed?n.dataTransfer.dropEffect="copy":["all","copyMove"].includes(n.dataTransfer.effectAllowed)&&(n.dataTransfer.dropEffect="move")),i&&this._updateDropMarkerThrottled(i)}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"clipboardInput",((t,n)=>{if("drop"!=n.method)return;const i=Pb(e,n.targetRanges,n.target);if(this._removeDropMarker(),!i)return this._finalizeDragging(!1),void t.stop();this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==Ib(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(i,!0))return this._finalizeDragging(!1),void t.stop();n.targetRanges=[e.editing.mapper.toViewRange(i)]}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(Ab);e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const n=t.targetRanges.map((e=>this.editor.editing.mapper.toModelRange(e)));this.editor.model.change((e=>e.setSelection(n)))}),{priority:"high"}),e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const n="move"==Ib(t.dataTransfer),i=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(i&&n)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,n=t.document;this.listenTo(n,"mousedown",((i,o)=>{if(r.isAndroid||!o)return;this._clearDraggableAttributesDelayed.cancel();let s=Mb(o.target);if(r.isBlink&&!e.isReadOnly&&!s&&!n.selection.isCollapsed){const e=n.selection.getSelectedElement();e&&rg(e)||(s=n.selection.editableElement)}s&&(t.change((e=>{e.setAttribute("draggable","true",s)})),this._draggableElement=e.editing.mapper.toModelElement(s))})),this.listenTo(n,"mouseup",(()=>{r.isAndroid||this._clearDraggableAttributesDelayed()}))}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change((t=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null}))}_setupDropMarker(){const e=this.editor;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:n})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return n.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(e){const t=this.toDomElement(e);return t.append("⁠",e.createElement("span"),"⁠"),t}))}})}_updateDropMarker(e){const t=this.editor,n=t.model.markers;t.model.change((t=>{n.has("drop-target")?n.get("drop-target").getRange().isEqual(e)||t.updateMarker("drop-target",{range:e}):t.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})}))}_removeDropMarker(){const e=this.editor.model;this._removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),e.markers.has("drop-target")&&e.change((e=>{e.removeMarker("drop-target")}))}_finalizeDragging(e){const t=this.editor,n=t.model;this._removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._draggedRange&&(e&&this.isEnabled&&n.deleteContent(n.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function Pb(e,t,n){const i=e.model,o=e.editing.mapper;let s=null;const a=t?t[0].start:null;if(n.is("uiElement")&&(n=n.parent),s=function(e,t){const n=e.model,i=e.editing.mapper;if(rg(t))return n.createRangeOn(i.toModelElement(t));if(!t.is("editableElement")){const e=t.findAncestor((e=>rg(e)||e.is("editableElement")));if(rg(e))return n.createRangeOn(i.toModelElement(e))}return null}(e,n),s)return s;const c=function(e,t){const n=e.editing.mapper,i=e.editing.view,o=n.toModelElement(t);if(o)return o;const r=i.createPositionBefore(t),s=n.findMappedViewAncestor(r);return n.toModelElement(s)}(e,n),l=a?o.toModelPosition(a):null;return l?(s=function(e,t,n){const i=e.model;if(!i.schema.checkChild(n,"$block"))return null;const o=i.createPositionAt(n,0),r=t.path.slice(0,o.path.length),s=i.createPositionFromPath(t.root,r),a=s.nodeAfter;if(a&&i.schema.isObject(a))return i.createRangeOn(a);return null}(e,l,c),s||(s=i.schema.getNearestSelectionRange(l,r.isGecko?"forward":"backward"),s||function(e,t){const n=e.model;let i=t;for(;i;){if(n.schema.isObject(i))return n.createRangeOn(i);i=i.parent}return null}(e,l.parent))):function(e,t){const n=e.model,i=n.schema,o=n.createPositionAt(t,0);return i.getNearestSelectionRange(o,"forward")}(e,c)}function Ib(e){return r.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function Ob(e,t){let n;function i(...o){i.cancel(),n=setTimeout((()=>e(...o)),t)}return i.cancel=()=>{clearTimeout(n)},i}function Mb(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(rg);if(rg(e))return e;const t=e.findAncestor((e=>rg(e)||e.is("editableElement")));return rg(t)?t:null}class Rb extends Oo{static get pluginName(){return"PastePlainText"}static get requires(){return[Ab]}init(){const e=this.editor,t=e.model,n=e.editing.view,i=n.document,o=t.document.selection;let r=!1;n.addObserver(vb),this.listenTo(i,"keydown",((e,t)=>{r=t.shiftKey})),e.plugins.get(Ab).on("contentInsertion",((e,n)=>{(r||function(e,t){if(e.childCount>1)return!1;const n=e.getChild(0);if(t.isObject(n))return!1;return 0==Array.from(n.getAttributeKeys()).length}(n.content,t.schema))&&t.change((e=>{const i=Array.from(o.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0}),i.push(...o.getAttributes());const r=e.createRangeIn(n.content);for(const t of r.getItems())t.is("$textProxy")&&e.setAttributes(i,t)}))}))}}class Nb extends Oo{static get pluginName(){return"Clipboard"}static get requires(){return[Ab,Sb,Rb]}}class Db extends Ro{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let n=e.schema.getLimitElement(t);if(t.containsEntireContent(n)||!Lb(e.schema,n))do{if(n=n.parent,!n)return}while(!Lb(e.schema,n));e.change((e=>{e.setSelection(n,"in")}))}}function Lb(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const Vb=mo("Ctrl+A");class jb extends Oo{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new Db(e)),this.listenTo(t,"keydown",((t,n)=>{fo(n)===Vb&&(e.execute("selectAll"),n.preventDefault())}))}}class Bb extends Oo{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(t=>{const n=e.commands.get("selectAll"),i=new Vh(t),o=t.t;return i.set({label:o("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),i.bind("isEnabled").to(n,"isEnabled"),this.listenTo(i,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),i}))}}class zb extends Oo{static get requires(){return[jb,Bb]}static get pluginName(){return"SelectAll"}}class Fb extends Ro{constructor(e){super(e),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),this.listenTo(e.data,"set",((e,t)=>{t[1]={...t[1]};const n=t[1];n.batchType||(n.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}addBatch(e){const t=this.editor.model.document.selection,n={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:n}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,n){const i=this.editor.model,o=i.document,r=[],s=e.map((e=>e.getTransformedByOperations(n))),a=s.flat();for(const e of s){const t=e.filter((e=>e.root!=o.graveyard)).filter((e=>!Ub(e,a)));t.length&&(Hb(t),r.push(t[0]))}r.length&&i.change((e=>{e.setSelection(r,{backward:t})}))}_undo(e,t){const n=this.editor.model,i=n.document;this._createdBatches.add(t);const o=e.operations.slice().filter((e=>e.isDocumentOperation));o.reverse();for(const e of o){const o=e.baseVersion+1,r=Array.from(i.history.getOperations(o)),s=dd([e.getReversed()],r,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(const o of s)t.addOperation(o),n.applyOperation(o),i.history.setOperationAsUndone(e,o)}}}function Hb(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}class Wb extends Fb{execute(e=null){const t=e?this._stack.findIndex((t=>t.batch==e)):this._stack.length-1,n=this._stack.splice(t,1)[0],i=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(i,(()=>{this._undo(n.batch,i);const e=this.editor.model.document.history.getOperations(n.batch.baseVersion);this._restoreSelection(n.selection.ranges,n.selection.isBackward,e),this.fire("revert",n.batch,i)})),this.refresh()}}class qb extends Fb{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(t,(()=>{const n=e.batch.operations[e.batch.operations.length-1].baseVersion+1,i=this.editor.model.document.history.getOperations(n);this._restoreSelection(e.selection.ranges,e.selection.isBackward,i),this._undo(e.batch,t)})),this.refresh()}}class Zb extends Oo{static get pluginName(){return"UndoEditing"}constructor(e){super(e),this._batchRegistry=new WeakSet}init(){const e=this.editor;this._undoCommand=new Wb(e),this._redoCommand=new qb(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",((e,t)=>{const n=t[0];if(!n.isDocumentOperation)return;const i=n.batch,o=this._redoCommand._createdBatches.has(i),r=this._undoCommand._createdBatches.has(i);this._batchRegistry.has(i)||(this._batchRegistry.add(i),i.isUndoable&&(o?this._undoCommand.addBatch(i):r||(this._undoCommand.addBatch(i),this._redoCommand.clearStack())))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((e,t,n)=>{this._redoCommand.addBatch(n)})),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo")}}const $b='',Kb='';class Gb extends Oo{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,n=e.t,i="ltr"==t.uiLanguageDirection?$b:Kb,o="ltr"==t.uiLanguageDirection?Kb:$b;this._addButton("undo",n("Undo"),"CTRL+Z",i),this._addButton("redo",n("Redo"),"CTRL+Y",o)}_addButton(e,t,n,i){const o=this.editor;o.ui.componentFactory.add(e,(r=>{const s=o.commands.get(e),a=new Vh(r);return a.set({label:t,icon:i,keystroke:n,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",(()=>{o.execute(e),o.editing.view.focus()})),a}))}}class Yb extends Oo{static get requires(){return[Zb,Gb]}static get pluginName(){return"Undo"}}class Qb extends Oo{static get requires(){return[Nb,$m,zb,Qm,Im,Yb]}static get pluginName(){return"Essentials"}}class Jb extends Ro{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,n=t.schema,i=t.document.selection,o=Array.from(i.getSelectedBlocks()),r=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(r){const t=o.filter((e=>Xb(e)||tw(n,e)));this._applyQuote(e,t)}else this._removeQuote(e,o.filter(Xb))}))}_getValue(){const e=xo(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!Xb(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,n=xo(e.getSelectedBlocks());return!!n&&tw(t,n)}_removeQuote(e,t){ew(e,t).reverse().forEach((t=>{if(t.start.isAtStart&&t.end.isAtEnd)return void e.unwrap(t.start.parent);if(t.start.isAtStart){const n=e.createPositionBefore(t.start.parent);return void e.move(t,n)}t.end.isAtEnd||e.split(t.end);const n=e.createPositionAfter(t.end.parent);e.move(t,n)}))}_applyQuote(e,t){const n=[];ew(e,t).reverse().forEach((t=>{let i=Xb(t.start);i||(i=e.createElement("blockQuote"),e.wrap(t,i)),n.push(i)})),n.reverse().reduce(((t,n)=>t.nextSibling==n?(e.merge(e.createPositionAfter(t)),t):n))}}function Xb(e){return"blockQuote"==e.parent.name?e.parent:null}function ew(e,t){let n,i=0;const o=[];for(;i{const i=e.model.document.differ.getChanges();for(const e of i)if("insert"==e.type){const i=e.position.nodeAfter;if(!i)continue;if(i.is("element","blockQuote")&&i.isEmpty)return n.remove(i),!0;if(i.is("element","blockQuote")&&!t.checkChild(e.position,i))return n.unwrap(i),!0;if(i.is("element")){const e=n.createRangeIn(i);for(const i of e.getItems())if(i.is("element","blockQuote")&&!t.checkChild(n.createPositionBefore(i),i))return n.unwrap(i),!0}}else if("remove"==e.type){const t=e.position.parent;if(t.is("element","blockQuote")&&t.isEmpty)return n.remove(t),!0}return!1}));const n=this.editor.editing.view.document,i=e.model.document.selection,o=e.commands.get("blockQuote");this.listenTo(n,"enter",((t,n)=>{if(!i.isCollapsed||!o.value)return;i.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())}),{context:"blockquote"}),this.listenTo(n,"delete",((t,n)=>{if("backward"!=n.direction||!i.isCollapsed||!o.value)return;const r=i.getLastPosition().parent;r.isEmpty&&!r.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())}),{context:"blockquote"})}}var iw=n(5558),ow={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};zo()(iw.Z,ow);iw.Z.locals;class rw extends Oo{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",(n=>{const i=e.commands.get("blockQuote"),o=new Vh(n);return o.set({label:t("Block quote"),icon:Eh.quote,tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(i,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),o}))}}class sw extends Oo{static get requires(){return[nw,rw]}static get pluginName(){return"BlockQuote"}}function aw(e){const t=e.t,n=e.config.get("codeBlock.languages");for(const e of n)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class=`language-${e.language}`);return n}function cw(e,t,n){const i={};for(const o of e)"class"===t?i[o[t].split(" ").shift()]=o[n]:i[o[t]]=o[n];return i}function lw(e){return e.data.match(/^(\s*)/)[0]}function dw(e){const t=e.document.selection,n=[];if(t.isCollapsed)n.push(t.anchor);else{const i=t.getFirstRange().getWalker({ignoreElementEnd:!0,direction:"backward"});for(const{item:t}of i)if(t.is("$textProxy")&&t.parent.is("element","codeBlock")){const i=lw(t.textNode),{parent:o,startOffset:r}=t.textNode,s=e.createPositionAt(o,r+i.length);n.push(s)}}return n}function uw(e){const t=xo(e.getSelectedBlocks());return t&&t.is("element","codeBlock")}function hw(e,t){return!t.is("rootElement")&&!e.isLimit(t)&&e.checkChild(t.parent,"codeBlock")}class fw extends Ro{constructor(e){super(e),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,n=t.model,i=n.document.selection,o=aw(t)[0],r=Array.from(i.getSelectedBlocks()),s=void 0===e.forceValue?!this.value:e.forceValue,a=function(e,t,n){if(e.language)return e.language;if(e.usePreviousLanguageChoice&&t)return t;return n}(e,this._lastLanguage,o.language);n.change((e=>{s?this._applyCodeBlock(e,r,a):this._removeCodeBlock(e,r)}))}_getValue(){const e=xo(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,n=xo(e.getSelectedBlocks());return!!n&&hw(t,n)}_applyCodeBlock(e,t,n){this._lastLanguage=n;const i=this.editor.model.schema,o=t.filter((e=>hw(i,e)));for(const t of o)e.rename(t,"codeBlock"),e.setAttribute("language",n,t),i.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter((e=>!i.checkChild(t,e))).forEach((t=>e.remove(t)));o.reverse().forEach(((t,n)=>{const i=o[n+1];t.previousSibling===i&&(e.appendElement("softBreak",i),e.merge(e.createPositionBefore(t)))}))}_removeCodeBlock(e,t){const n=t.filter((e=>e.is("element","codeBlock")));for(const t of n){const n=e.createRangeOn(t);for(const t of Array.from(n.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:n}=e.split(e.createPositionBefore(t));e.rename(n.nodeAfter,"paragraph"),e.removeAttribute("language",n.nodeAfter),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}class mw extends Ro{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 n=dw(e);for(const i of n){const n=t.createText(this._indentSequence);e.insertContent(n,i)}}))}_checkEnabled(){return!!this._indentSequence&&uw(this.editor.model.document.selection)}}class gw extends Ro{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=dw(e);for(const n of t){const t=pw(e,n,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!uw(e.document.selection)&&dw(e).some((t=>pw(e,t,this._indentSequence)))}}function pw(e,t,n){const i=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(!i)return null;const o=lw(i),r=o.lastIndexOf(n);if(r+n.length!==o.length)return null;if(-1===r)return null;const{parent:s,startOffset:a}=i;return e.createRange(e.createPositionAt(s,a+r),e.createPositionAt(s,a+r+n.length))}function bw(e,t,n=!1){const i=cw(t,"language","class"),o=cw(t,"language","label");return(t,r,s)=>{const{writer:a,mapper:c,consumable:l}=s;if(!l.consume(r.item,"insert"))return;const d=r.item.getAttribute("language"),u=c.toViewPosition(e.createPositionBefore(r.item)),h={};n&&(h["data-language"]=o[d],h.spellcheck="false");const f=a.createContainerElement("code",{class:i[d]||null}),m=a.createContainerElement("pre",h,f);a.insert(u,m),c.bindElements(r.item,f)}}const ww="paragraph";class kw extends Oo{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[Qm]}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,n=e.model,i=e.editing.view,o=e.plugins.has("DocumentListEditing"),r=aw(e);e.commands.add("codeBlock",new fw(e)),e.commands.add("indentCodeBlock",new mw(e)),e.commands.add("outdentCodeBlock",new gw(e)),this.listenTo(i.document,"tab",((t,n)=>{const i=n.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(i).isEnabled&&(e.execute(i),n.stopPropagation(),n.preventDefault(),t.stop())}),{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",isBlock:!0,allowAttributes:["language"]}),t.addAttributeCheck(((e,t)=>{const n=e.endsWith("codeBlock")&&t.startsWith("list")&&"list"!==t;return!(!o||!n)||!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",bw(n,r,!0)),e.data.downcastDispatcher.on("insert:codeBlock",bw(n,r)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,n,i)=>{if("codeBlock"!==n.item.parent.name)return;const{writer:o,mapper:r,consumable:s}=i;if(!s.consume(n.item,"insert"))return;const a=r.toViewPosition(e.createPositionBefore(n.item));o.insert(a,o.createText("\n"))}}(n),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const n=cw(t,"class","language"),i=t[0].language;return(e,t,o)=>{const r=t.viewItem,s=r.parent;if(!s||!s.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:c}=o;if(!a.test(r,{name:!0}))return;const l=c.createElement("codeBlock"),d=[...r.getClassNames()];d.length||d.push("");for(const e of d){const t=n[e];if(t){c.setAttribute("language",t,l);break}}l.hasAttribute("language")||c.setAttribute("language",i,l),o.convertChildren(r,l),o.safeInsert(l,t.modelCursor)&&(a.consume(r,{name:!0}),o.updateConversionResult(l,t))}}(0,r)),e.data.upcastDispatcher.on("text",((e,t,{consumable:n,writer:i})=>{let o=t.modelCursor;if(!n.test(t.viewItem))return;if(!o.findAncestor("codeBlock"))return;n.consume(t.viewItem);const r=t.viewItem.data.split("\n").map((e=>i.createText(e))),s=r[r.length-1];for(const e of r)if(i.insert(e,o),o=o.getShiftedBy(e.offsetSize),e!==s){const e=i.createElement("softBreak");i.insert(e,o),o=i.createPositionAfter(e)}t.modelRange=i.createRange(t.modelCursor,o),t.modelCursor=o})),e.data.upcastDispatcher.on("element:pre",((e,t,{consumable:n})=>{const i=t.viewItem;if(i.findAncestor("pre"))return;const o=Array.from(i.getChildren()),r=o.find((e=>e.is("element","code")));if(r)for(const e of o)e!==r&&e.is("$text")&&n.consume(e,{name:!0})}),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,i)=>{let o=n.createRange(n.document.selection.anchor);if(i.targetRanges&&(o=e.editing.mapper.toModelRange(i.targetRanges[0])),!o.start.parent.is("element","codeBlock"))return;const r=i.dataTransfer.getData("text/plain"),s=new cu(e.editing.view.document);i.content=function(e,t){const n=e.createDocumentFragment(),i=t.split("\n"),o=i.reduce(((t,n,o)=>(t.push(n),o{const o=i.anchor;!i.isCollapsed&&o.parent.is("element","codeBlock")&&o.hasSameParentAs(i.focus)&&n.change((n=>{const r=e.return;if(r.childCount>1||i.containsEntireContent(o.parent)){const t=n.createElement("codeBlock",o.parent.getAttributes());n.append(r,t);const i=n.createDocumentFragment();n.append(t,i),e.return=i}else{const e=r.getChild(0);t.checkAttribute(e,"code")&&n.setAttribute("code",!0,e)}}))}))}afterInit(){const e=this.editor,t=e.commands,n=t.get("indent"),i=t.get("outdent");n&&n.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),i&&i.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",((t,n)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const n=e.model,i=n.document,o=e.editing.view,r=i.selection.getLastPosition(),s=r.nodeAfter;if(t||!i.selection.isCollapsed||!r.isAtStart)return!1;if(!vw(s))return!1;return e.model.change((t=>{e.execute("enter");const n=i.selection.anchor.parent.previousSibling;t.rename(n,ww),t.setSelection(n,"in"),e.model.schema.removeDisallowedAttributes([n],t),t.remove(s)})),o.scrollToTheSelection(),!0}(e,n.isSoft)||function(e,t){const n=e.model,i=n.document,o=e.editing.view,r=i.selection.getLastPosition(),s=r.nodeBefore;let a;if(t||!i.selection.isCollapsed||!r.isAtEnd||!s||!s.previousSibling)return!1;if(vw(s)&&vw(s.previousSibling))a=n.createRange(n.createPositionBefore(s.previousSibling),n.createPositionAfter(s));else if(_w(s)&&vw(s.previousSibling)&&vw(s.previousSibling.previousSibling))a=n.createRange(n.createPositionBefore(s.previousSibling.previousSibling),n.createPositionAfter(s));else{if(!(_w(s)&&vw(s.previousSibling)&&_w(s.previousSibling.previousSibling)&&vw(s.previousSibling.previousSibling.previousSibling)))return!1;a=n.createRange(n.createPositionBefore(s.previousSibling.previousSibling.previousSibling),n.createPositionAfter(s))}return e.model.change((t=>{t.remove(a),e.execute("enter");const n=i.selection.anchor.parent;t.rename(n,ww),e.model.schema.removeDisallowedAttributes([n],t)})),o.scrollToTheSelection(),!0}(e,n.isSoft)||function(e){const t=e.model,n=t.document,i=n.selection.getLastPosition(),o=i.nodeBefore||i.textNode;let r;o&&o.is("$text")&&(r=lw(o));e.model.change((t=>{e.execute("shiftEnter"),r&&t.insertText(r,n.selection.anchor)}))}(e),n.preventDefault(),t.stop())}),{context:"pre"})}}function _w(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function vw(e){return e&&e.is("element","softBreak")}var yw=n(348),xw={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};zo()(yw.Z,xw);yw.Z.locals;class Aw extends Oo{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,n=e.ui.componentFactory,i=aw(e);n.add("codeBlock",(n=>{const o=e.commands.get("codeBlock"),r=Af(n,Yh),s=r.buttonView;return s.set({label:t("Insert code block"),tooltip:!0,icon:'',isToggleable:!0}),s.bind("isOn").to(o,"value",(e=>!!e)),s.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()})),r.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),r.class="ck-code-block-dropdown",r.bind("isEnabled").to(o),Ef(r,this._getLanguageListItemDefinitions(i)),r}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),n=new yo;for(const i of e){const e={type:"button",model:new Kf({_codeBlockLanguage:i.language,label:i.label,withText:!0})};e.model.bind("isOn").to(t,"value",(t=>t===e.model._codeBlockLanguage)),n.add(e)}return n}}class Cw extends Oo{static get requires(){return[kw,Aw]}static get pluginName(){return"CodeBlock"}}class Ew extends Ro{refresh(){const e=this.editor.model,t=xo(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&Tw(t,e.schema)}execute(e={}){const t=this.editor.model,n=t.document;t.change((i=>{const o=(e.selection||n.selection).getSelectedBlocks();for(const e of o)!e.is("element","paragraph")&&Tw(e,t.schema)&&i.rename(e,"paragraph")}))}}function Tw(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class Sw extends Ro{execute(e){const t=this.editor.model,n=e.attributes;let i=e.position;t.change((e=>{const o=e.createElement("paragraph");if(n&&t.schema.setAllowedAttributes(o,n,e),!t.schema.checkChild(i.parent,o)){const n=t.schema.findAllowedParent(i,o);if(!n)return;i=e.split(i,n).position}t.insertContent(o,i),e.setSelection(o,"in")}))}}class Pw extends Oo{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new Ew(e)),e.commands.add("insertParagraph",new Sw(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>Pw.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}Pw.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class Iw extends Ro{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=xo(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>Ow(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,n=t.document,i=e.value;t.change((e=>{const o=Array.from(n.selection.getSelectedBlocks()).filter((e=>Ow(e,i,t.schema)));for(const t of o)t.is("element",i)||e.rename(t,i)}))}}function Ow(e,t,n){return n.checkChild(e.parent,t)&&!n.isObject(e)}const Mw="paragraph";class Rw extends Oo{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[Pw]}init(){const e=this.editor,t=e.config.get("heading.options"),n=[];for(const i of t)i.model!==Mw&&(e.model.schema.register(i.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(i),n.push(i.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new Iw(e,n))}afterInit(){const e=this.editor,t=e.commands.get("enter"),n=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,i)=>{const o=e.model.document.selection.getFirstPosition().parent;n.some((e=>o.is("element",e.model)))&&!o.is("element",Mw)&&0===o.childCount&&i.writer.rename(o,Mw)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:p.get("low")+1})}}var Nw=n(4684),Dw={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};zo()(Nw.Z,Dw);Nw.Z.locals;class Lw extends Oo{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,n=function(e){const t=e.t,n={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=n[e.title];return t&&t!=e.title&&(e.title=t),e}))}(e),i=t("Choose heading"),o=t("Heading");e.ui.componentFactory.add("heading",(t=>{const r={},s=new yo,a=e.commands.get("heading"),c=e.commands.get("paragraph"),l=[a];for(const e of n){const t={type:"button",model:new Kf({label:e.title,class:e.class,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),r[e.model]=e.title}const d=Af(t);return Ef(d,s),d.buttonView.set({isOn:!1,withText:!0,tooltip:o}),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 n=e||t&&"paragraph";return r[n]?r[n]:i})),this.listenTo(d,"execute",(t=>{e.execute(t.source.commandName,t.source.commandValue?{value:t.source.commandValue}:void 0),e.editing.view.focus()})),d}))}}class Vw extends Oo{static get requires(){return[Rw,Lw]}static get pluginName(){return"Heading"}}class jw extends Ro{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,n=t.document,i=Array.from(n.selection.getSelectedBlocks()).filter((e=>zw(e,t.schema))),o=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(o){let t=i[i.length-1].nextSibling,n=Number.POSITIVE_INFINITY,o=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=n;)r>o.getAttribute("listIndent")&&(r=o.getAttribute("listIndent")),o.getAttribute("listIndent")==r&&e[t?"unshift":"push"](o),o=o[t?"previousSibling":"nextSibling"]}}function zw(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class Fw extends Ro{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 n=Array.from(t.selection.getSelectedBlocks());e.change((e=>{const t=n[n.length-1];let i=t.nextSibling;for(;i&&"listItem"==i.name&&i.getAttribute("listIndent")>t.getAttribute("listIndent");)n.push(i),i=i.nextSibling;this._indentBy<0&&(n=n.reverse());for(const t of n){const n=t.getAttribute("listIndent")+this._indentBy;n<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",n,t)}this.fire("_executeCleanup",n)}))}_checkEnabled(){const e=xo(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("element","listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),n=e.getAttribute("listType");let i=e.previousSibling;for(;i&&i.is("element","listItem")&&i.getAttribute("listIndent")>=t;){if(i.getAttribute("listIndent")==t)return i.getAttribute("listType")==n;i=i.previousSibling}return!1}return!0}}function Hw(e,t){const n=t.mapper,i=t.writer,o="numbered"==e.getAttribute("listType")?"ol":"ul",r=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=Qw,t}(i),s=i.createContainerElement(o,null);return i.insert(i.createPositionAt(s,0),r),n.bindElements(e,r),r}function Uw(e,t,n,i){const o=t.parent,r=n.mapper,s=n.writer;let a=r.toViewPosition(i.createPositionBefore(e));const c=Zw(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),l=e.previousSibling;if(c&&c.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=r.toViewElement(c);a=s.breakContainer(s.createPositionAfter(e))}else if(l&&"listItem"==l.name){a=r.toViewPosition(i.createPositionAt(l,"end"));const e=r.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=r.toViewPosition(i.createPositionBefore(e));if(a=qw(a),s.insert(a,o),l&&"listItem"==l.name){const e=r.toViewElement(l),n=s.createRange(s.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of n)if(e.item.is("element","li")){const i=s.breakContainer(s.createPositionBefore(e.item)),o=e.item.parent,r=s.createPositionAt(t,"end");Ww(s,r.nodeBefore,r.nodeAfter),s.move(s.createRangeOn(o),r),n.position=i}}else{const n=o.nextSibling;if(n&&(n.is("element","ul")||n.is("element","ol"))){let i=null;for(const t of n.getChildren()){const n=r.toModelElement(t);if(!(n&&n.getAttribute("listIndent")>e.getAttribute("listIndent")))break;i=t}i&&(s.breakContainer(s.createPositionAfter(i)),s.move(s.createRangeOn(i.parent),s.createPositionAt(t,"end")))}}Ww(s,o,o.nextSibling),Ww(s,o.previousSibling,o)}function Ww(e,t,n){return!t||!n||"ul"!=t.name&&"ol"!=t.name||t.name!=n.name||t.getAttribute("class")!==n.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function qw(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function Zw(e,t){const n=!!t.sameIndent,i=!!t.smallerIndent,o=t.listIndent;let r=e;for(;r&&"listItem"==r.name;){const e=r.getAttribute("listIndent");if(n&&o==e||i&&o>e)return r;r="forward"===t.direction?r.nextSibling:r.previousSibling}return null}function $w(e,t,n,i){e.ui.componentFactory.add(t,(o=>{const r=e.commands.get(t),s=new Vh(o);return s.set({label:n,icon:i,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),s}))}function Kw(e,t){const n=[],i=e.parent,o={ignoreElementEnd:!1,startPosition:e,shallow:!0,direction:t},r=i.getAttribute("listIndent"),s=[...new pc(o)].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")r)){if(e.getAttribute("listType")!==i.getAttribute("listType"))break;if(e.getAttribute("listStyle")!==i.getAttribute("listStyle"))break;if(e.getAttribute("listReversed")!==i.getAttribute("listReversed"))break;if(e.getAttribute("listStart")!==i.getAttribute("listStart"))break;"backward"===t?n.unshift(e):n.push(e)}}return n}const Gw=["disc","circle","square"],Yw=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function Qw(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:ns.call(this)}class Jw extends Oo{static get pluginName(){return"ListUtils"}getListTypeFromListStyleType(e){return function(e){return Gw.includes(e)?"bulleted":Yw.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 n=e.change((e=>e.createPositionAt(t,0)));return[...Kw(n,"backward"),...Kw(n,"forward")]})).flat();return t=[...new Set(t)],t}(e)}getSiblingNodes(e,t){return Kw(e,t)}}function Xw(e){return(t,n,i)=>{const o=i.consumable;if(!o.test(n.item,"insert")||!o.test(n.item,"attribute:listType")||!o.test(n.item,"attribute:listIndent"))return;o.consume(n.item,"insert"),o.consume(n.item,"attribute:listType"),o.consume(n.item,"attribute:listIndent");const r=n.item;Uw(r,Hw(r,i),i,e)}}function ek(e,t,n){if(!n.consumable.test(t.item,e.name))return;const i=n.mapper.toViewElement(t.item),o=n.writer;o.breakContainer(o.createPositionBefore(i)),o.breakContainer(o.createPositionAfter(i));const r=i.parent,s="numbered"==t.attributeNewValue?"ol":"ul";o.rename(s,r)}function tk(e,t,n){n.consumable.consume(t.item,e.name);const i=n.mapper.toViewElement(t.item).parent,o=n.writer;Ww(o,i,i.nextSibling),Ww(o,i.previousSibling,i)}function nk(e,t,n){if(n.consumable.test(t.item,e.name)&&"listItem"!=t.item.name){let e=n.mapper.toViewPosition(t.range.start);const i=n.writer,o=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=i.breakContainer(e),"li"==e.parent.name);){const t=e,n=i.createPositionAt(e.parent,"end");if(!t.isEqual(n)){const e=i.remove(i.createRange(t,n));o.push(e)}e=i.createPositionAfter(e.parent)}if(o.length>0){for(let t=0;t0){const t=Ww(i,n,n.nextSibling);t&&t.parent==n&&e.offset--}}Ww(i,e.nodeBefore,e.nodeAfter)}}}function ik(e,t,n){const i=n.mapper.toViewPosition(t.position),o=i.nodeBefore,r=i.nodeAfter;Ww(n.writer,o,r)}function ok(e,t,n){if(n.consumable.consume(t.viewItem,{name:!0})){const e=n.writer,i=e.createElement("listItem"),o=function(e){let t=0,n=e.parent;for(;n;){if(n.is("element","li"))t++;else{const e=n.previousSibling;e&&e.is("element","li")&&t++}n=n.parent}return t}(t.viewItem);e.setAttribute("listIndent",o,i);const r=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",r,i),!n.safeInsert(i,t.modelCursor))return;const s=function(e,t,n){const{writer:i,schema:o}=n;let r=i.createPositionAfter(e);for(const s of t)if("ul"==s.name||"ol"==s.name)r=n.convertItem(s,r).modelCursor;else{const t=n.convertItem(s,i.createPositionAt(e,"end")),a=t.modelRange.start.nodeAfter;a&&a.is("element")&&!o.checkChild(e,a.name)&&(e=t.modelCursor.parent.is("element","listItem")?t.modelCursor.parent:lk(t.modelCursor),r=i.createPositionAfter(e))}return r}(i,t.viewItem.getChildren(),n);t.modelRange=e.createRange(t.modelCursor,s),n.updateConversionResult(i,t)}}function rk(e,t,n){if(n.consumable.test(t.viewItem,{name:!0})){const e=Array.from(t.viewItem.getChildren());for(const t of e){!(t.is("element","li")||uk(t))&&t._remove()}}}function sk(e,t,n){if(n.consumable.test(t.viewItem,{name:!0})){if(0===t.viewItem.childCount)return;const e=[...t.viewItem.getChildren()];let n=!1;for(const t of e)n&&!uk(t)&&t._remove(),uk(t)&&(n=!0)}}function ak(e){return(t,n)=>{if(n.isPhantom)return;const i=n.modelPosition.nodeBefore;if(i&&i.is("element","listItem")){const t=n.mapper.toViewElement(i),o=t.getAncestors().find(uk),r=e.createPositionAt(t,0).getWalker();for(const e of r){if("elementStart"==e.type&&e.item.is("element","li")){n.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==o){n.viewPosition=e.nextPosition;break}}}}}function ck(e,[t,n,i]){let o,r=t.is("documentFragment")?t.getChild(0):t;if(o=n?this.createSelection(n,i):this.document.selection,r&&r.is("element","listItem")){const e=o.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(;r&&r.is("element","listItem");)r._setAttribute("listIndent",r.getAttribute("listIndent")+e),r=r.nextSibling}}}function lk(e){const t=new pc({startPosition:e});let n;do{n=t.next()}while(!n.value.item.is("element","listItem"));return n.value.item}function dk(e,t,n,i,o,r){const s=Zw(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e,foo:"b"}),a=o.mapper,c=o.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=r.createPositionAt(s,"end");d=a.toViewPosition(e)}else d=n;d=qw(d);for(const e of[...i.getChildren()])uk(e)&&(d=c.move(c.createRangeOn(e),d).end,Ww(c,e,e.nextSibling),Ww(c,e.previousSibling,e))}function uk(e){return e.is("element","ol")||e.is("element","ul")}class hk extends Oo{static get pluginName(){return"ListEditing"}static get requires(){return[$m,Pm,Jw]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,n=e.editing;var i;e.model.document.registerPostFixer((t=>function(e,t){const n=e.document.differ.getChanges(),i=new Map;let o=!1;for(const i of n)if("insert"==i.type&&"listItem"==i.name)r(i.position);else if("insert"==i.type&&"listItem"!=i.name){if("$text"!=i.name){const n=i.position.nodeAfter;n.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",n),o=!0),n.hasAttribute("listType")&&(t.removeAttribute("listType",n),o=!0),n.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",n),o=!0),n.hasAttribute("listReversed")&&(t.removeAttribute("listReversed",n),o=!0),n.hasAttribute("listStart")&&(t.removeAttribute("listStart",n),o=!0);for(const t of Array.from(e.createRangeIn(n)).filter((e=>e.item.is("element","listItem"))))r(t.previousPosition)}r(i.position.getShiftedBy(i.length))}else"remove"==i.type&&"listItem"==i.name?r(i.position):("attribute"==i.type&&"listIndent"==i.attributeKey||"attribute"==i.type&&"listType"==i.attributeKey)&&r(i.range.start);for(const e of i.values())s(e),a(e);return o;function r(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(i.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,i.has(e))return;i.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&i.set(t,t)}}function s(e){let n=0,i=null;for(;e&&e.is("element","listItem");){const r=e.getAttribute("listIndent");if(r>n){let s;null===i?(i=r-n,s=n):(i>r&&(i=r),s=r-i),t.setAttribute("listIndent",s,e),o=!0}else i=null,n=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let n=[],i=null;for(;e&&e.is("element","listItem");){const r=e.getAttribute("listIndent");if(i&&i.getAttribute("listIndent")>r&&(n=n.slice(0,r+1)),0!=r)if(n[r]){const i=n[r];e.getAttribute("listType")!=i&&(t.setAttribute("listType",i,e),o=!0)}else n[r]=e.getAttribute("listType");i=e,e=e.nextSibling}}}(e.model,t))),n.mapper.registerViewToModelLength("li",fk),t.mapper.registerViewToModelLength("li",fk),n.mapper.on("modelToViewPosition",ak(n.view)),n.mapper.on("viewToModelPosition",(i=e.model,(e,t)=>{const n=t.viewPosition,o=n.parent,r=t.mapper;if("ul"==o.name||"ol"==o.name){if(n.isAtEnd){const e=r.toModelElement(n.nodeBefore),o=r.getModelLength(n.nodeBefore);t.modelPosition=i.createPositionBefore(e).getShiftedBy(o)}else{const e=r.toModelElement(n.nodeAfter);t.modelPosition=i.createPositionBefore(e)}e.stop()}else if("li"==o.name&&n.nodeBefore&&("ul"==n.nodeBefore.name||"ol"==n.nodeBefore.name)){const s=r.toModelElement(o);let a=1,c=n.nodeBefore;for(;c&&uk(c);)a+=r.getModelLength(c),c=c.previousSibling;t.modelPosition=i.createPositionBefore(s).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",ak(n.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",nk,{priority:"high"}),t.on("insert:listItem",Xw(e.model)),t.on("attribute:listType:listItem",ek,{priority:"high"}),t.on("attribute:listType:listItem",tk,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,n,i)=>{if(!i.consumable.consume(n.item,"attribute:listIndent"))return;const o=i.mapper.toViewElement(n.item),r=i.writer;r.breakContainer(r.createPositionBefore(o)),r.breakContainer(r.createPositionAfter(o));const s=o.parent,a=s.previousSibling,c=r.createRangeOn(s);r.remove(c),a&&a.nextSibling&&Ww(r,a,a.nextSibling),dk(n.attributeOldValue+1,n.range.start,c.start,o,i,e),Uw(n.item,o,i,e);for(const e of n.item.getChildren())i.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,n,i)=>{const o=i.mapper.toViewPosition(n.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,r=i.writer;r.breakContainer(r.createPositionBefore(o)),r.breakContainer(r.createPositionAfter(o));const s=o.parent,a=s.previousSibling,c=r.createRangeOn(s),l=r.remove(c);a&&a.nextSibling&&Ww(r,a,a.nextSibling),dk(i.mapper.toModelElement(o).getAttribute("listIndent")+1,n.position,c.start,o,i,e);for(const e of r.createRangeIn(l).getItems())i.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",ik,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",nk,{priority:"high"}),t.on("insert:listItem",Xw(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",rk,{priority:"high"}),e.on("element:ol",rk,{priority:"high"}),e.on("element:li",sk,{priority:"high"}),e.on("element:li",ok)})),e.model.on("insertContent",ck,{priority:"high"}),e.commands.add("numberedList",new jw(e,"numbered")),e.commands.add("bulletedList",new jw(e,"bulleted")),e.commands.add("indentList",new Fw(e,"forward")),e.commands.add("outdentList",new Fw(e,"backward"));const o=n.view.document;this.listenTo(o,"enter",((e,t)=>{const n=this.editor.model.document,i=n.selection.getLastPosition().parent;n.selection.isCollapsed&&"listItem"==i.name&&i.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(o,"delete",((e,t)=>{if("backward"!==t.direction)return;const n=this.editor.model.document.selection;if(!n.isCollapsed)return;const i=n.getFirstPosition();if(!i.isAtStart)return;const o=i.parent;if("listItem"!==o.name)return;o.previousSibling&&"listItem"===o.previousSibling.name||(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(e.editing.view.document,"tab",((t,n)=>{const i=n.shiftKey?"outdentList":"indentList";this.editor.commands.get(i).isEnabled&&(e.execute(i),n.stopPropagation(),n.preventDefault(),t.stop())}),{context:"li"})}afterInit(){const e=this.editor.commands,t=e.get("indent"),n=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),n&&n.registerChildCommand(e.get("outdentList"))}}function fk(e){let t=1;for(const n of e.getChildren())if("ul"==n.name||"ol"==n.name)for(const e of n.getChildren())t+=fk(e);return t}class mk extends Oo{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;$w(this.editor,"numberedList",e("Numbered List"),''),$w(this.editor,"bulletedList",e("Bulleted List"),'')}}class gk extends Oo{static get requires(){return[hk,mk]}static get pluginName(){return"List"}}function pk(e,t){return`${e}:${t=t||wo(e)}`}class bk extends Ro{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 n=this.editor.model,i=n.document.selection,o=!!e&&pk(e,t);n.change((e=>{if(i.isCollapsed)o?e.setSelectionAttribute("language",o):e.removeSelectionAttribute("language");else{const t=n.schema.getValidRanges(i.getRanges(),"language");for(const n of t)o?e.setAttribute("language",o,n):e.removeAttribute("language",n)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,n=e.document.selection;if(n.isCollapsed)return n.getAttribute("language")||!1;for(const e of n.getRanges())for(const n of e.getItems())if(t.checkAttribute(n,"language"))return n.getAttribute("language")||!1;return!1}}class wk extends Oo{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 bk(e))}_defineConverters(){const e=this.editor.conversion;e.for("upcast").elementToAttribute({model:{key:"language",value:e=>pk(e.getAttribute("lang"),e.getAttribute("dir"))},view:{name:"span",attributes:{lang:/[\s\S]+/}}}),e.for("downcast").attributeToElement({model:"language",view:(e,{writer:t},n)=>{if(!e)return;if(!n.item.is("$textProxy")&&!n.item.is("documentSelection"))return;const{languageCode:i,textDirection:o}=function(e){const[t,n]=e.split(":");return{languageCode:t,textDirection:n}}(e);return t.createAttributeElement("span",{lang:i,dir:o})}})}}var kk=n(858),_k={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};zo()(kk.Z,_k);kk.Z.locals;class vk extends Oo{static get pluginName(){return"TextPartLanguageUI"}init(){const e=this.editor,t=e.t,n=e.config.get("language.textPartLanguage"),i=t("Choose language"),o=t("Remove language"),r=t("Language");e.ui.componentFactory.add("textPartLanguage",(t=>{const s=new yo,a={},c=e.commands.get("textPartLanguage");s.add({type:"button",model:new Kf({label:o,languageCode:!1,withText:!0})}),s.add({type:"separator"});for(const e of n){const t={type:"button",model:new Kf({label:e.title,languageCode:e.languageCode,textDirection:e.textDirection,withText:!0})},n=pk(e.languageCode,e.textDirection);t.model.bind("isOn").to(c,"value",(e=>e===n)),s.add(t),a[n]=e.title}const l=Af(t);return Ef(l,s),l.buttonView.set({isOn:!1,withText:!0,tooltip:r}),l.extendTemplate({attributes:{class:["ck-text-fragment-language-dropdown"]}}),l.bind("isEnabled").to(c,"isEnabled"),l.buttonView.bind("label").to(c,"value",(e=>a[e]||i)),this.listenTo(l,"execute",(t=>{c.execute({languageCode:t.source.languageCode,textDirection:t.source.textDirection}),e.editing.view.focus()})),l}))}}class yk extends Oo{static get requires(){return[wk,vk]}static get pluginName(){return"TextPartLanguage"}}class xk extends Ro{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,n=t.document.selection,i=e.value;t.change((e=>{if(n.isCollapsed)i?e.setSelectionAttribute(this.attributeKey,i):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(n.getRanges(),this.attributeKey);for(const t of o)i?e.setAttribute(this.attributeKey,i,t):e.removeAttribute(this.attributeKey,t)}}))}}class Ak extends yo{constructor(e){super(e),this.set("isEmpty",!0),this.on("change",(()=>{this.set("isEmpty",0===this.length)}))}add(e,t){this.find((t=>t.color===e.color))||super.add(e,t)}hasColor(e){return!!this.find((t=>t.color===e))}}u(Ak,W);var Ck=n(4590),Ek={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};zo()(Ck.Z,Ek);Ck.Z.locals;class Tk extends sh{constructor(e,{colors:t,columns:n,removeButtonLabel:i,documentColorsLabel:o,documentColorsCount:r}){super(e),this.items=this.createCollection(),this.colorDefinitions=t,this.focusTracker=new Ao,this.keystrokes=new Co,this.set("selectedColor"),this.removeButtonLabel=i,this.columns=n,this.documentColors=new Ak,this.documentColorsCount=r,this._focusables=new Lu,this._focusCycler=new tf({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this._documentColorsLabel=o,this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-table"]},children:this.items}),this.items.add(this._createRemoveColorButton())}updateDocumentColors(e,t){const n=e.document,i=this.documentColorsCount;this.documentColors.clear();for(const o of n.getRootNames()){const r=n.getRoot(o),s=e.createRangeIn(r);for(const e of s.getItems())if(e.is("$textProxy")&&e.hasAttribute(t)&&(this._addColorToDocumentColors(e.getAttribute(t)),this.documentColors.length>=i))return}}updateSelectedColors(){const e=this.documentColorsGrid,t=this.staticColorsGrid,n=this.selectedColor;t.selectedColor=n,e&&(e.selectedColor=n)}render(){super.render(),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}appendGrids(){if(!this.staticColorsGrid&&(this.staticColorsGrid=this._createStaticColorsGrid(),this.items.add(this.staticColorsGrid),this.focusTracker.add(this.staticColorsGrid.element),this._focusables.add(this.staticColorsGrid),this.documentColorsCount)){const e=Vu.bind(this.documentColors,this.documentColors),t=new Rf(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.focusTracker.add(this.documentColorsGrid.element),this._focusables.add(this.documentColorsGrid)}}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_createRemoveColorButton(){const e=new Vh;return e.set({withText:!0,icon:Eh.eraser,label:this.removeButtonLabel}),e.class="ck-color-table__remove-color",e.on("execute",(()=>{this.fire("execute",{value:null})})),e.render(),this.focusTracker.add(e.element),this._focusables.add(e),e}_createStaticColorsGrid(){const e=new qh(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return e.delegate("execute").to(this),e}_createDocumentColorsGrid(){const e=Vu.bind(this.documentColors,this.documentColors),t=new qh(this.locale,{columns:this.columns});return t.delegate("execute").to(this),t.extendTemplate({attributes:{class:e.if("isEmpty","ck-hidden")}}),t.items.bindTo(this.documentColors).using((e=>{const t=new Hh;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})})),t})),this.documentColors.on("change:isEmpty",((e,n,i)=>{i&&(t.selectedColor=null)})),t}_addColorToDocumentColors(e){const t=this.colorDefinitions.find((t=>t.color===e));t?this.documentColors.add(Object.assign({},t)):this.documentColors.add({color:e,label:e,options:{hasBorder:!1}})}}const Sk="fontSize",Pk="fontFamily",Ik="fontColor",Ok="fontBackgroundColor";function Mk(e,t){const n={model:{key:e,values:[]},view:{},upcastAlso:{}};for(const e of t)n.model.values.push(e.model),n.view[e.model]=e.view,e.upcastAlso&&(n.upcastAlso[e.model]=e.upcastAlso);return n}function Rk(e){return t=>t.getStyle(e).replace(/\s/g,"")}function Nk(e){return(t,{writer:n})=>n.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class Dk extends xk{constructor(e){super(e,Pk)}}function Lk(e){return e.map(Vk).filter((e=>!!e))}function Vk(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=e.replace(/"|'/g,"").split(","),n=t[0],i=t.map(jk).join(", ");return{title:n,model:i,view:{name:"span",styles:{"font-family":i},priority:7}}}(e):void 0}function jk(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class Bk extends Oo{static get pluginName(){return"FontFamilyEditing"}constructor(e){super(e),e.config.define(Pk,{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:Pk}),e.model.schema.setAttributeProperties(Pk,{isFormatting:!0,copyOnEnter:!0});const t=Lk(e.config.get("fontFamily.options")).filter((e=>e.model)),n=Mk(Pk,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(Pk,new Dk(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:Pk,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:Pk,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:Pk,value:e=>e.getAttribute("face")}})}}class zk extends Oo{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,n=this._getLocalizedOptions(),i=e.commands.get(Pk);e.ui.componentFactory.add(Pk,(o=>{const r=Af(o);return Ef(r,function(e,t){const n=new yo;for(const i of e){const e={type:"button",model:new Kf({commandName:Pk,commandParam:i.model,label:i.title,withText:!0})};e.model.bind("isOn").to(t,"value",(e=>e===i.model||!(!e||!i.model)&&e.split(",")[0].replace(/'/g,"").toLowerCase()===i.model.toLowerCase())),i.view&&i.view.styles&&e.model.set("labelStyle",`font-family: ${i.view.styles["font-family"]}`),n.add(e)}return n}(n,i)),r.buttonView.set({label:t("Font Family"),icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),r.bind("isEnabled").to(i),this.listenTo(r,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),r}))}_getLocalizedOptions(){const e=this.editor,t=e.t;return Lk(e.config.get(Pk).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class Fk extends Oo{static get requires(){return[Bk,zk]}static get pluginName(){return"FontFamily"}}class Hk extends xk{constructor(e){super(e,Sk)}}function Uk(e){return e.map((e=>function(e){if(t=e,"object"==typeof t&&t.title&&t.model&&t.view)return qk(e);var t;const n=function(e){return Wk[e]||Wk[e.model]}(e);if(n)return qk(n);if("default"===e)return{model:void 0,title:"Default"};if(function(e){let t;if("object"==typeof e){if(!e.model)throw new k("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}(e))return;return function(e){"number"!=typeof e&&"string"!=typeof e||(e={title:String(e),model:`${parseFloat(e)}px`});return e.view={name:"span",styles:{"font-size":e.model}},qk(e)}(e)}(e))).filter((e=>!!e))}const Wk={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 qk(e){return e.view.priority||(e.view.priority=7),e}const Zk=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class $k extends Oo{static get pluginName(){return"FontSizeEditing"}constructor(e){super(e),e.config.define(Sk,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Sk}),e.model.schema.setAttributeProperties(Sk,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),n=Uk(this.editor.config.get("fontSize.options")).filter((e=>e.model)),i=Mk(Sk,n);t?(this._prepareAnyValueConverters(i),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(Sk,new Hk(e))}_prepareAnyValueConverters(e){const t=this.editor,n=e.model.values.filter((e=>{return!(t=String(e),pu.test(t)||function(e){return bu.test(e)}(String(e)));var t}));if(n.length)throw new k("font-size-invalid-use-of-named-presets",null,{presets:n});t.conversion.for("downcast").attributeToElement({model:Sk,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:Sk,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:Sk,value:e=>{const t=e.getAttribute("size"),n="-"===t[0]||"+"===t[0];let i=parseInt(t,10);n&&(i=3+i);const o=Zk.length-1,r=Math.min(Math.max(i,0),o);return Zk[r]}}})}}var Kk=n(9875),Gk={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};zo()(Kk.Z,Gk);Kk.Z.locals;class Yk extends Oo{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,n=this._getLocalizedOptions(),i=e.commands.get(Sk);e.ui.componentFactory.add(Sk,(o=>{const r=Af(o);return Ef(r,function(e,t){const n=new yo;for(const i of e){const e={type:"button",model:new Kf({commandName:Sk,commandParam:i.model,label:i.title,class:"ck-fontsize-option",withText:!0})};i.view&&i.view.styles&&e.model.set("labelStyle",`font-size:${i.view.styles["font-size"]}`),i.view&&i.view.classes&&e.model.set("class",`${e.model.class} ${i.view.classes}`),e.model.bind("isOn").to(t,"value",(e=>e===i.model)),n.add(e)}return n}(n,i)),r.buttonView.set({label:t("Font Size"),icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),r.bind("isEnabled").to(i),this.listenTo(r,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),r}))}_getLocalizedOptions(){const e=this.editor,t=e.t,n={Default:t("Default"),Tiny:t("Tiny"),Small:t("Small"),Big:t("Big"),Huge:t("Huge")};return Uk(e.config.get(Sk).options).map((e=>{const t=n[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class Qk extends Oo{static get requires(){return[$k,Yk]}static get pluginName(){return"FontSize"}normalizeSizeOptions(e){return Uk(e)}}class Jk extends xk{constructor(e){super(e,Ik)}}class Xk extends Oo{static get pluginName(){return"FontColorEditing"}constructor(e){super(e),e.config.define(Ik,{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:Ik,value:Rk("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:Ik,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:Ik,view:Nk("color")}),e.commands.add(Ik,new Jk(e)),e.model.schema.extend("$text",{allowAttributes:Ik}),e.model.schema.setAttributeProperties(Ik,{isFormatting:!0,copyOnEnter:!0})}}class e_ extends Oo{constructor(e,{commandName:t,icon:n,componentName:i,dropdownLabel:o}){super(e),this.commandName=t,this.componentName=i,this.icon=n,this.dropdownLabel=o,this.columns=e.config.get(`${this.componentName}.columns`),this.colorTableView=void 0}init(){const e=this.editor,t=e.locale,n=t.t,i=e.commands.get(this.commandName),o=function(e){return e.map(Fh).filter((e=>!!e))}(e.config.get(this.componentName).colors),r=function(e,t){const n=e.t,i={Black:n("Black"),"Dim grey":n("Dim grey"),Grey:n("Grey"),"Light grey":n("Light grey"),White:n("White"),Red:n("Red"),Orange:n("Orange"),Yellow:n("Yellow"),"Light green":n("Light green"),Green:n("Green"),Aquamarine:n("Aquamarine"),Turquoise:n("Turquoise"),"Light blue":n("Light blue"),Blue:n("Blue"),Purple:n("Purple")};return t.map((e=>{const t=i[e.label];return t&&t!=e.label&&(e.label=t),e}))}(t,o),s=e.config.get(`${this.componentName}.documentColors`);e.ui.componentFactory.add(this.componentName,(t=>{const o=Af(t);return this.colorTableView=function({dropdownView:e,colors:t,columns:n,removeButtonLabel:i,documentColorsLabel:o,documentColorsCount:r}){const s=e.locale,a=new Tk(s,{colors:t,columns:n,removeButtonLabel:i,documentColorsLabel:o,documentColorsCount:r});return e.colorTableView=a,e.panelView.children.add(a),a.delegate("execute").to(e,"execute"),a}({dropdownView:o,colors:r.map((e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}}))),columns:this.columns,removeButtonLabel:n("Remove color"),documentColorsLabel:0!==s?n("Document colors"):void 0,documentColorsCount:void 0===s?this.columns:s}),this.colorTableView.bind("selectedColor").to(i,"value"),o.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),o.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),o.bind("isEnabled").to(i),o.on("execute",((t,n)=>{e.execute(this.commandName,n),e.editing.view.focus()})),o.on("change:isOpen",((t,n,i)=>{o.colorTableView.appendGrids(),i&&(0!==s&&this.colorTableView.updateDocumentColors(e.model,this.componentName),this.colorTableView.updateSelectedColors())})),Tf(o,(()=>o.colorTableView.staticColorsGrid.items.find((e=>e.isOn)))),o}))}}class t_ extends e_{constructor(e){const t=e.locale.t;super(e,{commandName:Ik,componentName:Ik,icon:'',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class n_ extends Oo{static get requires(){return[Xk,t_]}static get pluginName(){return"FontColor"}}class i_ extends xk{constructor(e){super(e,Ok)}}class o_ extends Oo{static get pluginName(){return"FontBackgroundColorEditing"}constructor(e){super(e),e.config.define(Ok,{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(Pu),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:Ok,value:Rk("background-color")}}),e.conversion.for("downcast").attributeToElement({model:Ok,view:Nk("background-color")}),e.commands.add(Ok,new i_(e)),e.model.schema.extend("$text",{allowAttributes:Ok}),e.model.schema.setAttributeProperties(Ok,{isFormatting:!0,copyOnEnter:!0})}}class r_ extends e_{constructor(e){const t=e.locale.t;super(e,{commandName:Ok,componentName:Ok,icon:'',dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class s_ extends Oo{static get requires(){return[o_,r_]}static get pluginName(){return"FontBackgroundColor"}}class a_ extends Oo{static get requires(){return[Fk,Qk,n_,s_]}static get pluginName(){return"Font"}}function c_(e,t,n,{blockElements:i,inlineObjectElements:o}){let r=n.createPositionAt(e,"forward"==t?"after":"before");return r=r.getLastMatchingPosition((({item:e})=>e.is("element")&&!i.includes(e.name)&&!o.includes(e.name)),{direction:t}),"forward"==t?r.nodeAfter:r.nodeBefore}function l_(e,t){return!!e&&e.is("element")&&t.includes(e.name)}function d_(e,t){if(!e.childCount)return;const n=new cu(e.document),i=function(e,t){const n=t.createRangeIn(e),i=new er({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),o=[];for(const e of n)if("elementStart"===e.type&&i.match(e.item)){const t=f_(e.item);o.push({element:e.item,id:t.id,order:t.order,indent:t.indent})}return o}(e,n);if(!i.length)return;let o=null,r=1;i.forEach(((e,s)=>{const a=function(e,t){if(!e)return!0;if(e.id!==t.id)return t.indent-e.indent!=1;const n=t.element.previousSibling;if(!n)return!0;return i=n,!(i.is("element","ol")||i.is("element","ul"));var i}(i[s-1],e),c=a?null:i[s-1],l=(u=e,(d=c)?u.indent-d.indent:u.indent-1);var d,u;if(a&&(o=null,r=1),!o||0!==l){const i=function(e,t){const n=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi"),i=/mso-level-number-format:([^;]{0,100});/gi,o=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,r=n.exec(t);let s="decimal",a="ol",c=null;if(r&&r[1]){const t=i.exec(r[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);return e.is("$text")?e:e.getChild(0)}}(e);if(!t)return null;const n=t._data;if("o"===n)return"circle";if("·"===n)return"disc";if("§"===n)return"square";return null}(e.element);t&&(s=t)}else{const e=o.exec(r[1]);e&&e[1]&&(c=parseInt(e[1]))}}return{type:a,startIndex:c,style:u_(s)}}(e,t);if(o){if(e.indent>r){const e=o.getChild(o.childCount-1),t=e.getChild(e.childCount-1);o=h_(i,t,n),r+=1}else if(e.indent1&&n.setAttribute("start",e.startIndex,o),o}function f_(e){const t={},n=e.getStyle("mso-list");if(n){const e=n.match(/(^|\s{1,100})l(\d+)/i),i=n.match(/\s{0,100}lfo(\d+)/i),o=n.match(/\s{0,100}level(\d+)/i);e&&i&&o&&(t.id=e[2],t.order=i[1],t.indent=o[1])}return t}const m_=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class g_{constructor(e){this.document=e}isActive(e){return m_.test(e)}execute(e){const t=new cu(this.document),{body:n}=e._parsedData;!function(e,t){for(const n of e.getChildren())if(n.is("element","b")&&"normal"===n.getStyle("font-weight")){const i=e.getChildIndex(n);t.remove(n),t.insertChild(i,n.getChildren(),e)}}(n,t),function(e,t){for(const n of t.createRangeIn(e)){const e=n.item;if(e.is("element","li")){const n=e.getChild(0);n&&n.is("element","p")&&t.unwrapElement(n)}}}(n,t),function(e,t){const n=new ks(t.document.stylesProcessor),i=new da(n,{renderingMode:"data"}),o=i.blockElements,r=i.inlineObjectElements,s=[];for(const n of t.createRangeIn(e)){const e=n.item;if(e.is("element","br")){const n=c_(e,"forward",t,{blockElements:o,inlineObjectElements:r}),i=c_(e,"backward",t,{blockElements:o,inlineObjectElements:r}),a=l_(n,o);(l_(i,o)||a)&&s.push(e)}}for(const e of s)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(n,t),e.content=n}}function p_(e,t){if(!e.childCount)return;const n=new cu,i=function(e,t){const n=t.createRangeIn(e),i=new er({name:/v:(.+)/}),o=[];for(const e of n){if("elementStart"!=e.type)continue;const t=e.item,n=t.previousSibling&&t.previousSibling.name||null;i.match(t)&&t.getAttribute("o:gfxdata")&&"v:shapetype"!==n&&o.push(e.item.getAttribute("id"))}return o}(e,n);!function(e,t,n){const i=n.createRangeIn(t),o=new er({name:"img"}),r=[];for(const t of i)if(o.match(t.item)){const n=t.item,i=n.getAttribute("v:shapes")?n.getAttribute("v:shapes").split(" "):[];i.length&&i.every((t=>e.indexOf(t)>-1))?r.push(n):n.getAttribute("src")||r.push(n)}for(const e of r)n.remove(e)}(i,e,n),function(e,t){const n=t.createRangeIn(e),i=new er({name:/v:(.+)/}),o=[];for(const e of n)"elementStart"==e.type&&i.match(e.item)&&o.push(e.item);for(const e of o)t.remove(e)}(e,n);const o=function(e,t){const n=t.createRangeIn(e),i=new er({name:"img"}),o=[];for(const e of n)i.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&o.push(e.item);return o}(e,n);o.length&&function(e,t,n){if(e.length===t.length)for(let i=0;iString.fromCharCode(parseInt(e,16)))).join(""))}const w_=//i,k_=/xmlns:o="urn:schemas-microsoft-com/i;class __{constructor(e){this.document=e}isActive(e){return w_.test(e)||k_.test(e)}execute(e){const{body:t,stylesString:n}=e._parsedData;d_(t,n),p_(t,e.dataTransfer.getData("text/rtf")),e.content=t}}function v_(e){return e.replace(/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length)))}function y_(e,t){const n=new DOMParser,i=function(e){return v_(v_(e)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/ <\//g," <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(e){const t="",n="",i=e.indexOf(t);if(i<0)return e;const o=e.indexOf(n,i+t.length);return e.substring(0,i+t.length)+(o>=0?e.substring(o):"")}(e=e.replace(/