From 18236aab4fae9ac70afaea00d6889f7f0c8e1f8a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 17 Aug 2023 13:09:19 +0200 Subject: [PATCH] Upgrade to CKEditor5 v39.0.1 --- wcfsetup/install/files/js/3rdParty/ckeditor/ckeditor5.bundle.js | 2 +- wcfsetup/install/files/style/ckeditor5.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/ckeditor/ckeditor5.bundle.js b/wcfsetup/install/files/js/3rdParty/ckeditor/ckeditor5.bundle.js index fe4d01068b3..8deea7b4c3e 100644 --- a/wcfsetup/install/files/js/3rdParty/ckeditor/ckeditor5.bundle.js +++ b/wcfsetup/install/files/js/3rdParty/ckeditor/ckeditor5.bundle.js @@ -1,2 +1,2 @@ /*! For license information please see ckeditor5.bundle.js.LICENSE.txt */ -var CKEditor5;!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"%0 of %1",Accept:"Accept","Align cell text to the bottom":"Align cell text to the bottom","Align cell text to the center":"Align cell text to the center","Align cell text to the left":"Align cell text to the left","Align cell text to the middle":"Align cell text to the middle","Align cell text to the right":"Align cell text to the right","Align cell text to the top":"Align cell text to the top","Align center":"Align center","Align left":"Align left","Align right":"Align right","Align table to the left":"Align table to the left","Align table to the right":"Align table to the right",Alignment:"Alignment",Aquamarine:"Aquamarine",Background:"Background",Big:"Big",Black:"Black","Block quote":"Block quote",Blue:"Blue","Blue marker":"Blue marker",Bold:"Bold",Border:"Border","Break text":"Break text","Bulleted List":"Bulleted List","Bulleted list styles toolbar":"Bulleted list styles toolbar",Cancel:"Cancel","Caption for image: %0":"Caption for image: %0","Caption for the image":"Caption for the image","Cell properties":"Cell properties","Center table":"Center table","Centered image":"Centered image","Change image text alternative":"Change image text alternative","Choose heading":"Choose heading",Circle:"Circle",Code:"Code",Color:"Color","Color picker":"Color picker",Column:"Column",Dashed:"Dashed",Decimal:"Decimal","Decimal with leading zero":"Decimal with leading zero","Decrease indent":"Decrease indent",Default:"Default","Delete column":"Delete column","Delete row":"Delete row","Dim grey":"Dim grey",Dimensions:"Dimensions",Disc:"Disc","Document colors":"Document colors",Dotted:"Dotted",Double:"Double",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","Enter table caption":"Enter table 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","Green marker":"Green marker","Green pen":"Green pen",Grey:"Grey",Groove:"Groove","Header column":"Header column","Header row":"Header row",Heading:"Heading","Heading 1":"Heading 1","Heading 2":"Heading 2","Heading 3":"Heading 3","Heading 4":"Heading 4","Heading 5":"Heading 5","Heading 6":"Heading 6",Height:"Height",HEX:"HEX",Highlight:"Highlight","Horizontal line":"Horizontal line","Horizontal text alignment toolbar":"Horizontal text alignment toolbar","HTML snippet":"HTML snippet",Huge:"Huge","Image resize list":"Image resize list","Image toolbar":"Image toolbar","image widget":"image widget","In line":"In line","Increase indent":"Increase indent",Insert:"Insert","Insert code block":"Insert code block","Insert column left":"Insert column left","Insert column right":"Insert column right","Insert HTML":"Insert HTML","Insert image":"Insert image","Insert image via URL":"Insert image via URL","Insert 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",Inset:"Inset",Italic:"Italic",Justify:"Justify","Justify cell text":"Justify cell text","Left aligned image":"Left aligned image","Light blue":"Light blue","Light green":"Light green","Light grey":"Light grey",Link:"Link","Link image":"Link image","Link URL":"Link URL","List properties":"List properties","Lower-latin":"Lower-latin","Lower–roman":"Lower–roman","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",None:"None","Numbered List":"Numbered List","Numbered list styles toolbar":"Numbered list styles toolbar","Open in a new tab":"Open in a new tab","Open link in new tab":"Open link in new tab",Orange:"Orange",Original:"Original",Outset:"Outset",Padding:"Padding",Paragraph:"Paragraph","Paste raw HTML here...":"Paste raw HTML here...","Pink marker":"Pink marker","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","Red pen":"Red pen",Redo:"Redo","Remove color":"Remove color","Remove Format":"Remove Format","Remove highlight":"Remove highlight","Resize image":"Resize image","Resize image to %0":"Resize image to %0","Resize image to the original size":"Resize image to the original size","Restore default":"Restore default","Reversed order":"Reversed order","Rich Text Editor":"Rich Text Editor",Ridge:"Ridge","Right aligned image":"Right aligned image",Row:"Row",Save:"Save","Save changes":"Save changes","Saving changes":"Saving 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",Solid:"Solid","Split cell horizontally":"Split cell horizontally","Split cell vertically":"Split cell vertically",Square:"Square","Start at":"Start at","Start index must be greater than 0.":"Start index must be greater than 0.",Strikethrough:"Strikethrough",Style:"Style",Subscript:"Subscript",Superscript:"Superscript","Table alignment toolbar":"Table alignment toolbar","Table cell text alignment":"Table cell text alignment","Table properties":"Table properties","Table toolbar":"Table toolbar","Text alignment":"Text alignment","Text alignment toolbar":"Text alignment toolbar","Text alternative":"Text alternative","Text highlight toolbar":"Text highlight toolbar",'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".':'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".','The value is invalid. Try "10px" or "2em" or simply "2".':'The value is invalid. Try "10px" or "2em" or simply "2".',"This link has no URL":"This link has no URL",Tiny:"Tiny","To-do List":"To-do List","Toggle caption off":"Toggle caption off","Toggle caption on":"Toggle caption on","Toggle the circle list style":"Toggle the circle list style","Toggle the decimal list style":"Toggle the decimal list style","Toggle the decimal with leading zero list style":"Toggle the decimal with leading zero list style","Toggle the disc list style":"Toggle the disc list style","Toggle the lower–latin list style":"Toggle the lower–latin list style","Toggle the lower–roman list style":"Toggle the lower–roman list style","Toggle the square list style":"Toggle the square list style","Toggle the upper–latin list style":"Toggle the upper–latin list style","Toggle the upper–roman list style":"Toggle the upper–roman list style",Turquoise:"Turquoise","Type or paste your content here.":"Type or paste your content here.","Type your title":"Type your title",Underline:"Underline",Undo:"Undo",Unlink:"Unlink",Update:"Update","Update image URL":"Update image URL","Upload failed":"Upload failed","Upload in progress":"Upload in progress","Upper-latin":"Upper-latin","Upper-roman":"Upper-roman","Vertical text alignment toolbar":"Vertical text alignment toolbar",White:"White","Widget toolbar":"Widget toolbar",Width:"Width","Wrap text":"Wrap text",Yellow:"Yellow","Yellow marker":"Yellow marker"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),(()=>{var e={511:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Alignment:()=>f,AlignmentEditing:()=>u,AlignmentUI:()=>g});var n=i(6854),o=i(6553);const s=["left","right","center","justify"];function r(e){return s.includes(e)}function a(e,t){return"rtl"==t.contentLanguageDirection?"right"===e:"left"===e}function l(e){const t=e.map((e=>{let t;return t="string"==typeof e?{name:e}:e,t})).filter((e=>{const t=s.includes(e.name);return t||(0,o.KE)("alignment-config-name-not-recognized",{option:e}),t})),i=t.filter((e=>Boolean(e.className))).length;if(i&&i{const s=n.slice(i+1);if(s.some((e=>e.name==t.name)))throw new o.Bb("alignment-config-name-already-defined",{option:t,configuredOptions:e});if(t.className&&s.some((e=>e.className==t.className)))throw new o.Bb("alignment-config-classname-already-defined",{option:t,configuredOptions:e})})),t}const c="alignment";class d extends n.mY{refresh(){const e=this.editor.locale,t=(0,o.Ps)(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=Boolean(t)&&this._canBeAligned(t),this.isEnabled&&t.hasAttribute("alignment")?this.value=t.getAttribute("alignment"):this.value="rtl"===e.contentLanguageDirection?"right":"left"}execute(e={}){const t=this.editor,i=t.locale,n=t.model,o=n.document,s=e.value;n.change((e=>{const t=Array.from(o.selection.getSelectedBlocks()).filter((e=>this._canBeAligned(e))),n=t[0].getAttribute("alignment");a(s,i)||n===s||!s?function(e,t){for(const i of e)t.removeAttribute(c,i)}(t,e):function(e,t,i){for(const n of e)t.setAttribute(c,i,n)}(t,e,s)}))}_canBeAligned(e){return this.editor.model.schema.checkAttribute(e,c)}}class u extends n.Sy{static get pluginName(){return"AlignmentEditing"}constructor(e){super(e),e.config.define("alignment",{options:s.map((e=>({name:e})))})}init(){const e=this.editor,t=e.locale,i=e.model.schema,n=l(e.config.get("alignment.options")).filter((e=>r(e.name)&&!a(e.name,t))),o=n.some((e=>!!e.className));i.extend("$block",{allowAttributes:"alignment"}),e.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),o?e.conversion.attributeToAttribute(function(e){const t={};for(const i of e)t[i.name]={key:"class",value:i.className};return{model:{key:"alignment",values:e.map((e=>e.name))},view:t}}(n)):e.conversion.for("downcast").attributeToAttribute(function(e){const t={};for(const{name:i}of e)t[i]={key:"style",value:{"text-align":i}};return{model:{key:"alignment",values:e.map((e=>e.name))},view:t}}(n));const s=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"style",value:{"text-align":i}},model:{key:"alignment",value:i}});return t}(n);for(const t of s)e.conversion.for("upcast").attributeToAttribute(t);const c=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"align",value:i},model:{key:"alignment",value:i}});return t}(n);for(const t of c)e.conversion.for("upcast").attributeToAttribute(t);e.commands.add("alignment",new d(e))}}var h=i(7095);const m=new Map([["left",n.icons.alignLeft],["right",n.icons.alignRight],["center",n.icons.alignCenter],["justify",n.icons.alignJustify]]);class g extends n.Sy{get localizedOptionTitles(){const e=this.editor.t;return{left:e("Align left"),right:e("Align right"),center:e("Align center"),justify:e("Justify")}}static get pluginName(){return"AlignmentUI"}init(){const e=this.editor,t=e.ui.componentFactory,i=e.t,n=l(e.config.get("alignment.options"));n.map((e=>e.name)).filter(r).forEach((e=>this._addButton(e))),t.add("alignment",(o=>{const s=(0,h.t9)(o);(0,h.up)(s,(()=>n.map((e=>t.create(`alignment:${e.name}`)))),{enableActiveItemFocusOnDropdownOpen:!0,isVertical:!0,ariaLabel:i("Text alignment toolbar")}),s.buttonView.set({label:i("Text alignment"),tooltip:!0}),s.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const r="rtl"===o.contentLanguageDirection?m.get("right"):m.get("left"),a=e.commands.get("alignment");return s.buttonView.bind("icon").to(a,"value",(e=>m.get(e)||r)),s.bind("isEnabled").to(a,"isEnabled"),this.listenTo(s,"execute",(()=>{e.editing.view.focus()})),s}))}_addButton(e){const t=this.editor;t.ui.componentFactory.add(`alignment:${e}`,(i=>{const n=t.commands.get("alignment"),o=new h.r5(i);return o.set({label:this.localizedOptionTitles[e],icon:m.get(e),tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(n),o.bind("isOn").to(n,"value",(t=>t===e)),this.listenTo(o,"execute",(()=>{t.execute("alignment",{value:e}),t.editing.view.focus()})),o}))}}class f extends n.Sy{static get requires(){return[u,g]}static get pluginName(){return"Alignment"}}},6549:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Autosave:()=>r});var n=i(6854),o=i(6553),s=i(6682);class r extends n.Sy{static get pluginName(){return"Autosave"}static get requires(){return[n.lR]}constructor(e){super(e),this._action=null;const t=e.config.get("autosave")||{},i=t.waitingTime||1e3;this.set("state","synchronized"),this._debouncedSave=(0,s.Z)(this._save.bind(this),i),this._lastDocumentVersion=e.model.document.version,this._savePromise=null,this._domEmitter=new((0,o.Xu)()),this._config=t,this._pendingActions=e.plugins.get(n.lR),this._makeImmediateSave=!1}init(){const e=this.editor,t=e.model.document;this.listenTo(e,"ready",(()=>{this.listenTo(t,"change:data",((e,t)=>{this._saveCallbacks.length&&t.isLocal&&("synchronized"===this.state&&(this.state="waiting",this._setPendingAction()),"waiting"===this.state&&this._debouncedSave())}))})),this.listenTo(e,"destroy",(()=>this._flush()),{priority:"highest"}),this._domEmitter.listenTo(window,"beforeunload",((e,t)=>{this._pendingActions.hasAny&&(t.returnValue=this._pendingActions.first.message)}))}destroy(){this._domEmitter.stopListening(),super.destroy()}save(){return this._debouncedSave.cancel(),this._save()}_flush(){this._debouncedSave.flush()}_save(){return this._savePromise?(this._makeImmediateSave=this.editor.model.document.version>this._lastDocumentVersion,this._savePromise):(this._setPendingAction(),this.state="saving",this._lastDocumentVersion=this.editor.model.document.version,this._savePromise=Promise.resolve().then((()=>Promise.all(this._saveCallbacks.map((e=>e(this.editor)))))).finally((()=>{this._savePromise=null})).then((()=>{if(this._makeImmediateSave)return this._makeImmediateSave=!1,this._save();this.editor.model.document.version>this._lastDocumentVersion?(this.state="waiting",this._debouncedSave()):(this.state="synchronized",this._pendingActions.remove(this._action),this._action=null)})).catch((e=>{throw this.state="error",this.state="saving",this._debouncedSave(),e})),this._savePromise)}_setPendingAction(){const e=this.editor.t;this._action||(this._action=this._pendingActions.add(e("Saving changes")))}get _saveCallbacks(){const e=[];return this.adapter&&this.adapter.save&&e.push(this.adapter.save),this._config.save&&e.push(this._config.save),e}}},7971:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Bold:()=>d,BoldEditing:()=>r,BoldUI:()=>c,Code:()=>p,CodeEditing:()=>m,CodeUI:()=>f,Italic:()=>y,ItalicEditing:()=>w,ItalicUI:()=>_,Strikethrough:()=>x,StrikethroughEditing:()=>C,StrikethroughUI:()=>E,Subscript:()=>V,SubscriptEditing:()=>S,SubscriptUI:()=>I,Superscript:()=>N,SuperscriptEditing:()=>O,SuperscriptUI:()=>M,Underline:()=>H,UnderlineEditing:()=>L,UnderlineUI:()=>z});var n=i(6854);class o extends n.mY{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,!0):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of o)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.hasAttribute(this.attributeKey);for(const e of i.getRanges())for(const i of e.getItems())if(t.checkAttribute(i,this.attributeKey))return i.hasAttribute(this.attributeKey);return!1}}const s="bold";class r extends n.Sy{static get pluginName(){return"BoldEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:s}),e.model.schema.setAttributeProperties(s,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:s,view:"strong",upcastAlso:["b",e=>{const t=e.getStyle("font-weight");return t&&("bold"==t||Number(t)>=600)?{name:!0,styles:["font-weight"]}:null}]}),e.commands.add(s,new o(e,s)),e.keystrokes.set("CTRL+B",s)}}var a=i(7095);const l="bold";class c extends n.Sy{static get pluginName(){return"BoldUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(l,(i=>{const o=e.commands.get(l),s=new a.r5(i);return s.set({label:t("Bold"),icon:n.icons.bold,keystroke:"CTRL+B",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(s,"execute",(()=>{e.execute(l),e.editing.view.focus()})),s}))}}class d extends n.Sy{static get requires(){return[r,c]}static get pluginName(){return"Bold"}}var u=i(5187);const h="code";class m extends n.Sy{static get pluginName(){return"CodeEditing"}static get requires(){return[u.mh]}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:h}),e.model.schema.setAttributeProperties(h,{isFormatting:!0,copyOnEnter:!1}),e.conversion.attributeToElement({model:h,view:"code",upcastAlso:{styles:{"word-wrap":"break-word"}}}),e.commands.add(h,new o(e,h)),e.plugins.get(u.mh).registerAttribute(h),(0,u.Im)(e,h,"code","ck-code_selected")}}const g="code";class f extends n.Sy{static get pluginName(){return"CodeUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(g,(i=>{const n=e.commands.get(g),o=new a.r5(i);return o.set({label:t("Code"),icon:'',tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(g),e.editing.view.focus()})),o}))}}class p extends n.Sy{static get requires(){return[m,f]}static get pluginName(){return"Code"}}const b="italic";class w extends n.Sy{static get pluginName(){return"ItalicEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:b}),e.model.schema.setAttributeProperties(b,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:b,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add(b,new o(e,b)),e.keystrokes.set("CTRL+I",b)}}const v="italic";class _ extends n.Sy{static get pluginName(){return"ItalicUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(v,(i=>{const n=e.commands.get(v),o=new a.r5(i);return o.set({label:t("Italic"),icon:'',keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(v),e.editing.view.focus()})),o}))}}class y extends n.Sy{static get requires(){return[w,_]}static get pluginName(){return"Italic"}}const k="strikethrough";class C extends n.Sy{static get pluginName(){return"StrikethroughEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:k}),e.model.schema.setAttributeProperties(k,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:k,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),e.commands.add(k,new o(e,k)),e.keystrokes.set("CTRL+SHIFT+X","strikethrough")}}const A="strikethrough";class E extends n.Sy{static get pluginName(){return"StrikethroughUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(A,(i=>{const n=e.commands.get(A),o=new a.r5(i);return o.set({label:t("Strikethrough"),icon:'',keystroke:"CTRL+SHIFT+X",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(A),e.editing.view.focus()})),o}))}}class x extends n.Sy{static get requires(){return[C,E]}static get pluginName(){return"Strikethrough"}}const T="subscript";class S extends n.Sy{static get pluginName(){return"SubscriptEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:T}),e.model.schema.setAttributeProperties(T,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:T,view:"sub",upcastAlso:[{styles:{"vertical-align":"sub"}}]}),e.commands.add(T,new o(e,T))}}const P="subscript";class I extends n.Sy{static get pluginName(){return"SubscriptUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(P,(i=>{const n=e.commands.get(P),o=new a.r5(i);return o.set({label:t("Subscript"),icon:'',tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(P),e.editing.view.focus()})),o}))}}class V extends n.Sy{static get requires(){return[S,I]}static get pluginName(){return"Subscript"}}const R="superscript";class O extends n.Sy{static get pluginName(){return"SuperscriptEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:R}),e.model.schema.setAttributeProperties(R,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:R,view:"sup",upcastAlso:[{styles:{"vertical-align":"super"}}]}),e.commands.add(R,new o(e,R))}}const B="superscript";class M extends n.Sy{static get pluginName(){return"SuperscriptUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(B,(i=>{const n=e.commands.get(B),o=new a.r5(i);return o.set({label:t("Superscript"),icon:'',tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(B),e.editing.view.focus()})),o}))}}class N extends n.Sy{static get requires(){return[O,M]}static get pluginName(){return"Superscript"}}const D="underline";class L extends n.Sy{static get pluginName(){return"UnderlineEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:D}),e.model.schema.setAttributeProperties(D,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:D,view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),e.commands.add(D,new o(e,D)),e.keystrokes.set("CTRL+U","underline")}}const F="underline";class z extends n.Sy{static get pluginName(){return"UnderlineUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(F,(i=>{const n=e.commands.get(F),o=new a.r5(i);return o.set({label:t("Underline"),icon:'',keystroke:"CTRL+U",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(F),e.editing.view.focus()})),o}))}}class H extends n.Sy{static get requires(){return[L,z]}static get pluginName(){return"Underline"}}},3306:(e,t,i)=>{"use strict";i.r(t),i.d(t,{BlockQuote:()=>g,BlockQuoteEditing:()=>u,BlockQuoteUI:()=>m});var n=i(6854),o=i(1863),s=i(5187),r=i(6553);class a extends n.mY{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,n=t.document.selection,o=Array.from(n.getSelectedBlocks()),s=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(s){const t=o.filter((e=>l(e)||d(i,e)));this._applyQuote(e,t)}else this._removeQuote(e,o.filter(l))}))}_getValue(){const e=this.editor.model.document.selection,t=(0,r.Ps)(e.getSelectedBlocks());return!(!t||!l(t))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=(0,r.Ps)(e.getSelectedBlocks());return!!i&&d(t,i)}_removeQuote(e,t){c(e,t).reverse().forEach((t=>{if(t.start.isAtStart&&t.end.isAtEnd)return void e.unwrap(t.start.parent);if(t.start.isAtStart){const i=e.createPositionBefore(t.start.parent);return void e.move(t,i)}t.end.isAtEnd||e.split(t.end);const i=e.createPositionAfter(t.end.parent);e.move(t,i)}))}_applyQuote(e,t){const i=[];c(e,t).reverse().forEach((t=>{let n=l(t.start);n||(n=e.createElement("blockQuote"),e.wrap(t,n)),i.push(n)})),i.reverse().reduce(((t,i)=>t.nextSibling==i?(e.merge(e.createPositionAfter(t)),t):i))}}function l(e){return"blockQuote"==e.parent.name?e.parent:null}function c(e,t){let i,n=0;const o=[];for(;n{const n=e.model.document.differ.getChanges();for(const e of n)if("insert"==e.type){const n=e.position.nodeAfter;if(!n)continue;if(n.is("element","blockQuote")&&n.isEmpty)return i.remove(n),!0;if(n.is("element","blockQuote")&&!t.checkChild(e.position,n))return i.unwrap(n),!0;if(n.is("element")){const e=i.createRangeIn(n);for(const n of e.getItems())if(n.is("element","blockQuote")&&!t.checkChild(i.createPositionBefore(n),n))return i.unwrap(n),!0}}else if("remove"==e.type){const t=e.position.parent;if(t.is("element","blockQuote")&&t.isEmpty)return i.remove(t),!0}return!1}));const i=this.editor.editing.view.document,n=e.model.document.selection,o=e.commands.get("blockQuote");this.listenTo(i,"enter",((t,i)=>{n.isCollapsed&&o.value&&n.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"}),this.listenTo(i,"delete",((t,i)=>{if("backward"!=i.direction||!n.isCollapsed||!o.value)return;const s=n.getLastPosition().parent;s.isEmpty&&!s.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"})}}var h=i(7095);class m extends n.Sy{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",(i=>{const o=e.commands.get("blockQuote"),s=new h.r5(i);return s.set({label:t("Block quote"),icon:n.icons.quote,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(s,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),s}))}}class g extends n.Sy{static get requires(){return[u,m]}static get pluginName(){return"BlockQuote"}}},6597:(e,t,i)=>{"use strict";i.r(t),i.d(t,{CodeBlock:()=>v,CodeBlockEditing:()=>g,CodeBlockUI:()=>w});var n=i(6854),o=i(1863),s=i(3291),r=i(6553),a=i(4934);class l extends n.mY{constructor(e){super(e),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,i=t.model,n=i.document.selection,o=(0,a.getNormalizedAndLocalizedLanguageDefinitions)(t)[0],s=Array.from(n.getSelectedBlocks()),r=null==e.forceValue?!this.value:e.forceValue,l=function(e,t,i){return e.language?e.language:e.usePreviousLanguageChoice&&t?t:i}(e,this._lastLanguage,o.language);i.change((e=>{r?this._applyCodeBlock(e,s,l):this._removeCodeBlock(e,s)}))}_getValue(){const e=this.editor.model.document.selection,t=(0,r.Ps)(e.getSelectedBlocks());return!(!t||!t.is("element","codeBlock"))&&t.getAttribute("language")}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=(0,r.Ps)(e.getSelectedBlocks());return!!i&&(0,a.canBeCodeBlock)(t,i)}_applyCodeBlock(e,t,i){this._lastLanguage=i;const n=this.editor.model.schema,o=t.filter((e=>(0,a.canBeCodeBlock)(n,e)));for(const t of o)e.rename(t,"codeBlock"),e.setAttribute("language",i,t),n.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter((e=>!n.checkChild(t,e))).forEach((t=>e.remove(t)));o.reverse().forEach(((t,i)=>{const n=o[i+1];t.previousSibling===n&&(e.appendElement("softBreak",n),e.merge(e.createPositionBefore(t)))}))}_removeCodeBlock(e,t){const i=t.filter((e=>e.is("element","codeBlock")));for(const t of i){const i=e.createRangeOn(t);for(const t of Array.from(i.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:i}=e.split(e.createPositionBefore(t)),n=i.nodeAfter;e.rename(n,"paragraph"),e.removeAttribute("language",n),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}class c extends n.mY{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((t=>{const i=(0,a.getIndentOutdentPositions)(e);for(const n of i){const i=t.createText(this._indentSequence);e.insertContent(i,n)}}))}_checkEnabled(){return!!this._indentSequence&&(0,a.isModelSelectionInCodeBlock)(this.editor.model.document.selection)}}class d extends n.mY{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=(0,a.getIndentOutdentPositions)(e);for(const i of t){const t=u(e,i,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!(0,a.isModelSelectionInCodeBlock)(e.document.selection)&&(0,a.getIndentOutdentPositions)(e).some((t=>u(e,t,this._indentSequence)))}}function u(e,t,i){const n=function(e){let t=e.parent.getChild(e.index);return t&&!t.is("element","softBreak")||(t=e.nodeBefore),!t||t.is("element","softBreak")?null:t}(t);if(!n)return null;const o=(0,a.getLeadingWhiteSpaces)(n),s=o.lastIndexOf(i);if(s+i.length!==o.length)return null;if(-1===s)return null;const{parent:r,startOffset:l}=n;return e.createRange(e.createPositionAt(r,l+s),e.createPositionAt(r,l+s+i.length))}function h(e,t,i=!1){const n=(0,a.getPropertyAssociation)(t,"language","class"),o=(0,a.getPropertyAssociation)(t,"language","label");return(t,s,r)=>{const{writer:a,mapper:l,consumable:c}=r;if(!c.consume(s.item,"insert"))return;const d=s.item.getAttribute("language"),u=l.toViewPosition(e.createPositionBefore(s.item)),h={};i&&(h["data-language"]=o[d],h.spellcheck="false");const m=n[d]?{class:n[d]}:void 0,g=a.createContainerElement("code",m),f=a.createContainerElement("pre",h,g);a.insert(u,f),l.bindElements(s.item,g)}}const m="paragraph";class g extends n.Sy{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[o.G]}constructor(e){super(e),e.config.define("codeBlock",{languages:[{language:"plaintext",label:"Plain text"},{language:"c",label:"C"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"diff",label:"Diff"},{language:"html",label:"HTML"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"php",label:"PHP"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"typescript",label:"TypeScript"},{language:"xml",label:"XML"}],indentSequence:"\t"})}init(){const e=this.editor,t=e.model.schema,i=e.model,n=e.editing.view,o=e.plugins.has("DocumentListEditing"),r=(0,a.getNormalizedAndLocalizedLanguageDefinitions)(e);e.commands.add("codeBlock",new l(e)),e.commands.add("indentCodeBlock",new c(e)),e.commands.add("outdentCodeBlock",new d(e)),this.listenTo(n.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",isBlock:!0,allowAttributes:["language"]}),t.addAttributeCheck(((e,t)=>{const i=e.endsWith("codeBlock")&&t.startsWith("list")&&"list"!==t;return!(!o||!i)||!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",h(i,r,!0)),e.data.downcastDispatcher.on("insert:codeBlock",h(i,r)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,i,n)=>{if("codeBlock"!==i.item.parent.name)return;const{writer:o,mapper:s,consumable:r}=n;if(!r.consume(i.item,"insert"))return;const a=s.toViewPosition(e.createPositionBefore(i.item));o.insert(a,o.createText("\n"))}}(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const i=(0,a.getPropertyAssociation)(t,"class","language"),n=t[0].language;return(e,t,o)=>{const s=t.viewItem,r=s.parent;if(!r||!r.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:l}=o;if(!a.test(s,{name:!0}))return;const c=l.createElement("codeBlock"),d=[...s.getClassNames()];d.length||d.push("");for(const e of d){const t=i[e];if(t){l.setAttribute("language",t,c);break}}c.hasAttribute("language")||l.setAttribute("language",n,c),o.convertChildren(s,c),o.safeInsert(c,t.modelCursor)&&(a.consume(s,{name:!0}),o.updateConversionResult(c,t))}}(0,r)),e.data.upcastDispatcher.on("text",((e,t,{consumable:i,writer:n})=>{let o=t.modelCursor;if(!i.test(t.viewItem))return;if(!o.findAncestor("codeBlock"))return;i.consume(t.viewItem);const s=t.viewItem.data.split("\n").map((e=>n.createText(e))),r=s[s.length-1];for(const e of s)if(n.insert(e,o),o=o.getShiftedBy(e.offsetSize),e!==r){const e=n.createElement("softBreak");n.insert(e,o),o=n.createPositionAfter(e)}t.modelRange=n.createRange(t.modelCursor,o),t.modelCursor=o})),e.data.upcastDispatcher.on("element:pre",((e,t,{consumable:i})=>{const n=t.viewItem;if(n.findAncestor("pre"))return;const o=Array.from(n.getChildren()),s=o.find((e=>e.is("element","code")));if(s)for(const e of o)e!==s&&e.is("$text")&&i.consume(e,{name:!0})}),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,n)=>{let o=i.createRange(i.document.selection.anchor);if(n.targetRanges&&(o=e.editing.mapper.toModelRange(n.targetRanges[0])),!o.start.parent.is("element","codeBlock"))return;const r=n.dataTransfer.getData("text/plain"),l=new s.yj(e.editing.view.document);n.content=(0,a.rawSnippetTextToViewDocumentFragment)(l,r)})),this.listenTo(i,"getSelectedContent",((e,[n])=>{const o=n.anchor;!n.isCollapsed&&o.parent.is("element","codeBlock")&&o.hasSameParentAs(n.focus)&&i.change((i=>{const s=e.return;if(o.parent.is("element")&&(s.childCount>1||n.containsEntireContent(o.parent))){const t=i.createElement("codeBlock",o.parent.getAttributes());i.append(s,t);const n=i.createDocumentFragment();return i.append(t,n),void(e.return=n)}const r=s.getChild(0);t.checkAttribute(r,"code")&&i.setAttribute("code",!0,r)}))}))}afterInit(){const e=this.editor,t=e.commands,i=t.get("indent"),n=t.get("outdent");i&&i.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),n&&n.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",((t,i)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const i=e.model.document,n=e.editing.view,o=i.selection.getLastPosition(),s=o.nodeAfter;return!(t||!i.selection.isCollapsed||!o.isAtStart)&&(!!p(s)&&(e.model.change((t=>{e.execute("enter");const n=i.selection.anchor.parent.previousSibling;t.rename(n,m),t.setSelection(n,"in"),e.model.schema.removeDisallowedAttributes([n],t),t.remove(s)})),n.scrollToTheSelection(),!0))}(e,i.isSoft)||function(e,t){const i=e.model,n=i.document,o=e.editing.view,s=n.selection.getLastPosition(),r=s.nodeBefore;let a;if(t||!n.selection.isCollapsed||!s.isAtEnd||!r||!r.previousSibling)return!1;if(p(r)&&p(r.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling),i.createPositionAfter(r));else if(f(r)&&p(r.previousSibling)&&p(r.previousSibling.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling),i.createPositionAfter(r));else{if(!(f(r)&&p(r.previousSibling)&&f(r.previousSibling.previousSibling)&&r.previousSibling.previousSibling&&p(r.previousSibling.previousSibling.previousSibling)))return!1;a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling.previousSibling),i.createPositionAfter(r))}return e.model.change((t=>{t.remove(a),e.execute("enter");const i=n.selection.anchor.parent;t.rename(i,m),e.model.schema.removeDisallowedAttributes([i],t)})),o.scrollToTheSelection(),!0}(e,i.isSoft)||function(e){const t=e.model.document,i=t.selection.getLastPosition(),n=i.nodeBefore||i.textNode;let o;n&&n.is("$text")&&(o=(0,a.getLeadingWhiteSpaces)(n)),e.model.change((i=>{e.execute("shiftEnter"),o&&i.insertText(o,t.selection.anchor)}))}(e),i.preventDefault(),t.stop())}),{context:"pre"})}}function f(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function p(e){return e&&e.is("element","softBreak")}var b=i(7095);class w extends n.Sy{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,n=(0,a.getNormalizedAndLocalizedLanguageDefinitions)(e);i.add("codeBlock",(i=>{const o=e.commands.get("codeBlock"),s=(0,b.t9)(i,b.Rm),r=s.buttonView,a=t("Insert code block");return r.set({label:a,tooltip:!0,icon:'',isToggleable:!0}),r.bind("isOn").to(o,"value",(e=>!!e)),r.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()})),s.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),s.class="ck-code-block-dropdown",s.bind("isEnabled").to(o),(0,b.Pm)(s,(()=>this._getLanguageListItemDefinitions(n)),{role:"menu",ariaLabel:a}),s}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new r.FE;for(const n of e){const e={type:"button",model:new b.Hn({_codeBlockLanguage:n.language,label:n.label,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(t=>t===e.model._codeBlockLanguage)),i.add(e)}return i}}class v extends n.Sy{static get requires(){return[g,w]}static get pluginName(){return"CodeBlock"}}},4934:(e,t,i)=>{"use strict";i.r(t),i.d(t,{canBeCodeBlock:()=>d,getIndentOutdentPositions:()=>l,getLeadingWhiteSpaces:()=>r,getNormalizedAndLocalizedLanguageDefinitions:()=>o,getPropertyAssociation:()=>s,isModelSelectionInCodeBlock:()=>c,rawSnippetTextToViewDocumentFragment:()=>a});var n=i(6553);function o(e){const t=e.t,i=e.config.get("codeBlock.languages");for(const e of i)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class=`language-${e.language}`);return i}function s(e,t,i){const n={};for(const o of e)"class"===t?n[o[t].split(" ").shift()]=o[i]:n[o[t]]=o[i];return n}function r(e){return e.data.match(/^(\s*)/)[0]}function a(e,t){const i=e.createDocumentFragment(),n=t.split("\n"),o=n.reduce(((t,i,o)=>(t.push(i),o{"use strict";i.r(t),i.d(t,{Command:()=>r,Context:()=>d,ContextPlugin:()=>u,DataApiMixin:()=>w,Editor:()=>f,ElementApiMixin:()=>v,MultiCommand:()=>l,PendingActions:()=>y,Plugin:()=>o,attachToForm:()=>b,icons:()=>E,secureSourceElement:()=>_});var n=i(5044);class o extends((0,n.ObservableMixin)()){constructor(e){super(),this._disableStack=new Set,this.editor=e,this.set("isEnabled",!0)}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",s,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",s),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}}function s(e){e.return=!1,e.stop()}class r extends((0,n.ObservableMixin)()){constructor(e){super(),this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._affectsData=!0,this._isEnabledBasedOnSelection=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",(()=>{this.refresh()})),this.listenTo(e,"change:isReadOnly",(()=>{this.refresh()})),this.on("set:isEnabled",(t=>{if(!this.affectsData)return;const i=e.model.document.selection,n=!("$graveyard"==i.getFirstPosition().root.rootName)&&e.model.canEditAt(i);(e.isReadOnly||this._isEnabledBasedOnSelection&&!n)&&(t.return=!1,t.stop())}),{priority:"highest"}),this.on("execute",(e=>{this.isEnabled||e.stop()}),{priority:"high"})}get affectsData(){return this._affectsData}set affectsData(e){this._affectsData=e}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",a,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",a),this.refresh())}execute(...e){}destroy(){this.stopListening()}}function a(e){e.return=!1,e.stop()}class l extends r{constructor(){super(...arguments),this._childCommandsDefinitions=[]}refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){(0,n.insertToPriorityArray)(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 c extends((0,n.EmitterMixin)()){constructor(e,t=[],i=[]){super(),this._plugins=new Map,this._context=e,this._availablePlugins=new Map;for(const e of t)e.pluginName&&this._availablePlugins.set(e.pluginName,e);this._contextPlugins=new Map;for(const[e,t]of i)this._contextPlugins.set(e,t),this._contextPlugins.set(t,e),e.pluginName&&this._availablePlugins.set(e.pluginName,e)}*[Symbol.iterator](){for(const e of this._plugins)"function"==typeof e[0]&&(yield e)}get(e){const t=this._plugins.get(e);if(!t){let t=e;throw"function"==typeof e&&(t=e.pluginName||e.name),new n.CKEditorError("plugincollection-plugin-not-loaded",this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}init(e,t=[],i=[]){const o=this,s=this._context;!function e(t,i=new Set){t.forEach((t=>{l(t)&&(i.has(t)||(i.add(t),t.pluginName&&!o._availablePlugins.has(t.pluginName)&&o._availablePlugins.set(t.pluginName,t),t.requires&&e(t.requires,i)))}))}(e),h(e);const r=[...function e(t,i=new Set){return t.map((e=>l(e)?e:o._availablePlugins.get(e))).reduce(((t,n)=>i.has(n)?t:(i.add(n),n.requires&&(h(n.requires,n),e(n.requires,i).forEach((e=>t.add(e)))),t.add(n))),new Set)}(e.filter((e=>!d(e,t))))];!function(e,t){for(const i of t){if("function"!=typeof i)throw new n.CKEditorError("plugincollection-replace-plugin-invalid-type",null,{pluginItem:i});const t=i.pluginName;if(!t)throw new n.CKEditorError("plugincollection-replace-plugin-missing-name",null,{pluginItem:i});if(i.requires&&i.requires.length)throw new n.CKEditorError("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const s=o._availablePlugins.get(t);if(!s)throw new n.CKEditorError("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:t});const r=e.indexOf(s);if(-1===r){if(o._contextPlugins.has(s))return;throw new n.CKEditorError("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:t})}if(s.requires&&s.requires.length)throw new n.CKEditorError("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:t});e.splice(r,1,i),o._availablePlugins.set(t,i)}}(r,i);const a=function(e){return e.map((e=>{let t=o._contextPlugins.get(e);return t=t||new e(s),o._add(e,t),t}))}(r);return m(a,"init").then((()=>m(a,"afterInit"))).then((()=>a));function l(e){return"function"==typeof e}function c(e){return l(e)&&!!e.isContextPlugin}function d(e,t){return t.some((t=>t===e||u(e)===t||u(t)===e))}function u(e){return l(e)?e.pluginName||e.name:e}function h(e,i=null){e.map((e=>l(e)?e:o._availablePlugins.get(e)||e)).forEach((e=>{!function(e,t){if(!l(e)){if(t)throw new n.CKEditorError("plugincollection-soft-required",s,{missingPlugin:e,requiredBy:u(t)});throw new n.CKEditorError("plugincollection-plugin-not-found",s,{plugin:e})}}(e,i),function(e,t){if(c(t)&&!c(e))throw new n.CKEditorError("plugincollection-context-required",s,{plugin:u(e),requiredBy:u(t)})}(e,i),function(e,i){if(i&&d(e,t))throw new n.CKEditorError("plugincollection-required",s,{plugin:u(e),requiredBy:u(i)})}(e,i)}))}function m(e,t){return e.reduce(((e,i)=>i[t]?o._contextPlugins.has(i)?e:e.then(i[t].bind(i)):e),Promise.resolve())}}destroy(){const e=[];for(const[,t]of this)"function"!=typeof t.destroy||this._contextPlugins.has(t)||e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);const i=e.pluginName;if(i){if(this._plugins.has(i))throw new n.CKEditorError("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}}class d{constructor(e){this._contextOwner=null,this.config=new n.Config(e,this.constructor.defaultConfig);const t=this.constructor.builtinPlugins;this.config.define("plugins",t),this.plugins=new c(this,t);const i=this.config.get("language")||{};this.locale=new n.Locale({uiLanguage:"string"==typeof i?i:i.ui,contentLanguage:this.config.get("language.content")}),this.t=this.locale.t,this.editors=new n.Collection}initPlugins(){const e=this.config.get("plugins")||[],t=this.config.get("substitutePlugins")||[];for(const i of e.concat(t)){if("function"!=typeof i)throw new n.CKEditorError("context-initplugins-constructor-only",null,{Plugin:i});if(!0!==i.isContextPlugin)throw new n.CKEditorError("context-initplugins-invalid-plugin",null,{Plugin:i})}return this.plugins.init(e,[],t)}destroy(){return Promise.all(Array.from(this.editors,(e=>e.destroy()))).then((()=>this.plugins.destroy()))}_addEditor(e,t){if(this._contextOwner)throw new n.CKEditorError("context-addeditor-private-context");this.editors.add(e),t&&(this._contextOwner=e)}_removeEditor(e){return this.editors.has(e)&&this.editors.remove(e),this._contextOwner===e?this.destroy():Promise.resolve()}_getEditorConfig(){const e={};for(const t of this.config.names())["plugins","removePlugins","extraPlugins"].includes(t)||(e[t]=this.config.get(t));return e}static create(e){return new Promise((t=>{const i=new this(e);t(i.initPlugins().then((()=>i)))}))}}class u extends((0,n.ObservableMixin)()){constructor(e){super(),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}var h=i(6243);class m{constructor(){this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){const i=this.get(e);if(!i)throw new n.CKEditorError("commandcollection-command-not-found",this,{commandName:e});return i.execute(...t)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const e of this.commands())e.destroy()}}class g extends n.KeystrokeHandler{constructor(e){super(),this.editor=e}set(e,t,i={}){if("string"==typeof t){const e=t;t=(t,i)=>{this.editor.execute(e),i()}}super.set(e,t,i)}}class f extends((0,n.ObservableMixin)()){constructor(e={}){super();const t=this.constructor,i=e.language||t.defaultConfig&&t.defaultConfig.language;this._context=e.context||new d({language:i}),this._context._addEditor(this,!e.context);const o=Array.from(t.builtinPlugins||[]);this.config=new n.Config(e,t.defaultConfig),this.config.define("plugins",o),this.config.define(this._context._getEditorConfig()),this.plugins=new c(this,o,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new m,this.set("state","initializing"),this.once("ready",(()=>this.state="ready"),{priority:"high"}),this.once("destroy",(()=>this.state="destroyed"),{priority:"high"}),this.model=new h.Model,this.on("change:isReadOnly",(()=>{this.model.document.isReadOnly=this.isReadOnly}));const s=new h.StylesProcessor;this.data=new h.DataController(this.model,s),this.editing=new h.EditingController(this.model,s),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new h.Conversion([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 g(this),this.keystrokes.listenTo(this.editing.view.document)}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new n.CKEditorError("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new n.CKEditorError("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 n.CKEditorError("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),0===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!1,!0))}initPlugins(){const e=this.config,t=e.get("plugins"),i=e.get("removePlugins")||[],n=e.get("extraPlugins")||[],o=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(n),i,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){n.CKEditorError.rethrowUnexpectedError(e,this)}}focus(){this.editing.view.focus()}static create(...e){throw new Error("This is an abstract method.")}}var p=i(3234);function b(e){if(!(0,p.Z)(e.updateSourceElement))throw new n.CKEditorError("attachtoform-missing-elementapi-interface",e);const t=e.sourceElement;if(function(e){return!!e&&"textarea"===e.tagName.toLowerCase()}(t)&&t.form){let i;const n=t.form,o=()=>e.updateSourceElement();(0,p.Z)(n.submit)&&(i=n.submit,n.submit=()=>{o(),i.apply(n)}),n.addEventListener("submit",o),e.on("destroy",(()=>{n.removeEventListener("submit",o),i&&(n.submit=i)}))}}function w(e){return class extends e{setData(e){this.data.set(e)}getData(e){return this.data.get(e)}}}{const e=w(Object);w.setData=e.prototype.setData,w.getData=e.prototype.getData}function v(e){return class extends e{updateSourceElement(e=this.data.get()){if(!this.sourceElement)throw new n.CKEditorError("editor-missing-sourceelement",this);const t=this.config.get("updateSourceElementOnDestroy"),i=this.sourceElement instanceof HTMLTextAreaElement;t||i?(0,n.setDataInElement)(this.sourceElement,e):(0,n.setDataInElement)(this.sourceElement,"")}}}function _(e,t){if(t.ckeditorInstance)throw new n.CKEditorError("editor-source-element-already-used",e);t.ckeditorInstance=e,e.once("destroy",(()=>{delete t.ckeditorInstance}))}v.updateSourceElement=v(Object).prototype.updateSourceElement;class y extends u{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new n.Collection({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new n.CKEditorError("pendingactions-add-invalid-message",this);const t=new((0,n.ObservableMixin)());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]()}}var k=i(2946),C=i(7630),A=i(5270);const E={bold:'',cancel:k.Z,caption:'',check:C.Z,cog:'',eraser:A.Z,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:''}},5480:(e,t,i)=>{"use strict";i.r(t),i.d(t,{ClassicEditor:()=>y});var n=i(7095),o=i(3291),s=i(6553);class r extends n.S8{constructor(e,t){super(e),this.view=t,this._toolbarConfig=(0,n.iw)(e.config.get("toolbar")),this._elementReplacer=new s.a6,this.listenTo(e.editing.view,"scrollToTheSelection",this._handleScrollToTheSelectionWithStickyPanel.bind(this))}get element(){return this.view.element}init(e){const t=this.editor,i=this.view,n=t.editing.view,o=i.editable,s=n.document.getRoot();o.name=s.rootName,i.render();const r=o.element;this.setEditableElement(o.name,r),i.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),t.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.view;e.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),e.stickyPanel.limiterElement=e.element,e.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",(({top:e})=>e||0)),e.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(e.toolbar)}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.sourceElement;let s;const r=e.config.get("placeholder");r&&(s="string"==typeof r?r:r[this.view.editable.name]),!s&&n&&"textarea"===n.tagName.toLowerCase()&&(s=n.getAttribute("placeholder")),s&&(i.placeholder=s),(0,o.ID)({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}_handleScrollToTheSelectionWithStickyPanel(e,t,i){const n=this.view.stickyPanel;if(n.isSticky){const e=new s.UL(n.element).height;t.viewportOffset.top+=e}else{const e=()=>{this.editor.editing.view.scrollToTheSelection(i)};this.listenTo(n,"change:isSticky",e),setTimeout((()=>{this.stopListening(n,"change:isSticky",e)}),20)}}}class a extends n.py{constructor(e,t,i={}){super(e),this.stickyPanel=new n.lp(e),this.toolbar=new n.jB(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),this.editable=new n.r1(e,t)}render(){super.render(),this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}var l=i(6854);class c{constructor(e){if(this.crashes=[],this.state="initializing",this._now=Date.now,this.crashes=[],this._crashNumberLimit="number"==typeof e.crashNumberLimit?e.crashNumberLimit:3,this._minimumNonErrorTimePeriod="number"==typeof e.minimumNonErrorTimePeriod?e.minimumNonErrorTimePeriod:5e3,this._boundErrorHandler=e=>{const t="error"in e?e.error:e.reason;t instanceof Error&&this._handleError(t,e)},this._listeners={},!this._restart)throw new Error("The Watchdog class was split into the abstract `Watchdog` class and the `EditorWatchdog` class. Please, use `EditorWatchdog` if you have used the `Watchdog` class previously.")}destroy(){this._stopErrorHandling(),this._listeners={}}on(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}off(e,t){this._listeners[e]=this._listeners[e].filter((e=>e!==t))}_fire(e,...t){const i=this._listeners[e]||[];for(const e of i)e.apply(this,[null,...t])}_startErrorHandling(){window.addEventListener("error",this._boundErrorHandler),window.addEventListener("unhandledrejection",this._boundErrorHandler)}_stopErrorHandling(){window.removeEventListener("error",this._boundErrorHandler),window.removeEventListener("unhandledrejection",this._boundErrorHandler)}_handleError(e,t){if(this._shouldReactToError(e)){this.crashes.push({message:e.message,stack:e.stack,filename:t instanceof ErrorEvent?t.filename:void 0,lineno:t instanceof ErrorEvent?t.lineno:void 0,colno:t instanceof ErrorEvent?t.colno:void 0,date:this._now()});const i=this._shouldRestart();this.state="crashed",this._fire("stateChange"),this._fire("error",{error:e,causesRestart:i}),i?this._restart():(this.state="crashedPermanently",this._fire("stateChange"))}}_shouldReactToError(e){return e.is&&e.is("CKEditorError")&&void 0!==e.context&&null!==e.context&&"ready"===this.state&&this._isErrorComingFromThisItem(e)}_shouldRestart(){return this.crashes.length<=this._crashNumberLimit||(this.crashes[this.crashes.length-1].date-this.crashes[this.crashes.length-1-this._crashNumberLimit].date)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}}function d(e,t=new Set){const i=[e],n=new Set;let o=0;for(;i.length>o;){const e=i[o++];if(!n.has(e)&&u(e)&&!t.has(e))if(n.add(e),Symbol.iterator in e)try{for(const t of e)i.push(t)}catch(e){}else for(const t in e)"defaultValue"!==t&&i.push(e[t])}return n}function u(e){const t=Object.prototype.toString.call(e),i=typeof e;return!("number"===i||"boolean"===i||"string"===i||"symbol"===i||"function"===i||"[object Date]"===t||"[object RegExp]"===t||"[object Module]"===t||null==e||e._watchdogExcluded||e instanceof EventTarget||e instanceof Event)}function h(e,t,i=new Set){if(e===t&&"object"==typeof(n=e)&&null!==n)return!0;var n;const o=d(e,i),s=d(t,i);for(const e of o)if(s.has(e))return!0;return!1}var m=i(111),g=i(3251),f=i(4612);class p extends c{constructor(e,t={}){super(t),this._editor=null,this._initUsingData=!0,this._editables={},this._throttledSave=(0,m.Z)(this._save.bind(this),"number"==typeof t.saveInterval?t.saveInterval:5e3),e&&(this._creator=(t,i)=>e.create(t,i)),this._destructor=e=>e.destroy()}get editor(){return this._editor}get _item(){return this._editor}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}_restart(){return Promise.resolve().then((()=>(this.state="initializing",this._fire("stateChange"),this._destroy()))).catch((e=>{console.error("An error happened during the editor destroying.",e)})).then((()=>{const e={},t=[],i=this._config.rootsAttributes||{},n={};for(const[o,s]of Object.entries(this._data.roots))s.isLoaded?(e[o]="",n[o]=i[o]||{}):t.push(o);const o={...this._config,extraPlugins:this._config.extraPlugins||[],lazyRoots:t,rootsAttributes:n,_watchdogInitialData:this._data};return delete o.initialData,o.extraPlugins.push(b),this._initUsingData?this.create(e,o,o.context):(0,g.Z)(this._elementOrData)?this.create(this._elementOrData,o,o.context):this.create(this._editables,o,o.context)})).then((()=>{this._fire("restart")}))}create(e=this._elementOrData,t=this._config,i){return Promise.resolve().then((()=>(super._startErrorHandling(),this._elementOrData=e,this._initUsingData="string"==typeof e||Object.keys(e).length>0&&"string"==typeof Object.values(e)[0],this._config=this._cloneEditorConfiguration(t)||{},this._config.context=i,this._creator(e,this._config)))).then((e=>{this._editor=e,e.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=e.model.document.version,this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this.state="ready",this._fire("stateChange")}))}destroy(){return Promise.resolve().then((()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling(),this._throttledSave.cancel();const e=this._editor;return this._editor=null,e.model.document.off("change:data",this._throttledSave),this._destructor(e)}))}_save(){const e=this._editor.model.document.version;try{this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this._lastDocumentVersion=e}catch(e){console.error(e,"An error happened during restoring editor data. Editor will be restored from the previously saved data.")}}_setExcludedProperties(e){this._excludedProps=e}_getData(){const e=this._editor,t=e.model.document.roots.filter((e=>e.isAttached()&&"$graveyard"!=e.rootName)),{plugins:i}=e,n=i.has("CommentsRepository")&&i.get("CommentsRepository"),o=i.has("TrackChanges")&&i.get("TrackChanges"),s={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};t.forEach((e=>{s.roots[e.rootName]={content:JSON.stringify(Array.from(e.getChildren())),attributes:JSON.stringify(Array.from(e.getAttributes())),isLoaded:e._isLoaded}}));for(const t of e.model.markers)t._affectsData&&(s.markers[t.name]={rangeJSON:t.getRange().toJSON(),usingOperation:t._managedUsingOperations,affectsData:t._affectsData});return n&&(s.commentThreads=JSON.stringify(n.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),o&&(s.suggestions=JSON.stringify(o.getSuggestions({toJSON:!0,skipNotAttached:!0}))),s}_getEditables(){const e={};for(const t of this.editor.model.document.getRootNames()){const i=this.editor.ui.getEditableElement(t);i&&(e[t]=i)}return e}_isErrorComingFromThisItem(e){return h(this._editor,e.context,this._excludedProps)}_cloneEditorConfiguration(e){return(0,f.Z)(e,((e,t)=>(0,g.Z)(e)||"context"===t?e:void 0))}}class b{constructor(e){this.editor=e,this._data=e.config.get("_watchdogInitialData")}init(){this.editor.data.on("init",(e=>{e.stop(),this.editor.model.enqueueChange({isUndoable:!1},(e=>{this._restoreCollaborationData(),this._restoreEditorData(e)})),this.editor.data.fire("ready")}),{priority:999})}_createNode(e,t){if("name"in t){const i=e.createElement(t.name,t.attributes);if(t.children)for(const n of t.children)i._appendChild(this._createNode(e,n));return i}return e.createText(t.data,t.attributes)}_restoreEditorData(e){const t=this.editor;Object.entries(this._data.roots).forEach((([i,{content:n,attributes:o}])=>{const s=JSON.parse(n),r=JSON.parse(o),a=t.model.document.getRoot(i);for(const[t,i]of r)e.setAttribute(t,i,a);for(const t of s){const i=this._createNode(e,t);e.insert(i,a,"end")}})),Object.entries(this._data.markers).forEach((([i,n])=>{const{document:o}=t.model,{rangeJSON:{start:s,end:r},...a}=n,l=o.getRoot(s.root),c=e.createPositionFromPath(l,s.path,s.stickiness),d=e.createPositionFromPath(l,r.path,r.stickiness),u=e.createRange(c,d);e.addMarker(i,{range:u,...a})}))}_restoreCollaborationData(){const e=JSON.parse(this._data.commentThreads),t=JSON.parse(this._data.suggestions);e.forEach((e=>{const t=this.editor.config.get("collaboration.channelId"),i=this.editor.plugins.get("CommentsRepository");i.hasCommentThread(e.threadId)&&i.getCommentThread(e.threadId).remove(),i.addCommentThread({channelId:t,...e})})),t.forEach((e=>{const t=this.editor.plugins.get("TrackChangesEditing");t.hasSuggestion(e.id)?t.getSuggestion(e.id).attributes=e.attributes:t.addSuggestionData(e)}))}}const w=Symbol("MainQueueId");class v{constructor(){this._onEmptyCallbacks=[],this._queues=new Map,this._activeActions=0}onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){const i=e===w;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());const n=(i?Promise.all(this._queues.values()):Promise.all([this._queues.get(w),this._queues.get(e)])).then(t),o=n.catch((()=>{}));return this._queues.set(e,o),n.finally((()=>{this._activeActions--,this._queues.get(e)===o&&0===this._activeActions&&this._onEmptyCallbacks.forEach((e=>e()))}))}}function _(e){return Array.isArray(e)?e:[e]}class y extends((0,l.W9)((0,l.xK)(l.ML))){constructor(e,t={}){if(!k(e)&&void 0!==t.initialData)throw new s.Bb("editor-create-initial-data",null);super(t),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return k(e)?(0,s.yy)(e):e}(e)),k(e)&&(this.sourceElement=e),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=new a(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:i});this.ui=new r(this,n),(0,l.P$)(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise((i=>{const n=new this(e,t);i(n.initPlugins().then((()=>n.ui.init(k(e)?e:null))).then((()=>n.data.init(n.config.get("initialData")))).then((()=>n.fire("ready"))).then((()=>n)))}))}}function k(e){return(0,g.Z)(e)}y.Context=l._y,y.EditorWatchdog=p,y.ContextWatchdog=class extends c{constructor(e,t={}){super(t),this._watchdogs=new Map,this._context=null,this._contextProps=new Set,this._actionQueues=new v,this._watchdogConfig=t,this._creator=t=>e.create(t),this._destructor=e=>e.destroy(),this._actionQueues.onEmpty((()=>{"initializing"===this.state&&(this.state="ready",this._fire("stateChange"))}))}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}get context(){return this._context}create(e={}){return this._actionQueues.enqueue(w,(()=>(this._contextConfig=e,this._create())))}getItem(e){return this._getWatchdog(e)._item}getItemState(e){return this._getWatchdog(e).state}add(e){const t=_(e);return Promise.all(t.map((e=>this._actionQueues.enqueue(e.id,(()=>{if("destroyed"===this.state)throw new Error("Cannot add items to destroyed watchdog.");if(!this._context)throw new Error("Context was not created yet. You should call the `ContextWatchdog#create()` method first.");let t;if(this._watchdogs.has(e.id))throw new Error(`Item with the given id is already added: '${e.id}'.`);if("editor"===e.type)return t=new p(null,this._watchdogConfig),t.setCreator(e.creator),t._setExcludedProperties(this._contextProps),e.destructor&&t.setDestructor(e.destructor),this._watchdogs.set(e.id,t),t.on("error",((i,{error:n,causesRestart:o})=>{this._fire("itemError",{itemId:e.id,error:n}),o&&this._actionQueues.enqueue(e.id,(()=>new Promise((i=>{const n=()=>{t.off("restart",n),this._fire("itemRestart",{itemId:e.id}),i()};t.on("restart",n)}))))})),t.create(e.sourceElementOrData,e.config,this._context);throw new Error(`Not supported item type: '${e.type}'.`)})))))}remove(e){const t=_(e);return Promise.all(t.map((e=>this._actionQueues.enqueue(e,(()=>{const t=this._getWatchdog(e);return this._watchdogs.delete(e),t.destroy()})))))}destroy(){return this._actionQueues.enqueue(w,(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_restart(){return this._actionQueues.enqueue(w,(()=>(this.state="initializing",this._fire("stateChange"),this._destroy().catch((e=>{console.error("An error happened during destroying the context or items.",e)})).then((()=>this._create())).then((()=>this._fire("restart"))))))}_create(){return Promise.resolve().then((()=>(this._startErrorHandling(),this._creator(this._contextConfig)))).then((e=>(this._context=e,this._contextProps=d(this._context),Promise.all(Array.from(this._watchdogs.values()).map((e=>(e._setExcludedProperties(this._contextProps),e.create(void 0,void 0,this._context))))))))}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling();const e=this._context;return this._context=null,this._contextProps=new Set,Promise.all(Array.from(this._watchdogs.values()).map((e=>e.destroy()))).then((()=>this._destructor(e)))}))}_getWatchdog(e){const t=this._watchdogs.get(e);if(!t)throw new Error(`Item with the given id was not registered: ${e}.`);return t}_isErrorComingFromThisItem(e){for(const t of this._watchdogs.values())if(t._isErrorComingFromThisItem(e))return!1;return h(this._context,e.context)}}},6243:(e,t,i)=>{"use strict";i.r(t),i.d(t,{AttributeElement:()=>De,AttributeOperation:()=>jn,BubblingEventInfo:()=>Pe,ClickObserver:()=>Zo,Conversion:()=>Tn,DataController:()=>xn,DataTransfer:()=>Wt,DocumentFragment:()=>Eo,DocumentSelection:()=>Ti,DomConverter:()=>Ct,DomEventData:()=>It,DomEventObserver:()=>Vt,DowncastWriter:()=>Ke,EditingController:()=>on,Element:()=>ei,FocusObserver:()=>Ft,History:()=>bo,HtmlDataProcessor:()=>En,InsertOperation:()=>Fn,LivePosition:()=>lo,LiveRange:()=>Ci,MarkerOperation:()=>Wn,Matcher:()=>_,MergeOperation:()=>Hn,Model:()=>qo,MouseObserver:()=>Go,MoveOperation:()=>Ln,NoOperation:()=>$n,Observer:()=>St,OperationFactory:()=>Jn,Position:()=>ni,Range:()=>ci,RenameOperation:()=>qn,Renderer:()=>ht,RootAttributeOperation:()=>Kn,RootOperation:()=>Zn,SplitOperation:()=>zn,StylesProcessor:()=>me,TabObserver:()=>qt,Text:()=>Qt,TextProxy:()=>Xt,TreeWalker:()=>ti,UpcastWriter:()=>Jo,View:()=>Zt,ViewAttributeElement:()=>De,ViewContainerElement:()=>we,ViewDocument:()=>Ne,ViewDocumentFragment:()=>qe,ViewEditableElement:()=>_e,ViewElement:()=>pe,ViewEmptyElement:()=>ze,ViewRawElement:()=>je,ViewRootEditableElement:()=>ke,ViewText:()=>b,ViewTreeWalker:()=>Ce,ViewUIElement:()=>We,addBackgroundRules:()=>As,addBorderRules:()=>Es,addMarginRules:()=>Ms,addPaddingRules:()=>Ns,disablePlaceholder:()=>s,enablePlaceholder:()=>o,findOptimalInsertionRange:()=>zo,getBoxSidesShorthandValue:()=>ys,getBoxSidesValueReducer:()=>_s,getBoxSidesValues:()=>vs,getFillerOffset:()=>ve,getPositionShorthandNormalizer:()=>ks,getShorthandValues:()=>Cs,hidePlaceholder:()=>a,isAttachment:()=>ps,isColor:()=>os,isLength:()=>ls,isLineStyle:()=>rs,isPercentage:()=>ds,isPosition:()=>gs,isRepeat:()=>hs,isURL:()=>ws,needsPlaceholder:()=>l,showPlaceholder:()=>r,transformSets:()=>to});const n=new WeakMap;function o({view:e,element:t,isDirectHost:i=!0,keepOnFocus:o=!1}){const s=e.document;function r(r){n.get(s).set(t,{text:r,isDirectHost:i,keepOnFocus:o,hostElement:i?t:null}),e.change((e=>c(s,e)))}n.has(s)||(n.set(s,new Map),s.registerPostFixer((e=>c(s,e))),s.on("change:isComposing",(()=>{e.change((e=>c(s,e)))}),{priority:"high"})),t.is("editableElement")&&t.on("change:placeholder",((e,t,i)=>{r(i)})),t.placeholder&&r(t.placeholder)}function s(e,t){const i=t.document;n.has(i)&&e.change((e=>{const o=n.get(i),s=o.get(t);e.removeAttribute("data-placeholder",s.hostElement),a(e,s.hostElement),o.delete(t)}))}function r(e,t){return!t.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",t),!0)}function a(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function l(e,t){if(!e.isAttached())return!1;const i=Array.from(e.getChildren()).some((e=>!e.is("uiElement")));if(i)return!1;const n=e.document,o=n.selection.anchor;return!(n.isComposing&&o&&o.parent===e||!t&&n.isFocused&&(!o||o.parent===e))}function c(e,t){const i=n.get(e),o=[];let s=!1;for(const[e,n]of i)n.isDirectHost&&(o.push(e),d(t,e,n)&&(s=!0));for(const[e,n]of i){if(n.isDirectHost)continue;const i=u(e);i&&(o.includes(i)||(n.hostElement=i,d(t,e,n)&&(s=!0)))}return s}function d(e,t,i){const{text:n,isDirectHost:o,hostElement:s}=i;let c=!1;return s.getAttribute("data-placeholder")!==n&&(e.setAttribute("data-placeholder",n,s),c=!0),(o||1==t.childCount)&&l(s,i.keepOnFocus)?r(e,s)&&(c=!0):a(e,s)&&(c=!0),c}function u(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}var h=i(5044);class m{is(){throw new Error("is() method is abstract")}}var g=i(9256);const f=function(e){return(0,g.Z)(e,4)};i(9807);class p extends((0,h.EmitterMixin)(m)){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 h.CKEditorError("view-node-not-found-in-parent",this);return e}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.root.is("rootElement")}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.index),t=t.parent;return e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let o=0;for(;i[o]==n[o]&&i[o];)o++;return 0===o?null:i[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=(0,h.compareArrays)(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n]e.data.length)throw new h.CKEditorError("view-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.data.length)throw new h.CKEditorError("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}getAncestors(e={}){const t=[];let i=e.includeSelf?this.textNode:this.parent;for(;null!==i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}}w.prototype.is=function(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e};var v=i(7514);class _{constructor(...e){this._patterns=[],this.add(...e)}add(...e){for(let t of e)("string"==typeof t||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(const t of e)for(const e of this._patterns){const i=y(t,e);if(i)return{element:t,pattern:e,match:i}}return null}matchAll(...e){const t=[];for(const i of e)for(const e of this._patterns){const n=y(i,e);n&&t.push({element:i,pattern:e,match:n})}return t.length>0?t:null}getElementName(){if(1!==this._patterns.length)return null;const e=this._patterns[0],t=e.name;return"function"==typeof e||!t||t instanceof RegExp?null:t}}function y(e,t){if("function"==typeof t)return t(e);const i={};return t.name&&(i.name=function(e,t){return e instanceof RegExp?!!t.match(e):e===t}(t.name,e.name),!i.name)||t.attributes&&(i.attributes=function(e,t){const i=new Set(t.getAttributeKeys());return(0,v.Z)(e)?(void 0!==e.style&&(0,h.logWarning)("matcher-pattern-deprecated-attributes-style-key",e),void 0!==e.class&&(0,h.logWarning)("matcher-pattern-deprecated-attributes-class-key",e)):(i.delete("style"),i.delete("class")),k(e,i,(e=>t.getAttribute(e)))}(t.attributes,e),!i.attributes)||t.classes&&(i.classes=function(e,t){return k(e,t.getClassNames(),(()=>{}))}(t.classes,e),!i.classes)||t.styles&&(i.styles=function(e,t){return k(e,t.getStyleNames(!0),(e=>t.getStyle(e)))}(t.styles,e),!i.styles)?null:i}function k(e,t,i){const n=function(e){return Array.isArray(e)?e.map((e=>(0,v.Z)(e)?(void 0!==e.key&&void 0!==e.value||(0,h.logWarning)("matcher-pattern-missing-key-or-value",e),[e.key,e.value]):[e,!0])):(0,v.Z)(e)?Object.entries(e):[[e,!0]]}(e),o=Array.from(t),s=[];if(n.forEach((([e,t])=>{o.forEach((n=>{(function(e,t){return!0===e||e===t||e instanceof RegExp&&t.match(e)})(e,n)&&function(e,t,i){if(!0===e)return!0;const n=i(t);return e===n||e instanceof RegExp&&!!String(n).match(e)}(t,n,i)&&s.push(n)}))})),n.length&&!(s.lengtht===e));return Array.isArray(t)}set(e,t){if((0,C.Z)(e))for(const[t,i]of Object.entries(e))this._styleProcessor.toNormalizedForm(t,i,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t=ge(e);(function(e,t){null==e||z(e,t)})(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]&&!(0,C.Z)(this._styles[e]))return this._styles[e];const t=this._styleProcessor.getReducedForm(e,this._styles).find((([t])=>t===e));return Array.isArray(t)?t[1]:void 0}getStyleNames(e=!1){return this.isEmpty?[]:e?this._styleProcessor.getStyleNames(this._styles):this._getStylesEntries().map((([e])=>e))}clear(){this._styles={}}_getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const i of t)e.push(...this._styleProcessor.getReducedForm(i,this._styles));return e}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const i=t.splice(0,t.length-1).join("."),n=H(this._styles,i);n&&!Array.from(Object.keys(n)).length&&this.remove(i)}}class me{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,i){if((0,C.Z)(t))fe(i,ge(e),t);else if(this._normalizers.has(e)){const n=this._normalizers.get(e),{path:o,value:s}=n(t);fe(i,o,s)}else fe(i,e,t)}getNormalized(e,t){if(!e)return le({},t);if(void 0!==t[e])return t[e];if(this._extractors.has(e)){const i=this._extractors.get(e);if("string"==typeof i)return H(t,i);const n=i(e,t);if(n)return n}return H(t,ge(e))}getReducedForm(e,t){const i=this.getNormalized(e,t);return void 0===i?[]:this._reducers.has(e)?this._reducers.get(e)(i):[[e,i]]}getStyleNames(e){const t=Array.from(this._consumables.keys()).filter((t=>{const i=this.getNormalized(t,e);return i&&"object"==typeof i?Object.keys(i).length:i})),i=new Set([...t,...Object.keys(e)]);return Array.from(i.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 i of t)this._mapStyleNames(i,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function ge(e){return e.replace("-",".")}function fe(e,t,i){let n=i;(0,C.Z)(i)&&(n=le({},H(e,t),i)),ue(e,t,n)}class pe extends p{constructor(e,t,i,n){if(super(e),this._unsafeAttributesToRender=[],this._customProperties=new Map,this.name=t,this._attrs=function(e){const t=(0,h.toMap)(e);for(const[e,i]of t)null===i?t.delete(e):"string"!=typeof i&&t.set(e,String(i));return t}(i),this._children=[],n&&this._insertChild(0,n),this._classes=new Set,this._attrs.has("class")){const e=this._attrs.get("class");be(this._classes,e),this._attrs.delete("class")}this._styles=new he(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style"))}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes.size>0&&(yield"class"),this._styles.isEmpty||(yield"style"),yield*this._attrs.keys()}*getAttributes(){yield*this._attrs.entries(),this._classes.size>0&&(yield["class",this.getAttribute("class")]),this._styles.isEmpty||(yield["style",this.getAttribute("style")])}getAttribute(e){if("class"==e)return this._classes.size>0?[...this._classes].join(" "):void 0;if("style"==e){const e=this._styles.toString();return""==e?void 0:e}return this._attrs.get(e)}hasAttribute(e){return"class"==e?this._classes.size>0:"style"==e?!this._styles.isEmpty:this._attrs.has(e)}isSimilar(e){if(!(e instanceof pe))return!1;if(this===e)return!0;if(this.name!=e.name)return!1;if(this._attrs.size!==e._attrs.size||this._classes.size!==e._classes.size||this._styles.size!==e._styles.size)return!1;for(const[t,i]of this._attrs)if(!e._attrs.has(t)||e._attrs.get(t)!==i)return!1;for(const t of this._classes)if(!e._classes.has(t))return!1;for(const t of this._styles.getStyleNames())if(!e._styles.has(t)||e._styles.getAsString(t)!==this._styles.getAsString(t))return!1;return!0}hasClass(...e){for(const t of e)if(!this._classes.has(t))return!1;return!0}getClassNames(){return this._classes.keys()}getStyle(e){return this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles.getNormalized(e)}getStyleNames(e){return this._styles.getStyleNames(e)}hasStyle(...e){for(const t of e)if(!this._styles.has(t))return!1;return!0}findAncestor(...e){const t=new _(...e);let i=this.parent;for(;i&&!i.is("documentFragment");){if(t.match(i))return i;i=i.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=Array.from(this._classes).sort().join(","),t=this._styles.toString(),i=Array.from(this._attrs).map((e=>`${e[0]}="${e[1]}"`)).sort().join(" ");return this.name+(""==e?"":` class="${e}"`)+(t?` style="${t}"`:"")+(""==i?"":` ${i}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(e=!1){const t=[];if(e)for(const i of this.getChildren())t.push(i._clone(e));const i=new this.constructor(this.document,this.name,this._attrs,t);return i._classes=new Set(this._classes),i._styles.set(this._styles.getNormalized()),i._customProperties=new Map(this._customProperties),i.getFillerOffset=this.getFillerOffset,i._unsafeAttributesToRender=this._unsafeAttributesToRender,i}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this);let i=0;const n=function(e,t){return"string"==typeof t?[new b(e,t)]:((0,h.isIterable)(t)||(t=[t]),Array.from(t).map((t=>"string"==typeof t?new b(e,t):t instanceof w?new b(e,t.data):t)))}(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,t.document=this.document,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this);for(let i=e;i0&&(this._classes.clear(),!0):"style"==e?!this._styles.isEmpty&&(this._styles.clear(),!0):this._attrs.delete(e)}_addClass(e){this._fireChange("attributes",this);for(const t of(0,h.toArray)(e))this._classes.add(t)}_removeClass(e){this._fireChange("attributes",this);for(const t of(0,h.toArray)(e))this._classes.delete(t)}_setStyle(e,t){this._fireChange("attributes",this),"string"!=typeof e?this._styles.set(e):this._styles.set(e,t)}_removeStyle(e){this._fireChange("attributes",this);for(const t of(0,h.toArray)(e))this._styles.remove(t)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}}function be(e,t){const i=t.split(/\s+/);e.clear(),i.forEach((t=>e.add(t)))}pe.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 we extends pe{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=ve}}function ve(){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}we.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 _e extends((0,h.ObservableMixin)(we)){constructor(e,t,i,n){super(e,t,i,n),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("placeholder",void 0),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",(t=>t&&e.selection.editableElement==this)),this.listenTo(e.selection,"change",(()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this}))}destroy(){this.stopListening()}}_e.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 ye=Symbol("rootName");class ke extends _e{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(ye)}set rootName(e){this._setCustomProperty(ye,e)}set _name(e){this.name=e}}ke.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 Ce{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new h.CKEditorError("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new h.CKEditorError("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=Ae._createAt(e.startPosition):this._position=Ae._createAt(e.boundaries["backward"==e.direction?"end":"start"]),this.direction=e.direction||"forward",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i;do{i=this.position,t=this.next()}while(!t.done&&e(t.value));t.done||(this._position=i)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&e.offset===i.childCount)return{done:!0,value:void 0};if(i===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let n;if(i instanceof b){if(e.isAtEnd)return this._position=Ae._createAfter(i),this._next();n=i.data[e.offset]}else n=i.getChild(e.offset);if(n instanceof pe){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}else e=new Ae(n,0);return this._position=e,this._formatReturnValue("elementStart",n,t,e,1)}if(n instanceof b){if(this.singleCharacters)return e=new Ae(n,0),this._position=e,this._next();let i,o=n.data.length;return n==this._boundaryEndParent?(o=this.boundaries.end.offset,i=new w(n,0,o),e=Ae._createAfter(i)):(i=new w(n,0,n.data.length),e.offset++),this._position=e,this._formatReturnValue("text",i,t,e,o)}if("string"==typeof n){let n;n=this.singleCharacters?1:(i===this._boundaryEndParent?this.boundaries.end.offset:i.data.length)-e.offset;const o=new w(i,e.offset,n);return e.offset+=n,this._position=e,this._formatReturnValue("text",o,t,e,n)}return e=Ae._createAfter(i),this._position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",i,t,e)}_previous(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&0===e.offset)return{done:!0,value:void 0};if(i==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let n;if(i instanceof b){if(e.isAtStart)return this._position=Ae._createBefore(i),this._previous();n=i.data[e.offset-1]}else n=i.getChild(e.offset-1);if(n instanceof pe)return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",n,t,e,1)):(e=new Ae(n,n.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",n,t,e));if(n instanceof b){if(this.singleCharacters)return e=new Ae(n,n.data.length),this._position=e,this._previous();let i,o=n.data.length;if(n==this._boundaryStartParent){const t=this.boundaries.start.offset;i=new w(n,t,n.data.length-t),o=i.data.length,e=Ae._createBefore(i)}else i=new w(n,0,n.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",i,t,e,o)}if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{const t=i===this._boundaryStartParent?this.boundaries.start.offset:0;n=e.offset-t}e.offset-=n;const o=new w(i,e.offset,n);return this._position=e,this._formatReturnValue("text",o,t,e,n)}return e=Ae._createBefore(i),this._position=e,this._formatReturnValue("elementStart",i,t,e,1)}_formatReturnValue(e,t,i,n,o){return t instanceof w&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?i=Ae._createAfter(t.textNode):(n=Ae._createAfter(t.textNode),this._position=n)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?i=Ae._createBefore(t.textNode):(n=Ae._createBefore(t.textNode),this._position=n))),{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:o}}}}class Ae extends m{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 _e);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(e){const t=Ae._createAt(this),i=t.offset+e;return t.offset=i<0?0:i,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new Ce(t);return i.skip(e),i.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),i=e.getAncestors();let n=0;for(;t[n]==i[n]&&t[n];)n++;return 0===n?null:t[n-1]}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return"before"==this.compareWith(e)}isAfter(e){return"after"==this.compareWith(e)}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";const t=this.parent.is("node")?this.parent.getPath():[],i=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),i.push(e.offset);const n=(0,h.compareArrays)(t,i);switch(n){case"prefix":return"before";case"extension":return"after";default:return t[n]0?new this(i,n):new this(n,i)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(Ae._createBefore(e),t)}}function xe(e){return!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))}Ee.prototype.is=function(e){return"range"===e||"view:range"===e};class Te extends((0,h.EmitterMixin)(m)){constructor(...e){super(),this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",e.length&&this.setTo(...e)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return 1===this.rangeCount&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(const t of this._ranges)e&&!t.start.isBefore(e.start)||(e=t);return e?e.clone():null}getLastRange(){let e=null;for(const t of this._ranges)e&&!t.end.isAfter(e.end)||(e=t);return e?e.clone():null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake)return!1;if(this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel)return!1;if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=(0,h.count)(this.getRanges());if(t!=(0,h.count)(e.getRanges()))return!1;if(0==t)return!0;for(let t of this.getRanges()){t=t.getTrimmed();let i=!1;for(let n of e.getRanges())if(n=n.getTrimmed(),t.start.isEqual(n.start)&&t.end.isEqual(n.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,i,n]=e;if("object"==typeof i&&(n=i,i=void 0),null===t)this._setRanges([]),this._setFakeOptions(n);else if(t instanceof Te||t instanceof Se)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof Ee)this._setRanges([t],n&&n.backward),this._setFakeOptions(n);else if(t instanceof Ae)this._setRanges([new Ee(t)]),this._setFakeOptions(n);else if(t instanceof p){const e=!!n&&!!n.backward;let o;if(void 0===i)throw new h.CKEditorError("view-selection-setto-required-second-parameter",this);o="in"==i?Ee._createIn(t):"on"==i?Ee._createOn(t):new Ee(Ae._createAt(t,i)),this._setRanges([o],e),this._setFakeOptions(n)}else{if(!(0,h.isIterable)(t))throw new h.CKEditorError("view-selection-setto-not-selectable",this);this._setRanges(t,n&&n.backward),this._setFakeOptions(n)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new h.CKEditorError("view-selection-setfocus-no-ranges",this);const i=Ae._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.pop(),"before"==i.compareWith(n)?this._addRange(new Ee(i,n),!0):this._addRange(new Ee(n,i)),this.fire("change")}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(const t of e)this._addRange(t);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,t=!1){if(!(e instanceof Ee))throw new h.CKEditorError("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 h.CKEditorError("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new Ee(e.start,e.end))}}Te.prototype.is=function(e){return"selection"===e||"view:selection"===e};class Se extends((0,h.EmitterMixin)(m)){constructor(...e){super(),this._selection=new Te,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)}}Se.prototype.is=function(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e};class Pe extends h.EventInfo{constructor(e,t,i){super(e,t),this.startRange=i,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const Ie=Symbol("bubbling contexts");function Ve(e){return class extends e{fire(e,...t){try{const i=e instanceof h.EventInfo?e:new h.EventInfo(this,e),n=Me(this);if(!n.size)return;if(Re(i,"capturing",this),Oe(n,"$capture",i,...t))return i.return;const o=i.startRange||this.selection.getFirstRange(),s=o?o.getContainedElement():null,r=!!s&&Boolean(Be(n,s));let a=s||function(e){if(!e)return null;const t=e.start.parent,i=e.end.parent,n=t.getPath(),o=i.getPath();return n.length>o.length?t:i}(o);if(Re(i,"atTarget",a),!r){if(Oe(n,"$text",i,...t))return i.return;Re(i,"bubbling",a)}for(;a;){if(a.is("rootElement")){if(Oe(n,"$root",i,...t))return i.return}else if(a.is("element")&&Oe(n,a.name,i,...t))return i.return;if(Oe(n,a,i,...t))return i.return;a=a.parent,Re(i,"bubbling",a)}return Re(i,"bubbling",this),Oe(n,"$document",i,...t),i.return}catch(e){h.CKEditorError.rethrowUnexpectedError(e,this)}}_addEventListener(e,t,i){const n=(0,h.toArray)(i.context||"$document"),o=Me(this);for(const s of n){let n=o.get(s);n||(n=new((0,h.EmitterMixin)()),o.set(s,n)),this.listenTo(n,e,t,i)}}_removeEventListener(e,t){const i=Me(this);for(const n of i.values())this.stopListening(n,e,t)}}}{const e=Ve(Object);["fire","_addEventListener","_removeEventListener"].forEach((t=>{Ve[t]=e.prototype[t]}))}function Re(e,t,i){e instanceof Pe&&(e._eventPhase=t,e._currentTarget=i)}function Oe(e,t,i,...n){const o="string"==typeof t?e.get(t):Be(e,t);return!!o&&(o.fire(i,...n),i.stop.called)}function Be(e,t){for(const[i,n]of e)if("function"==typeof i&&i(t))return n;return null}function Me(e){return e[Ie]||(e[Ie]=new Map),e[Ie]}class Ne extends(Ve((0,h.ObservableMixin)())){constructor(e){super(),this._postFixers=new Set,this.selection=new Se,this.roots=new h.Collection({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.map((e=>e.destroy())),this.stopListening()}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(t=i(e),t)break}while(t)}}class De extends pe{constructor(e,t,i,n){super(e,t,i,n),this._priority=10,this._id=null,this._clonesGroup=null,this.getFillerOffset=Le}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new h.CKEditorError("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 Le(){if(Fe(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(Fe(e)>1)return null;e=e.parent}return!e||Fe(e)>1?null:this.childCount}function Fe(e){return Array.from(e.getChildren()).filter((e=>!e.is("uiElement"))).length}De.DEFAULT_PRIORITY=10,De.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 ze extends pe{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=He}_insertChild(e,t){if(t&&(t instanceof p||Array.from(t).length>0))throw new h.CKEditorError("view-emptyelement-cannot-add",[this,t]);return 0}}function He(){return null}ze.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 We extends pe{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=Ue}_insertChild(e,t){if(t&&(t instanceof p||Array.from(t).length>0))throw new h.CKEditorError("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 Ue(){return null}We.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 je extends pe{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=$e}_insertChild(e,t){if(t&&(t instanceof p||Array.from(t).length>0))throw new h.CKEditorError("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}function $e(){return null}je.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 qe extends((0,h.EmitterMixin)(m)){constructor(e,t){super(),this._children=[],this._customProperties=new Map,this.document=e,t&&this._insertChild(0,t)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return 0===this.childCount}get root(){return this}get parent(){return null}get name(){}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,t){this._fireChange("children",this);let i=0;const n=function(e,t){return"string"==typeof t?[new b(e,t)]:((0,h.isIterable)(t)||(t=[t]),Array.from(t).map((t=>"string"==typeof t?new b(e,t):t instanceof w?new b(e,t.data):t)))}(this.document,t);for(const t of n)null!==t.parent&&t._remove(),t.parent=this,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this);for(let i=e;i{const i=e[e.length-1],n=!t.is("uiElement");return i&&i.breakAttributes==n?i.nodes.push(t):e.push({breakAttributes:n,nodes:[t]}),e}),[]);let n=null,o=e;for(const{nodes:e,breakAttributes:t}of i){const i=this._insertNodes(o,e,t);n||(n=i.start),o=i.end}return n?new Ee(n,o):new Ee(e)}remove(e){const t=e instanceof Ee?e:Ee._createOn(e);if(tt(t,this.document),t.isCollapsed)return new qe(this.document);const{start:i,end:n}=this._breakAttributesRange(t,!0),o=i.parent,s=n.offset-i.offset,r=o._removeChildren(i.offset,s);for(const e of r)this._removeFromClonedElementsGroup(e);const a=this.mergeAttributes(i);return t.start=a,t.end=a.clone(),new qe(this.document,r)}clear(e,t){tt(e,this.document);const i=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const n of i){const i=n.item;let o;if(i.is("element")&&t.isSimilar(i))o=Ee._createOn(i);else if(!n.nextPosition.isAfter(e.start)&&i.is("$textProxy")){const e=i.getAncestors().find((e=>e.is("element")&&t.isSimilar(e)));e&&(o=Ee._createIn(e))}o&&(o.end.isAfter(e.end)&&(o.end=e.end),o.start.isBefore(e.start)&&(o.start=e.start),this.remove(o))}}move(e,t){let i;if(t.isAfter(e.end)){const n=(t=this._breakAttributes(t,!0)).parent,o=n.childCount;e=this._breakAttributesRange(e,!0),i=this.remove(e),t.offset+=n.childCount-o}else i=this.remove(e);return this.insert(t,i)}wrap(e,t){if(!(t instanceof De))throw new h.CKEditorError("view-writer-wrap-invalid-attribute",this.document);if(tt(e,this.document),e.isCollapsed){let n=e.start;n.parent.is("element")&&(i=n.parent,!Array.from(i.getChildren()).some((e=>!e.is("uiElement"))))&&(n=n.getLastMatchingPosition((e=>e.item.is("uiElement")))),n=this._wrapPosition(n,t);const o=this.document.selection;return o.isCollapsed&&o.getFirstPosition().isEqual(e.start)&&this.setSelection(n),new Ee(n)}return this._wrapRange(e,t);var i}unwrap(e,t){if(!(t instanceof De))throw new h.CKEditorError("view-writer-unwrap-invalid-attribute",this.document);if(tt(e,this.document),e.isCollapsed)return e;const{start:i,end:n}=this._breakAttributesRange(e,!0),o=i.parent,s=this._unwrapChildren(o,i.offset,n.offset,t),r=this.mergeAttributes(s.start);r.isEqual(s.start)||s.end.offset--;const a=this.mergeAttributes(s.end);return new Ee(r,a)}rename(e,t){const i=new we(this.document,e,t.getAttributes());return this.insert(Ae._createAfter(t),i),this.move(Ee._createIn(t),Ae._createAt(i,0)),this.remove(Ee._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return Ae._createAt(e,t)}createPositionAfter(e){return Ae._createAfter(e)}createPositionBefore(e){return Ae._createBefore(e)}createRange(e,t){return new Ee(e,t)}createRangeOn(e){return Ee._createOn(e)}createRangeIn(e){return Ee._createIn(e)}createSelection(...e){return new Te(...e)}createSlot(e="children"){if(!this._slotFactory)throw new h.CKEditorError("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,i){let n,o;if(n=i?Ze(e):e.parent.is("$text")?e.parent.parent:e.parent,!n)throw new h.CKEditorError("view-writer-invalid-position-container",this.document);o=i?this._breakAttributes(e,!0):e.parent.is("$text")?Je(e):e;const s=n._insertChild(o.offset,t);for(const e of t)this._addToClonedElementsGroup(e);const r=o.getShiftedBy(s),a=this.mergeAttributes(o);a.isEqual(o)||r.offset--;const l=this.mergeAttributes(r);return new Ee(a,l)}_wrapChildren(e,t,i,n){let o=t;const s=[];for(;oa.priority)&&r.getIdentity()!1,e.parent._insertChild(e.offset,i);const n=new Ee(e,e.getShiftedBy(1));this.wrap(n,t);const o=new Ae(i.parent,i.index);i._remove();const s=o.nodeBefore,r=o.nodeAfter;return s instanceof b&&r instanceof b?Ye(s,r):Ge(o)}_wrapAttributeElement(e,t){if(!it(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&t.hasAttribute(i)&&t.getAttribute(i)!==e.getAttribute(i))return!1;for(const i of e.getStyleNames())if(t.hasStyle(i)&&t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&(t.hasAttribute(i)||this.setAttribute(i,e.getAttribute(i),t));for(const i of e.getStyleNames())t.hasStyle(i)||this.setStyle(i,e.getStyle(i),t);for(const i of e.getClassNames())t.hasClass(i)||this.addClass(i,t);return!0}_unwrapAttributeElement(e,t){if(!it(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&(!t.hasAttribute(i)||t.getAttribute(i)!==e.getAttribute(i)))return!1;if(!t.hasClass(...e.getClassNames()))return!1;for(const i of e.getStyleNames())if(!t.hasStyle(i)||t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&this.removeAttribute(i,t);return this.removeClass(Array.from(e.getClassNames()),t),this.removeStyle(Array.from(e.getStyleNames()),t),!0}_breakAttributesRange(e,t=!1){const i=e.start,n=e.end;if(tt(e,this.document),e.isCollapsed){const i=this._breakAttributes(e.start,t);return new Ee(i,i)}const o=this._breakAttributes(n,t),s=o.parent.childCount,r=this._breakAttributes(i,t);return o.offset+=o.parent.childCount-s,new Ee(r,o)}_breakAttributes(e,t=!1){const i=e.offset,n=e.parent;if(e.parent.is("emptyElement"))throw new h.CKEditorError("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new h.CKEditorError("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new h.CKEditorError("view-writer-cannot-break-raw-element",this.document);if(!t&&n.is("$text")&&et(n.parent))return e.clone();if(et(n))return e.clone();if(n.is("$text"))return this._breakAttributes(Je(e),t);if(i==n.childCount){const e=new Ae(n.parent,n.index+1);return this._breakAttributes(e,t)}if(0===i){const e=new Ae(n.parent,n.index);return this._breakAttributes(e,t)}{const e=n.index+1,o=n._clone();n.parent._insertChild(e,o),this._addToClonedElementsGroup(o);const s=n.childCount-i,r=n._removeChildren(i,s);o._appendChild(r);const a=new Ae(n.parent,e);return this._breakAttributes(a,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const t of e.getChildren())this._addToClonedElementsGroup(t);const t=e.id;if(!t)return;let i=this._cloneGroups.get(t);i||(i=new Set,this._cloneGroups.set(t,i)),i.add(e),e._clonesGroup=i}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const t of e.getChildren())this._removeFromClonedElementsGroup(t);const t=e.id;if(!t)return;const i=this._cloneGroups.get(t);i&&i.delete(e)}}function Ze(e){let t=e.parent;for(;!et(t);){if(!t)return;t=t.parent}return t}function Ge(e){const t=e.nodeBefore;if(t&&t.is("$text"))return new Ae(t,t.data.length);const i=e.nodeAfter;return i&&i.is("$text")?new Ae(i,0):e}function Je(e){if(e.offset==e.parent.data.length)return new Ae(e.parent.parent,e.parent.index+1);if(0===e.offset)return new Ae(e.parent.parent,e.parent.index);const t=e.parent.data.slice(e.offset);return e.parent._data=e.parent.data.slice(0,e.offset),e.parent.parent._insertChild(e.parent.index+1,new b(e.root.document,t)),new Ae(e.parent.parent,e.parent.index+1)}function Ye(e,t){const i=e.data.length;return e._data+=t.data,t._remove(),new Ae(e,i)}const Qe=[b,De,we,ze,je,We];function Xe(e,t){for(const i of e){if(!Qe.some((e=>i instanceof e)))throw new h.CKEditorError("view-writer-insert-invalid-node-type",t);i.is("$text")||Xe(i.getChildren(),t)}}function et(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function tt(e,t){const i=Ze(e.start),n=Ze(e.end);if(!i||!n||i!==n)throw new h.CKEditorError("view-writer-invalid-range-container",t)}function it(e,t){return null===e.id&&null===t.id}const nt=e=>e.createTextNode(" "),ot=e=>{const t=e.createElement("span");return t.dataset.ckeFiller="true",t.innerText=" ",t},st=e=>{const t=e.createElement("br");return t.dataset.ckeFiller="true",t},rt=7,at="⁠".repeat(rt);function lt(e){return"string"==typeof e?e.substr(0,rt)===at:(0,h.isText)(e)&&e.data.substr(0,rt)===at}function ct(e){return e.data.length==rt&<(e)}function dt(e){const t="string"==typeof e?e:e.data;return lt(e)?t.slice(rt):t}function ut(e,t){if(t.keyCode==h.keyCodes.arrowleft){const e=t.domTarget.ownerDocument.defaultView.getSelection();if(1==e.rangeCount&&e.getRangeAt(0).collapsed){const t=e.getRangeAt(0).startContainer,i=e.getRangeAt(0).startOffset;lt(t)&&i<=rt&&e.collapse(t,0)}}}class ht extends((0,h.ObservableMixin)()){constructor(e,t){super(),this.domDocuments=new Set,this.markedAttributes=new Set,this.markedChildren=new Set,this.markedTexts=new Set,this._inlineFiller=null,this._fakeSelectionContainer=null,this.domConverter=e,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),h.env.isBlink&&!h.env.isAndroid&&this.on("change:isSelecting",(()=>{this.isSelecting||this.render()})),this.set("isComposing",!1),this.on("change:isComposing",(()=>{this.isComposing||this.render()}))}markToSync(e,t){if("text"===e)this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if("attributes"===e)this.markedAttributes.add(t);else{if("children"!==e)throw new h.CKEditorError("view-renderer-unknown-type",this);this.markedChildren.add(t)}}}render(){if(this.isComposing&&!h.env.isAndroid)return;let e=null;const t=!(h.env.isBlink&&!h.env.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=Ae._createBefore(e.parent)));for(const e of this.markedAttributes)this._updateAttrs(e);for(const t of this.markedChildren)this._updateChildren(t,{inlineFillerPosition:e});for(const t of this.markedTexts)!this.markedChildren.has(t.parent)&&this.domConverter.mapViewToDom(t.parent)&&this._updateText(t,{inlineFillerPosition:e});if(t)if(e){const t=this.domConverter.viewPositionToDom(e),i=t.parent.ownerDocument;lt(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=mt(i,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),i=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),n=this._diffNodeLists(t,i),o=this._findUpdateActions(n,t,i,gt);if(-1!==o.indexOf("update")){const n={equal:0,insert:0,delete:0};for(const s of o)if("update"===s){const o=n.equal+n.insert,s=n.equal+n.delete,r=e.getChild(o);!r||r.is("uiElement")||r.is("rawElement")||this._updateElementMappings(r,t[s]),(0,h.remove)(i[o]),n.equal++}else n[s]++}}_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")?Ae._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&&(0,h.isText)(t.parent)&<(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!lt(e))throw new h.CKEditorError("view-renderer-filler-was-lost",this);ct(e)?e.remove():e.data=e.data.substr(rt),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,i=e.offset;if(!this.domConverter.mapViewToDom(t.root))return!1;if(!t.is("element"))return!1;if(!function(e){if("false"==e.getAttribute("contenteditable"))return!1;const t=e.findAncestor((e=>e.hasAttribute("contenteditable")));return!t||"true"==t.getAttribute("contenteditable")}(t))return!1;if(i===t.getFillerOffset())return!1;const n=e.nodeBefore,o=e.nodeAfter;return!(n instanceof b||o instanceof b||h.env.isAndroid&&(n||o))}_updateText(e,t){const i=this.domConverter.findCorrespondingDomText(e);let n=this.domConverter.viewToDom(e).data;const o=t.inlineFillerPosition;o&&o.parent==e.parent&&o.offset==e.index&&(n=at+n),bt(i,n)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(t.attributes).map((e=>e.name)),n=e.getAttributeKeys();for(const i of n)this.domConverter.setDomElementAttribute(t,i,e.getAttribute(i),e);for(const n of i)e.hasAttribute(n)||this.domConverter.removeDomElementAttribute(t,n)}_updateChildren(e,t){const i=this.domConverter.mapViewToDom(e);if(!i)return;if(h.env.isAndroid){let e=null;for(const t of Array.from(i.childNodes)){if(e&&(0,h.isText)(e)&&(0,h.isText)(t)){i.normalize();break}e=t}}const n=t.inlineFillerPosition,o=i.childNodes,s=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));n&&n.parent===e&&mt(i.ownerDocument,s,n.offset);const r=this._diffNodeLists(o,s),a=this._findUpdateActions(r,o,s,ft);let l=0;const c=new Set;for(const e of a)"delete"===e?(c.add(o[l]),(0,h.remove)(o[l])):"equal"!==e&&"update"!==e||l++;l=0;for(const e of a)"insert"===e?((0,h.insertAt)(i,l,s[l]),l++):"update"===e?(bt(o[l],s[l].data),l++):"equal"===e&&(this._markDescendantTextToSync(this.domConverter.domToView(s[l])),l++);for(const e of c)e.parentNode||this.domConverter.unbindDomElement(e)}_diffNodeLists(e,t){return e=function(e,t){const i=Array.from(e);if(0==i.length||!t)return i;return i[i.length-1]==t&&i.pop(),i}(e,this._fakeSelectionContainer),(0,h.diff)(e,t,pt.bind(null,this.domConverter))}_findUpdateActions(e,t,i,n){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let o=[],s=[],r=[];const a={equal:0,insert:0,delete:0};for(const l of e)"insert"===l?r.push(i[a.equal+a.insert]):"delete"===l?s.push(t[a.equal+a.delete]):(o=o.concat((0,h.diff)(s,r,n).map((e=>"equal"===e?"update":e))),o.push("equal"),s=[],r=[]),a[l]++;return o.concat((0,h.diff)(s,r,n).map((e=>"equal"===e?"update":e)))}_markDescendantTextToSync(e){if(e)if(e.is("$text"))this.markedTexts.add(e);else if(e.is("element"))for(const t of e.getChildren())this._markDescendantTextToSync(t)}_updateSelection(){if(h.env.isBlink&&!h.env.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(0===this.selection.rangeCount)return this._removeDomSelection(),void this._removeFakeSelection();const e=this.domConverter.mapViewToDom(this.selection.editableElement);this.isFocused&&e&&(this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&h.env.isAndroid||this._updateDomSelection(e))}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=function(e){const t=e.createElement("div");return t.className="ck-fake-selection-container",Object.assign(t.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),t.textContent=" ",t}(t));const i=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(i,this.selection),!this._fakeSelectionNeedsUpdate(e))return;i.parentElement&&i.parentElement==e||e.appendChild(i),i.textContent=this.selection.fakeSelectionLabel||" ";const n=t.getSelection(),o=t.createRange();n.removeAllRanges(),o.selectNodeContents(i),n.addRange(o)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const i=this.domConverter.viewPositionToDom(this.selection.anchor),n=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(i.parent,i.offset,n.parent,n.offset),h.env.isGecko&&function(e,t){const i=e.parent;if(i.nodeType!=Node.ELEMENT_NODE||e.offset!=i.childNodes.length-1)return;const n=i.childNodes[e.offset];n&&"BR"==n.tagName&&t.addRange(t.getRangeAt(0))}(n,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return!(t&&this.selection.isEqual(t)||!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,i=e.ownerDocument.getSelection();return!t||t.parentElement!==e||i.anchorNode!==t&&!t.contains(i.anchorNode)||t.textContent!==this.selection.fakeSelectionLabel}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const i=e.activeElement,n=this.domConverter.mapDomToView(i);i&&n&&t.removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function mt(e,t,i){const n=t instanceof Array?t:t.childNodes,o=n[i];if((0,h.isText)(o))return o.data=at+o.data,o;{const o=e.createTextNode(at);return Array.isArray(t)?n.splice(i,0,o):(0,h.insertAt)(t,i,o),o}}function gt(e,t){return(0,h.isNode)(e)&&(0,h.isNode)(t)&&!(0,h.isText)(e)&&!(0,h.isText)(t)&&!(0,h.isComment)(e)&&!(0,h.isComment)(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function ft(e,t){return(0,h.isNode)(e)&&(0,h.isNode)(t)&&(0,h.isText)(e)&&(0,h.isText)(t)}function pt(e,t,i){return t===i||((0,h.isText)(t)&&(0,h.isText)(i)?t.data===i.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(i)))}function bt(e,t){const i=e.data;if(i==t)return;const n=(0,h.fastDiff)(i,t);for(const t of n)"insert"===t.type?e.insertData(t.index,t.values.join("")):e.deleteData(t.index,t.howMany)}const wt=st(h.global.document),vt=nt(h.global.document),_t=ot(h.global.document),yt="data-ck-unsafe-attribute-",kt="data-ck-unsafe-element";class Ct{constructor(e,{blockFillerMode:t,renderingMode:i="editing"}={}){this._domToViewMapping=new WeakMap,this._viewToDomMapping=new WeakMap,this._fakeSelectionMapping=new WeakMap,this._rawContentElementMatcher=new _,this._inlineObjectElementMatcher=new _,this.document=e,this.renderingMode=i,this.blockFillerMode=t||("editing"===i?"br":"nbsp"),this.preElements=["pre"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this.unsafeElements=["script","style"],this._domDocument="editing"===this.renderingMode?h.global.document:h.global.document.implementation.createHTMLDocument("")}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new Te(t))}fakeSelectionToView(e){return this._fakeSelectionMapping.get(e)}bindElements(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}unbindDomElement(e){const t=this._domToViewMapping.get(e);if(t){this._domToViewMapping.delete(e),this._viewToDomMapping.delete(t);for(const t of Array.from(e.children))this.unbindDomElement(t)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,i){return"data"===this.renderingMode||!(e=e.toLowerCase()).startsWith("on")&&("srcdoc"!==e||!t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i))&&("img"===i&&("src"===e||"srcset"===e)||"source"===i&&"srcset"===e||!t.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))}setContentOf(e,t){if("data"===this.renderingMode)return void(e.innerHTML=t);const i=(new DOMParser).parseFromString(t,"text/html"),n=i.createDocumentFragment(),o=i.body.childNodes;for(;o.length>0;)n.appendChild(o[0]);const s=i.createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r=[];let a;for(;a=s.nextNode();)r.push(a);for(const e of r){for(const t of e.getAttributeNames())this.setDomElementAttribute(e,t,e.getAttribute(t));const t=e.tagName.toLowerCase();this._shouldRenameElement(t)&&(Tt(t),e.replaceWith(this._createReplacementDomElement(t,e)))}for(;e.firstChild;)e.firstChild.remove();e.append(n)}viewToDom(e,t={}){if(e.is("$text")){const t=this._processDataFromViewText(e);return this._domDocument.createTextNode(t)}{if(this.mapViewToDom(e))return this.mapViewToDom(e);let i;if(e.is("documentFragment"))i=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(i,e);else{if(e.is("uiElement"))return i="$comment"===e.name?this._domDocument.createComment(e.getCustomProperty("$rawContent")):e.render(this._domDocument,this),t.bind&&this.bindElements(i,e),i;this._shouldRenameElement(e.name)?(Tt(e.name),i=this._createReplacementDomElement(e.name)):i=e.hasAttribute("xmlns")?this._domDocument.createElementNS(e.getAttribute("xmlns"),e.name):this._domDocument.createElement(e.name),e.is("rawElement")&&e.render(i,this),t.bind&&this.bindElements(i,e);for(const t of e.getAttributeKeys())this.setDomElementAttribute(i,t,e.getAttribute(t),e)}if(!1!==t.withChildren)for(const n of this.viewChildrenToDom(e,t))i.appendChild(n);return i}}setDomElementAttribute(e,t,i,n){const o=this.shouldRenderAttribute(t,i,e.tagName.toLowerCase())||n&&n.shouldRenderUnsafeAttribute(t);o||(0,h.logWarning)("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:i}),(0,h.isValidAttributeName)(t)?(e.hasAttribute(t)&&!o?e.removeAttribute(t):e.hasAttribute(yt+t)&&o&&e.removeAttribute(yt+t),e.setAttribute(o?t:yt+t,i)):(0,h.logWarning)("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:i})}removeDomElementAttribute(e,t){t!=kt&&(e.removeAttribute(t),e.removeAttribute(yt+t))}*viewChildrenToDom(e,t={}){const i=e.getFillerOffset&&e.getFillerOffset();let n=0;for(const o of e.getChildren()){i===n&&(yield this._getBlockFiller());const e=o.is("element")&&!!o.getCustomProperty("dataPipeline:transparentRendering")&&!(0,h.first)(o.getAttributes());e&&"data"==this.renderingMode?yield*this.viewChildrenToDom(o,t):(e&&(0,h.logWarning)("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:o}),yield this.viewToDom(o,t)),n++}i===n&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),i=this.viewPositionToDom(e.end),n=this._domDocument.createRange();return n.setStart(t.parent,t.offset),n.setEnd(i.parent,i.offset),n}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const i=this.findCorrespondingDomText(t);if(!i)return null;let n=e.offset;return lt(i)&&(n+=rt),{parent:i,offset:n}}{let i,n,o;if(0===e.offset){if(i=this.mapViewToDom(t),!i)return null;o=i.childNodes[0]}else{const t=e.nodeBefore;if(n=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(t),!n)return null;i=n.parentNode,o=n.nextSibling}return(0,h.isText)(o)&<(o)?{parent:o,offset:rt}:{parent:i,offset:n?(0,h.indexOf)(n)+1:0}}}domToView(e,t={}){const i=[],n=this._domToView(e,t,i),o=n.next().value;return o?(n.next(),this._processDomInlineNodes(null,i,t),o.is("$text")&&0==o.data.length?null:o):null}*domChildrenToView(e,t={},i=[]){for(let n=0;n{const{scrollLeft:t,scrollTop:i}=e;n.push([t,i])})),t.focus(),Et(t,(e=>{const[t,i]=n.shift();e.scrollLeft=t,e.scrollTop=i})),h.global.window.scrollTo(e,i)}}_clearDomSelection(){const e=this.mapViewToDom(this.document.selection.editableElement);if(!e)return;const t=e.ownerDocument.defaultView.getSelection(),i=this.domSelectionToView(t);i&&i.rangeCount>0&&t.removeAllRanges()}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(e){return"br"==this.blockFillerMode?e.isEqualNode(wt):!("BR"!==e.tagName||!xt(e,this.blockElements)||1!==e.parentNode.childNodes.length)||e.isEqualNode(_t)||function(e,t){return e.isEqualNode(vt)&&xt(e,t)&&1===e.parentNode.childNodes.length}(e,this.blockElements)}isDomSelectionBackward(e){if(e.isCollapsed)return!1;const t=this._domDocument.createRange();try{t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset)}catch(e){return!1}const i=t.collapsed;return t.detach(),i}getHostViewElement(e){const t=(0,h.getAncestors)(e);for(t.pop();t.length;){const e=t.pop(),i=this._domToViewMapping.get(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return i}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}registerInlineObjectMatcher(e){this._inlineObjectElementMatcher.add(e)}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return nt(this._domDocument);case"markedNbsp":return ot(this._domDocument);case"br":return st(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if((0,h.isText)(e)&<(e)&&t0?t[e-1]:null,l=e+1this.preElements.includes(e.name))))return t;if(" "==t.charAt(0)){const i=this._getTouchingInlineViewNode(e,!1);!(i&&i.is("$textProxy")&&this._nodeEndsWithSpace(i))&&i||(t=" "+t.substr(1))}if(" "==t.charAt(t.length-1)){const i=this._getTouchingInlineViewNode(e,!0),n=i&&i.is("$textProxy")&&" "==i.data.charAt(0);" "!=t.charAt(t.length-2)&&i&&!n||(t=t.substr(0,t.length-1)+" ")}return t.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(e){if(e.getAncestors().some((e=>this.preElements.includes(e.name))))return!1;const t=this._processDataFromViewText(e);return" "==t.charAt(t.length-1)}_getTouchingInlineViewNode(e,t){const i=new Ce({startPosition:t?Ae._createAfter(e):Ae._createBefore(e),direction:t?"forward":"backward"});for(const e of i){if(e.item.is("element","br"))return null;if(this._isInlineObjectElement(e.item))return e.item;if(e.item.is("containerElement"))return null;if(e.item.is("$textProxy"))return e.item}return null}_isBlockDomElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isBlockViewElement(e){return e.is("element")&&this.blockElements.includes(e.name)}_isInlineObjectElement(e){return!!e.is("element")&&("br"==e.name||this.inlineObjectElements.includes(e.name)||!!this._inlineObjectElementMatcher.match(e))}_createViewElement(e,t){if((0,h.isComment)(e))return new We(this.document,"$comment");const i=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new pe(this.document,i)}_isViewElementWithRawContent(e,t){return!1!==t.withChildren&&e.is("element")&&!!this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return"editing"===this.renderingMode&&this.unsafeElements.includes(t)}_createReplacementDomElement(e,t){const i=this._domDocument.createElement("span");if(i.setAttribute(kt,e),t){for(;t.firstChild;)i.appendChild(t.firstChild);for(const e of t.getAttributeNames())i.setAttribute(e,t.getAttribute(e))}return i}}function At(e,t){return e.getAncestors().some((e=>e.is("element")&&t.includes(e.name)))}function Et(e,t){let i=e;for(;i;)t(i),i=i.parentElement}function xt(e,t){const i=e.parentNode;return!!i&&!!i.tagName&&t.includes(i.tagName.toLowerCase())}function Tt(e){"script"===e&&(0,h.logWarning)("domconverter-unsafe-script-element-detected"),"style"===e&&(0,h.logWarning)("domconverter-unsafe-style-element-detected")}class St extends((0,h.DomEmitterMixin)()){constructor(e){super(),this._isEnabled=!1,this.view=e,this.document=e.document}get isEnabled(){return this._isEnabled}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(e){return e&&3===e.nodeType&&(e=e.parentNode),!(!e||1!==e.nodeType)&&e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}var Pt=i(207);class It{constructor(e,t,i){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,(0,Pt.Z)(this,i)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class Vt extends St{constructor(){super(...arguments),this.useCapture=!1}observe(e){("string"==typeof this.domEventType?[this.domEventType]:this.domEventType).forEach((t=>{this.listenTo(e,t,((e,t)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(t.target)&&this.onDomEvent(t)}),{useCapture:this.useCapture})}))}stopObserving(e){this.stopListening(e)}fire(e,t,i){this.isEnabled&&this.document.fire(e,new It(this.view,t,i))}}class Rt extends Vt{constructor(){super(...arguments),this.domEventType=["keydown","keyup"]}onDomEvent(e){const t={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return(0,h.getCode)(this)}};this.fire(e.type,e,t)}}var Ot=i(6682);class Bt extends St{constructor(e){super(e),this._fireSelectionChangeDoneDebounced=(0,Ot.Z)((e=>{this.document.fire("selectionChangeDone",e)}),200)}observe(){const e=this.document;e.on("arrowKey",((t,i)=>{e.selection.isFake&&this.isEnabled&&i.preventDefault()}),{context:"$capture"}),e.on("arrowKey",((t,i)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(i.keyCode)}),{priority:"lowest"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,i=new Te(t.getRanges(),{backward:t.isBackward,fake:!1});e!=h.keyCodes.arrowleft&&e!=h.keyCodes.arrowup||i.setTo(i.getFirstPosition()),e!=h.keyCodes.arrowright&&e!=h.keyCodes.arrowdown||i.setTo(i.getLastPosition());const n={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",n),this._fireSelectionChangeDoneDebounced(n)}}var Mt=i(1152);const Nt=function(e,t,i){var n=(i="function"==typeof i?i:void 0)?i(e,t):void 0;return void 0===n?(0,Mt.Z)(e,t,void 0,i):!!n};class Dt extends St{constructor(e){super(e),this._config={childList:!0,characterData:!0,subtree:!0},this.domConverter=e.domConverter,this.renderer=e._renderer,this._domElements=new Set,this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(e){this._domElements.add(e),this.isEnabled&&this._mutationObserver.observe(e,this._config)}stopObserving(e){if(this._domElements.delete(e),this.isEnabled){this._mutationObserver.disconnect();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}}enable(){super.enable();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}disable(){super.disable(),this._mutationObserver.disconnect()}destroy(){super.destroy(),this._mutationObserver.disconnect()}_onMutations(e){if(0===e.length)return;const t=this.domConverter,i=new Set,n=new Set;for(const i of e){const e=t.mapDomToView(i.target);e&&(e.is("uiElement")||e.is("rawElement")||"childList"!==i.type||this._isBogusBrMutation(i)||n.add(e))}for(const o of e){const e=t.mapDomToView(o.target);if((!e||!e.is("uiElement")&&!e.is("rawElement"))&&"characterData"===o.type){const e=t.findCorrespondingViewText(o.target);e&&!n.has(e.parent)?i.add(e):!e&<(o.target)&&n.add(t.mapDomToView(o.target.parentNode))}}let o=!1;for(const e of i)o=!0,this.renderer.markToSync("text",e);for(const e of n){const i=t.mapViewToDom(e),n=Array.from(e.getChildren()),s=Array.from(t.domChildrenToView(i,{withChildren:!1}));Nt(n,s,Lt)||(o=!0,this.renderer.markToSync("children",e))}o&&this.view.forceRender()}_isBogusBrMutation(e){let t=null;return null===e.nextSibling&&0===e.removedNodes.length&&1==e.addedNodes.length&&(t=this.domConverter.domToView(e.addedNodes[0],{withChildren:!1})),t&&t.is("element","br")}}function Lt(e,t){if(!Array.isArray(e))return e===t||!(!e.is("$text")||!t.is("$text"))&&e.data===t.data}class Ft extends Vt{constructor(e){super(e),this._isFocusChanging=!1,this.domEventType=["focus","blur"],this.useCapture=!0;const t=this.document;t.on("focus",(()=>{this._isFocusChanging=!0,this._renderTimeoutId=setTimeout((()=>{this.flush(),e.change((()=>{}))}),50)})),t.on("blur",((i,n)=>{const o=t.selection.editableElement;null!==o&&o!==n.target||(t.isFocused=!1,this._isFocusChanging=!1,e.change((()=>{})))}))}flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),super.destroy()}}class zt extends St{constructor(e){super(e),this.mutationObserver=e.getObserver(Dt),this.focusObserver=e.getObserver(Ft),this.selection=this.document.selection,this.domConverter=e.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=(0,Ot.Z)((e=>{this.document.fire("selectionChangeDone",e)}),200),this._clearInfiniteLoopInterval=setInterval((()=>this._clearInfiniteLoop()),1e3),this._documentIsSelectingInactivityTimeoutDebounced=(0,Ot.Z)((()=>this.document.isSelecting=!1),5e3),this._loopbackCounter=0}observe(e){const t=e.ownerDocument,i=()=>{this.document.isSelecting&&(this._handleSelectionChange(null,t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",(()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()}),{priority:"highest"}),this.listenTo(e,"keydown",i,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",i,{priority:"highest",useCapture:!0}),this._documents.has(t)||(this.listenTo(t,"mouseup",i,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",((e,i)=>{this.document.isComposing&&!h.env.isAndroid||(this._handleSelectionChange(i,t),this._documentIsSelectingInactivityTimeoutDebounced())})),this._documents.add(t))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e,t){if(!this.isEnabled)return;const i=t.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(i.anchorNode))return;this.mutationObserver.flush();const n=this.domConverter.domSelectionToView(i);if(0!=n.rangeCount){if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.selection.isEqual(n)||!this.domConverter.isDomSelectionCorrect(i))if(++this._loopbackCounter>60)this._reportInfiniteLoop();else if(this.selection.isSimilar(n))this.view.forceRender();else{const e={oldSelection:this.selection,newSelection:n,domSelection:i};this.document.fire("selectionChange",e),this._fireSelectionChangeDoneDebounced(e)}}else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}}class Ht extends Vt{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 Wt{constructor(e,t={}){this._files=t.cacheFiles?Ut(e):null,this._native=e}get files(){return this._files||(this._files=Ut(this._native)),this._files}get types(){return this._native.types}getData(e){return this._native.getData(e)}setData(e,t){this._native.setData(e,t)}set effectAllowed(e){this._native.effectAllowed=e}get effectAllowed(){return this._native.effectAllowed}set dropEffect(e){this._native.dropEffect=e}get dropEffect(){return this._native.dropEffect}setDragImage(e,t,i){this._native.setDragImage(e,t,i)}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}function Ut(e){const t=Array.from(e.files||[]),i=Array.from(e.items||[]);return t.length?t:i.filter((e=>"file"===e.kind)).map((e=>e.getAsFile()))}class jt extends Vt{constructor(){super(...arguments),this.domEventType="beforeinput"}onDomEvent(e){const t=e.getTargetRanges(),i=this.view,n=i.document;let o=null,s=null,r=[];if(e.dataTransfer&&(o=new Wt(e.dataTransfer)),null!==e.data?s=e.data:o&&(s=o.getData("text/plain")),n.selection.isFake)r=Array.from(n.selection.getRanges());else if(t.length)r=t.map((e=>{const t=i.domConverter.domPositionToView(e.startContainer,e.startOffset),n=i.domConverter.domPositionToView(e.endContainer,e.endOffset);return t?i.createRange(t,n):n?i.createRange(n):void 0})).filter((e=>!!e));else if(h.env.isAndroid){const t=e.target.ownerDocument.defaultView.getSelection();r=Array.from(i.domConverter.domSelectionToView(t).getRanges())}if(h.env.isAndroid&&"insertCompositionText"==e.inputType&&s&&s.endsWith("\n"))this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[i.createRange(r[0].end)]});else if("insertText"==e.inputType&&s&&s.includes("\n")){const t=s.split(/\n{1,2}/g);let i=r;for(let s=0;s{if(this.isEnabled&&(0,h.isArrowKeyCode)(t.keyCode)){const i=new Pe(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(i,t),i.stop.called&&e.stop()}}))}observe(){}stopObserving(){}}class qt extends St{constructor(e){super(e);const t=this.document;t.on("keydown",((e,i)=>{if(!this.isEnabled||i.keyCode!=h.keyCodes.tab||i.ctrlKey)return;const n=new Pe(t,"tab",t.selection.getFirstRange());t.fire(n,i),n.stop.called&&e.stop()}))}observe(){}stopObserving(){}}const Kt=function(e){return(0,g.Z)(e,5)};class Zt extends((0,h.ObservableMixin)()){constructor(e){var t;super(),this.domRoots=new Map,this._initialDomRootAttributes=new WeakMap,this._observers=new Map,this._ongoingChange=!1,this._postFixersInProgress=!1,this._renderingDisabled=!1,this._hasChangedSinceTheLastRendering=!1,this.document=new Ne(e),this.domConverter=new Ct(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new ht(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new Ke(this.document),this.addObserver(Dt),this.addObserver(Ft),this.addObserver(zt),this.addObserver(Rt),this.addObserver(Bt),this.addObserver(Ht),this.addObserver($t),this.addObserver(jt),this.addObserver(qt),this.document.on("arrowKey",ut,{priority:"low"}),(t=this).document.on("arrowKey",((e,i)=>function(e,t,i){if(t.keyCode==h.keyCodes.arrowright){const e=t.domTarget.ownerDocument.defaultView.getSelection(),n=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(n||t.shiftKey){const t=e.focusNode,o=e.focusOffset,s=i.domPositionToView(t,o);if(null===s)return;let r=!1;const a=s.getLastMatchingPosition((e=>(e.item.is("uiElement")&&(r=!0),!(!e.item.is("uiElement")&&!e.item.is("attributeElement")))));if(r){const t=i.viewPositionToDom(a);n?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}}(0,i,t.domConverter)),{priority:"low"}),this.on("render",(()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1})),this.listenTo(this.document.selection,"change",(()=>{this._hasChangedSinceTheLastRendering=!0})),this.listenTo(this.document,"change:isFocused",(()=>{this._hasChangedSinceTheLastRendering=!0})),h.env.isiOS&&this.listenTo(this.document,"blur",((e,t)=>{this.domConverter.mapDomToView(t.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}))}attachDomRoot(e,t="main"){const i=this.document.getRoot(t);i._name=e.tagName.toLowerCase();const n={};for(const{name:t,value:o}of Array.from(e.attributes))n[t]=o,"class"===t?this._writer.addClass(o.split(" "),i):this._writer.setAttribute(t,o,i);this._initialDomRootAttributes.set(e,n);const o=()=>{this._writer.setAttribute("contenteditable",(!i.isReadOnly).toString(),i),i.isReadOnly?this._writer.addClass("ck-read-only",i):this._writer.removeClass("ck-read-only",i)};o(),this.domRoots.set(t,e),this.domConverter.bindElements(e,i),this._renderer.markToSync("children",i),this._renderer.markToSync("attributes",i),this._renderer.domDocuments.add(e.ownerDocument),i.on("change:children",((e,t)=>this._renderer.markToSync("children",t))),i.on("change:attributes",((e,t)=>this._renderer.markToSync("attributes",t))),i.on("change:text",((e,t)=>this._renderer.markToSync("text",t))),i.on("change:isReadOnly",(()=>this.change(o))),i.on("change",(()=>{this._hasChangedSinceTheLastRendering=!0}));for(const i of this._observers.values())i.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach((({name:e})=>t.removeAttribute(e)));const i=this._initialDomRootAttributes.get(t);for(const e in i)t.setAttribute(e,i[e]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t);for(const e of this._observers.values())e.stopObserving(t)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;t=new e(this),this._observers.set(e,t);for(const[e,i]of this.domRoots)t.observe(i,e);return t.enable(),t}getObserver(e){return this._observers.get(e)}disableObservers(){for(const e of this._observers.values())e.disable()}enableObservers(){for(const e of this._observers.values())e.enable()}scrollToTheSelection({alignToTop:e,forceScroll:t,viewportOffset:i=20,ancestorOffset:n=20}={}){const o=this.document.selection.getFirstRange();if(!o)return;const s=Kt({alignToTop:e,forceScroll:t,viewportOffset:i,ancestorOffset:n});"number"==typeof i&&(i={top:i,bottom:i,left:i,right:i});const r={target:this.domConverter.viewRangeToDom(o),viewportOffset:i,ancestorOffset:n,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",r,s),(0,h.scrollViewportToShowTarget)(r)}focus(){if(!this.document.isFocused){const e=this.document.selection.editableElement;e&&(this.domConverter.focus(e),this.forceRender())}}change(e){if(this.isRenderingInProgress||this._postFixersInProgress)throw new h.CKEditorError("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){h.CKEditorError.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Ft).flush(),this.change((()=>{}))}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return Ae._createAt(e,t)}createPositionAfter(e){return Ae._createAfter(e)}createPositionBefore(e){return Ae._createBefore(e)}createRange(e,t){return new Ee(e,t)}createRangeOn(e){return Ee._createOn(e)}createRangeIn(e){return Ee._createIn(e)}createSelection(...e){return new Te(...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 Gt{is(){throw new Error("is() method is abstract")}}class Jt extends Gt{constructor(e){super(),this.parent=null,this._attrs=(0,h.toMap)(e)}get document(){return null}get index(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildIndex(this)))throw new h.CKEditorError("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 h.CKEditorError("model-node-not-found-in-parent",this);return e}get offsetSize(){return 1}get endOffset(){return this.parent?this.startOffset+this.offsetSize:null}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return null!==this.parent&&this.root.isAttached()}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let o=0;for(;i[o]==n[o]&&i[o];)o++;return 0===o?null:i[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),n=(0,h.compareArrays)(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n](e[t[0]]=t[1],e)),{})),e}_clone(e){return new this.constructor(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,t){this._attrs.set(e,t)}_setAttributesTo(e){this._attrs=(0,h.toMap)(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}Jt.prototype.is=function(e){return"node"===e||"model:node"===e};class Yt{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 h.CKEditorError("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){let t=0;for(const i of this._nodes){if(e>=t&&ee.toJSON()))}}class Qt extends Jt{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 Qt(this.data,this.getAttributes())}static fromJSON(e){return new Qt(e.data,e.attributes)}}Qt.prototype.is=function(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e};class Xt extends Gt{constructor(e,t,i){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new h.CKEditorError("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new h.CKEditorError("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get startOffset(){return null!==this.textNode.startOffset?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return null!==this.startOffset?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}getPath(){const e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}Xt.prototype.is=function(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e};class ei extends Jt{constructor(e,t,i){super(t),this._children=new Yt,this.name=e,i&&this._insertChild(0,i)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let t=this;for(const i of e)t=t.getChild(t.offsetToIndex(i));return t}findAncestor(e,t={}){let i=t.includeSelf?this:this.parent;for(;i;){if(i.name===e)return i;i=i.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?Array.from(this._children).map((e=>e._clone(!0))):void 0;return new ei(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){return"string"==typeof e?[new Qt(e)]:((0,h.isIterable)(e)||(e=[e]),Array.from(e).map((e=>"string"==typeof e?new Qt(e):e instanceof Xt?new Qt(e.data,e.getAttributes()):e)))}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}static fromJSON(e){let t;if(e.children){t=[];for(const i of e.children)i.name?t.push(ei.fromJSON(i)):t.push(Qt.fromJSON(i))}return new ei(e.name,e.attributes,t)}}ei.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 ti{constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new h.CKEditorError("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new h.CKEditorError("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=ni._createAt(this.boundaries["backward"==this.direction?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null,this._visitedParent=this.position.parent}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i,n,o;do{n=this.position,o=this._visitedParent,({done:t,value:i}=this.next())}while(!t&&e(i));t||(this._position=n,this._visitedParent=o)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(null===i.parent&&t.offset===i.maxOffset)return{done:!0,value:void 0};if(i===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const n=oi(t,i),o=n||si(t,i,n);if(o instanceof ei){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}else t.path.push(0),this._visitedParent=o;return this._position=t,ii("elementStart",o,e,t,1)}if(o instanceof Qt){let n;if(this.singleCharacters)n=1;else{let e=o.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offsete&&(e=this.boundaries.start.offset),n=t.offset-e}const o=t.offset-s.startOffset,r=new Xt(s,o-n,n);return t.offset-=n,this._position=t,ii("text",r,e,t,n)}return t.path.pop(),this._position=t,this._visitedParent=i.parent,ii("elementStart",i,e,t,1)}}function ii(e,t,i,n,o){return{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:o}}}class ni extends Gt{constructor(e,t,i="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new h.CKEditorError("model-position-root-invalid",e);if(!(t instanceof Array)||0===t.length)throw new h.CKEditorError("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=i}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;t1)return!1;if(1===t)return ai(e,this,i);if(-1===t)return ai(this,e,i)}return this.path.length===e.path.length||(this.path.length>e.path.length?li(this.path,t):li(e.path,t))}hasSameParentAs(e){if(this.root!==e.root)return!1;const t=this.getParentPath(),i=e.getParentPath();return"same"==(0,h.compareArrays)(t,i)}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=ni._createAt(this)}return t}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){const t=e.movedRange;return t.containsPosition(this)||t.start.isEqual(this)&&"toNext"==this.stickiness?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(e){const t=e.movedRange;let i;return t.containsPosition(this)||t.start.isEqual(this)?(i=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(i=i._getTransformedByDeletion(e.deletionPosition,1))):i=this.isEqual(e.deletionPosition)?ni._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),i}_getTransformedByDeletion(e,t){const i=ni._createAt(this);if(this.root!=e.root)return i;if("same"==(0,h.compareArrays)(e.getParentPath(),this.getParentPath())){if(e.offsetthis.offset)return null;i.offset-=t}}else if("prefix"==(0,h.compareArrays)(e.getParentPath(),this.getParentPath())){const n=e.path.length-1;if(e.offset<=this.path[n]){if(e.offset+t>this.path[n])return null;i.path[n]-=t}}return i}_getTransformedByInsertion(e,t){const i=ni._createAt(this);if(this.root!=e.root)return i;if("same"==(0,h.compareArrays)(e.getParentPath(),this.getParentPath()))(e.offset=t;){if(e.path[n]+o!==i.maxOffset)return!1;o=1,n--,i=i.parent}return!0}(e,i+1)}function li(e,t){for(;tt+1;){const t=n.maxOffset-i.offset;0!==t&&e.push(new ci(i,i.getShiftedBy(t))),i.path=i.path.slice(0,-1),i.offset++,n=n.parent}for(;i.path.length<=this.end.path.length;){const t=this.end.path[i.path.length-1],n=t-i.offset;0!==n&&e.push(new ci(i,i.getShiftedBy(n))),i.offset=t,i.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new ti(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new ti(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new ti(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 ci(this.start,this.end)]}getTransformedByOperations(e){const t=[new ci(this.start,this.end)];for(const i of e)for(let e=0;e0?new this(i,n):new this(n,i)}static _createIn(e){return new this(ni._createAt(e,0),ni._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(ni._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new h.CKEditorError("range-create-from-ranges-empty-array",null);if(1==e.length)return e[0].clone();const t=e[0];e.sort(((e,t)=>e.start.isAfter(t.start)?1:-1));const i=e.indexOf(t),n=new this(t.start,t.end);if(i>0)for(let t=i-1;e[t].end.isEqual(n.start);t++)n.start=ni._createAt(e[t].start);for(let t=i+1;t{if(t.viewPosition)return;const i=this._modelToViewMapping.get(t.modelPosition.parent);if(!i)throw new h.CKEditorError("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(i,t.modelPosition.offset)}),{priority:"low"}),this.on("viewToModelPosition",((e,t)=>{if(t.modelPosition)return;const i=this.findMappedViewAncestor(t.viewPosition),n=this._viewToModelMapping.get(i),o=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,i);t.modelPosition=ni._createAt(n,o)}),{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const i=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const t of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(t);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e),this._modelToViewMapping.get(i)==e&&this._modelToViewMapping.delete(i))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)}bindElementToMarker(e,t){const i=this._markerNameToElements.get(t)||new Set;i.add(e);const n=this._elementToMarkerNames.get(e)||new Set;n.add(t),this._markerNameToElements.set(t,i),this._elementToMarkerNames.set(e,n)}unbindElementFromMarkerName(e,t){const i=this._markerNameToElements.get(t);i&&(i.delete(e),0==i.size&&this._markerNameToElements.delete(t));const n=this._elementToMarkerNames.get(e);n&&(n.delete(t),0==n.size&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){const e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(const[e,t]of this._deferredBindingRemovals)e.root==t&&this.unbindViewElement(e);this._deferredBindingRemovals=new Map}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this._deferredBindingRemovals=new Map}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new ci(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new Ee(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){const t={viewPosition:e,mapper:this};return this.fire("viewToModelPosition",t),t.modelPosition}toViewPosition(e,t={}){const i={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",i),i.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const i=new Set;for(const e of t)if(e.is("attributeElement"))for(const t of e.getElementsWithSameId())i.add(t);else i.add(e);return i}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,i){if(i!=e)return this._toModelOffset(e.parent,e.index,i)+this._toModelOffset(e,t,e);if(e.is("$text"))return t;let n=0;for(let i=0;i1?t[0]+":"+t[1]:t[0]}class mi extends((0,h.EmitterMixin)()){constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,i){const n=this._createConversionApi(i,e.getRefreshedItems());for(const t of e.getMarkersToRemove())this._convertMarkerRemove(t.name,t.range,n);const o=this._reduceChanges(e.getChanges());for(const e of o)"insert"===e.type?this._convertInsert(ci._createFromPositionAndShift(e.position,e.length),n):"reinsert"===e.type?this._convertReinsert(ci._createFromPositionAndShift(e.position,e.length),n):"remove"===e.type?this._convertRemove(e.position,e.length,e.name,n):this._convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,n);for(const e of n.mapper.flushUnboundMarkerNames()){const i=t.get(e).getRange();this._convertMarkerRemove(e,i,n),this._convertMarkerAdd(e,i,n)}for(const t of e.getMarkersToAdd())this._convertMarkerAdd(t.name,t.range,n);n.mapper.flushDeferredBindings(),n.consumable.verifyAllConsumed("insert")}convert(e,t,i,n={}){const o=this._createConversionApi(i,void 0,n);this._convertInsert(e,o);for(const[e,i]of t)this._convertMarkerAdd(e,i,o);o.consumable.verifyAllConsumed("insert")}convertSelection(e,t,i){const n=this._createConversionApi(i);this.fire("cleanSelection",{selection:e},n);const o=e.getFirstPosition().root;if(!n.mapper.toViewElement(o))return;const s=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(n.consumable,e,s),this.fire("selection",{selection:e},n),e.isCollapsed){for(const t of s)if(n.consumable.test(e,"addMarker:"+t.name)){const i=t.getRange();if(!gi(e.getFirstPosition(),t,n.mapper))continue;const o={item:e,markerName:t.name,markerRange:i};this.fire(`addMarker:${t.name}`,o,n)}for(const t of e.getAttributeKeys())if(n.consumable.test(e,"attribute:"+t)){const i={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};this.fire(`attribute:${t}:$text`,i,n)}}}_convertInsert(e,t,i={}){i.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,Array.from(e));for(const i of Array.from(e.getWalker({shallow:!0})).map(fi))this._testAndFire("insert",i,t)}_convertRemove(e,t,i,n){this.fire(`remove:${i}`,{position:e,length:t},n)}_convertAttribute(e,t,i,n,o){this._addConsumablesForRange(o.consumable,e,`attribute:${t}`);for(const s of e){const e={item:s.item,range:ci._createFromPositionAndShift(s.previousPosition,s.length),attributeKey:t,attributeOldValue:i,attributeNewValue:n};this._testAndFire(`attribute:${t}`,e,o)}}_convertReinsert(e,t){const i=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,i);for(const e of i.map(fi))this._testAndFire("insert",{...e,reconversion:!0},t)}_convertMarkerAdd(e,t,i){if("$graveyard"==t.root.rootName)return;const n=`addMarker:${e}`;if(i.consumable.add(t,n),this.fire(n,{markerName:e,markerRange:t},i),i.consumable.consume(t,n)){this._addConsumablesForRange(i.consumable,t,n);for(const o of t.getItems()){if(!i.consumable.test(o,n))continue;const s={item:o,range:ci._createOn(o),markerName:e,markerRange:t};this.fire(n,s,i)}}}_convertMarkerRemove(e,t,i){"$graveyard"!=t.root.rootName&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},i)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.changes}_addConsumablesForInsert(e,t){for(const i of t){const t=i.item;if(null===e.test(t,"insert")){e.add(t,"insert");for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i)}}return e}_addConsumablesForRange(e,t,i){for(const n of t.getItems())e.add(n,i);return e}_addConsumablesForSelection(e,t,i){e.add(t,"selection");for(const n of i)e.add(t,"addMarker:"+n.name);for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i);return e}_testAndFire(e,t,i){const n=function(e,t){return`${e}:${t.item.is("element")?t.item.name:"$text"}`}(e,t),o=t.item.is("$textProxy")?i.consumable._getSymbolForTextProxy(t.item):t.item,s=this._firedEventsMap.get(i),r=s.get(o);if(r){if(r.has(n))return;r.add(n)}else s.set(o,new Set([n]));this.fire(n,t,i)}_testAndFireAddAttributes(e,t){const i={item:e,range:ci._createOn(e)};for(const e of i.item.getAttributeKeys())i.attributeKey=e,i.attributeOldValue=null,i.attributeNewValue=i.item.getAttribute(e),this._testAndFire(`attribute:${e}`,i,t)}_createConversionApi(e,t=new Set,i={}){const n={...this._conversionApi,consumable:new ui,writer:e,options:i,convertItem:e=>this._convertInsert(ci._createOn(e),n),convertChildren:e=>this._convertInsert(ci._createIn(e),n,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,n),canReuseView:e=>!t.has(n.mapper.toModelElement(e))};return this._firedEventsMap.set(n,new Map),n}}function gi(e,t,i){const n=t.getRange(),o=Array.from(e.getAncestors());return o.shift(),o.reverse(),!o.some((e=>{if(n.containsItem(e))return!!i.toViewElement(e).getCustomProperty("addHighlight")}))}function fi(e){return{item:e.item,range:ci._createFromPositionAndShift(e.previousPosition,e.length)}}class pi extends((0,h.EmitterMixin)(Gt)){constructor(...e){super(),this._lastRangeBackward=!1,this._attrs=new Map,this._ranges=[],e.length&&this.setTo(...e)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return 1===this._ranges.length&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new ci(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 ci(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 ci(e.start,e.end):null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}setTo(...e){let[t,i,n]=e;if("object"==typeof i&&(n=i,i=void 0),null===t)this._setRanges([]);else if(t instanceof pi)this._setRanges(t.getRanges(),t.isBackward);else if(t&&"function"==typeof t.getRanges)this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof ci)this._setRanges([t],!!n&&!!n.backward);else if(t instanceof ni)this._setRanges([new ci(t)]);else if(t instanceof Jt){const e=!!n&&!!n.backward;let o;if("in"==i)o=ci._createIn(t);else if("on"==i)o=ci._createOn(t);else{if(void 0===i)throw new h.CKEditorError("model-selection-setto-required-second-parameter",[this,t]);o=new ci(ni._createAt(t,i))}this._setRanges([o],e)}else{if(!(0,h.isIterable)(t))throw new h.CKEditorError("model-selection-setto-not-selectable",[this,t]);this._setRanges(t,n&&!!n.backward)}}_setRanges(e,t=!1){const i=Array.from(e),n=i.some((t=>{if(!(t instanceof ci))throw new h.CKEditorError("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every((e=>!e.isEqual(t)))}));(i.length!==this._ranges.length||n)&&(this._replaceAllRanges(i),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(null===this.anchor)throw new h.CKEditorError("model-selection-setfocus-no-ranges",[this,e]);const i=ni._createAt(e,t);if("same"==i.compareWith(this.focus))return;const n=this.anchor;this._ranges.length&&this._popRange(),"before"==i.compareWith(n)?(this._pushRange(new ci(i,n)),this._lastRangeBackward=!0):(this._pushRange(new ci(n,i)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const i=vi(t.start,e);yi(i,t)&&(yield i);for(const i of t.getWalker()){const n=i.item;"elementEnd"==i.type&&wi(n,e,t)&&(yield n)}const n=vi(t.end,e);ki(n,t)&&(yield n)}}containsEntireContent(e=this.anchor.root){const t=ni._createAt(e,0),i=ni._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new ci(e.start,e.end))}_checkRange(e){for(let t=0;t0;)this._popRange()}_popRange(){this._ranges.pop()}}function bi(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&!!e.parent)}function wi(e,t,i){return bi(e,t)&&_i(e,i)}function vi(e,t){const i=e.parent.root.document.model.schema,n=e.parent.getAncestors({parentFirst:!0,includeSelf:!0});let o=!1;const s=n.find((e=>!o&&(o=i.isLimit(e),!o&&bi(e,t))));return n.forEach((e=>t.add(e))),s}function _i(e,t){const i=function(e){const t=e.root.document.model.schema;let i=e.parent;for(;i;){if(t.isBlock(i))return i;i=i.parent}}(e);return!i||!t.containsRange(ci._createOn(i),!0)}function yi(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.start.isTouching(ni._createAt(e,e.maxOffset))&&_i(e,t))}function ki(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.end.isTouching(ni._createAt(e,0))&&_i(e,t))}pi.prototype.is=function(e){return"selection"===e||"model:selection"===e};class Ci extends((0,h.EmitterMixin)(ci)){constructor(e,t){super(e,t),Ai.call(this)}detach(){this.stopListening()}toRange(){return new ci(this.start,this.end)}static fromRange(e){return new Ci(e.start,e.end)}}function Ai(){this.listenTo(this.root.document.model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&Ei.call(this,i)}),{priority:"low"})}function Ei(e){const t=this.getTransformedByOperation(e),i=ci._createFromRanges(t),n=!i.isEqual(this),o=function(e,t){switch(t.type){case"insert":return e.containsPosition(t.position);case"move":case"remove":case"reinsert":case"merge":return e.containsPosition(t.sourcePosition)||e.start.isEqual(t.sourcePosition)||e.containsPosition(t.targetPosition);case"split":return e.containsPosition(t.splitPosition)||e.containsPosition(t.insertionPosition)}return!1}(this,e);let s=null;if(n){"$graveyard"==i.root.rootName&&(s="remove"==e.type?e.sourcePosition:e.deletionPosition);const t=this.toRange();this.start=i.start,this.end=i.end,this.fire("change:range",t,{deletionPosition:s})}else o&&this.fire("change:content",this.toRange(),{deletionPosition:s})}Ci.prototype.is=function(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e};const xi="selection:";class Ti extends((0,h.EmitterMixin)(Gt)){constructor(e){super(),this._selection=new Si(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 xi+e}static _isStoreAttributeKey(e){return e.startsWith(xi)}}Ti.prototype.is=function(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e};class Si extends pi{constructor(e){super(),this.markers=new h.Collection({idProperty:"name"}),this._attributePriority=new Map,this._selectionRestorePosition=null,this._hasChangedRange=!1,this._overriddenGravityRegister=new Set,this._observedMarkers=new Set,this._model=e.model,this._document=e,this.listenTo(this._model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&"marker"!=i.type&&"rename"!=i.type&&"noop"!=i.type&&(0==this._ranges.length&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))}),{priority:"lowest"}),this.on("change:range",(()=>{this._validateSelectionRanges(this.getRanges())})),this.listenTo(this._model.markers,"update",((e,t,i,n)=>{this._updateMarker(t,n)})),this.listenTo(this._document,"change",((e,t)=>{!function(e,t){const i=e.document.differ;for(const n of i.getChanges()){if("insert"!=n.type)continue;const i=n.position.parent;n.length===i.maxOffset&&e.enqueueChange(t,(e=>{const t=Array.from(i.getAttributeKeys()).filter((e=>e.startsWith(xi)));for(const n of t)e.removeAttribute(n,i)}))}}(this._model,t)}))}get isCollapsed(){return 0===this._ranges.length?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let e=0;e{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=n.deletionPosition;const e=this._ranges.indexOf(t);this._ranges.splice(e,1),t.detach()}})),t}updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const t of this._model.markers){const i=t.name.split(":",1)[0];if(!this._observedMarkers.has(i))continue;const n=t.getRange();for(const i of this.getRanges())n.containsRange(i,!i.isCollapsed)&&e.push(t)}const i=Array.from(this.markers);for(const i of e)this.markers.has(i)||(this.markers.add(i),t=!0);for(const i of Array.from(this.markers))e.includes(i)||(this.markers.remove(i),t=!0);t&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateMarker(e,t){const i=e.name.split(":",1)[0];if(!this._observedMarkers.has(i))return;let n=!1;const o=Array.from(this.markers),s=this.markers.has(e);if(t){let i=!1;for(const e of this.getRanges())if(t.containsRange(e,!e.isCollapsed)){i=!0;break}i&&!s?(this.markers.add(e),n=!0):!i&&s&&(this.markers.remove(e),n=!0)}else s&&(this.markers.remove(e),n=!0);n&&this.fire("change:marker",{oldMarkers:o,directChange:!1})}_updateAttributes(e){const t=(0,h.toMap)(this._getSurroundingAttributes()),i=(0,h.toMap)(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[e,t]of this._attributePriority)"low"==t&&(this._attrs.delete(e),this._attributePriority.delete(e));this._setAttributesTo(t);const n=[];for(const[e,t]of this.getAttributes())i.has(e)&&i.get(e)===t||n.push(e);for(const[e]of i)this.hasAttribute(e)||n.push(e);n.length>0&&this.fire("change:attribute",{attributeKeys:n,directChange:!1})}_setAttribute(e,t,i=!0){const n=i?"normal":"low";return("low"!=n||"normal"!=this._attributePriority.get(e))&&(super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,n),!0))}_removeAttribute(e,t=!0){const i=t?"normal":"low";return!("low"==i&&"normal"==this._attributePriority.get(e)||(this._attributePriority.set(e,i),!super.hasAttribute(e)||(this._attrs.delete(e),0)))}_setAttributesTo(e){const t=new Set;for(const[t,i]of this.getAttributes())e.get(t)!==i&&this._removeAttribute(t,!1);for(const[i,n]of e)this._setAttribute(i,n,!1)&&t.add(i);return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())if(t.startsWith(xi)){const i=t.substr(10);yield[i,e.getAttribute(t)]}}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;if("$graveyard"==e.root.rootName)return null;let i=null;if(this.isCollapsed){const n=e.textNode?e.textNode:e.nodeBefore,o=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(i=Pi(n,t)),i||(i=Pi(o,t)),!this.isGravityOverridden&&!i){let e=n;for(;e&&!i;)e=e.previousSibling,i=Pi(e,t)}if(!i){let e=o;for(;e&&!i;)e=e.nextSibling,i=Pi(e,t)}i||(i=this.getStoredAttributes())}else{const e=this.getFirstRange();for(const n of e){if(n.item.is("element")&&t.isObject(n.item)){i=Pi(n.item,t);break}if("text"==n.type){i=n.item.getAttributes();break}}}return i}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function Pi(e,t){if(!e)return null;if(e instanceof Xt||e instanceof Qt)return e.getAttributes();if(!t.isInline(e))return null;if(!t.isObject(e))return[];const i=[];for(const[n,o]of e.getAttributes())t.checkAttribute("$text",n)&&!1!==t.getAttributeProperties(n).copyFromObject&&i.push([n,o]);return i}class Ii{constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}class Vi extends Ii{elementToElement(e){return this.add(function(e){const t=Bi(e.model),i=Mi(e.view,"container");return t.attributes.length&&(t.children=!0),n=>{n.on(`insert:${t.name}`,function(e,t=Ui){return(i,n,o)=>{if(!t(n.item,o.consumable,{preflight:!0}))return;const s=e(n.item,o,n);if(!s)return;t(n.item,o.consumable);const r=o.mapper.toViewPosition(n.range.start);o.mapper.bindElements(n.item,s),o.writer.insert(r,s),o.convertAttributes(n.item),Hi(s,n.item.getChildren(),o,{reconversion:n.reconversion})}}(i,zi(t)),{priority:e.converterPriority||"normal"}),(t.children||t.attributes.length)&&n.on("reduceChanges",Fi(t),{priority:"low"})}}(e))}elementToStructure(e){return this.add(function(e){const t=Bi(e.model),i=Mi(e.view,"container");return t.children=!0,n=>{if(n._conversionApi.schema.checkChild(t.name,"$text"))throw new h.CKEditorError("conversion-element-to-structure-disallowed-text",n,{elementName:t.name});var o,s;n.on(`insert:${t.name}`,(o=i,s=zi(t),(e,t,i)=>{if(!s(t.item,i.consumable,{preflight:!0}))return;const n=new Map;i.writer._registerSlotFactory(function(e,t,i){return(n,o)=>{const s=n.createContainerElement("$slot");let r=null;if("children"===o)r=Array.from(e.getChildren());else{if("function"!=typeof o)throw new h.CKEditorError("conversion-slot-mode-unknown",i.dispatcher,{modeOrFilter:o});r=Array.from(e.getChildren()).filter((e=>o(e)))}return t.set(s,r),s}}(t.item,n,i));const r=o(t.item,i,t);if(i.writer._clearSlotFactory(),!r)return;!function(e,t,i){const n=Array.from(t.values()).flat(),o=new Set(n);if(o.size!=n.length)throw new h.CKEditorError("conversion-slot-filter-overlap",i.dispatcher,{element:e});if(o.size!=e.childCount)throw new h.CKEditorError("conversion-slot-filter-incomplete",i.dispatcher,{element:e})}(t.item,n,i),s(t.item,i.consumable);const a=i.mapper.toViewPosition(t.range.start);i.mapper.bindElements(t.item,r),i.writer.insert(a,r),i.convertAttributes(t.item),function(e,t,i,n){i.mapper.on("modelToViewPosition",r,{priority:"highest"});let o=null,s=null;for([o,s]of t)Hi(e,s,i,n),i.writer.move(i.writer.createRangeIn(o),i.writer.createPositionBefore(o)),i.writer.remove(o);function r(e,t){const i=t.modelPosition.nodeAfter,n=s.indexOf(i);n<0||(t.viewPosition=t.mapper.findPositionIn(o,n))}i.mapper.off("modelToViewPosition",r)}(r,n,i,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),n.on("reduceChanges",Fi(t),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){let t=(e=Kt(e)).model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;if(t.name&&(i+=":"+t.name),t.values)for(const i of t.values)e.view[i]=Mi(e.view[i],"attribute");else e.view=Mi(e.view,"attribute");const n=Ni(e);return t=>{t.on(i,function(e){return(t,i,n)=>{if(!n.consumable.test(i.item,t.name))return;const o=e(i.attributeOldValue,n,i),s=e(i.attributeNewValue,n,i);if(!o&&!s)return;n.consumable.consume(i.item,t.name);const r=n.writer,a=r.document.selection;if(i.item instanceof pi||i.item instanceof Ti)r.wrap(a.getFirstRange(),s);else{let e=n.mapper.toViewRange(i.range);null!==i.attributeOldValue&&o&&(e=r.unwrap(e,o)),null!==i.attributeNewValue&&s&&r.wrap(e,s)}}}(n),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){let t=(e=Kt(e)).model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;if(t.name&&(i+=":"+t.name),t.values)for(const i of t.values)e.view[i]=Di(e.view[i]);else e.view=Di(e.view);const n=Ni(e);return t=>{var o;t.on(i,(o=n,(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=o(t.attributeOldValue,i,t),s=o(t.attributeNewValue,i,t);if(!n&&!s)return;i.consumable.consume(t.item,e.name);const r=i.mapper.toViewElement(t.item),a=i.writer;if(!r)throw new h.CKEditorError("conversion-attribute-to-attribute-on-text",i.dispatcher,t);if(null!==t.attributeOldValue&&n)if("class"==n.key){const e=(0,h.toArray)(n.value);for(const t of e)a.removeClass(t,r)}else if("style"==n.key){const e=Object.keys(n.value);for(const t of e)a.removeStyle(t,r)}else a.removeAttribute(n.key,r);if(null!==t.attributeNewValue&&s)if("class"==s.key){const e=(0,h.toArray)(s.value);for(const t of e)a.addClass(t,r)}else if("style"==s.key){const e=Object.keys(s.value);for(const t of e)a.setStyle(t,s.value[t],r)}else a.setAttribute(s.key,s.value,r)}),{priority:e.converterPriority||"normal"})}}(e))}markerToElement(e){return this.add(function(e){const t=Mi(e.view,"ui");return i=>{var n;i.on(`addMarker:${e.model}`,(n=t,(e,t,i)=>{t.isOpening=!0;const o=n(t,i);t.isOpening=!1;const s=n(t,i);if(!o||!s)return;const r=t.markerRange;if(r.isCollapsed&&!i.consumable.consume(r,e.name))return;for(const t of r)if(!i.consumable.consume(t.item,e.name))return;const a=i.mapper,l=i.writer;l.insert(a.toViewPosition(r.start),o),i.mapper.bindElementToMarker(o,t.markerName),r.isCollapsed||(l.insert(a.toViewPosition(r.end),s),i.mapper.bindElementToMarker(s,t.markerName)),e.stop()}),{priority:e.converterPriority||"normal"}),i.on(`removeMarker:${e.model}`,((e,t,i)=>{const n=i.mapper.markerNameToElements(t.markerName);if(n){for(const e of n)i.mapper.unbindElementFromMarkerName(e,t.markerName),i.writer.clear(i.writer.createRangeOn(e),e);i.writer.clearClonedElementsGroup(t.markerName),e.stop()}}),{priority:e.converterPriority||"normal"})}}(e))}markerToHighlight(e){return this.add(function(e){return t=>{var i;t.on(`addMarker:${e.model}`,(i=e.view,(e,t,n)=>{if(!t.item)return;if(!(t.item instanceof pi||t.item instanceof Ti||t.item.is("$textProxy")))return;const o=Li(i,t,n);if(!o)return;if(!n.consumable.consume(t.item,e.name))return;const s=n.writer,r=Ri(s,o),a=s.document.selection;if(t.item instanceof pi||t.item instanceof Ti)s.wrap(a.getFirstRange(),r);else{const e=n.mapper.toViewRange(t.range),i=s.wrap(e,r);for(const e of i.getItems())if(e.is("attributeElement")&&e.isSimilar(r)){n.mapper.bindElementToMarker(e,t.markerName);break}}}),{priority:e.converterPriority||"normal"}),t.on(`addMarker:${e.model}`,function(e){return(t,i,n)=>{if(!i.item)return;if(!(i.item instanceof ei))return;const o=Li(e,i,n);if(!o)return;if(!n.consumable.test(i.item,t.name))return;const s=n.mapper.toViewElement(i.item);if(s&&s.getCustomProperty("addHighlight")){n.consumable.consume(i.item,t.name);for(const e of ci._createIn(i.item))n.consumable.consume(e.item,t.name);s.getCustomProperty("addHighlight")(s,o,n.writer),n.mapper.bindElementToMarker(s,i.markerName)}}}(e.view),{priority:e.converterPriority||"normal"}),t.on(`removeMarker:${e.model}`,function(e){return(t,i,n)=>{if(i.markerRange.isCollapsed)return;const o=Li(e,i,n);if(!o)return;const s=Ri(n.writer,o),r=n.mapper.markerNameToElements(i.markerName);if(r){for(const e of r)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("attributeElement")?n.writer.unwrap(n.writer.createRangeOn(e),s):e.getCustomProperty("removeHighlight")(e,o.id,n.writer);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}markerToData(e){return this.add(function(e){const t=(e=Kt(e)).model;let i=e.view;return i||(i=i=>({group:t,name:i.substr(e.model.length+1)})),n=>{var o;n.on(`addMarker:${t}`,(o=i,(e,t,i)=>{const n=o(t.markerName,i);if(!n)return;const s=t.markerRange;i.consumable.consume(s,e.name)&&(Oi(s,!1,i,t,n),Oi(s,!0,i,t,n),e.stop())}),{priority:e.converterPriority||"normal"}),n.on(`removeMarker:${t}`,function(e){return(t,i,n)=>{const o=e(i.markerName,n);if(!o)return;const s=n.mapper.markerNameToElements(i.markerName);if(s){for(const e of s)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("containerElement")?(r(`data-${o.group}-start-before`,e),r(`data-${o.group}-start-after`,e),r(`data-${o.group}-end-before`,e),r(`data-${o.group}-end-after`,e)):n.writer.clear(n.writer.createRangeOn(e),e);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}function r(e,t){if(t.hasAttribute(e)){const i=new Set(t.getAttribute(e).split(","));i.delete(o.name),0==i.size?n.writer.removeAttribute(e,t):n.writer.setAttribute(e,Array.from(i).join(","),t)}}}}(i),{priority:e.converterPriority||"normal"})}}(e))}}function Ri(e,t){const i=e.createAttributeElement("span",t.attributes);return t.classes&&i._addClass(t.classes),"number"==typeof t.priority&&(i._priority=t.priority),i._id=t.id,i}function Oi(e,t,i,n,o){const s=t?e.start:e.end,r=s.nodeAfter&&s.nodeAfter.is("element")?s.nodeAfter:null,a=s.nodeBefore&&s.nodeBefore.is("element")?s.nodeBefore:null;if(r||a){let e,s;t&&r||!t&&!a?(e=r,s=!0):(e=a,s=!1);const l=i.mapper.toViewElement(e);if(l)return void function(e,t,i,n,o,s){const r=`data-${s.group}-${t?"start":"end"}-${i?"before":"after"}`,a=e.hasAttribute(r)?e.getAttribute(r).split(","):[];a.unshift(s.name),n.writer.setAttribute(r,a.join(","),e),n.mapper.bindElementToMarker(e,o.markerName)}(l,t,s,i,n,o)}!function(e,t,i,n,o){const s=`${o.group}-${t?"start":"end"}`,r=o.name?{name:o.name}:null,a=i.writer.createUIElement(s,r);i.writer.insert(e,a),i.mapper.bindElementToMarker(a,n.markerName)}(i.mapper.toViewPosition(s),t,i,n,o)}function Bi(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 Mi(e,t){return"function"==typeof e?e:(i,n)=>function(e,t,i){let n;"string"==typeof e&&(e={name:e});const o=t.writer,s=Object.assign({},e.attributes);if("container"==i)n=o.createContainerElement(e.name,s);else if("attribute"==i){const t={priority:e.priority||De.DEFAULT_PRIORITY};n=o.createAttributeElement(e.name,s,t)}else n=o.createUIElement(e.name,s);if(e.styles){const t=Object.keys(e.styles);for(const i of t)o.setStyle(i,e.styles[i],n)}if(e.classes){const t=e.classes;if("string"==typeof t)o.addClass(t,n);else for(const e of t)o.addClass(e,n)}return n}(e,n,t)}function Ni(e){return e.model.values?(t,i,n)=>{const o=e.view[t];return o?o(t,i,n):null}:e.view}function Di(e){return"string"==typeof e?t=>({key:e,value:t}):"object"==typeof e?e.value?()=>e:t=>({key:e.key,value:t}):e}function Li(e,t,i){const n="function"==typeof e?e(t,i):e;return n?(n.priority||(n.priority=10),n.id||(n.id=t.markerName),n):null}function Fi(e){const t=function(e){return(t,i)=>{if(!t.is("element",e.name))return!1;if("attribute"==i.type){if(e.attributes.includes(i.attributeKey))return!0}else if(e.children)return!0;return!1}}(e);return(e,i)=>{const n=[];i.reconvertedElements||(i.reconvertedElements=new Set);for(const e of i.changes){const o="attribute"==e.type?e.range.start.nodeAfter:e.position.parent;if(o&&t(o,e)){if(!i.reconvertedElements.has(o)){i.reconvertedElements.add(o);const e=ni._createBefore(o);let t=n.length;for(let i=n.length-1;i>=0;i--){const o=n[i],s=("attribute"==o.type?o.range.start:o.position).compareWith(e);if("before"==s||"remove"==o.type&&"same"==s)break;t=i}n.splice(t,0,{type:"remove",name:o.name,position:e,length:1},{type:"reinsert",name:o.name,position:e,length:1})}}else n.push(e)}i.changes=n}}function zi(e){return(t,i,n={})=>{const o=["insert"];for(const i of e.attributes)t.hasAttribute(i)&&o.push(`attribute:${i}`);return!!o.every((e=>i.test(t,e)))&&(n.preflight||o.forEach((e=>i.consume(t,e))),!0)}}function Hi(e,t,i,n){for(const o of t)Wi(e.root,o,i,n)||i.convertItem(o)}function Wi(e,t,i,n){const{writer:o,mapper:s}=i;if(!n.reconversion)return!1;const r=s.toViewElement(t);return!(!r||r.root==e||!i.canReuseView(r)||(o.move(o.createRangeOn(r),s.toViewPosition(ni._createBefore(t))),0))}function Ui(e,t,{preflight:i}={}){return i?t.test(e,"insert"):t.consume(e,"insert")}function ji(e){const{schema:t,document:i}=e.model;for(const n of i.getRoots())if(n.isEmpty&&!t.checkChild(n,"$text")&&t.checkChild(n,"paragraph"))return e.insertElement("paragraph",n),!0;return!1}function $i(e,t,i){const n=i.createContext(e);return!!i.checkChild(n,"paragraph")&&!!i.checkChild(n.push("paragraph"),t)}function qi(e,t){const i=t.createElement("paragraph");return t.insert(i,e),t.createPositionAt(i,0)}class Ki extends Ii{elementToElement(e){return this.add(Zi(e))}elementToAttribute(e){return this.add(function(e){Yi(e=Kt(e));const t=Qi(e,!1),i=Gi(e.view),n=i?`element:${i}`:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){let t=null;("string"==typeof(e=Kt(e)).view||e.view.key)&&(t=function(e){"string"==typeof e.view&&(e.view={key:e.view});const t=e.view.key;let i;return i="class"==t||"style"==t?{["class"==t?"classes":"styles"]:e.view.value}:{attributes:{[t]:void 0===e.view.value?/[\s\S]*/:e.view.value}},e.view.name&&(i.name=e.view.name),e.view=i,t}(e)),Yi(e,t);const i=Qi(e,!0);return t=>{t.on("element",i,{priority:e.converterPriority||"low"})}}(e))}elementToMarker(e){return this.add(function(e){const t=function(e){return(t,i)=>{const n="string"==typeof e?e:e(t,i);return i.writer.createElement("$marker",{"data-name":n})}}(e.model);return Zi({...e,model:t})}(e))}dataToMarker(e){return this.add(function(e){(e=Kt(e)).model||(e.model=t=>t?e.view+":"+t:e.view);const t={view:e.view,model:e.model},i=Ji(Xi(t,"start")),n=Ji(Xi(t,"end"));return o=>{o.on(`element:${e.view}-start`,i,{priority:e.converterPriority||"normal"}),o.on(`element:${e.view}-end`,n,{priority:e.converterPriority||"normal"});const s=h.priorities.low,r=h.priorities.highest,a=h.priorities.get(e.converterPriority)/r;o.on("element",function(e){return(t,i,n)=>{const o=`data-${e.view}`;function s(t,o){for(const s of o){const o=e.model(s,n),r=n.writer.createElement("$marker",{"data-name":o});n.writer.insert(r,t),i.modelCursor.isEqual(t)?i.modelCursor=i.modelCursor.getShiftedBy(1):i.modelCursor=i.modelCursor._getTransformedByInsertion(t,1),i.modelRange=i.modelRange._getTransformedByInsertion(t,1)[0]}}(n.consumable.test(i.viewItem,{attributes:o+"-end-after"})||n.consumable.test(i.viewItem,{attributes:o+"-start-after"})||n.consumable.test(i.viewItem,{attributes:o+"-end-before"})||n.consumable.test(i.viewItem,{attributes:o+"-start-before"}))&&(i.modelRange||Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor)),n.consumable.consume(i.viewItem,{attributes:o+"-end-after"})&&s(i.modelRange.end,i.viewItem.getAttribute(o+"-end-after").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-start-after"})&&s(i.modelRange.end,i.viewItem.getAttribute(o+"-start-after").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-end-before"})&&s(i.modelRange.start,i.viewItem.getAttribute(o+"-end-before").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-start-before"})&&s(i.modelRange.start,i.viewItem.getAttribute(o+"-start-before").split(",")))}}(t),{priority:s+a})}}(e))}}function Zi(e){const t=Ji(e=Kt(e)),i=Gi(e.view),n=i?`element:${i}`:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"normal"})}}function Gi(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}function Ji(e){const t=new _(e.view);return(i,n,o)=>{const s=t.match(n.viewItem);if(!s)return;const r=s.match;if(r.name=!0,!o.consumable.test(n.viewItem,r))return;const a=function(e,t,i){return e instanceof Function?e(t,i):i.writer.createElement(e)}(e.model,n.viewItem,o);a&&o.safeInsert(a,n.modelCursor)&&(o.consumable.consume(n.viewItem,r),o.convertChildren(n.viewItem,a),o.updateConversionResult(a,n))}}function Yi(e,t=null){const i=null===t||(e=>e.getAttribute(t)),n="object"!=typeof e.model?e.model:e.model.key,o="object"!=typeof e.model||void 0===e.model.value?i:e.model.value;e.model={key:n,value:o}}function Qi(e,t){const i=new _(e.view);return(n,o,s)=>{if(!o.modelRange&&t)return;const r=i.match(o.viewItem);if(!r)return;if(function(e,t){const i="function"==typeof e?e(t):e;return!("object"==typeof i&&!Gi(i))&&(!i.classes&&!i.attributes&&!i.styles)}(e.view,o.viewItem)?r.match.name=!0:delete r.match.name,!s.consumable.test(o.viewItem,r.match))return;const a=e.model.key,l="function"==typeof e.model.value?e.model.value(o.viewItem,s):e.model.value;if(null===l)return;o.modelRange||Object.assign(o,s.convertChildren(o.viewItem,o.modelCursor));const c=function(e,t,i,n){let o=!1;for(const s of Array.from(e.getItems({shallow:i})))n.schema.checkAttribute(s,t.key)&&(o=!0,s.hasAttribute(t.key)||n.writer.setAttribute(t.key,t.value,s));return o}(o.modelRange,{key:a,value:l},t,s);c&&(s.consumable.test(o.viewItem,{name:!0})&&(r.match.name=!0),s.consumable.consume(o.viewItem,r.match))}}function Xi(e,t){return{view:`${e.view}-${t}`,model:(t,i)=>{const n=t.getAttribute("name"),o=e.model(n,i);return i.writer.createElement("$marker",{"data-name":o})}}}function en(e,t){return e.isCollapsed?function(e,t){const i=e.start,n=t.getNearestSelectionRange(i);if(!n){const e=i.getAncestors().reverse().find((e=>t.isObject(e)));return e?ci._createOn(e):null}if(!n.isCollapsed)return n;const o=n.start;return i.isEqual(o)?null:new ci(o)}(e,t):function(e,t){const{start:i,end:n}=e,o=t.checkChild(i,"$text"),s=t.checkChild(n,"$text"),r=t.getLimitElement(i),a=t.getLimitElement(n);if(r===a){if(o&&s)return null;if(function(e,t,i){const n=e.nodeAfter&&!i.isLimit(e.nodeAfter)||i.checkChild(e,"$text"),o=t.nodeBefore&&!i.isLimit(t.nodeBefore)||i.checkChild(t,"$text");return n||o}(i,n,t)){const e=i.nodeAfter&&t.isSelectable(i.nodeAfter)?null:t.getNearestSelectionRange(i,"forward"),o=n.nodeBefore&&t.isSelectable(n.nodeBefore)?null:t.getNearestSelectionRange(n,"backward"),s=e?e.start:i,r=o?o.end:n;return new ci(s,r)}}const l=r&&!r.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const e=i.nodeAfter&&n.nodeBefore&&i.nodeAfter.parent===n.nodeBefore.parent,o=l&&(!e||!nn(i.nodeAfter,t)),s=c&&(!e||!nn(n.nodeBefore,t));let d=i,u=n;return o&&(d=ni._createBefore(tn(r,t))),s&&(u=ni._createAfter(tn(a,t))),new ci(d,u)}return null}(e,t)}function tn(e,t){let i=e,n=i;for(;t.isLimit(n)&&n.parent;)i=n,n=n.parent;return i}function nn(e,t){return e&&t.isSelectable(e)}class on extends((0,h.ObservableMixin)()){constructor(e,t){super(),this.model=e,this.view=new Zt(t),this.mapper=new di,this.downcastDispatcher=new mi({mapper:this.mapper,schema:e.schema});const i=this.model.document,n=i.selection,o=this.model.markers;var s,r,a;this.listenTo(this.model,"_beforeChanges",(()=>{this.view._disableRendering(!0)}),{priority:"highest"}),this.listenTo(this.model,"_afterChanges",(()=>{this.view._disableRendering(!1)}),{priority:"lowest"}),this.listenTo(i,"change",(()=>{this.view.change((e=>{this.downcastDispatcher.convertChanges(i.differ,o,e),this.downcastDispatcher.convertSelection(n,o,e)}))}),{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(i,n)=>{const o=n.newSelection,s=[];for(const e of o.getRanges())s.push(t.toModelRange(e));const r=e.createSelection(s,{backward:o.isBackward});r.isEqual(e.document.selection)||e.change((e=>{e.setSelection(r)}))}}(this.model,this.mapper)),this.listenTo(this.view.document,"beforeinput",(s=this.mapper,r=this.model.schema,a=this.view,(e,t)=>{if(!a.document.isComposing||h.env.isAndroid)for(let e=0;e{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewPosition(t.range.start),s=n.createText(t.item.data);n.insert(o,s)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)}),{priority:"lowest"}),this.downcastDispatcher.on("remove",((e,t,i)=>{const n=i.mapper.toViewPosition(t.position),o=t.position.getShiftedBy(t.length),s=i.mapper.toViewPosition(o,{isPhantom:!0}),r=i.writer.createRange(n,s),a=i.writer.remove(r.getTrimmed());for(const e of i.writer.createRangeIn(a).getItems())i.mapper.unbindViewElement(e,{defer:!0})}),{priority:"low"}),this.downcastDispatcher.on("cleanSelection",((e,t,i)=>{const n=i.writer,o=n.document.selection;for(const e of o.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&i.writer.mergeAttributes(e.start);n.setSelection(null)})),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=t.selection;if(n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const o=[];for(const e of n.getRanges())o.push(i.mapper.toViewRange(e));i.writer.setSelection(o,{backward:n.isBackward})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=t.selection;if(!n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const o=i.writer,s=n.getFirstPosition(),r=i.mapper.toViewPosition(s),a=o.breakAttributes(r);o.setSelection(a)}),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using((e=>{if("$graveyard"==e.rootName)return null;const t=new ke(this.view.document,e.name);return t.rootName=e.rootName,this.mapper.bindElements(e,t),t}))}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const t="string"==typeof e?e:e.name,i=this.model.markers.get(t);if(!i)throw new h.CKEditorError("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change((()=>{this.model.markers._refresh(i)}))}reconvertItem(e){this.model.change((()=>{this.model.document.differ._refreshItem(e)}))}}class sn{constructor(){this._consumables=new Map}add(e,t){let i;e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):(this._consumables.has(e)?i=this._consumables.get(e):(i=new an(e),this._consumables.set(e,i)),i.add(t))}test(e,t){const i=this._consumables.get(e);return void 0===i?null:e.is("$text")||e.is("documentFragment")?i:i.test(t)}consume(e,t){return!!this.test(e,t)&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!1):this._consumables.get(e).consume(t),!0)}revert(e,t){const i=this._consumables.get(e);void 0!==i&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):i.revert(t))}static consumablesFromElement(e){const t={element:e,name:!0,attributes:[],classes:[],styles:[]},i=e.getAttributeKeys();for(const e of i)"style"!=e&&"class"!=e&&t.attributes.push(e);const n=e.getClassNames();for(const e of n)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 sn),e.is("$text"))return t.add(e),t;e.is("element")&&t.add(e,sn.consumablesFromElement(e)),e.is("documentFragment")&&t.add(e);for(const i of e.getChildren())t=sn.createFrom(i,t);return t}}const rn=["attributes","classes","styles"];class an{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 rn)t in e&&this._add(t,e[t])}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const t of rn)if(t in e){const i=this._test(t,e[t]);if(!0!==i)return i}return!0}consume(e){e.name&&(this._canConsumeName=!1);for(const t of rn)t in e&&this._consume(t,e[t])}revert(e){e.name&&(this._canConsumeName=!0);for(const t of rn)t in e&&this._revert(t,e[t])}_add(e,t){const i=(0,A.Z)(t)?t:[t],n=this._consumables[e];for(const t of i){if("attributes"===e&&("class"===t||"style"===t))throw new h.CKEditorError("viewconsumable-invalid-attribute",this);if(n.set(t,!0),"styles"===e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))n.set(e,!0)}}_test(e,t){const i=(0,A.Z)(t)?t:[t],n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){const e=n.get(t);if(void 0===e)return null;if(!e)return!1}else{const e="class"==t?"classes":"styles",i=this._test(e,[...this._consumables[e].keys()]);if(!0!==i)return i}return!0}_consume(e,t){const i=(0,A.Z)(t)?t:[t],n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){if(n.set(t,!1),"styles"==e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))n.set(e,!1)}else{const e="class"==t?"classes":"styles";this._consume(e,[...this._consumables[e].keys()])}}_revert(e,t){const i=(0,A.Z)(t)?t:[t],n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t)!1===n.get(t)&&n.set(t,!0);else{const e="class"==t?"classes":"styles";this._revert(e,[...this._consumables[e].keys()])}}}class ln extends((0,h.ObservableMixin)()){constructor(){super(),this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",((e,t)=>{t[0]=new cn(t[0])}),{priority:"highest"}),this.on("checkChild",((e,t)=>{t[0]=new cn(t[0]),t[1]=this.getDefinition(t[1])}),{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new h.CKEditorError("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 h.CKEditorError("schema-cannot-extend-missing-item",this,{itemName:e});this._sourceDefinitions[e].push(Object.assign({},t)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(e){let t;return t="string"==typeof e?e:"is"in e&&(e.is("$text")||e.is("$textProxy"))?"$text":e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const t=this.getDefinition(e);return!(!t||!t.isBlock)}isLimit(e){const t=this.getDefinition(e);return!(!t||!t.isLimit&&!t.isObject)}isObject(e){const t=this.getDefinition(e);return!!t&&!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent)}isInline(e){const t=this.getDefinition(e);return!(!t||!t.isInline)}isSelectable(e){const t=this.getDefinition(e);return!(!t||!t.isSelectable&&!t.isObject)}isContent(e){const t=this.getDefinition(e);return!(!t||!t.isContent&&!t.isObject)}checkChild(e,t){return!!t&&this._checkContextMatch(t,e)}checkAttribute(e,t){const i=this.getDefinition(e.last);return!!i&&i.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof ni){const t=e.nodeBefore,i=e.nodeAfter;if(!(t instanceof ei))throw new h.CKEditorError("schema-check-merge-no-element-before",this);if(!(i instanceof ei))throw new h.CKEditorError("schema-check-merge-no-element-after",this);return this.checkMerge(t,i)}for(const i of t.getChildren())if(!this.checkChild(e,i))return!1;return!0}addChildCheck(e){this.on("checkChild",((t,[i,n])=>{if(!n)return;const o=e(i,n);"boolean"==typeof o&&(t.stop(),t.return=o)}),{priority:"high"})}addAttributeCheck(e){this.on("checkAttribute",((t,[i,n])=>{const o=e(i,n);"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;for(t=e instanceof ni?e.parent:(e instanceof ci?[e]:Array.from(e.getRanges())).reduce(((e,t)=>{const i=t.getCommonAncestor();return e?e.getCommonAncestor(i,{includeSelf:!0}):i}),null);!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const i=[...e.getFirstPosition().getAncestors(),new Qt("",e.getAttributes())];return this.checkAttribute(i,t)}{const i=e.getRanges();for(const e of i)for(const i of e)if(this.checkAttribute(i.item,t))return!0}return!1}*getValidRanges(e,t){e=function*(e){for(const t of e)yield*t.getMinimalFlatRanges()}(e);for(const i of e)yield*this._getValidRangesForRange(i,t)}getNearestSelectionRange(e,t="both"){if("$graveyard"==e.root.rootName)return null;if(this.checkChild(e,"$text"))return new ci(e);let i,n;const o=e.getAncestors().reverse().find((e=>this.isLimit(e)))||e.root;"both"!=t&&"backward"!=t||(i=new ti({boundaries:ci._createIn(o),startPosition:e,direction:"backward"})),"both"!=t&&"forward"!=t||(n=new ti({boundaries:ci._createIn(o),startPosition:e}));for(const e of function*(e,t){let i=!1;for(;!i;){if(i=!0,e){const t=e.next();t.done||(i=!1,yield{walker:e,value:t.value})}if(t){const e=t.next();e.done||(i=!1,yield{walker:t,value:e.value})}}}(i,n)){const t=e.walker==i?"elementEnd":"elementStart",n=e.value;if(n.type==t&&this.isObject(n.item))return ci._createOn(n.item);if(this.checkChild(n.nextPosition,"$text"))return new ci(n.nextPosition)}return null}findAllowedParent(e,t){let i=e.parent;for(;i;){if(this.checkChild(i,t))return i;if(this.isLimit(i))return null;i=i.parent}return null}setAllowedAttributes(e,t,i){const n=i.model;for(const[o,s]of Object.entries(t))n.schema.checkAttribute(e,o)&&i.setAttribute(o,s,e)}removeDisallowedAttributes(e,t){for(const i of e)if(i.is("$text"))kn(this,i,t);else{const e=ci._createIn(i).getPositions();for(const i of e)kn(this,i.nodeBefore||i.parent,t)}}getAttributesWithProperty(e,t,i){const n={};for(const[o,s]of e.getAttributes()){const e=this.getAttributeProperties(o);void 0!==e[t]&&(void 0!==i&&i!==e[t]||(n[o]=s))}return n}createContext(e){return new cn(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,i=Object.keys(t);for(const n of i)e[n]=dn(t[n],n);for(const t of i)un(e,t);for(const t of i)hn(e,t);for(const t of i)mn(e,t);for(const t of i)gn(e,t),fn(e,t);for(const t of i)pn(e,t),bn(e,t),wn(e,t);this._compiledDefinitions=e}_checkContextMatch(e,t,i=t.length-1){const n=t.getItem(i);if(e.allowIn.includes(n.name)){if(0==i)return!0;{const e=this.getDefinition(n);return this._checkContextMatch(e,t,i-1)}}return!1}*_getValidRangesForRange(e,t){let i=e.start,n=e.start;for(const o of e.getItems({shallow:!0}))o.is("element")&&(yield*this._getValidRangesForRange(ci._createIn(o),t)),this.checkAttribute(o,t)||(i.isEqual(n)||(yield new ci(i,n)),i=ni._createAfter(o)),n=ni._createAfter(o);i.isEqual(n)||(yield new ci(i,n))}}class cn{constructor(e){if(e instanceof cn)return e;let t;t="string"==typeof e?[e]:Array.isArray(e)?e:e.getAncestors({includeSelf:!0}),this._items=t.map(yn)}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 cn([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 dn(e,t){const i={name:t,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],allowChildren:[],inheritTypesFrom:[]};return function(e,t){for(const i of e){const e=Object.keys(i).filter((e=>e.startsWith("is")));for(const n of e)t[n]=!!i[n]}}(e,i),vn(e,i,"allowIn"),vn(e,i,"allowContentOf"),vn(e,i,"allowWhere"),vn(e,i,"allowAttributes"),vn(e,i,"allowAttributesOf"),vn(e,i,"allowChildren"),vn(e,i,"inheritTypesFrom"),function(e,t){for(const i of e){const e=i.inheritAllFrom;e&&(t.allowContentOf.push(e),t.allowWhere.push(e),t.allowAttributesOf.push(e),t.inheritTypesFrom.push(e))}}(e,i),i}function un(e,t){const i=e[t];for(const n of i.allowChildren){const i=e[n];i&&i.allowIn.push(t)}i.allowChildren.length=0}function hn(e,t){for(const i of e[t].allowContentOf)e[i]&&_n(e,i).forEach((e=>{e.allowIn.push(t)}));delete e[t].allowContentOf}function mn(e,t){for(const i of e[t].allowWhere){const n=e[i];if(n){const i=n.allowIn;e[t].allowIn.push(...i)}}delete e[t].allowWhere}function gn(e,t){for(const i of e[t].allowAttributesOf){const n=e[i];if(n){const i=n.allowAttributes;e[t].allowAttributes.push(...i)}}delete e[t].allowAttributesOf}function fn(e,t){const i=e[t];for(const t of i.inheritTypesFrom){const n=e[t];if(n){const e=Object.keys(n).filter((e=>e.startsWith("is")));for(const t of e)t in i||(i[t]=n[t])}}delete i.inheritTypesFrom}function pn(e,t){const i=e[t],n=i.allowIn.filter((t=>e[t]));i.allowIn=Array.from(new Set(n))}function bn(e,t){const i=e[t];for(const n of i.allowIn)e[n].allowChildren.push(t)}function wn(e,t){const i=e[t];i.allowAttributes=Array.from(new Set(i.allowAttributes))}function vn(e,t,i){for(const n of e){const e=n[i];"string"==typeof e?t[i].push(e):Array.isArray(e)&&t[i].push(...e)}}function _n(e,t){const i=e[t];return(n=e,Object.keys(n).map((e=>n[e]))).filter((e=>e.allowIn.includes(i.name)));var n}function yn(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 kn(e,t,i){for(const n of t.getAttributeKeys())e.checkAttribute(t,n)||i.removeAttribute(n,t)}class Cn extends((0,h.EmitterMixin)()){constructor(e){super(),this._splitParts=new Map,this._cursorParents=new Map,this._modelCursor=null,this._emptyElementsToKeep=new Set,this.conversionApi={...e,consumable:null,writer:null,store:null,convertItem:(e,t)=>this._convertItem(e,t),convertChildren:(e,t)=>this._convertChildren(e,t),safeInsert:(e,t)=>this._safeInsert(e,t),updateConversionResult:(e,t)=>this._updateConversionResult(e,t),splitToAllowedParent:(e,t)=>this._splitToAllowedParent(e,t),getSplitParts:e=>this._getSplitParts(e),keepEmptyElement:e=>this._keepEmptyElement(e)}}convert(e,t,i=["$root"]){this.fire("viewCleanup",e),this._modelCursor=function(e,t){let i;for(const n of new cn(e)){const e={};for(const t of n.getAttributeKeys())e[t]=n.getAttribute(t);const o=t.createElement(n.name,e);i&&t.insert(o,i),i=ni._createAt(o,0)}return i}(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=sn.createFrom(e),this.conversionApi.store={};const{modelRange:n}=this._convertItem(e,this._modelCursor),o=t.createDocumentFragment();if(n){this._removeEmptyElements();for(const e of Array.from(this._modelCursor.parent.getChildren()))t.append(e,o);o.markers=function(e,t){const i=new Set,n=new Map,o=ci._createIn(e).getItems();for(const e of o)e.is("element","$marker")&&i.add(e);for(const e of i){const i=e.getAttribute("data-name"),o=t.createPositionBefore(e);n.has(i)?n.get(i).end=o.clone():n.set(i,new ci(o.clone())),t.remove(e)}return n}(o,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,o}_convertItem(e,t){const i={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,i,this.conversionApi):e.is("$text")?this.fire("text",i,this.conversionApi):this.fire("documentFragment",i,this.conversionApi),i.modelRange&&!(i.modelRange instanceof ci))throw new h.CKEditorError("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:ni._createAt(t,0);const n=new ci(i);for(const t of Array.from(e.getChildren())){const e=this._convertItem(t,i);e.modelRange instanceof ci&&(n.end=e.modelRange.end,i=e.modelCursor)}return{modelRange:n,modelCursor:i}}_safeInsert(e,t){const i=this._splitToAllowedParent(e,t);return!!i&&(this.conversionApi.writer.insert(e,i.position),!0)}_updateConversionResult(e,t){const i=this._getSplitParts(e),n=this.conversionApi.writer;t.modelRange||(t.modelRange=n.createRange(n.createPositionBefore(e),n.createPositionAfter(i[i.length-1])));const o=this._cursorParents.get(e);t.modelCursor=o?n.createPositionAt(o,0):t.modelRange.end}_splitToAllowedParent(e,t){const{schema:i,writer:n}=this.conversionApi;let o=i.findAllowedParent(t,e);if(o){if(o===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(o)&&(o=null)}if(!o)return $i(t,e,i)?{position:qi(t,n)}:null;const s=this.conversionApi.writer.split(t,o),r=[];for(const e of s.range.getWalker())if("elementEnd"==e.type)r.push(e.item);else{const t=r.pop(),i=e.item;this._registerSplitPair(t,i)}const a=s.range.end.parent;return this._cursorParents.set(e,a),{position:s.position,cursorParent:a}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);const i=this._splitParts.get(e);this._splitParts.set(t,i),i.push(t)}_getSplitParts(e){let t;return t=this._splitParts.has(e)?this._splitParts.get(e):[e],t}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){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 An{getHtml(e){const t=document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class En{constructor(e){this.skipComments=!0,this.domParser=new DOMParser,this.domConverter=new Ct(e,{renderingMode:"data"}),this.htmlWriter=new An}toData(e){const t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this.domConverter.domToView(t,{skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode="marked"==e?"markedNbsp":"nbsp"}_toDom(e){e.match(/<(?:html|body|head|meta)(?:\s[^>]*)?>/i)||(e=`${e}`);const t=this.domParser.parseFromString(e,"text/html"),i=t.createDocumentFragment(),n=t.body.childNodes;for(;n.length>0;)i.appendChild(n[0]);return i}}class xn extends((0,h.EmitterMixin)()){constructor(e,t){super(),this.model=e,this.mapper=new di,this.downcastDispatcher=new mi({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewPosition(t.range.start),s=n.createText(t.item.data);n.insert(o,s)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)}),{priority:"lowest"}),this.upcastDispatcher=new Cn({schema:e.schema}),this.viewDocument=new Ne(t),this.stylesProcessor=t,this.htmlProcessor=new En(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new Ke(this.viewDocument),this.upcastDispatcher.on("text",((e,t,{schema:i,consumable:n,writer:o})=>{let s=t.modelCursor;if(!n.test(t.viewItem))return;if(!i.checkChild(s,"$text")){if(!$i(s,"$text",i))return;if(0==t.viewItem.data.trim().length)return;const e=s.nodeBefore;s=qi(s,o),e&&e.is("element","$marker")&&(o.move(o.createRangeOn(e),s),s=o.createPositionAfter(e))}n.consume(t.viewItem);const r=o.createText(t.viewItem.data);o.insert(r,s),t.modelRange=o.createRange(s,s.getShiftedBy(r.offsetSize)),t.modelCursor=t.modelRange.end}),{priority:"lowest"}),this.upcastDispatcher.on("element",((e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}}),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",((e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}}),{priority:"lowest"}),(0,h.ObservableMixin)().prototype.decorate.call(this,"init"),(0,h.ObservableMixin)().prototype.decorate.call(this,"set"),(0,h.ObservableMixin)().prototype.decorate.call(this,"get"),(0,h.ObservableMixin)().prototype.decorate.call(this,"toView"),(0,h.ObservableMixin)().prototype.decorate.call(this,"toModel"),this.on("init",(()=>{this.fire("ready")}),{priority:"lowest"}),this.on("ready",(()=>{this.model.enqueueChange({isUndoable:!1},ji)}),{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new h.CKEditorError("datacontroller-get-non-existent-root",this);const n=this.model.document.getRoot(t);return n.isAttached()||(0,h.logWarning)("datacontroller-get-detached-root",this),"empty"!==i||this.model.hasContent(n,{ignoreWhitespaces:!0})?this.stringify(n,e):""}stringify(e,t={}){const i=this.toView(e,t);return this.processor.toData(i)}toView(e,t={}){const i=this.viewDocument,n=this._viewWriter;this.mapper.clearBindings();const o=ci._createIn(e),s=new qe(i);this.mapper.bindElements(e,s);const r=e.is("documentFragment")?e.markers:function(e){const t=[],i=e.root.document;if(!i)return new Map;const n=ci._createIn(e);for(const e of i.model.markers){const i=e.getRange(),o=i.isCollapsed,s=i.start.isEqual(n.start)||i.end.isEqual(n.end);if(o&&s)t.push([e.name,i]);else{const o=n.getIntersection(i);o&&t.push([e.name,o])}}return t.sort((([e,t],[i,n])=>{if("after"!==t.end.compareWith(n.start))return 1;if("before"!==t.start.compareWith(n.end))return-1;switch(t.start.compareWith(n.start)){case"before":return 1;case"after":return-1;default:switch(t.end.compareWith(n.end)){case"before":return 1;case"after":return-1;default:return i.localeCompare(e)}}})),new Map(t)}(e);return this.downcastDispatcher.convert(o,r,n,t),s}init(e){if(this.model.document.version)throw new h.CKEditorError("datacontroller-init-document-not-empty",this);let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new h.CKEditorError("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},(e=>{for(const i of Object.keys(t)){const n=this.model.document.getRoot(i);e.insert(this.parse(t[i],n),n,0)}})),Promise.resolve()}set(e,t={}){let i={};if("string"==typeof e?i.main=e:i=e,!this._checkIfRootsExists(Object.keys(i)))throw new h.CKEditorError("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},(e=>{e.setSelection(null),e.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const t of Object.keys(i)){const n=this.model.document.getRoot(t);e.remove(e.createRangeIn(n)),e.insert(this.parse(i[t],n),n,0)}}))}parse(e,t="$root"){const i=this.processor.toView(e);return this.toModel(i,t)}toModel(e,t="$root"){return this.model.change((i=>this.upcastDispatcher.convert(e,i,t)))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const t of e)if(!this.model.document.getRoot(t))return!1;return!0}}class Tn{constructor(e,t){this._helpers=new Map,this._downcast=(0,h.toArray)(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=(0,h.toArray)(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const i=this._downcast.includes(t);if(!this._upcast.includes(t)&&!i)throw new h.CKEditorError("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new h.CKEditorError("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:i}of Sn(e))this.for("upcast").elementToElement({model:t,view:i,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:i}of Sn(e))this.for("upcast").elementToAttribute({view:i,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:i}of Sn(e))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:i}){if(this._helpers.has(e))throw new h.CKEditorError("conversion-group-exists",this);const n=i?new Vi(t):new Ki(t);this._helpers.set(e,n)}}function*Sn(e){if(e.model.values)for(const t of e.model.values){const i={key:e.model.key,value:t},n=e.view[t],o=e.upcastAlso?e.upcastAlso[t]:void 0;yield*Pn(i,n,o)}else yield*Pn(e.model,e.view,e.upcastAlso)}function*Pn(e,t,i){if(yield{model:e,view:t},i)for(const t of(0,h.toArray)(i))yield{model:e,view:t}}class In{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 Vn(e,t){const i=Bn(t),n=i.reduce(((e,t)=>e+t.offsetSize),0),o=e.parent;Nn(e);const s=e.index;return o._insertChild(s,i),Mn(o,s+i.length),Mn(o,s),new ci(e,e.getShiftedBy(n))}function Rn(e){if(!e.isFlat)throw new h.CKEditorError("operation-utils-remove-range-not-flat",this);const t=e.start.parent;Nn(e.start),Nn(e.end);const i=t._removeChildren(e.start.index,e.end.index-e.start.index);return Mn(t,e.start.index),i}function On(e,t){if(!e.isFlat)throw new h.CKEditorError("operation-utils-move-range-not-flat",this);const i=Rn(e);return Vn(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),i)}function Bn(e){const t=[];!function e(i){if("string"==typeof i)t.push(new Qt(i));else if(i instanceof Xt)t.push(new Qt(i.data,i.getAttributes()));else if(i instanceof Jt)t.push(i);else if((0,h.isIterable)(i))for(const t of i)e(t)}(e);for(let e=1;ee.maxOffset)throw new h.CKEditorError("move-operation-nodes-do-not-exist",this);if(e===t&&i=i&&this.targetPosition.path[e]e._clone(!0)))),t=new Fn(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new ni(e,[0]);return new Ln(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffsete._clone(!0)))),Vn(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){const i=[];for(const t of e.nodes)t.name?i.push(ei.fromJSON(t)):i.push(Qt.fromJSON(t));const n=new Fn(ni.fromJSON(e.position,t),i,e.baseVersion);return n.shouldReceiveAttributes=e.shouldReceiveAttributes,n}}class zn extends In{constructor(e,t,i,n,o){super(o),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=i,this.graveyardPosition=n?n.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new ni(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new ci(this.splitPosition,e)}get affectedSelectable(){const e=[ci._createFromPositionAndShift(this.splitPosition,0),ci._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(ci._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new zn(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new ni(e,[0]);return new Hn(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 n=e.range.getDifference(t.range).map((t=>new jn(t,e.key,e.oldValue,e.newValue,0))),o=e.range.getIntersection(t.range);return o&&i.aIsStrong&&n.push(new jn(o,t.key,t.newValue,e.newValue,0)),0==n.length?[new $n(0)]:n}return[e]})),Qn(jn,Fn,((e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){const i=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map((t=>new jn(t,e.key,e.oldValue,e.newValue,e.baseVersion)));if(t.shouldReceiveAttributes){const n=so(t,e.key,e.oldValue);n&&i.unshift(n)}return i}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]})),Qn(jn,Hn,((e,t)=>{const i=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&i.push(ci._createFromPositionAndShift(t.graveyardPosition,1));const n=e.range._getTransformedByMergeOperation(t);return n.isCollapsed||i.push(n),i.map((t=>new jn(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),Qn(jn,Ln,((e,t)=>function(e,t){const i=ci._createFromPositionAndShift(t.sourcePosition,t.howMany);let n=null,o=[];i.containsRange(e,!0)?n=e:e.start.hasSameParentAs(i.start)?(o=e.getDifference(i),n=e.getIntersection(i)):o=[e];const s=[];for(let e of o){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const i=t.getMovedRangeStart(),n=e.start.hasSameParentAs(i),o=e._getTransformedByInsertion(i,t.howMany,n);s.push(...o)}return n&&s.push(n._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]),s}(e.range,t).map((t=>new jn(t,e.key,e.oldValue,e.newValue,e.baseVersion))))),Qn(jn,zn,((e,t)=>{if(e.range.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.range.end.offset++,[e];if(e.range.start.hasSameParentAs(t.splitPosition)&&e.range.containsPosition(t.splitPosition)){const i=e.clone();return i.range=new ci(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness="toPrevious",[e,i]}return e.range=e.range._getTransformedBySplitOperation(t),[e]})),Qn(Fn,jn,((e,t)=>{const i=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const n=so(e,t.key,t.newValue);n&&i.push(n)}return i})),Qn(Fn,Fn,((e,t,i)=>(e.position.isEqual(t.position)&&i.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e]))),Qn(Fn,Ln,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Qn(Fn,zn,((e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e]))),Qn(Fn,Hn,((e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e]))),Qn(Wn,Fn,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e]))),Qn(Wn,Wn,((e,t,i)=>{if(e.name==t.name){if(!i.aIsStrong)return[new $n(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]})),Qn(Wn,Hn,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e]))),Qn(Wn,Ln,((e,t,i)=>{if(e.oldRange&&(e.oldRange=ci._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){if(i.abRelation){const n=ci._createFromRanges(e.newRange._getTransformedByMoveOperation(t));if("left"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.start))return e.newRange.end=n.end,e.newRange.start.path=i.abRelation.path,[e];if("right"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.end))return e.newRange.start=n.start,e.newRange.end.path=i.abRelation.path,[e]}e.newRange=ci._createFromRanges(e.newRange._getTransformedByMoveOperation(t))}return[e]})),Qn(Wn,zn,((e,t,i)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(i.abRelation){const n=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)&&i.abRelation.wasStartBeforeMergedElement?e.newRange.start=ni._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!i.abRelation.wasInLeftElement&&(e.newRange.start=ni._createAt(t.moveTargetPosition)),e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasInRightElement?e.newRange.end=ni._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?e.newRange.end=ni._createAt(t.insertionPosition):e.newRange.end=n.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]})),Qn(Hn,Fn,((e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e]))),Qn(Hn,Hn,((e,t,i)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition)){if(i.bWasUndone){const i=t.graveyardPosition.path.slice();return i.push(0),e.sourcePosition=new ni(t.graveyardPosition.root,i),e.howMany=0,[e]}return[new $n(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!i.bWasUndone&&"splitAtSource"!=i.abRelation){const n="$graveyard"==e.targetPosition.root.rootName,o="$graveyard"==t.targetPosition.root.rootName;if(o&&!n||(!n||o)&&i.aIsStrong){const i=t.targetPosition._getTransformedByMergeOperation(t),n=e.targetPosition._getTransformedByMergeOperation(t);return[new Ln(i,e.howMany,n,0)]}return[new $n(0)]}return e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMergeOperation(t),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),e.graveyardPosition.isEqual(t.graveyardPosition)&&i.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),Qn(Hn,Ln,((e,t,i)=>{const n=ci._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!i.bWasUndone&&!i.forceWeakRemove&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.sourcePosition)?[new $n(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])})),Qn(Hn,zn,((e,t,i)=>{if(t.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByDeletion(t.graveyardPosition,1),e.deletionPosition.isEqual(t.graveyardPosition)&&(e.howMany=t.howMany)),e.targetPosition.isEqual(t.splitPosition)){const n=0!=t.howMany,o=t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition);if(n||o||"mergeTargetNotMoved"==i.abRelation)return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e]}if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==i.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==i.abRelation||e.sourcePosition.offset>0)return e.sourcePosition=t.moveTargetPosition.clone(),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}return e.sourcePosition.hasSameParentAs(t.splitPosition)&&(e.howMany=t.splitPosition.offset),e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]})),Qn(Ln,Fn,((e,t)=>{const i=ci._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=i.start,e.howMany=i.end.offset-i.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]})),Qn(Ln,Ln,((e,t,i)=>{const n=ci._createFromPositionAndShift(e.sourcePosition,e.howMany),o=ci._createFromPositionAndShift(t.sourcePosition,t.howMany);let s,r=i.aIsStrong,a=!i.aIsStrong;if("insertBefore"==i.abRelation||"insertAfter"==i.baRelation?a=!0:"insertAfter"!=i.abRelation&&"insertBefore"!=i.baRelation||(a=!1),s=e.targetPosition.isEqual(t.targetPosition)&&a?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),ro(e,t)&&ro(t,e))return[t.getReversed()];if(n.containsPosition(t.targetPosition)&&n.containsRange(o,!0))return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),ao([n],s);if(o.containsPosition(e.targetPosition)&&o.containsRange(n,!0))return n.start=n.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),n.end=n.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),ao([n],s);const l=(0,h.compareArrays)(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==l||"extension"==l)return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),ao([n],s);"remove"!=e.type||"remove"==t.type||i.aWasUndone||i.forceWeakRemove?"remove"==e.type||"remove"!=t.type||i.bWasUndone||i.forceWeakRemove||(r=!1):r=!0;const c=[],d=n.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 i="same"==(0,h.compareArrays)(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),n=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,i);c.push(...n)}const u=n.getIntersection(o);return null!==u&&r&&(u.start=u.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),u.end=u.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===c.length?c.push(u):1==c.length?o.start.isBefore(n.start)||o.start.isEqual(n.start)?c.unshift(u):c.push(u):c.splice(1,0,u)),0===c.length?[new $n(e.baseVersion)]:ao(c,s)})),Qn(Ln,zn,((e,t,i)=>{let n=e.targetPosition.clone();e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=i.abRelation||(n=e.targetPosition._getTransformedBySplitOperation(t));const o=ci._createFromPositionAndShift(e.sourcePosition,e.howMany);if(o.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.howMany++,e.targetPosition=n,[e];if(o.start.hasSameParentAs(t.splitPosition)&&o.containsPosition(t.splitPosition)){let e=new ci(t.splitPosition,o.end);return e=e._getTransformedBySplitOperation(t),ao([new ci(o.start,t.splitPosition),e],n)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==i.abRelation&&(n=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==i.abRelation&&(n=e.targetPosition);const s=[o._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const n=o.start.isEqual(t.graveyardPosition)||o.containsPosition(t.graveyardPosition);e.howMany>1&&n&&!i.aWasUndone&&s.push(ci._createFromPositionAndShift(t.insertionPosition,1))}return ao(s,n)})),Qn(Ln,Hn,((e,t,i)=>{const n=ci._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(t.sourcePosition))if("remove"!=e.type||i.forceWeakRemove){if(1==e.howMany)return i.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new $n(0)]}else if(!i.aWasUndone){const i=[];let n=t.graveyardPosition.clone(),o=t.targetPosition._getTransformedByMergeOperation(t);e.howMany>1&&(i.push(new Ln(e.sourcePosition,e.howMany-1,e.targetPosition,0)),n=n._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1),o=o._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1));const s=t.deletionPosition._getCombined(e.sourcePosition,e.targetPosition),r=new Ln(n,1,s,0),a=r.getMovedRangeStart().path.slice();a.push(0);const l=new ni(r.targetPosition.root,a);o=o._getTransformedByMove(n,s,1);const c=new Ln(o,t.howMany,l,0);return i.push(r),i.push(c),i}const o=ci._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]})),Qn(qn,Fn,((e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e]))),Qn(qn,Hn,((e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e]))),Qn(qn,Ln,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Qn(qn,qn,((e,t,i)=>{if(e.position.isEqual(t.position)){if(!i.aIsStrong)return[new $n(0)];e.oldName=t.newName}return[e]})),Qn(qn,zn,((e,t)=>{const i=e.position.path,n=t.splitPosition.getParentPath();if("same"==(0,h.compareArrays)(i,n)&&!t.graveyardPosition){const t=new qn(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]})),Qn(Kn,Kn,((e,t,i)=>{if(e.root===t.root&&e.key===t.key){if(!i.aIsStrong||e.newValue===t.newValue)return[new $n(0)];e.oldValue=t.newValue}return[e]})),Qn(Zn,Zn,((e,t)=>e.rootName===t.rootName&&e.isAdd===t.isAdd?[new $n(0)]:[e])),Qn(zn,Fn,((e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset{if(!e.graveyardPosition&&!i.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const i=t.graveyardPosition.path.slice();i.push(0);const n=new ni(t.graveyardPosition.root,i),o=zn.getInsertionPosition(new ni(t.graveyardPosition.root,i)),s=new zn(n,0,o,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=zn.getInsertionPosition(e.splitPosition),e.graveyardPosition=s.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[s,e]}return e.splitPosition.hasSameParentAs(t.deletionPosition)&&!e.splitPosition.isAfter(t.deletionPosition)&&e.howMany--,e.splitPosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=zn.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),Qn(zn,Ln,((e,t,i)=>{const n=ci._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const o=n.start.isEqual(e.graveyardPosition)||n.containsPosition(e.graveyardPosition);if(!i.bWasUndone&&o){const i=e.splitPosition._getTransformedByMoveOperation(t),n=e.graveyardPosition._getTransformedByMoveOperation(t),o=n.path.slice();o.push(0);const s=new ni(n.root,o);return[new Ln(i,e.howMany,s,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const o=e.splitPosition.isEqual(t.targetPosition);if(o&&("insertAtSource"==i.baRelation||"splitBefore"==i.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=zn.getInsertionPosition(e.splitPosition),[e];if(o&&i.abRelation&&i.abRelation.howMany){const{howMany:t,offset:n}=i.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(n),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.splitPosition)){const i=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=i,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new $n(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new $n(0)];if("splitBefore"==i.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){const n="$graveyard"==e.splitPosition.root.rootName,o="$graveyard"==t.splitPosition.root.rootName;if(o&&!n||(!n||o)&&i.aIsStrong){const i=[];return t.howMany&&i.push(new Ln(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&i.push(new Ln(e.splitPosition,e.howMany,e.moveTargetPosition,0)),i}return[new $n(0)]}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==i.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==i.baRelation){const i=t.insertionPosition.path.slice();i.push(0);const n=new ni(t.insertionPosition.root,i);return[e,new Ln(e.insertionPosition,1,n,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset{const i=t[0];i.isDocumentOperation&&uo.call(this,i)}),{priority:"low"})}function uo(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)}}lo.prototype.is=function(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e};class ho{constructor(e={}){"string"==typeof e&&(e="transparent"===e?{isUndoable:!1}:{},(0,h.logWarning)("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:i=!0,isUndo:n=!1,isTyping:o=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=i,this.isUndo=n,this.isTyping=o}get type(){return(0,h.logWarning)("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 mo{constructor(e){this._changesInElement=new Map,this._elementSnapshots=new Map,this._changedMarkers=new Map,this._changedRoots=new Map,this._changeCount=0,this._cachedChanges=null,this._cachedChangesWithGraveyard=null,this._refreshedItems=new Set,this._markerCollection=e}get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.size&&0==this._changedRoots.size}bufferOperation(e){const t=e;switch(t.type){case"insert":if(this._isInInsertedElement(t.position.parent))return;this._markInsert(t.position.parent,t.position.offset,t.nodes.maxOffset);break;case"addAttribute":case"removeAttribute":case"changeAttribute":for(const e of t.range.getItems({shallow:!0}))this._isInInsertedElement(e.parent)||this._markAttribute(e);break;case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const e=this._isInInsertedElement(t.sourcePosition.parent),i=this._isInInsertedElement(t.targetPosition.parent);e||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),i||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const e=ci._createFromPositionAndShift(t.position,1);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getData();this.bufferMarkerChange(t.name,e,e)}break}case"split":{const e=t.splitPosition.parent;this._isInInsertedElement(e)||this._markRemove(e,t.splitPosition.offset,t.howMany),this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1);break}case"merge":{const e=t.sourcePosition.parent;this._isInInsertedElement(e.parent)||this._markRemove(e.parent,e.startOffset,1);const i=t.graveyardPosition.parent;this._markInsert(i,t.graveyardPosition.offset,1);const n=t.targetPosition.parent;this._isInInsertedElement(n)||this._markInsert(n,t.targetPosition.offset,e.maxOffset);break}case"detachRoot":case"addRoot":{const e=t.affectedSelectable;if(!e._isLoaded)return;if(e.isAttached()==t.isAdd)return;this._bufferRootStateChange(t.rootName,t.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!t.root._isLoaded)return;const e=t.root.rootName;this._bufferRootAttributeChange(e,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,i){t.range&&t.range.root.is("rootElement")&&!t.range.root._isLoaded&&(t.range=null),i.range&&i.range.root.is("rootElement")&&!i.range.root._isLoaded&&(i.range=null);let n=this._changedMarkers.get(e);n?n.newMarkerData=i:(n={newMarkerData:i,oldMarkerData:t},this._changedMarkers.set(e,n)),null==n.oldMarkerData.range&&null==i.range&&this._changedMarkers.delete(e)}getMarkersToRemove(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.oldMarkerData.range&&e.push({name:t,range:i.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.newMarkerData.range&&e.push({name:t,range:i.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map((([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}})))}hasDataChanges(){if(this._changesInElement.size>0)return!0;if(this._changedRoots.size>0)return!0;for(const{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){const i=e.range&&!t.range,n=!e.range&&t.range,o=e.range&&t.range&&!e.range.isEqual(t.range);if(i||n||o)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const e of this._changesInElement.keys()){const i=this._changesInElement.get(e).sort(((e,t)=>e.offset===t.offset?e.type!=t.type?"remove"==e.type?-1:1:0:e.offsete.position.root!=t.position.root?e.position.root.rootNamee));for(const e of t)delete e.changeCount,"attribute"==e.type&&(delete e.position,delete e.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(po),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getChangedRoots(){return Array.from(this._changedRoots.values()).map((e=>{const t={...e};return void 0!==t.state&&delete t.attributes,t}))}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementSnapshots.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems=new Set,this._cachedChanges=null}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e))return void this._changedRoots.set(e,{name:e,state:t?"attached":"detached"});const i=this._changedRoots.get(e);void 0!==i.state?(delete i.state,void 0===i.attributes&&this._changedRoots.delete(e)):i.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,i,n){const o=this._changedRoots.get(e)||{name:e},s=o.attributes||{};if(s[t]){const e=s[t];n===e.oldValue?delete s[t]:e.newValue=n}else s[t]={oldValue:i,newValue:n};0===Object.entries(s).length?(delete o.attributes,void 0===o.state&&this._changedRoots.delete(e)):(o.attributes=s,this._changedRoots.set(e,o))}_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=ci._createOn(e);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getData();this.bufferMarkerChange(e.name,t,t)}this._cachedChanges=null}_bufferRootLoad(e){if(e.isAttached()){this._bufferRootStateChange(e.rootName,!0),this._markInsert(e,0,e.maxOffset);for(const t of e.getAttributeKeys())this._bufferRootAttributeChange(e.rootName,t,null,e.getAttribute(t));for(const t of this._markerCollection)if(t.getRange().root==e){const e=t.getData();this.bufferMarkerChange(t.name,{...e,range:null},e)}}}_markInsert(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n)}_markRemove(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n),this._removeAllNestedChanges(e,t,i)}_markAttribute(e){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshot(e);const i=this._getChangesForElement(e);this._handleChange(t,i),i.push(t);for(let e=0;ei.offset){if(n>o){const e={type:"attribute",offset:o,howMany:n-o,count:this._changeCount++};this._handleChange(e,t),t.push(e)}e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=i.offset&&e.offseto?(e.nodesToHandle=n-o,e.offset=o):e.nodesToHandle=0);if("remove"==i.type&&e.offseti.offset){const o={type:"attribute",offset:i.offset,howMany:n-i.offset,count:this._changeCount++};this._handleChange(o,t),t.push(o),e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==i.type&&(e.offset>=i.offset&&n<=o?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=i.offset&&n>=o&&(i.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,i){return{type:"insert",position:ni._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++}}_getRemoveDiff(e,t,i){return{type:"remove",position:ni._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,i){const n=[];i=new Map(i);for(const[o,s]of t){const t=i.has(o)?i.get(o):null;t!==s&&n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:o,attributeOldValue:s,attributeNewValue:t,changeCount:this._changeCount++}),i.delete(o)}for(const[t,o]of i)n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:o,changeCount:this._changeCount++});return n}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const i=this._changesInElement.get(t),n=e.startOffset;if(i)for(const e of i)if("insert"==e.type&&n>=e.offset&&nn){for(let t=0;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 h.CKEditorError("model-document-history-addoperation-incorrect-version",this,{operation:e,historyVersion:this.version});this._operations.push(e),this._version++,this._baseVersionToOperationIndex.set(e.baseVersion,this._operations.length-1)}getOperations(e,t=this.version){if(!this._operations.length)return[];const i=this._operations[0];void 0===e&&(e=i.baseVersion);let n=t-1;for(const[t,i]of this._gaps)e>t&&et&&nthis.lastOperation.baseVersion)return[];let o=this._baseVersionToOperationIndex.get(e);void 0===o&&(o=0);let s=this._baseVersionToOperationIndex.get(n);return void 0===s&&(s=this._operations.length-1),this._operations.slice(o,s+1)}getOperation(e){const t=this._baseVersionToOperationIndex.get(e);if(void 0!==t)return this._operations[t]}setOperationAsUndone(e,t){this._undoPairs.set(t,e),this._undoneOperations.add(e)}isUndoingOperation(e){return this._undoPairs.has(e)}isUndoneOperation(e){return this._undoneOperations.has(e)}getUndoneOperation(e){return this._undoPairs.get(e)}reset(){this._version=0,this._undoPairs=new Map,this._operations=[],this._undoneOperations=new Set,this._gaps=new Map,this._baseVersionToOperationIndex=new Map}}class wo extends ei{constructor(e,t,i="main"){super(t),this._isAttached=!0,this._isLoaded=!0,this._document=e,this.rootName=i}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}wo.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 vo="$graveyard";class _o extends((0,h.EmitterMixin)()){constructor(e){super(),this.model=e,this.history=new bo,this.selection=new Ti(this),this.roots=new h.Collection({idProperty:"rootName"}),this.differ=new mo(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",vo),this.listenTo(e,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&this.differ.bufferOperation(i)}),{priority:"high"}),this.listenTo(e,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&this.history.addOperation(i)}),{priority:"low"}),this.listenTo(this.selection,"change",(()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0})),this.listenTo(e.markers,"update",((e,t,i,n,o)=>{const s={...t.getData(),range:n};this.differ.bufferMarkerChange(t.name,o,s),null===i&&t.on("change",((e,i)=>{const n=t.getData();this.differ.bufferMarkerChange(t.name,{...n,range:i},n)}))})),this.registerPostFixer((e=>{let t=!1;for(const i of this.roots)i.isAttached()||i.isEmpty||(e.remove(e.createRangeIn(i)),t=!0);for(const i of this.model.markers)i.getRange().root.isAttached()||(e.removeMarker(i),t=!0);return t}))}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(vo)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new h.CKEditorError("model-document-createroot-name-exists",this,{name:t});const i=new wo(this,e,t);return this.roots.add(i),i}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map((e=>e.rootName))}getRoots(e=!1){return Array.from(this.roots).filter((t=>t!=this.graveyard&&(e||t.isAttached())&&t._isLoaded))}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=f(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){const e=this.getRoots();return e.length?e[0]:this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,i=t.schema,n=t.createPositionFromPath(e,[0]);return i.getNearestSelectionRange(n)||t.createRange(n)}_validateSelectionRange(e){return yo(e.start)&&yo(e.end)}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(this.selection.refresh(),t=i(e),t)break}while(t)}}function yo(e){const t=e.textNode;if(t){const i=t.data,n=e.offset-t.startOffset;return!(0,h.isInsideSurrogatePair)(i,n)&&!(0,h.isInsideCombinedSymbol)(i,n)}return!0}class ko extends((0,h.EmitterMixin)()){constructor(){super(...arguments),this._markers=new Map}[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof Co?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,i=!1,n=!1){const o=e instanceof Co?e.name:e;if(o.includes(","))throw new h.CKEditorError("markercollection-incorrect-marker-name",this);const s=this._markers.get(o);if(s){const e=s.getData(),r=s.getRange();let a=!1;return r.isEqual(t)||(s._attachLiveRange(Ci.fromRange(t)),a=!0),i!=s.managedUsingOperations&&(s._managedUsingOperations=i,a=!0),"boolean"==typeof n&&n!=s.affectsData&&(s._affectsData=n,a=!0),a&&this.fire(`update:${o}`,s,r,t,e),s}const r=Ci.fromRange(t),a=new Co(o,r,i,n);return this._markers.set(o,a),this.fire(`update:${o}`,a,null,t,{...a.getData(),range:null}),a}_remove(e){const t=e instanceof Co?e.name:e,i=this._markers.get(t);return!!i&&(this._markers.delete(t),this.fire(`update:${t}`,i,i.getRange(),null,i.getData()),this._destroyMarker(i),!0)}_refresh(e){const t=e instanceof Co?e.name:e,i=this._markers.get(t);if(!i)throw new h.CKEditorError("markercollection-refresh-marker-not-exists",this);const n=i.getRange();this.fire(`update:${t}`,i,n,n,i.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)null!==t.getRange().getIntersection(e)&&(yield t)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}class Co extends((0,h.EmitterMixin)(Gt)){constructor(e,t,i,n){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=i,this._affectsData=n}get managedUsingOperations(){if(!this._liveRange)throw new h.CKEditorError("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new h.CKEditorError("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new h.CKEditorError("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new h.CKEditorError("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new h.CKEditorError("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}}Co.prototype.is=function(e){return"marker"===e||"model:marker"===e};class Ao extends In{constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}get type(){return"detach"}get affectedSelectable(){return null}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new h.CKEditorError("detach-operation-on-document-node",this)}_execute(){Rn(ci._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class Eo extends Gt{constructor(e){super(),this.markers=new Map,this._children=new Yt,e&&this._insertChild(0,e)}[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}get nextSibling(){return null}get previousSibling(){return null}get root(){return this}get parent(){return null}get document(){return null}isAttached(){return!1}getAncestors(){return[]}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(const i of e)t=t.getChild(t.offsetToIndex(i));return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const i of e)i.name?t.push(ei.fromJSON(i)):t.push(Qt.fromJSON(i));return new Eo(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){return"string"==typeof e?[new Qt(e)]:((0,h.isIterable)(e)||(e=[e]),Array.from(e).map((e=>"string"==typeof e?new Qt(e):e instanceof Xt?new Qt(e.data,e.getAttributes()):e)))}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}}Eo.prototype.is=function(e){return"documentFragment"===e||"model:documentFragment"===e};class xo{constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new Qt(e,t)}createElement(e,t){return new ei(e,t)}createDocumentFragment(){return new Eo}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,i=0){if(this._assertWriterUsedCorrectly(),e instanceof Qt&&""==e.data)return;const n=ni._createAt(t,i);if(e.parent){if(Vo(e.root,n.root))return void this.move(ci._createOn(e),n);if(e.root.document)throw new h.CKEditorError("model-writer-insert-forbidden-move",this);this.remove(e)}const o=n.root.document?n.root.document.version:null,s=new Fn(n,e,o);if(e instanceof Qt&&(s.shouldReceiveAttributes=!0),this.batch.addOperation(s),this.model.applyOperation(s),e instanceof Eo)for(const[t,i]of e.markers){const e=ni._createAt(i.root,0),o={range:new ci(i.start._getCombined(e,n),i.end._getCombined(e,n)),usingOperation:!0,affectsData:!0};this.model.markers.has(t)?this.updateMarker(t,o):this.addMarker(t,o)}}insertText(e,t,i,n){t instanceof Eo||t instanceof ei||t instanceof ni?this.insert(this.createText(e),t,i):this.insert(this.createText(e,t),i,n)}insertElement(e,t,i,n){t instanceof Eo||t instanceof ei||t instanceof ni?this.insert(this.createElement(e),t,i):this.insert(this.createElement(e,t),i,n)}append(e,t){this.insert(e,t,"end")}appendText(e,t,i){t instanceof Eo||t instanceof ei?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),i,"end")}appendElement(e,t,i){t instanceof Eo||t instanceof ei?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),i,"end")}setAttribute(e,t,i){if(this._assertWriterUsedCorrectly(),i instanceof ci){const n=i.getMinimalFlatRanges();for(const i of n)To(this,e,t,i)}else So(this,e,t,i)}setAttributes(e,t){for(const[i,n]of(0,h.toMap)(e))this.setAttribute(i,n,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof ci){const i=t.getMinimalFlatRanges();for(const t of i)To(this,e,null,t)}else So(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=e=>{for(const t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof ci)for(const i of e.getItems())t(i);else t(e)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof ci))throw new h.CKEditorError("writer-move-invalid-range",this);if(!e.isFlat)throw new h.CKEditorError("writer-move-range-not-flat",this);const n=ni._createAt(t,i);if(n.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!Vo(e.root,n.root))throw new h.CKEditorError("writer-move-different-document",this);const o=e.root.document?e.root.document.version:null,s=new Ln(e.start,e.end.offset-e.start.offset,n,o);this.batch.addOperation(s),this.model.applyOperation(s)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof ci?e:ci._createOn(e)).getMinimalFlatRanges().reverse();for(const e of t)this._addOperationForAffectedMarkers("move",e),Io(e.start,e.end.offset-e.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,i=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof ei))throw new h.CKEditorError("writer-merge-no-element-before",this);if(!(i instanceof ei))throw new h.CKEditorError("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,i){return this.model.createPositionFromPath(e,t,i)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(...e){return this.model.createSelection(...e)}_mergeDetached(e){const t=e.nodeBefore,i=e.nodeAfter;this.move(ci._createIn(i),ni._createAt(t,"end")),this.remove(i)}_merge(e){const t=ni._createAt(e.nodeBefore,"end"),i=ni._createAt(e.nodeAfter,0),n=e.root.document.graveyard,o=new ni(n,[0]),s=e.root.document.version,r=new Hn(i,e.nodeAfter.maxOffset,t,o,s);this.batch.addOperation(r),this.model.applyOperation(r)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof ei))throw new h.CKEditorError("writer-rename-not-element-instance",this);const i=e.root.document?e.root.document.version:null,n=new qn(ni._createBefore(e),e.name,t,i);this.batch.addOperation(n),this.model.applyOperation(n)}split(e,t){this._assertWriterUsedCorrectly();let i,n,o=e.parent;if(!o.parent)throw new h.CKEditorError("writer-split-element-no-parent",this);if(t||(t=o.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new h.CKEditorError("writer-split-invalid-limit-element",this);do{const t=o.root.document?o.root.document.version:null,s=o.maxOffset-e.offset,r=zn.getInsertionPosition(e),a=new zn(e,s,r,null,t);this.batch.addOperation(a),this.model.applyOperation(a),i||n||(i=o,n=e.parent.nextSibling),o=(e=this.createPositionAfter(e.parent)).parent}while(o!==t);return{position:e,range:new ci(ni._createAt(i,"end"),ni._createAt(n,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new h.CKEditorError("writer-wrap-range-not-flat",this);const i=t instanceof ei?t:new ei(t);if(i.childCount>0)throw new h.CKEditorError("writer-wrap-element-not-empty",this);if(null!==i.parent)throw new h.CKEditorError("writer-wrap-element-attached",this);this.insert(i,e.start);const n=new ci(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(n,ni._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new h.CKEditorError("writer-unwrap-element-no-parent",this);this.move(ci._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new h.CKEditorError("writer-addmarker-no-usingoperation",this);const i=t.usingOperation,n=t.range,o=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new h.CKEditorError("writer-addmarker-marker-exists",this);if(!n)throw new h.CKEditorError("writer-addmarker-no-range",this);return i?(Po(this,e,null,n,o),this.model.markers.get(e)):this.model.markers._set(e,n,i,o)}updateMarker(e,t){this._assertWriterUsedCorrectly();const i="string"==typeof e?e:e.name,n=this.model.markers.get(i);if(!n)throw new h.CKEditorError("writer-updatemarker-marker-not-exists",this);if(!t)return(0,h.logWarning)("writer-updatemarker-reconvert-using-editingcontroller",{markerName:i}),void this.model.markers._refresh(n);const o="boolean"==typeof t.usingOperation,s="boolean"==typeof t.affectsData,r=s?t.affectsData:n.affectsData;if(!o&&!t.range&&!s)throw new h.CKEditorError("writer-updatemarker-wrong-options",this);const a=n.getRange(),l=t.range?t.range:a;o&&t.usingOperation!==n.managedUsingOperations?t.usingOperation?Po(this,i,null,l,r):(Po(this,i,a,null,r),this.model.markers._set(i,l,void 0,r)):n.managedUsingOperations?Po(this,i,a,l,r):this.model.markers._set(i,l,void 0,r)}removeMarker(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new h.CKEditorError("writer-removemarker-no-marker",this);const i=this.model.markers.get(t);i.managedUsingOperations?Po(this,t,i.getRange(),null,i.affectsData):this.model.markers._remove(t)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const i=this.model.document.getRoot(e);if(i&&i.isAttached())throw new h.CKEditorError("writer-addroot-root-exists",this);const n=this.model.document,o=new Zn(e,t,!0,n,n.version);return this.batch.addOperation(o),this.model.applyOperation(o),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new h.CKEditorError("writer-detachroot-no-root",this);for(const e of this.model.markers)e.getRange().root===t&&this.removeMarker(e);for(const e of t.getAttributeKeys())this.removeAttribute(e,t);this.remove(this.createRangeIn(t));const i=this.model.document,n=new Zn(t.rootName,t.name,!1,i,i.version);this.batch.addOperation(n),this.model.applyOperation(n)}setSelection(...e){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...e)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._setSelectionAttribute(e,t);else for(const[t,i]of(0,h.toMap)(e))this._setSelectionAttribute(t,i)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._removeSelectionAttribute(e);else for(const t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){const i=this.model.document.selection;if(i.isCollapsed&&i.anchor.parent.isEmpty){const n=Ti._getStoreAttributeKey(e);this.setAttribute(n,t,i.anchor.parent)}i._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const i=Ti._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new h.CKEditorError("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const i of this.model.markers){if(!i.managedUsingOperations)continue;const n=i.getRange();let o=!1;if("move"===e){const e=t;o=e.containsPosition(n.start)||e.start.isEqual(n.start)||e.containsPosition(n.end)||e.end.isEqual(n.end)}else{const e=t,i=e.nodeBefore,s=e.nodeAfter,r=n.start.parent==i&&n.start.isAtEnd,a=n.end.parent==s&&0==n.end.offset,l=n.end.nodeAfter==s,c=n.start.nodeAfter==s;o=r||a||l||c}o&&this.updateMarker(i.name,{range:n})}}}function To(e,t,i,n){const o=e.model,s=o.document;let r,a,l,c=n.start;for(const e of n.getWalker({shallow:!0}))l=e.item.getAttribute(t),r&&a!=l&&(a!=i&&d(),c=r),r=e.nextPosition,a=l;function d(){const n=new ci(c,r),l=n.root.document?s.version:null,d=new jn(n,t,a,i,l);e.batch.addOperation(d),o.applyOperation(d)}r instanceof ni&&r!=c&&a!=i&&d()}function So(e,t,i,n){const o=e.model,s=o.document,r=n.getAttribute(t);let a,l;if(r!=i){if(n.root===n){const e=n.document?s.version:null;l=new Kn(n,t,r,i,e)}else{a=new ci(ni._createBefore(n),e.createPositionAfter(n));const o=a.root.document?s.version:null;l=new jn(a,t,r,i,o)}e.batch.addOperation(l),o.applyOperation(l)}}function Po(e,t,i,n,o){const s=e.model,r=s.document,a=new Wn(t,i,n,s.markers,!!o,r.version);e.batch.addOperation(a),s.applyOperation(a)}function Io(e,t,i,n){let o;if(e.root.document){const i=n.document,s=new ni(i.graveyard,[0]);o=new Ln(e,t,s,i.version)}else o=new Ao(e,t);i.addOperation(o),n.applyOperation(o)}function Vo(e,t){return e===t||e instanceof wo&&t instanceof wo}function Ro(e,t,i={}){if(t.isCollapsed)return;const n=t.getFirstRange();if("$graveyard"==n.root.rootName)return;const o=e.schema;e.change((e=>{if(!i.doNotResetEntireContent&&function(e,t){const i=e.getLimitElement(t);if(!t.containsEntireContent(i))return!1;const n=t.getFirstRange();return n.start.parent!=n.end.parent&&e.checkChild(i,"paragraph")}(o,t))return void function(e,t){const i=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(i)),No(e,e.createPositionAt(i,0),t)}(e,t);const s={};if(!i.doNotAutoparagraph){const e=t.getSelectedElement();e&&Object.assign(s,o.getAttributesWithProperty(e,"copyOnReplace",!0))}const[r,a]=function(e){const t=e.root.document.model,i=e.start;let n=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){const i=function(e){const t=e.parent,i=t.root.document.model.schema,n=t.getAncestors({parentFirst:!0,includeSelf:!0});for(const e of n){if(i.isLimit(e))return null;if(i.isBlock(e))return e}}(n);if(i&&n.isTouching(t.createPositionAt(i,0))){const i=t.createSelection(e);t.modifySelection(i,{direction:"backward"});const o=i.getLastPosition(),s=t.createRange(o,n);t.hasContent(s,{ignoreMarkers:!0})||(n=o)}}return[lo.fromPosition(i,"toPrevious"),lo.fromPosition(n,"toNext")]}(n);r.isTouching(a)||e.remove(e.createRange(r,a)),i.leaveUnmerged||(function(e,t,i){const n=e.model;if(!Mo(e.model.schema,t,i))return;const[o,s]=function(e,t){const i=e.getAncestors(),n=t.getAncestors();let o=0;for(;i[o]&&i[o]==n[o];)o++;return[i[o],n[o]]}(t,i);o&&s&&(!n.hasContent(o,{ignoreMarkers:!0})&&n.hasContent(s,{ignoreMarkers:!0})?Bo(e,t,i,o.parent):Oo(e,t,i,o.parent))}(e,r,a),o.removeDisallowedAttributes(r.parent.getChildren(),e)),Do(e,t,r),!i.doNotAutoparagraph&&function(e,t){const i=e.checkChild(t,"$text"),n=e.checkChild(t,"paragraph");return!i&&n}(o,r)&&No(e,r,t,s),r.detach(),a.detach()}))}function Oo(e,t,i,n){const o=t.parent,s=i.parent;if(o!=n&&s!=n){for(t=e.createPositionAfter(o),(i=e.createPositionBefore(s)).isEqual(t)||e.insert(s,t),e.merge(t);i.parent.isEmpty;){const t=i.parent;i=e.createPositionBefore(t),e.remove(t)}Mo(e.model.schema,t,i)&&Oo(e,t,i,n)}}function Bo(e,t,i,n){const o=t.parent,s=i.parent;if(o!=n&&s!=n){for(t=e.createPositionAfter(o),(i=e.createPositionBefore(s)).isEqual(t)||e.insert(o,i);t.parent.isEmpty;){const i=t.parent;t=e.createPositionBefore(i),e.remove(i)}i=e.createPositionBefore(s),function(e,t){const i=t.nodeBefore,n=t.nodeAfter;i.name!=n.name&&e.rename(i,n.name),e.clearAttributes(i),e.setAttributes(Object.fromEntries(n.getAttributes()),i),e.merge(t)}(e,i),Mo(e.model.schema,t,i)&&Bo(e,t,i,n)}}function Mo(e,t,i){const n=t.parent,o=i.parent;return n!=o&&!e.isLimit(n)&&!e.isLimit(o)&&function(e,t,i){const n=new ci(e,t);for(const e of n.getWalker())if(i.isLimit(e.item))return!1;return!0}(t,i,e)}function No(e,t,i,n={}){const o=e.createElement("paragraph");e.model.schema.setAllowedAttributes(o,n,e),e.insert(o,t),Do(e,i,e.createPositionAt(o,0))}function Do(e,t,i){t instanceof Ti?e.setSelection(i):t.setTo(i)}function Lo(e,t){const i=[];Array.from(e.getItems({direction:"backward"})).map((e=>t.createRangeOn(e))).filter((t=>(t.start.isAfter(e.start)||t.start.isEqual(e.start))&&(t.end.isBefore(e.end)||t.end.isEqual(e.end)))).forEach((e=>{i.push(e.start.parent),t.remove(e)})),i.forEach((e=>{let i=e;for(;i.parent&&i.isEmpty;){const e=t.createRangeOn(i);i=i.parent,t.remove(e)}}))}class Fo{constructor(e,t,i){this._firstNode=null,this._lastNode=null,this._lastAutoParagraph=null,this._filterAttributesOf=[],this._affectedStart=null,this._affectedEnd=null,this._nodeToSelect=null,this.model=e,this.writer=t,this.position=i,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0)}handleNodes(e){for(const t of Array.from(e))this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),i=this.writer.createPositionAfter(e);if(i.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new h.CKEditorError("insertcontent-invalid-insertion-position",this);this.position=i,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?ci._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new ci(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=lo.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 h.CKEditorError("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=lo.fromPosition(e,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(e)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=lo.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof ei))return;if(!this._canMergeLeft(e))return;const t=lo._createBefore(e);t.stickiness="toNext";const i=lo.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=lo._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=lo._createAt(t.nodeBefore,"end","toNext")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof ei))return;if(!this._canMergeRight(e))return;const t=lo._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new h.CKEditorError("insertcontent-invalid-insertion-position",this);this.position=ni._createAt(t.nodeBefore,"end");const i=lo.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=lo._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=lo._createAt(t.nodeBefore,0,"toPrevious")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof ei&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof ei&&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 zo(e,t,i="auto"){const n=e.getSelectedElement();if(n&&t.schema.isObject(n)&&!t.schema.isInline(n))return"before"==i||"after"==i?t.createRange(t.createPositionAt(n,i)):t.createRangeOn(n);const o=(0,h.first)(e.getSelectedBlocks());if(!o)return t.createRange(e.focus);if(o.isEmpty)return t.createRange(t.createPositionAt(o,0));const s=t.createPositionAfter(o);return e.focus.isTouching(s)?t.createRange(s):t.createRange(t.createPositionBefore(o))}const Ho=' ,.?!:;"-()';function Wo(e,t){const{isForward:i,walker:n,unit:o,schema:s,treatEmojiAsSingleUnit:r}=e,{type:a,item:l,nextPosition:c}=t;if("text"==a)return"word"===e.unit?function(e,t){let i=e.position.textNode;for(i||(i=t?e.position.nodeAfter:e.position.nodeBefore);i&&i.is("$text");){const n=e.position.offset-i.startOffset;if($o(i,n,t))i=t?e.position.nodeAfter:e.position.nodeBefore;else{if(jo(i.data,n,t))break;e.next()}}return e.position}(n,i):function(e,t,i){const n=e.position.textNode;if(n){const o=n.data;let s=e.position.offset-n.startOffset;for(;(0,h.isInsideSurrogatePair)(o,s)||"character"==t&&(0,h.isInsideCombinedSymbol)(o,s)||i&&(0,h.isInsideEmojiSequence)(o,s);)e.next(),s=e.position.offset-n.startOffset}return e.position}(n,o,r);if(a==(i?"elementStart":"elementEnd")){if(s.isSelectable(l))return ni._createAt(l,i?"after":"before");if(s.checkChild(c,"$text"))return c}else{if(s.isLimit(l))return void n.skip((()=>!0));if(s.checkChild(c,"$text"))return c}}function Uo(e,t){const i=e.root,n=ni._createAt(i,t?"end":0);return t?new ci(e,n):new ci(n,e)}function jo(e,t,i){const n=t+(i?0:-1);return Ho.includes(e.charAt(n))}function $o(e,t,i){return t===(i?e.offsetSize:0)}class qo extends((0,h.ObservableMixin)()){constructor(){var e;super(),this.markers=new ko,this.document=new _o(this),this.schema=new ln,this._pendingChanges=[],this._currentWriter=null,["deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach((e=>this.decorate(e))),this.on("applyOperation",((e,t)=>{t[0]._validate()}),{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck(((e,t)=>{if("$marker"===t.name)return!0})),(e=this).document.registerPostFixer((t=>function(e,t){const i=t.document.selection,n=t.schema,o=[];let s=!1;for(const e of i.getRanges()){const t=en(e,n);t&&!t.isEqual(e)?(o.push(t),s=!0):o.push(e)}return s&&e.setSelection(function(e){const t=[...e],i=new Set;let n=1;for(;n!i.has(t)))}(o),{backward:i.isBackward}),!1}(t,e))),this.document.registerPostFixer(ji),this.on("insertContent",((e,[t,i])=>{e.return=function(e,t,i){return e.change((n=>{const o=i||e.document.selection;o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0});const s=new Fo(e,n,o.anchor),r=[];let a;if(t.is("documentFragment")){if(t.markers.size){const e=[];for(const[i,n]of t.markers){const{start:t,end:o}=n,s=t.isEqual(o);e.push({position:t,name:i,isCollapsed:s},{position:o,name:i,isCollapsed:s})}e.sort((({position:e},{position:t})=>e.isBefore(t)?1:-1));for(const{position:i,name:o,isCollapsed:s}of e){let e=null,a=null;const l=i.parent===t&&i.isAtStart,c=i.parent===t&&i.isAtEnd;l||c?s&&(a=l?"start":"end"):(e=n.createElement("$marker"),n.insert(e,i)),r.push({name:o,element:e,collapsed:a})}}a=t.getChildren()}else a=[t];s.handleNodes(a);let l=s.getSelectionRange();if(t.is("documentFragment")&&r.length){const e=l?Ci.fromRange(l):null,t={};for(let e=r.length-1;e>=0;e--){const{name:i,element:o,collapsed:a}=r[e],l=!t[i];if(l&&(t[i]=[]),o){const e=n.createPositionAt(o,"before");t[i].push(e),n.remove(o)}else{const e=s.getAffectedRange();if(!e){a&&t[i].push(s.position);continue}a?t[i].push(e[a]):t[i].push(l?e.start:e.end)}}for(const[e,[i,o]]of Object.entries(t))i&&o&&i.root===o.root&&n.addMarker(e,{usingOperation:!0,affectsData:!0,range:new ci(i,o)});e&&(l=e.toRange(),e.detach())}l&&(o instanceof Ti?n.setSelection(l):o.setTo(l));const c=s.getAffectedRange()||e.createRange(o.anchor);return s.destroy(),c}))}(this,t,i)})),this.on("insertObject",((e,[t,i,n])=>{e.return=function(e,t,i,n={}){if(!e.schema.isObject(t))throw new h.CKEditorError("insertobject-element-not-an-object",e,{object:t});const o=i||e.document.selection;let s=o;n.findOptimalPosition&&e.schema.isBlock(t)&&(s=e.createSelection(zo(o,e,n.findOptimalPosition)));const r=(0,h.first)(o.getSelectedBlocks()),a={};return r&&Object.assign(a,e.schema.getAttributesWithProperty(r,"copyOnReplace",!0)),e.change((i=>{s.isCollapsed||e.deleteContent(s,{doNotAutoparagraph:!0});let o=t;const r=s.anchor.parent;!e.schema.checkChild(r,t)&&e.schema.checkChild(r,"paragraph")&&e.schema.checkChild("paragraph",t)&&(o=i.createElement("paragraph"),i.insert(t,o)),e.schema.setAllowedAttributes(o,a,i);const l=e.insertContent(o,s);return l.isCollapsed||n.setSelection&&function(e,t,i,n){const o=e.model;if("on"==i)return void e.setSelection(t,"on");if("after"!=i)throw new h.CKEditorError("insertobject-invalid-place-parameter-value",o);let s=t.nextSibling;o.schema.isInline(t)?e.setSelection(t,"after"):(!(s&&o.schema.checkChild(s,"$text"))&&o.schema.checkChild(t.parent,"paragraph")&&(s=e.createElement("paragraph"),o.schema.setAllowedAttributes(s,n,e),o.insertContent(s,e.createPositionAfter(t))),s&&e.setSelection(s,0))}(i,t,n.setSelection,a),l}))}(this,t,i,n)})),this.on("canEditAt",(e=>{const t=!this.document.isReadOnly;e.return=t,t||e.stop()}))}change(e){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new ho,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(e){h.CKEditorError.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{e?"function"==typeof e?(t=e,e=new ho):e instanceof ho||(e=new ho(e)):e=new ho,this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(e){h.CKEditorError.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,i,...n){const o=Ko(t,i);return this.fire("insertContent",[e,o,i,...n])}insertObject(e,t,i,n,...o){const s=Ko(t,i);return this.fire("insertObject",[e,s,n,n,...o])}deleteContent(e,t){Ro(this,e,t)}modifySelection(e,t){!function(e,t,i={}){const n=e.schema,o="backward"!=i.direction,s=i.unit?i.unit:"character",r=!!i.treatEmojiAsSingleUnit,a=t.focus,l=new ti({boundaries:Uo(a,o),singleCharacters:!0,direction:o?"forward":"backward"}),c={walker:l,schema:n,isForward:o,unit:s,treatEmojiAsSingleUnit:r};let d;for(;d=l.next();){if(d.done)return;const i=Wo(c,d.value);if(i)return void(t instanceof Ti?e.change((e=>{e.setSelectionFocus(i)})):t.setFocus(i))}}(this,e,t)}getSelectedContent(e){return function(e,t){return e.change((e=>{const i=e.createDocumentFragment(),n=t.getFirstRange();if(!n||n.isCollapsed)return i;const o=n.start.root,s=n.start.getCommonPath(n.end),r=o.getNodeByPath(s);let a;a=n.start.parent==n.end.parent?n:e.createRange(e.createPositionAt(r,n.start.path[s.length]),e.createPositionAt(r,n.end.path[s.length]+1));const l=a.end.offset-a.start.offset;for(const t of a.getItems({shallow:!0}))t.is("$textProxy")?e.appendText(t.data,t.getAttributes(),i):e.append(e.cloneElement(t,!0),i);if(a!=n){const t=n._getTransformedByMove(a.start,e.createPositionAt(i,0),l)[0],o=e.createRange(e.createPositionAt(i,0),t.start);Lo(e.createRange(t.end,e.createPositionAt(i,"end")),e),Lo(o,e)}return i}))}(this,e)}hasContent(e,t={}){const i=e instanceof ci?e:ci._createIn(e);if(i.isCollapsed)return!1;const{ignoreWhitespaces:n=!1,ignoreMarkers:o=!1}=t;if(!o)for(const e of this.markers.getMarkersIntersectingRange(i))if(e.affectsData)return!0;for(const e of i.getItems())if(this.schema.isContent(e)){if(!e.is("$textProxy"))return!0;if(!n)return!0;if(-1!==e.data.search(/\S/))return!0}return!1}canEditAt(e){const t=Ko(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,i){return new ni(e,t,i)}createPositionAt(e,t){return ni._createAt(e,t)}createPositionAfter(e){return ni._createAfter(e)}createPositionBefore(e){return ni._createBefore(e)}createRange(e,t){return new ci(e,t)}createRangeIn(e){return ci._createIn(e)}createRangeOn(e){return ci._createOn(e)}createSelection(...e){return new pi(...e)}createBatch(e){return new ho(e)}createOperationFromJSON(e){return Jn.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 xo(this,t);const i=this._pendingChanges[0].callback(this._currentWriter);e.push(i),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}return e}}function Ko(e,t){if(e)return e instanceof pi||e instanceof Ti?e:e instanceof Jt?t||0===t?new pi(e,t):e.is("rootElement")?new pi(e,"in"):new pi(e,"on"):new pi(e)}class Zo extends Vt{constructor(){super(...arguments),this.domEventType="click"}onDomEvent(e){this.fire(e.type,e)}}class Go extends Vt{constructor(){super(...arguments),this.domEventType=["mousedown","mouseup","mouseover","mouseout"]}onDomEvent(e){this.fire(e.type,e)}}class Jo{constructor(e){this.document=e}createDocumentFragment(e){return new qe(this.document,e)}createElement(e,t,i){return new pe(this.document,e,t,i)}createText(e){return new b(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,i){return i._insertChild(e,t)}removeChildren(e,t,i){return i._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const i=e.parent;if(i){const n=i.getChildIndex(e);return this.removeChildren(n,1,i),this.insertChild(n,t,i),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const i=t.getChildIndex(e);this.remove(e),this.insertChild(i,e.getChildren(),t)}}rename(e,t){const i=new pe(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,i)?i:null}setAttribute(e,t,i){i._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){(0,v.Z)(e)&&void 0===i?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return Ae._createAt(e,t)}createPositionAfter(e){return Ae._createAfter(e)}createPositionBefore(e){return Ae._createBefore(e)}createRange(e,t){return new Ee(e,t)}createRangeOn(e){return Ee._createOn(e)}createRangeIn(e){return Ee._createIn(e)}createSelection(...e){return new Te(...e)}}const Yo=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Qo=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,Xo=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,es=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,ts=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,is=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,ns=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 os(e){return e.startsWith("#")?Yo.test(e):e.startsWith("rgb")?Qo.test(e)||Xo.test(e):e.startsWith("hsl")?es.test(e)||ts.test(e):ns.has(e.toLowerCase())}const ss=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];function rs(e){return ss.includes(e)}const as=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function ls(e){return as.test(e)}const cs=/^[+-]?[0-9]*([.][0-9]+)?%$/;function ds(e){return cs.test(e)}const us=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function hs(e){return us.includes(e)}const ms=["center","top","bottom","left","right"];function gs(e){return ms.includes(e)}const fs=["fixed","scroll","local"];function ps(e){return fs.includes(e)}const bs=/^url\(/;function ws(e){return bs.test(e)}function vs(e=""){if(""===e)return{top:void 0,right:void 0,bottom:void 0,left:void 0};const t=Cs(e),i=t[0],n=t[2]||i,o=t[1]||i;return{top:i,bottom:n,right:o,left:t[3]||o}}function _s(e){return t=>{const{top:i,right:n,bottom:o,left:s}=t,r=[];return[i,n,s,o].every((e=>!!e))?r.push([e,ys(t)]):(i&&r.push([e+"-top",i]),n&&r.push([e+"-right",n]),o&&r.push([e+"-bottom",o]),s&&r.push([e+"-left",s])),r}}function ys({top:e,right:t,bottom:i,left:n}){const o=[];return n!==t?o.push(e,t,i,n):i!==e?o.push(e,t,i):t!==e?o.push(e,t):o.push(e),o.join(" ")}function ks(e){return t=>({path:e,value:vs(t)})}function Cs(e){const t=e.matchAll(is);return Array.from(t).map((e=>e[0]))}function As(e){e.setNormalizer("background",(e=>{const t={},i=Cs(e);for(const e of i)hs(e)?(t.repeat=t.repeat||[],t.repeat.push(e)):gs(e)?(t.position=t.position||[],t.position.push(e)):ps(e)?t.attachment=e:os(e)?t.color=e:ws(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 Es(e){e.setNormalizer("border",(e=>{const{color:t,style:i,width:n}=Rs(e);return{path:"border",value:{color:vs(t),style:vs(i),width:vs(n)}}})),e.setNormalizer("border-top",xs("top")),e.setNormalizer("border-right",xs("right")),e.setNormalizer("border-bottom",xs("bottom")),e.setNormalizer("border-left",xs("left")),e.setNormalizer("border-color",Ts("color")),e.setNormalizer("border-width",Ts("width")),e.setNormalizer("border-style",Ts("style")),e.setNormalizer("border-top-color",Ps("color","top")),e.setNormalizer("border-top-style",Ps("style","top")),e.setNormalizer("border-top-width",Ps("width","top")),e.setNormalizer("border-right-color",Ps("color","right")),e.setNormalizer("border-right-style",Ps("style","right")),e.setNormalizer("border-right-width",Ps("width","right")),e.setNormalizer("border-bottom-color",Ps("color","bottom")),e.setNormalizer("border-bottom-style",Ps("style","bottom")),e.setNormalizer("border-bottom-width",Ps("width","bottom")),e.setNormalizer("border-left-color",Ps("color","left")),e.setNormalizer("border-left-style",Ps("style","left")),e.setNormalizer("border-left-width",Ps("width","left")),e.setExtractor("border-top",Is("top")),e.setExtractor("border-right",Is("right")),e.setExtractor("border-bottom",Is("bottom")),e.setExtractor("border-left",Is("left")),e.setExtractor("border-top-color","border.color.top"),e.setExtractor("border-right-color","border.color.right"),e.setExtractor("border-bottom-color","border.color.bottom"),e.setExtractor("border-left-color","border.color.left"),e.setExtractor("border-top-width","border.width.top"),e.setExtractor("border-right-width","border.width.right"),e.setExtractor("border-bottom-width","border.width.bottom"),e.setExtractor("border-left-width","border.width.left"),e.setExtractor("border-top-style","border.style.top"),e.setExtractor("border-right-style","border.style.right"),e.setExtractor("border-bottom-style","border.style.bottom"),e.setExtractor("border-left-style","border.style.left"),e.setReducer("border-color",_s("border-color")),e.setReducer("border-style",_s("border-style")),e.setReducer("border-width",_s("border-width")),e.setReducer("border-top",Os("top")),e.setReducer("border-right",Os("right")),e.setReducer("border-bottom",Os("bottom")),e.setReducer("border-left",Os("left")),e.setReducer("border",function(){return t=>{const i=Vs(t,"top"),n=Vs(t,"right"),o=Vs(t,"bottom"),s=Vs(t,"left"),r=[i,n,o,s],a={width:e(r,"width"),style:e(r,"style"),color:e(r,"color")},l=Bs(a,"all");if(l.length)return l;const c=Object.entries(a).reduce(((e,[t,i])=>(i&&(e.push([`border-${t}`,i]),r.forEach((e=>delete e[t]))),e)),[]);return[...c,...Bs(i,"top"),...Bs(n,"right"),...Bs(o,"bottom"),...Bs(s,"left")]};function e(e,t){return e.map((e=>e[t])).reduce(((e,t)=>e==t?e:null))}}()),e.setStyleRelation("border",["border-color","border-style","border-width","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),e.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),e.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),e.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),e.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),e.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function xs(e){return t=>{const{color:i,style:n,width:o}=Rs(t),s={};return void 0!==i&&(s.color={[e]:i}),void 0!==n&&(s.style={[e]:n}),void 0!==o&&(s.width={[e]:o}),{path:"border",value:s}}}function Ts(e){return t=>({path:"border",value:Ss(t,e)})}function Ss(e,t){return{[t]:vs(e)}}function Ps(e,t){return i=>({path:"border",value:{[e]:{[t]:i}}})}function Is(e){return(t,i)=>{if(i.border)return Vs(i.border,e)}}function Vs(e,t){const i={};return e.width&&e.width[t]&&(i.width=e.width[t]),e.style&&e.style[t]&&(i.style=e.style[t]),e.color&&e.color[t]&&(i.color=e.color[t]),i}function Rs(e){const t={},i=Cs(e);for(const e of i)ls(e)||/thin|medium|thick/.test(e)?t.width=e:rs(e)?t.style=e:t.color=e;return t}function Os(e){return t=>Bs(t,e)}function Bs(e,t){const i=[];if(e&&e.width&&i.push("width"),e&&e.style&&i.push("style"),e&&e.color&&i.push("color"),3==i.length){const n=i.map((t=>e[t])).join(" ");return["all"==t?["border",n]:[`border-${t}`,n]]}return"all"==t?[]:i.map((i=>[`border-${t}-${i}`,e[i]]))}function Ms(e){e.setNormalizer("margin",ks("margin")),e.setNormalizer("margin-top",(e=>({path:"margin.top",value:e}))),e.setNormalizer("margin-right",(e=>({path:"margin.right",value:e}))),e.setNormalizer("margin-bottom",(e=>({path:"margin.bottom",value:e}))),e.setNormalizer("margin-left",(e=>({path:"margin.left",value:e}))),e.setReducer("margin",_s("margin")),e.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}function Ns(e){e.setNormalizer("padding",ks("padding")),e.setNormalizer("padding-top",(e=>({path:"padding.top",value:e}))),e.setNormalizer("padding-right",(e=>({path:"padding.right",value:e}))),e.setNormalizer("padding-bottom",(e=>({path:"padding.bottom",value:e}))),e.setNormalizer("padding-left",(e=>({path:"padding.left",value:e}))),e.setReducer("padding",_s("padding")),e.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}},5725:(e,t,i)=>{"use strict";i.d(t,{C:()=>u,G:()=>f});var n=i(7833);function*o(e,t){for(const i of t)i&&e.getAttributeProperties(i[0]).copyOnEnter&&(yield i)}class s extends n.Command{execute(){this.editor.model.change((e=>{this.enterBlock(e),this.fire("afterExecute",{writer:e})}))}enterBlock(e){const t=this.editor.model,i=t.document.selection,n=t.schema,s=i.isCollapsed,a=i.getFirstRange(),l=a.start.parent,c=a.end.parent;if(n.isLimit(l)||n.isLimit(c))return s||l!=c||t.deleteContent(i),!1;if(s){const t=o(e.model.schema,i.getAttributes());return r(e,a.start),e.setSelectionAttribute(t),!0}{const n=!(a.start.isAtStart&&a.end.isAtEnd),o=l==c;if(t.deleteContent(i,{leaveUnmerged:n}),n){if(o)return r(e,i.focus),!0;e.setSelection(c,0)}}return!1}}function r(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}var a=i(6243),l=i(5044);const c={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class d extends a.Observer{constructor(e){super(e);const t=this.document;let i=!1;t.on("keydown",((e,t)=>{i=t.shiftKey})),t.on("beforeinput",((n,o)=>{if(!this.isEnabled)return;let s=o.inputType;l.env.isSafari&&i&&"insertParagraph"==s&&(s="insertLineBreak");const r=o.domEvent,d=c[s];if(!d)return;const u=new a.BubblingEventInfo(t,"enter",o.targetRanges[0]);t.fire(u,new a.DomEventData(e,r,{isSoft:d.isSoft})),u.stop.called&&n.stop()}))}observe(){}stopObserving(){}}class u extends n.Plugin{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,i=t.document;t.addObserver(d),e.commands.add("enter",new s(e)),this.listenTo(i,"enter",((n,o)=>{i.isComposing||o.preventDefault(),o.isSoft||(e.execute("enter"),t.scrollToTheSelection())}),{priority:"low"})}}class h extends n.Command{execute(){const e=this.editor.model,t=e.document;e.change((i=>{!function(e,t,i){const n=i.isCollapsed,s=i.getFirstRange(),r=s.start.parent,a=s.end.parent,l=r==a;if(n){const n=o(e.schema,i.getAttributes());m(e,t,s.end),t.removeSelectionAttribute(i.getAttributeKeys()),t.setSelectionAttribute(n)}else{const n=!(s.start.isAtStart&&s.end.isAtEnd);e.deleteContent(i,{leaveUnmerged:n}),l?m(e,t,i.focus):n&&t.setSelection(a,0)}}(e,i,t.selection),this.fire("afterExecute",{writer:i})}))}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=function(e,t){if(t.rangeCount>1)return!1;const i=t.anchor;if(!i||!e.checkChild(i,"softBreak"))return!1;const n=t.getFirstRange(),o=n.start.parent,s=n.end.parent;return!g(o,e)&&!g(s,e)||o===s}(e.schema,t.selection)}}function m(e,t,i){const n=t.createElement("softBreak");e.insertContent(n,i),t.setSelection(n,"after")}function g(e,t){return!e.is("rootElement")&&(t.isLimit(e)||g(e.parent,t))}class f extends n.Plugin{static get pluginName(){return"ShiftEnter"}init(){const e=this.editor,t=e.model.schema,i=e.conversion,n=e.editing.view,o=n.document;t.register("softBreak",{allowWhere:"$text",isInline:!0}),i.for("upcast").elementToElement({model:"softBreak",view:"br"}),i.for("downcast").elementToElement({model:"softBreak",view:(e,{writer:t})=>t.createEmptyElement("br")}),n.addObserver(d),e.commands.add("shiftEnter",new h(e)),this.listenTo(o,"enter",((t,i)=>{o.isComposing||i.preventDefault(),i.isSoft&&(e.execute("shiftEnter"),n.scrollToTheSelection())}),{priority:"low"})}}},1638:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Essentials:()=>b});var n=i(6854),o=i(4079),s=i(1863),r=i(7833),a=i(5044);class l extends r.Command{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let i=e.schema.getLimitElement(t);if(t.containsEntireContent(i)||!c(e.schema,i))do{if(i=i.parent,!i)return}while(!c(e.schema,i));e.change((e=>{e.setSelection(i,"in")}))}}function c(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const d=(0,a.parseKeystroke)("Ctrl+A");class u extends r.Plugin{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new l(e)),this.listenTo(t,"keydown",((t,i)=>{(0,a.getCode)(i)===d&&(e.execute("selectAll"),i.preventDefault())}))}}var h=i(2692);class m extends r.Plugin{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(t=>{const i=e.commands.get("selectAll"),n=new h.ButtonView(t),o=t.t;return n.set({label:o("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),n.bind("isEnabled").to(i,"isEnabled"),this.listenTo(n,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),n}))}}class g extends r.Plugin{static get requires(){return[u,m]}static get pluginName(){return"SelectAll"}}var f=i(5187),p=i(1903);class b extends n.Sy{static get requires(){return[o.TU,s.C,g,s.G,f.Mq,p.WP]}static get pluginName(){return"Essentials"}}},3457:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Font:()=>F,FontBackgroundColor:()=>L,FontBackgroundColorEditing:()=>N,FontBackgroundColorUI:()=>D,FontColor:()=>B,FontColorEditing:()=>V,FontColorUI:()=>O,FontFamily:()=>_,FontFamilyEditing:()=>b,FontFamilyUI:()=>v,FontSize:()=>P,FontSizeEditing:()=>T,FontSizeUI:()=>S});var n=i(6854);class o extends n.mY{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute(this.attributeKey),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value,o=e.batch,s=e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,n):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of o)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}};o?t.enqueueChange(o,(e=>{s(e)})):t.change((e=>{s(e)}))}}var s=i(7095);const r="fontSize",a="fontFamily",l="fontColor",c="fontBackgroundColor";function d(e,t){const i={model:{key:e,values:[]},view:{},upcastAlso:{}};for(const e of t)i.model.values.push(e.model),i.view[e.model]=e.view,e.upcastAlso&&(i.upcastAlso[e.model]=e.upcastAlso);return i}function u(e){return t=>t.getStyle(e).replace(/\s/g,"")}function h(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class m extends o{constructor(e){super(e,a)}}function g(e){return e.map(f).filter((e=>void 0!==e))}function f(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=e.replace(/"|'/g,"").split(","),i=t[0],n=t.map(p).join(", ");return{title:i,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}(e):void 0}function p(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class b extends n.Sy{static get pluginName(){return"FontFamilyEditing"}constructor(e){super(e),e.config.define(a,{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:a}),e.model.schema.setAttributeProperties(a,{isFormatting:!0,copyOnEnter:!0});const t=g(e.config.get("fontFamily.options")).filter((e=>e.model)),i=d(a,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(a,new m(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:a,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:a,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:a,value:e=>e.getAttribute("face")}})}}var w=i(6553);class v extends n.Sy{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(a),o=t("Font Family");e.ui.componentFactory.add(a,(t=>{const r=(0,s.t9)(t);return(0,s.Pm)(r,(()=>function(e,t){const i=new w.FE;for(const n of e){const e={type:"button",model:new s.Hn({commandName:a,commandParam:n.model,label:n.title,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(e=>e===n.model||!(!e||!n.model)&&e.split(",")[0].replace(/'/g,"").toLowerCase()===n.model.toLowerCase())),n.view&&"string"!=typeof n.view&&n.view.styles&&e.model.set("labelStyle",`font-family: ${n.view.styles["font-family"]}`),i.add(e)}return i}(i,n)),{role:"menu",ariaLabel:o}),r.buttonView.set({label:o,icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),r.bind("isEnabled").to(n),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 g(e.config.get(a).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class _ extends n.Sy{static get requires(){return[b,v]}static get pluginName(){return"FontFamily"}}var y=i(3291);class k extends o{constructor(e){super(e,r)}}function C(e){return e.map((e=>function(e){if("number"==typeof e&&(e=String(e)),"object"==typeof e&&((t=e).title&&t.model&&t.view))return E(e);var t;const i=function(e){return"string"==typeof e?A[e]:A[e.model]}(e);return i?E(i):"default"===e?{model:void 0,title:"Default"}:function(e){let t;if("object"==typeof e){if(!e.model)throw new w.Bb("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}(e)?void 0:function(e){return"string"==typeof e&&(e={title:e,model:`${parseFloat(e)}px`}),e.view={name:"span",styles:{"font-size":e.model}},E(e)}(e)}(e))).filter((e=>void 0!==e))}const A={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 E(e){return e.view&&"string"!=typeof e.view&&!e.view.priority&&(e.view.priority=7),e}const x=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class T extends n.Sy{static get pluginName(){return"FontSizeEditing"}constructor(e){super(e),e.config.define(r,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:r}),e.model.schema.setAttributeProperties(r,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=C(this.editor.config.get("fontSize.options")).filter((e=>e.model)),n=d(r,i);t?(this._prepareAnyValueConverters(n),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(r,new k(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter((e=>!(0,y.G9)(String(e))&&!(0,y.zz)(String(e))));if(i.length)throw new w.Bb("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:r,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:r,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:r,value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let n=parseInt(t,10);i&&(n=3+n);const o=x.length-1,s=Math.min(Math.max(n,0),o);return x[s]}}})}}class S extends n.Sy{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(r),o=t("Font Size");e.ui.componentFactory.add(r,(t=>{const a=(0,s.t9)(t);return(0,s.Pm)(a,(()=>function(e,t){const i=new w.FE;for(const n of e){const e={type:"button",model:new s.Hn({commandName:r,commandParam:n.model,label:n.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};n.view&&"string"!=typeof n.view&&(n.view.styles&&e.model.set("labelStyle",`font-size:${n.view.styles["font-size"]}`),n.view.classes&&e.model.set("class",`${e.model.class} ${n.view.classes}`)),e.model.bind("isOn").to(t,"value",(e=>e===n.model)),i.add(e)}return i}(i,n)),{role:"menu",ariaLabel:o}),a.buttonView.set({label:o,icon:'',tooltip:!0}),a.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),a.bind("isEnabled").to(n),this.listenTo(a,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),a}))}_getLocalizedOptions(){const e=this.editor,t=e.t,i={Default:t("Default"),Tiny:t("Tiny"),Small:t("Small"),Big:t("Big"),Huge:t("Huge")};return C(e.config.get(r).options).map((e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class P extends n.Sy{static get requires(){return[T,S]}static get pluginName(){return"FontSize"}normalizeSizeOptions(e){return C(e)}}class I extends o{constructor(e){super(e,l)}}class V extends n.Sy{static get pluginName(){return"FontColorEditing"}constructor(e){super(e),e.config.define(l,{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:l,value:u("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:l,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:l,view:h("color")}),e.commands.add(l,new I(e)),e.model.schema.extend("$text",{allowAttributes:l}),e.model.schema.setAttributeProperties(l,{isFormatting:!0,copyOnEnter:!0})}}class R extends n.Sy{constructor(e,{commandName:t,componentName:i,icon:n,dropdownLabel:o}){super(e),this.commandName=t,this.componentName=i,this.icon=n,this.dropdownLabel=o,this.columns=e.config.get(`${this.componentName}.columns`),this.colorSelectorView=void 0}init(){const e=this.editor,t=e.locale,i=t.t,n=e.commands.get(this.commandName),o=e.config.get(this.componentName),r=(0,s.S1)(o.colors),a=(0,s.k6)(t,r),l=o.documentColors,c=!1!==o.colorPicker;e.ui.componentFactory.add(this.componentName,(t=>{const r=(0,s.t9)(t);let d=!1;return this.colorSelectorView=function({dropdownView:e,colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:r,documentColorsCount:a,colorPickerViewConfig:l}){const c=e.locale,d=new s.MI(c,{colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:r,documentColorsCount:a,colorPickerViewConfig:l});return e.colorSelectorView=d,e.panelView.children.add(d),d}({dropdownView:r,colors:a.map((e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}}))),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==l?i("Document colors"):"",documentColorsCount:void 0===l?this.columns:l,colorPickerViewConfig:!!c&&(o.colorPicker||{})}),this.colorSelectorView.bind("selectedColor").to(n,"value"),r.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),r.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),r.bind("isEnabled").to(n),this.colorSelectorView.on("execute",((t,i)=>{r.isOpen&&e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),"colorPicker"!==i.source&&e.editing.view.focus(),"colorPickerSaveButton"===i.source&&(r.isOpen=!1)})),this.colorSelectorView.on("colorPicker:show",(()=>{this._undoStepBatch=e.model.createBatch()})),this.colorSelectorView.on("colorPicker:cancel",(()=>{this._undoStepBatch.operations.length&&(r.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()})),r.on("change:isOpen",((t,i,n)=>{d||(d=!0,r.colorSelectorView.appendUI()),n&&(0!==l&&this.colorSelectorView.updateDocumentColors(e.model,this.componentName),this.colorSelectorView.updateSelectedColors(),this.colorSelectorView.showColorGridsFragment())})),(0,s.Mh)(r,(()=>r.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find((e=>e.isOn)))),r}))}}class O extends R{constructor(e){const t=e.locale.t;super(e,{commandName:l,componentName:l,icon:'',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class B extends n.Sy{static get requires(){return[V,O]}static get pluginName(){return"FontColor"}}class M extends o{constructor(e){super(e,c)}}class N extends n.Sy{static get pluginName(){return"FontBackgroundColorEditing"}constructor(e){super(e),e.config.define(c,{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(y.QR),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:c,value:u("background-color")}}),e.conversion.for("downcast").attributeToElement({model:c,view:h("background-color")}),e.commands.add(c,new M(e)),e.model.schema.extend("$text",{allowAttributes:c}),e.model.schema.setAttributeProperties(c,{isFormatting:!0,copyOnEnter:!0})}}class D extends R{constructor(e){const t=e.locale.t;super(e,{commandName:c,componentName:c,icon:'',dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class L extends n.Sy{static get requires(){return[N,D]}static get pluginName(){return"FontBackgroundColor"}}class F extends n.Sy{static get requires(){return[_,P,B,L]}static get pluginName(){return"Font"}}},8107:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Heading:()=>m,HeadingButtonsUI:()=>f,HeadingEditing:()=>c,HeadingUI:()=>h,Title:()=>w});var n=i(6854),o=i(4690),s=i(6553);class r extends n.mY{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=(0,s.Ps)(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>a(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,i=t.document,n=e.value;t.change((e=>{const o=Array.from(i.selection.getSelectedBlocks()).filter((e=>a(e,n,t.schema)));for(const t of o)t.is("element",n)||e.rename(t,n)}))}}function a(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const l="paragraph";class c extends n.Sy{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[o.Paragraph]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const n of t)"paragraph"!==n.model&&(e.model.schema.register(n.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(n),i.push(n.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new r(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,n)=>{const o=e.model.document.selection.getFirstPosition().parent;i.some((e=>o.is("element",e.model)))&&!o.is("element",l)&&0===o.childCount&&n.writer.rename(o,l)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:s.tA.low+1})}}var d=i(7095);function u(e){const t=e.t,i={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map((e=>{const t=i[e.title];return t&&t!=e.title&&(e.title=t),e}))}class h extends n.Sy{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,i=u(e),n=t("Choose heading"),o=t("Heading");e.ui.componentFactory.add("heading",(t=>{const r={},a=new s.FE,l=e.commands.get("heading"),c=e.commands.get("paragraph"),u=[l];for(const e of i){const t={type:"button",model:new d.Hn({label:e.title,class:e.class,role:"menuitemradio",withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(c,"value"),t.model.set("commandName","paragraph"),u.push(c)):(t.model.bind("isOn").to(l,"value",(t=>t===e.model)),t.model.set({commandName:"heading",commandValue:e.model})),a.add(t),r[e.model]=e.title}const h=(0,d.t9)(t);return(0,d.Pm)(h,a,{ariaLabel:o,role:"menu"}),h.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),h.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),h.bind("isEnabled").toMany(u,"isEnabled",((...e)=>e.some((e=>e)))),h.buttonView.bind("label").to(l,"value",c,"value",((e,t)=>{const i=e||t&&"paragraph";return"boolean"==typeof i?n:r[i]?r[i]:n})),this.listenTo(h,"execute",(t=>{const{commandName:i,commandValue:n}=t.source;e.execute(i,n?{value:n}:void 0),e.editing.view.focus()})),h}))}}class m extends n.Sy{static get requires(){return[c,h]}static get pluginName(){return"Heading"}}const g={heading1:'',heading2:'',heading3:'',heading4:'',heading5:'',heading6:''};class f extends n.Sy{init(){u(this.editor).filter((e=>"paragraph"!==e.model)).map((e=>this._createButton(e)))}_createButton(e){const t=this.editor;t.ui.componentFactory.add(e.model,(i=>{const n=new d.r5(i),o=t.commands.get("heading");return n.label=e.title,n.icon=e.icon||g[e.model],n.tooltip=!0,n.isToggleable=!0,n.bind("isEnabled").to(o),n.bind("isOn").to(o,"value",(t=>t==e.model)),n.on("execute",(()=>{t.execute("heading",{value:e.model}),t.editing.view.focus()})),n}))}}var p=i(3291);const b=new Set(["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"]);class w extends n.Sy{constructor(){super(...arguments),this._bodyPlaceholder=new Map}static get pluginName(){return"Title"}static get requires(){return["Paragraph"]}init(){const e=this.editor,t=e.model;t.schema.register("title",{isBlock:!0,allowIn:"$root"}),t.schema.register("title-content",{isBlock:!0,allowIn:"title",allowAttributes:["alignment"]}),t.schema.extend("$text",{allowIn:"title-content"}),t.schema.addAttributeCheck((e=>{if(e.endsWith("title-content $text"))return!1})),e.editing.mapper.on("modelToViewPosition",_(e.editing.view)),e.data.mapper.on("modelToViewPosition",_(e.editing.view)),e.conversion.for("downcast").elementToElement({model:"title-content",view:"h1"}),e.conversion.for("downcast").add((e=>e.on("insert:title",((e,t,i)=>{i.consumable.consume(t.item,e.name)})))),e.data.upcastDispatcher.on("element:h1",v,{priority:"high"}),e.data.upcastDispatcher.on("element:h2",v,{priority:"high"}),e.data.upcastDispatcher.on("element:h3",v,{priority:"high"}),t.document.registerPostFixer((e=>this._fixTitleContent(e))),t.document.registerPostFixer((e=>this._fixTitleElement(e))),t.document.registerPostFixer((e=>this._fixBodyElement(e))),t.document.registerPostFixer((e=>this._fixExtraParagraph(e))),this._attachPlaceholders(),this._attachTabPressHandling()}getTitle(e={}){const t=e.rootName?e.rootName:void 0,i=this._getTitleElement(t).getChild(0);return this.editor.data.stringify(i,e)}getBody(e={}){const t=this.editor,i=t.data,n=t.model,o=e.rootName?e.rootName:void 0,s=t.model.document.getRoot(o),r=t.editing.view,a=new p.qD(r.document),l=n.createRangeIn(s),c=a.createDocumentFragment(),d=n.createPositionAfter(s.getChild(0)),u=n.createRange(d,n.createPositionAt(s,"end")),h=new Map;for(const e of n.markers){const t=u.getIntersection(e.getRange());t&&h.set(e.name,t)}return i.mapper.clearBindings(),i.mapper.bindElements(s,c),i.downcastDispatcher.convert(l,h,a,e),a.remove(a.createRangeOn(c.getChild(0))),t.data.processor.toData(c)}_getTitleElement(e){const t=this.editor.model.document.getRoot(e);for(const e of t.getChildren())if(y(e))return e}_fixTitleContent(e){let t=!1;for(const i of this.editor.model.document.getRootNames()){const n=this._getTitleElement(i);if(!n||1===n.maxOffset)continue;const o=Array.from(n.getChildren());o.shift();for(const t of o)e.move(e.createRangeOn(t),n,"after"),e.rename(t,"paragraph");t=!0}return t}_fixTitleElement(e){let t=!1;const i=this.editor.model;for(const n of this.editor.model.document.getRoots()){const o=Array.from(n.getChildren()).filter(y),s=o[0],r=n.getChild(0);if(r.is("element","title"))o.length>1&&(C(o,e,i),t=!0);else if(s||b.has(r.name))b.has(r.name)?k(r,e,i):e.move(e.createRangeOn(s),n,0),C(o,e,i),t=!0;else{const i=e.createElement("title");e.insert(i,n),e.insertElement("title-content",i),t=!0}}return t}_fixBodyElement(e){let t=!1;for(const i of this.editor.model.document.getRootNames()){const n=this.editor.model.document.getRoot(i);if(n.childCount<2){const o=e.createElement("paragraph");e.insert(o,n,1),this._bodyPlaceholder.set(i,o),t=!0}}return t}_fixExtraParagraph(e){let t=!1;for(const i of this.editor.model.document.getRootNames()){const n=this.editor.model.document.getRoot(i),o=this._bodyPlaceholder.get(i);E(o,n)&&(this._bodyPlaceholder.delete(i),e.remove(o),t=!0)}return t}_attachPlaceholders(){const e=this.editor,t=e.t,i=e.editing.view,n=e.sourceElement,o=e.config.get("title.placeholder")||t("Type your title"),s=e.config.get("placeholder")||n&&"textarea"===n.tagName.toLowerCase()&&n.getAttribute("placeholder")||t("Type or paste your content here.");e.editing.downcastDispatcher.on("insert:title-content",((e,t,n)=>{const s=n.mapper.toViewElement(t.item);s.placeholder=o,(0,p.ID)({view:i,element:s,keepOnFocus:!0})}));const r=new Map;i.document.registerPostFixer((e=>{let t=!1;for(const n of i.document.roots){if(n.isEmpty)continue;const i=n.getChild(1),o=r.get(n.rootName);i!==o&&(o&&((0,p.$_)(e,o),e.removeAttribute("data-placeholder",o)),e.setAttribute("data-placeholder",s,i),r.set(n.rootName,i),t=!0),t=(0,p.Q7)(i,!0)&&2===n.childCount&&"p"===i.name?!!(0,p.NJ)(e,i)||t:!!(0,p.$_)(e,i)||t}return t}))}_attachTabPressHandling(){const e=this.editor,t=e.model;e.keystrokes.set("TAB",((e,i)=>{t.change((e=>{const n=t.document.selection,o=Array.from(n.getSelectedBlocks());if(1===o.length&&o[0].is("element","title-content")){const t=n.getFirstPosition().root.getChild(1);e.setSelection(t,0),i()}}))})),e.keystrokes.set("SHIFT + TAB",((i,n)=>{t.change((i=>{const o=t.document.selection;if(!o.isCollapsed)return;const r=(0,s.Ps)(o.getSelectedBlocks()),a=o.getFirstPosition(),l=e.model.document.getRoot(a.root.rootName),c=l.getChild(0);r===l.getChild(1)&&a.isAtStart&&(i.setSelection(c.getChild(0),0),n())}))}))}}function v(e,t,i){const n=t.modelCursor,o=t.viewItem;if(!n.isAtStart||!n.parent.is("element","$root"))return;if(!i.consumable.consume(o,{name:!0}))return;const s=i.writer,r=s.createElement("title"),a=s.createElement("title-content");s.append(a,r),s.insert(r,n),i.convertChildren(o,a),i.updateConversionResult(r,t)}function _(e){return(t,i)=>{const n=i.modelPosition.parent;if(!n.is("element","title"))return;const o=n.parent,s=i.mapper.toViewElement(o);i.viewPosition=e.createPositionAt(s,0),t.stop()}}function y(e){return e.is("element","title")}function k(e,t,i){const n=t.createElement("title");t.insert(n,e,"before"),t.insert(e,n,0),t.rename(e,"title-content"),i.schema.removeDisallowedAttributes([e],t)}function C(e,t,i){let n=!1;for(const o of e)0!==o.index&&(A(o,t,i),n=!0);return n}function A(e,t,i){const n=e.getChild(0);n.isEmpty?t.remove(e):(t.move(t.createRangeOn(n),e,"before"),t.rename(n,"paragraph"),t.remove(e),i.schema.removeDisallowedAttributes([n],t))}function E(e,t){return!(!e||!e.is("element","paragraph")||e.childCount||t.childCount<=2||t.getChild(t.childCount-1)!==e)}},5242:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Highlight:()=>c,HighlightEditing:()=>s,HighlightUI:()=>a});var n=i(6854);class o extends n.mY{refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute("highlight"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"highlight")}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value;t.change((e=>{if(i.isCollapsed){const t=i.getFirstPosition();if(i.hasAttribute("highlight")){const i=e=>e.item.hasAttribute("highlight")&&e.item.getAttribute("highlight")===this.value,o=t.getLastMatchingPosition(i,{direction:"backward"}),s=t.getLastMatchingPosition(i),r=e.createRange(o,s);n&&this.value!==n?(t.isEqual(s)||e.setAttribute("highlight",n,r),e.setSelectionAttribute("highlight",n)):(t.isEqual(s)||e.removeAttribute("highlight",r),e.removeSelectionAttribute("highlight"))}else n&&e.setSelectionAttribute("highlight",n)}else{const o=t.schema.getValidRanges(i.getRanges(),"highlight");for(const t of o)n?e.setAttribute("highlight",n,t):e.removeAttribute("highlight",t)}}))}}class s extends n.Sy{static get pluginName(){return"HighlightEditing"}constructor(e){super(e),e.config.define("highlight",{options:[{model:"yellowMarker",class:"marker-yellow",title:"Yellow marker",color:"var(--ck-highlight-marker-yellow)",type:"marker"},{model:"greenMarker",class:"marker-green",title:"Green marker",color:"var(--ck-highlight-marker-green)",type:"marker"},{model:"pinkMarker",class:"marker-pink",title:"Pink marker",color:"var(--ck-highlight-marker-pink)",type:"marker"},{model:"blueMarker",class:"marker-blue",title:"Blue marker",color:"var(--ck-highlight-marker-blue)",type:"marker"},{model:"redPen",class:"pen-red",title:"Red pen",color:"var(--ck-highlight-pen-red)",type:"pen"},{model:"greenPen",class:"pen-green",title:"Green pen",color:"var(--ck-highlight-pen-green)",type:"pen"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"highlight"});const t=e.config.get("highlight.options");e.conversion.attributeToElement(function(e){const t={model:{key:"highlight",values:[]},view:{}};for(const i of e)t.model.values.push(i.model),t.view[i.model]={name:"mark",classes:i.class};return t}(t)),e.commands.add("highlight",new o(e))}}var r=i(7095);class a extends n.Sy{get localizedOptionTitles(){const e=this.editor.t;return{"Yellow marker":e("Yellow marker"),"Green marker":e("Green marker"),"Pink marker":e("Pink marker"),"Blue marker":e("Blue marker"),"Red pen":e("Red pen"),"Green pen":e("Green pen")}}static get pluginName(){return"HighlightUI"}init(){const e=this.editor.config.get("highlight.options");for(const t of e)this._addHighlighterButton(t);this._addRemoveHighlightButton(),this._addDropdown(e)}_addRemoveHighlightButton(){const e=this.editor.t,t=this.editor.commands.get("highlight");this._addButton("removeHighlight",e("Remove highlight"),n.icons.eraser,null,(e=>{e.bind("isEnabled").to(t,"isEnabled")}))}_addHighlighterButton(e){const t=this.editor.commands.get("highlight");this._addButton("highlight:"+e.model,e.title,l(e.type),e.model,(function(i){i.bind("isEnabled").to(t,"isEnabled"),i.bind("isOn").to(t,"value",(t=>t===e.model)),i.iconView.fillColor=e.color,i.isToggleable=!0}))}_addButton(e,t,i,n,o){const s=this.editor;s.ui.componentFactory.add(e,(e=>{const a=new r.r5(e),l=this.localizedOptionTitles[t]?this.localizedOptionTitles[t]:t;return a.set({label:l,icon:i,tooltip:!0}),a.on("execute",(()=>{s.execute("highlight",{value:n}),s.editing.view.focus()})),o(a),a}))}_addDropdown(e){const t=this.editor,i=t.t,n=t.ui.componentFactory,o=e[0],s=e.reduce(((e,t)=>(e[t.model]=t,e)),{});n.add("highlight",(a=>{const c=t.commands.get("highlight"),d=(0,r.t9)(a,r.Rm),u=d.buttonView;function h(e,t){const i=e&&e!==u.lastExecuted?e:u.lastExecuted;return s[i][t]}return u.set({label:i("Highlight"),tooltip:!0,lastExecuted:o.model,commandValue:o.model,isToggleable:!0}),u.bind("icon").to(c,"value",(e=>l(h(e,"type")))),u.bind("color").to(c,"value",(e=>h(e,"color"))),u.bind("commandValue").to(c,"value",(e=>h(e,"model"))),u.bind("isOn").to(c,"value",(e=>!!e)),u.delegate("execute").to(d),d.bind("isEnabled").to(c,"isEnabled"),(0,r.up)(d,(()=>{const t=e.map((e=>{const t=n.create("highlight:"+e.model);return this.listenTo(t,"execute",(()=>{d.buttonView.set({lastExecuted:e.model})})),t}));return t.push(new r.$y),t.push(n.create("removeHighlight")),t}),{enableActiveItemFocusOnDropdownOpen:!0,ariaLabel:i("Text highlight toolbar")}),function(e){e.buttonView.actionView.iconView.bind("fillColor").to(e.buttonView,"color")}(d),u.on("execute",(()=>{t.execute("highlight",{value:u.commandValue})})),this.listenTo(d,"execute",(()=>{t.editing.view.focus()})),d}))}}function l(e){return"marker"===e?'':''}class c extends n.Sy{static get requires(){return[s,a]}static get pluginName(){return"Highlight"}}},2337:(e,t,i)=>{"use strict";i.r(t),i.d(t,{HorizontalLine:()=>c,HorizontalLineEditing:()=>r,HorizontalLineUI:()=>l});var n=i(6854),o=i(5549);class s extends n.mY{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=function(e,t,i){const n=function(e,t){const i=(0,o.KT)(e,t).start.parent;return i.isEmpty&&!i.is("element","$root")?i.parent:i}(e,i);return t.checkChild(n,"horizontalLine")}(i,t,e)}execute(){const e=this.editor.model;e.change((t=>{const i=t.createElement("horizontalLine");e.insertObject(i,null,null,{setSelection:"after"})}))}}class r extends n.Sy{static get pluginName(){return"HorizontalLineEditing"}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),n.for("dataDowncast").elementToElement({model:"horizontalLine",view:(e,{writer:t})=>t.createEmptyElement("hr")}),n.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(e,{writer:t})=>{const n=i("Horizontal line"),s=t.createContainerElement("div",null,t.createEmptyElement("hr"));return t.addClass("ck-horizontal-line",s),t.setCustomProperty("hr",!0,s),function(e,t,i){return t.setCustomProperty("horizontalLine",!0,e),(0,o.XC)(e,t,{label:i})}(s,t,n)}}),n.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new s(e))}}var a=i(7095);class l extends n.Sy{static get pluginName(){return"HorizontalLineUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("horizontalLine",(i=>{const n=e.commands.get("horizontalLine"),o=new a.r5(i);return o.set({label:t("Horizontal line"),icon:'',tooltip:!0}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("horizontalLine"),e.editing.view.focus()})),o}))}}class c extends n.Sy{static get requires(){return[r,l,o.$L]}static get pluginName(){return"HorizontalLine"}}},8691:(e,t,i)=>{"use strict";i.r(t),i.d(t,{HtmlEmbed:()=>h,HtmlEmbedEditing:()=>c,HtmlEmbedUI:()=>u});var n=i(6854),o=i(5549),s=i(7095),r=i(6553);class a extends n.mY{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection,n=l(i);this.isEnabled=function(e,t,i){const n=function(e,t){const i=(0,o.KT)(e,t).start.parent;return i.isEmpty&&!i.is("rootElement")?i.parent:i}(e,i);return t.checkChild(n,"rawHtml")}(i,t,e),this.value=n?n.getAttribute("value")||"":null}execute(e){const t=this.editor.model,i=t.document.selection;t.change((n=>{let o;null!==this.value?o=l(i):(o=n.createElement("rawHtml"),t.insertObject(o,null,null,{setSelection:"on"})),n.setAttribute("value",e,o)}))}}function l(e){const t=e.getSelectedElement();return t&&t.is("element","rawHtml")?t:null}class c extends n.Sy{static get pluginName(){return"HtmlEmbedEditing"}constructor(e){super(e),this._widgetButtonViewReferences=new Set,e.config.define("htmlEmbed",{showPreviews:!1,sanitizeHtml:e=>((0,r.KE)("html-embed-provide-sanitize-function"),{html:e,hasChanged:!1})})}init(){const e=this.editor;e.model.schema.register("rawHtml",{inheritAllFrom:"$blockObject",allowAttributes:["value"]}),e.commands.add("htmlEmbed",new a(e)),this._setupConversion()}_setupConversion(){const e=this.editor,t=e.t,i=e.editing.view,n=this._widgetButtonViewReferences,s=e.config.get("htmlEmbed");function a({editor:e,domElement:i,state:o,props:s}){i.textContent="";const a=i.ownerDocument;let c;if(o.isEditable){const e={isDisabled:!1,placeholder:s.textareaPlaceholder};c=l({domDocument:a,state:o,props:e}),i.append(c)}else if(o.showPreviews){const n={sanitizeHtml:s.sanitizeHtml};i.append(function({editor:e,domDocument:i,state:n,props:o}){const s=o.sanitizeHtml(n.getRawHtmlValue()),a=n.getRawHtmlValue().length>0?t("No preview available"):t("Empty snippet content"),l=(0,r.az)(i,"div",{class:"ck ck-reset_all raw-html-embed__preview-placeholder"},a),c=(0,r.az)(i,"div",{class:"raw-html-embed__preview-content",dir:e.locale.contentLanguageDirection}),d=i.createRange().createContextualFragment(s.html);c.appendChild(d);return(0,r.az)(i,"div",{class:"raw-html-embed__preview"},[l,c])}({domDocument:a,state:o,props:n,editor:e}))}else{const e={isDisabled:!0,placeholder:s.textareaPlaceholder};i.append(l({domDocument:a,state:o,props:e}))}const u={onEditClick:s.onEditClick,onSaveClick:()=>{s.onSaveClick(c.value)},onCancelClick:s.onCancelClick};i.prepend(function({editor:e,domDocument:t,state:i,props:o}){const s=(0,r.az)(t,"div",{class:"raw-html-embed__buttons-wrapper"});if(i.isEditable){const t=d(e,"save",o.onSaveClick),i=d(e,"cancel",o.onCancelClick);s.append(t.element,i.element),n.add(t).add(i)}else{const t=d(e,"edit",o.onEditClick);s.append(t.element),n.add(t)}return s}({editor:e,domDocument:a,state:o,props:u}))}function l({domDocument:e,state:t,props:i}){const n=(0,r.az)(e,"textarea",{placeholder:i.placeholder,class:"ck ck-reset ck-input ck-input-text raw-html-embed__source"});return n.disabled=i.isDisabled,n.value=t.getRawHtmlValue(),n}this.editor.editing.view.on("render",(()=>{for(const e of n){if(e.element&&e.element.isConnected)return;e.destroy(),n.delete(e)}}),{priority:"lowest"}),e.data.registerRawContentMatcher({name:"div",classes:"raw-html-embed"}),e.conversion.for("upcast").elementToElement({view:{name:"div",classes:"raw-html-embed"},model:(e,{writer:t})=>t.createElement("rawHtml",{value:e.getCustomProperty("$rawContent")})}),e.conversion.for("dataDowncast").elementToElement({model:"rawHtml",view:(e,{writer:t})=>t.createRawElement("div",{class:"raw-html-embed"},(function(t){t.innerHTML=e.getAttribute("value")||""}))}),e.conversion.for("editingDowncast").elementToStructure({model:{name:"rawHtml",attributes:["value"]},view:(n,{writer:r})=>{let l,c,d;const u=r.createRawElement("div",{class:"raw-html-embed__content-wrapper"},(function(t){l=t,a({editor:e,domElement:t,state:c,props:d}),l.addEventListener("mousedown",(()=>{if(c.isEditable){const t=e.model;t.document.selection.getSelectedElement()!==n&&t.change((e=>e.setSelection(n,"on")))}}),!0)})),h={makeEditable(){c=Object.assign({},c,{isEditable:!0}),a({domElement:l,editor:e,state:c,props:d}),i.change((e=>{e.setAttribute("data-cke-ignore-events","true",u)})),l.querySelector("textarea").focus()},save(t){t!==c.getRawHtmlValue()?(e.execute("htmlEmbed",t),e.editing.view.focus()):this.cancel()},cancel(){c=Object.assign({},c,{isEditable:!1}),a({domElement:l,editor:e,state:c,props:d}),e.editing.view.focus(),i.change((e=>{e.removeAttribute("data-cke-ignore-events",u)}))}};c={showPreviews:s.showPreviews,isEditable:!1,getRawHtmlValue:()=>n.getAttribute("value")||""},d={sanitizeHtml:s.sanitizeHtml,textareaPlaceholder:t("Paste raw HTML here..."),onEditClick(){h.makeEditable()},onSaveClick(e){h.save(e)},onCancelClick(){h.cancel()}};const m=r.createContainerElement("div",{class:"raw-html-embed","data-html-embed-label":t("HTML snippet"),dir:e.locale.uiLanguageDirection},u);return r.setCustomProperty("rawHtmlApi",h,m),r.setCustomProperty("rawHtml",!0,m),(0,o.XC)(m,r,{label:t("HTML snippet"),hasSelectionHandle:!0})}})}}function d(e,t,i){const{t:o}=e.locale,r=new s.r5(e.locale),a=e.commands.get("htmlEmbed");return r.set({class:`raw-html-embed__${t}-button`,icon:n.icons.pencil,tooltip:!0,tooltipPosition:"rtl"===e.locale.uiLanguageDirection?"e":"w"}),r.render(),"edit"===t?(r.set({icon:n.icons.pencil,label:o("Edit source")}),r.bind("isEnabled").to(a)):"save"===t?(r.set({icon:n.icons.check,label:o("Save changes")}),r.bind("isEnabled").to(a)):r.set({icon:n.icons.cancel,label:o("Cancel")}),r.on("execute",i),r}class u extends n.Sy{static get pluginName(){return"HtmlEmbedUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("htmlEmbed",(i=>{const n=e.commands.get("htmlEmbed"),o=new s.r5(i);return o.set({label:t("Insert HTML"),icon:'',tooltip:!0}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("htmlEmbed"),e.editing.view.focus(),e.editing.view.document.selection.getSelectedElement().getCustomProperty("rawHtmlApi").makeEditable()})),o}))}}class h extends n.Sy{static get requires(){return[c,u,o.$L]}static get pluginName(){return"HtmlEmbed"}}},7261:(e,t,i)=>{"use strict";i.r(t),i.d(t,{AutoImage:()=>p,Image:()=>M,ImageBlock:()=>R,ImageBlockEditing:()=>V,ImageCaption:()=>z,ImageCaptionEditing:()=>L,ImageCaptionUI:()=>F,ImageCaptionUtils:()=>N,ImageEditing:()=>P,ImageInline:()=>B,ImageInsert:()=>re,ImageInsertUI:()=>oe,ImageInsertViaUrl:()=>se,ImageResize:()=>fe,ImageResizeButtons:()=>de,ImageResizeEditing:()=>le,ImageResizeHandles:()=>ge,ImageStyle:()=>De,ImageStyleEditing:()=>Ie,ImageStyleUI:()=>Oe,ImageTextAlternative:()=>C,ImageTextAlternativeEditing:()=>w,ImageTextAlternativeUI:()=>k,ImageToolbar:()=>Le,ImageUpload:()=>ee,ImageUploadEditing:()=>Q,ImageUploadProgress:()=>$,ImageUploadUI:()=>j,ImageUtils:()=>m,PictureEditing:()=>Fe});var n=i(6854),o=i(4079),s=i(3291),r=i(1903),a=i(5187),l=i(6553),c=i(5549);function d(e){return e.createContainerElement("figure",{class:"image"},[e.createEmptyElement("img"),e.createSlot("children")])}function u(e,t){const i=e.plugins.get("ImageUtils"),n=e.plugins.has("ImageInlineEditing")&&e.plugins.has("ImageBlockEditing");return e=>i.isInlineImageView(e)?n&&("block"==e.getStyle("display")||e.findAncestor(i.isBlockImageView)?"imageBlock":"imageInline")!==t?null:o(e):null;function o(e){const t={name:!0};return e.hasAttribute("src")&&(t.attributes=["src"]),t}}function h(e,t){const i=(0,l.Ps)(t.getSelectedBlocks());return!i||e.isObject(i)||i.isEmpty&&"listItem"!=i.name?"imageBlock":"imageInline"}class m extends n.Sy{static get pluginName(){return"ImageUtils"}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(e={},t=null,i=null){const n=this.editor,o=n.model,s=o.document.selection;i=g(n,t||s,i),e={...Object.fromEntries(s.getAttributes()),...e};for(const t in e)o.schema.checkAttribute(i,t)||delete e[t];return o.change((n=>{const s=n.createElement(i,e);return o.insertObject(s,t,null,{setSelection:"on",findOptimalPosition:t||"imageInline"==i?void 0:"auto"}),s.parent?s:null}))}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const i=e.getSelectedElement();if(i&&this.isImageWidget(i))return i;let n=t.parent;for(;n;){if(n.is("element")&&this.isImageWidget(n))return n;n=n.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}isImageAllowed(){const e=this.editor.model.document.selection;return function(e,t){if("imageBlock"==g(e,t,null)){const i=function(e,t){const i=(0,c.KT)(e,t).start.parent;return i.isEmpty&&!i.is("element","$root")?i.parent:i}(t,e.model);if(e.model.schema.checkChild(i,"imageBlock"))return!0}else if(e.model.schema.checkChild(t.focus,"imageInline"))return!0;return!1}(this.editor,e)&&function(e){return[...e.focus.getAncestors()].every((e=>!e.is("element","imageBlock")))}(e)}toImageWidget(e,t,i){return t.setCustomProperty("image",!0,e),(0,c.XC)(e,t,{label:()=>{const t=this.findViewImgElement(e).getAttribute("alt");return t?`${t} ${i}`:i}})}isImageWidget(e){return!!e.getCustomProperty("image")&&(0,c.Qd)(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:i}of t.createRangeIn(e))if(this.isInlineImageView(i))return i}}function g(e,t,i){const n=e.model.schema,o=e.config.get("image.insert.type");return e.plugins.has("ImageBlockEditing")?e.plugins.has("ImageInlineEditing")?i||("inline"===o?"imageInline":"block"===o?"imageBlock":t.is("selection")?h(n,t):n.checkChild(t,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}const f=new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@!$&'()*+,;=%-]+/.source+/\.(jpg|jpeg|png|gif|ico|webp|JPG|JPEG|PNG|GIF|ICO|WEBP)/.source+/(\?[\w.~:/[\]@!$&'()*+,;=%-]*)?/.source+/(#[\w.~:/[\]@!$&'()*+,;=%-]*)?$/.source));class p extends n.Sy{static get requires(){return[o.TU,m,r.WP,a.HG]}static get pluginName(){return"AutoImage"}constructor(e){super(e),this._timeoutId=null,this._positionToInsert=null}init(){const e=this.editor,t=e.model.document,i=e.plugins.get("ClipboardPipeline");this.listenTo(i,"inputTransformation",(()=>{const e=t.selection.getFirstRange(),i=s.jP.fromPosition(e.start);i.stickiness="toPrevious";const n=s.jP.fromPosition(e.end);n.stickiness="toNext",t.once("change:data",(()=>{this._embedImageBetweenPositions(i,n),i.detach(),n.detach()}),{priority:"high"})})),e.commands.get("undo").on("execute",(()=>{this._timeoutId&&(l.CO.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)}),{priority:"high"})}_embedImageBetweenPositions(e,t){const i=this.editor,n=new s.iE(e,t),o=n.getWalker({ignoreElementEnd:!0}),r=Object.fromEntries(i.model.document.selection.getAttributes()),a=this.editor.plugins.get("ImageUtils");let l="";for(const e of o)e.item.is("$textProxy")&&(l+=e.item.data);l=l.trim(),l.match(f)?(this._positionToInsert=s.jP.fromPosition(e),this._timeoutId=setTimeout((()=>{i.commands.get("insertImage").isEnabled?(i.model.change((e=>{let t;this._timeoutId=null,e.remove(n),n.detach(),"$graveyard"!==this._positionToInsert.root.rootName&&(t=this._positionToInsert.toPosition()),a.insertImage({...r,src:l},t),this._positionToInsert.detach(),this._positionToInsert=null})),i.plugins.get("Delete").requestUndoOnBackspace()):n.detach()}),100)):n.detach()}}class b extends n.mY{refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n=t.model,o=i.getClosestSelectedImageElement(n.document.selection);n.change((t=>{t.setAttribute("alt",e.newValue,o)}))}}class w extends n.Sy{static get requires(){return[m]}static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new b(this.editor))}}var v=i(7095);class _ extends v.G7{constructor(e){super(e);const t=this.locale.t;this.focusTracker=new l.Rh,this.keystrokes=new l.VD,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),n.icons.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),n.icons.cancel,"ck-button-cancel","cancel"),this._focusables=new v.vX,this._focusCycler=new v.I0({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),(0,v.GI)({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(e,t,i,n){const o=new v.r5(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:i}}),n&&o.delegate("execute").to(this,n),o}_createLabeledInputView(){const e=this.locale.t,t=new v.KP(this.locale,v.R);return t.label=e("Text alternative"),t}}function y(e){const t=e.editing.view,i=v.no.defaultPositions,n=e.plugins.get("ImageUtils");return{target:t.domConverter.mapViewToDom(n.getClosestSelectedImageWidget(t.document.selection)),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}class k extends n.Sy{static get requires(){return[v.WB]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",(i=>{const o=e.commands.get("imageTextAlternative"),s=new v.r5(i);return s.set({label:t("Change image text alternative"),icon:n.icons.lowVision,tooltip:!0}),s.bind("isEnabled").to(o,"isEnabled"),s.bind("isOn").to(o,"value",(e=>!!e)),this.listenTo(s,"execute",(()=>{this._showForm()})),s}))}_createForm(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new((0,v.RX)(_))(e.locale),this._form.render(),this.listenTo(this._form,"submit",(()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((e,t)=>{this._hideForm(!0),t()})),this.listenTo(e.ui,"update",(()=>{i.getClosestSelectedImageWidget(t.selection)?this._isVisible&&function(e){const t=e.plugins.get("ContextualBalloon");if(e.plugins.get("ImageUtils").getClosestSelectedImageWidget(e.editing.view.document.selection)){const i=y(e);t.updatePosition(i)}}(e):this._hideForm(!0)})),(0,v.eC)({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const e=this.editor,t=e.commands.get("imageTextAlternative"),i=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:y(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class C extends n.Sy{static get requires(){return[w,k]}static get pluginName(){return"ImageTextAlternative"}}function A(e,t){const i=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const o=n.writer,s=n.mapper.toViewElement(i.item),r=e.findViewImgElement(s);if(null===i.attributeNewValue){const e=i.attributeOldValue;e&&e.data&&(o.removeAttribute("srcset",r),o.removeAttribute("sizes",r),e.width&&o.removeAttribute("width",r))}else{const e=i.attributeNewValue;e&&e.data&&(o.setAttribute("srcset",e.data,r),o.setAttribute("sizes","100vw",r),e.width&&o.setAttribute("width",e.width,r))}};return e=>{e.on(`attribute:srcset:${t}`,i)}}function E(e,t,i){const n=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const o=n.writer,s=n.mapper.toViewElement(i.item),r=e.findViewImgElement(s);o.setAttribute(i.attributeKey,i.attributeNewValue||"",r)};return e=>{e.on(`attribute:${i}:${t}`,n)}}class x extends s.Qj{observe(e){this.listenTo(e,"load",((e,t)=>{const i=t.target;this.checkShouldIgnoreEventFromTarget(i)||"IMG"==i.tagName&&this._fireEvents(t)}),{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}class T extends n.mY{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||"block"===t&&(0,l.KE)("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||"inline"===t&&(0,l.KE)("image-inline-plugin-required")}refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=(0,l.qo)(e.source),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(i.getAttributes());t.forEach(((e,t)=>{const s=i.getSelectedElement();if("string"==typeof e&&(e={src:e}),t&&s&&n.isImage(s)){const t=this.editor.model.createPositionAfter(s);n.insertImage({...e,...o},t)}else n.insertImage({...e,...o})}))}}class S extends n.mY{refresh(){const e=this.editor.plugins.get("ImageUtils"),t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=e.isImage(t),this.value=this.isEnabled?t.getAttribute("src"):null}execute(e){const t=this.editor.model.document.selection.getSelectedElement();this.editor.model.change((i=>{i.setAttribute("src",e.source,t),i.removeAttribute("srcset",t),i.removeAttribute("sizes",t)}))}}class P extends n.Sy{static get requires(){return[m]}static get pluginName(){return"ImageEditing"}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(x),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:e=>{const t={data:e.getAttribute("srcset")};return e.hasAttribute("width")&&(t.width=e.getAttribute("width")),t}}});const i=new T(e),n=new S(e);e.commands.add("insertImage",i),e.commands.add("replaceImageSource",n),e.commands.add("imageInsert",i)}}class I extends n.mY{constructor(e,t){super(e),this._modelElementName=t}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=e.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=e.isInlineImage(t):this.isEnabled=e.isBlockImage(t)}execute(){const e=this.editor,t=this.editor.model,i=e.plugins.get("ImageUtils"),n=i.getClosestSelectedImageElement(t.document.selection),o=Object.fromEntries(n.getAttributes());return o.src||o.uploadId?t.change((e=>{const s=Array.from(t.markers).filter((e=>e.getRange().containsItem(n))),r=i.insertImage(o,t.createSelection(n,"on"),this._modelElementName);if(!r)return null;const a=e.createRangeOn(r);for(const t of s){const i=t.getRange(),n="$graveyard"!=i.root.rootName?i.getJoined(a,!0):a;e.updateMarker(t,{range:n})}return{oldElement:n,newElement:r}})):null}}class V extends n.Sy{static get requires(){return[P,m,o._l]}static get pluginName(){return"ImageBlockEditing"}init(){const e=this.editor;e.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),e.plugins.has("ImageInlineEditing")&&(e.commands.add("imageTypeBlock",new I(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:t})=>d(t)}),i.for("editingDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:i})=>n.toImageWidget(d(i),i,t("image widget"))}),i.for("downcast").add(E(n,"imageBlock","src")).add(E(n,"imageBlock","alt")).add(A(n,"imageBlock")),i.for("upcast").elementToElement({view:u(e,"imageBlock"),model:(e,{writer:t})=>t.createElement("imageBlock",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)}).add(function(e){const t=(t,i,n)=>{if(!n.consumable.test(i.viewItem,{name:!0,classes:"image"}))return;const o=e.findViewImgElement(i.viewItem);if(!o||!n.consumable.test(o,{name:!0}))return;n.consumable.consume(i.viewItem,{name:!0,classes:"image"});const s=n.convertItem(o,i.modelCursor),r=(0,l.Ps)(s.modelRange.getItems());r?(n.convertChildren(i.viewItem,r),n.updateConversionResult(r,i)):n.consumable.revert(i.viewItem,{name:!0,classes:"image"})};return e=>{e.on("element:figure",t)}}(n))}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",((o,r)=>{const a=Array.from(r.content.getChildren());let l;if(!a.every(n.isInlineImageView))return;l=r.targetRanges?e.editing.mapper.toModelRange(r.targetRanges[0]):t.document.selection.getFirstRange();const c=t.createSelection(l);if("imageBlock"===h(t.schema,c)){const e=new s.yj(i.document),t=a.map((t=>e.createElement("figure",{class:"image"},t)));r.content=e.createDocumentFragment(t)}}))}}class R extends n.Sy{static get requires(){return[V,c.$L,C]}static get pluginName(){return"ImageBlock"}}class O extends n.Sy{static get requires(){return[P,m,o._l]}static get pluginName(){return"ImageInlineEditing"}init(){const e=this.editor,t=e.model.schema;t.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"]}),t.addChildCheck(((e,t)=>{if(e.endsWith("caption")&&"imageInline"===t.name)return!1})),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new I(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToElement({model:"imageInline",view:(e,{writer:t})=>t.createEmptyElement("img")}),i.for("editingDowncast").elementToStructure({model:"imageInline",view:(e,{writer:i})=>n.toImageWidget(function(e){return e.createContainerElement("span",{class:"image-inline"},e.createEmptyElement("img"))}(i),i,t("image widget"))}),i.for("downcast").add(E(n,"imageInline","src")).add(E(n,"imageInline","alt")).add(A(n,"imageInline")),i.for("upcast").elementToElement({view:u(e,"imageInline"),model:(e,{writer:t})=>t.createElement("imageInline",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",((o,r)=>{const a=Array.from(r.content.getChildren());let l;if(!a.every(n.isBlockImageView))return;l=r.targetRanges?e.editing.mapper.toModelRange(r.targetRanges[0]):t.document.selection.getFirstRange();const c=t.createSelection(l);if("imageInline"===h(t.schema,c)){const e=new s.yj(i.document),t=a.map((t=>1===t.childCount?(Array.from(t.getAttributes()).forEach((i=>e.setAttribute(...i,n.findViewImgElement(t)))),t.getChild(0)):t));r.content=e.createDocumentFragment(t)}}))}}class B extends n.Sy{static get requires(){return[O,c.$L,C]}static get pluginName(){return"ImageInline"}}class M extends n.Sy{static get requires(){return[R,B]}static get pluginName(){return"Image"}}class N extends n.Sy{static get pluginName(){return"ImageCaptionUtils"}static get requires(){return[m]}getCaptionFromImageModelElement(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}getCaptionFromModelSelection(e){const t=this.editor.plugins.get("ImageUtils"),i=e.getFirstPosition().findAncestor("caption");return i&&t.isBlockImage(i.parent)?i:null}matchImageCaptionViewElement(e){const t=this.editor.plugins.get("ImageUtils");return"figcaption"==e.name&&t.isBlockImageView(e.parent)?{name:!0}:null}}class D extends n.mY{refresh(){const e=this.editor,t=e.plugins.get("ImageCaptionUtils"),i=e.plugins.get("ImageUtils");if(!e.plugins.has(V))return this.isEnabled=!1,void(this.value=!1);const n=e.model.document.selection,o=n.getSelectedElement();if(!o){const e=t.getCaptionFromModelSelection(n);return this.isEnabled=!!e,void(this.value=!!e)}this.isEnabled=i.isImage(o),this.isEnabled?this.value=!!t.getCaptionFromImageModelElement(o):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change((e=>{this.value?this._hideImageCaption(e):this._showImageCaption(e,t)}))}_showImageCaption(e,t){const i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageCaptionEditing"),o=this.editor.plugins.get("ImageUtils");let s=i.getSelectedElement();const r=n._getSavedCaption(s);o.isInlineImage(s)&&(this.editor.execute("imageTypeBlock"),s=i.getSelectedElement());const a=r||e.createElement("caption");e.append(a,s),t&&e.setSelection(a,"in")}_hideImageCaption(e){const t=this.editor,i=t.model.document.selection,n=t.plugins.get("ImageCaptionEditing"),o=t.plugins.get("ImageCaptionUtils");let s,r=i.getSelectedElement();r?s=o.getCaptionFromImageModelElement(r):(s=o.getCaptionFromModelSelection(i),r=s.parent),n._saveCaption(r,s),e.setSelection(r,"on"),e.remove(s)}}class L extends n.Sy{static get requires(){return[m,N]}static get pluginName(){return"ImageCaptionEditing"}constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema;t.isRegistered("caption")?t.extend("caption",{allowIn:"imageBlock"}):t.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleImageCaption",new D(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils"),o=e.t;e.conversion.for("upcast").elementToElement({view:e=>n.matchImageCaptionViewElement(e),model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>i.isBlockImage(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:n})=>{if(!i.isBlockImage(e.parent))return null;const r=n.createEditableElement("figcaption");n.setCustomProperty("imageCaption",!0,r),r.placeholder=o("Enter image caption"),(0,s.ID)({view:t,element:r,keepOnFocus:!0});const a=e.parent.getAttribute("alt"),l=a?o("Caption for image: %0",[a]):o("Caption for the image");return(0,c.sC)(r,n,{label:l})}})}_setupImageTypeCommandsIntegration(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.plugins.get("ImageCaptionUtils"),n=e.commands.get("imageTypeInline"),o=e.commands.get("imageTypeBlock"),s=e=>{if(!e.return)return;const{oldElement:n,newElement:o}=e.return;if(!n)return;if(t.isBlockImage(n)){const e=i.getCaptionFromImageModelElement(n);if(e)return void this._saveCaption(o,e)}const s=this._getSavedCaption(n);s&&this._saveCaption(o,s)};n&&this.listenTo(n,"execute",s,{priority:"low"}),o&&this.listenTo(o,"execute",s,{priority:"low"})}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?s.W_.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}_registerCaptionReconversion(){const e=this.editor,t=e.model,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils");t.document.on("change:data",(()=>{const o=t.document.differ.getChanges();for(const t of o){if("alt"!==t.attributeKey)continue;const o=t.range.start.nodeAfter;if(i.isBlockImage(o)){const t=n.getCaptionFromImageModelElement(o);if(!t)return;e.editing.reconvertItem(t)}}}))}}class F extends n.Sy{static get requires(){return[N]}static get pluginName(){return"ImageCaptionUI"}init(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageCaptionUtils"),o=e.t;e.ui.componentFactory.add("toggleImageCaption",(s=>{const r=e.commands.get("toggleImageCaption"),a=new v.r5(s);return a.set({icon:n.icons.caption,tooltip:!0,isToggleable:!0}),a.bind("isOn","isEnabled").to(r,"value","isEnabled"),a.bind("label").to(r,"value",(e=>o(e?"Toggle caption off":"Toggle caption on"))),this.listenTo(a,"execute",(()=>{e.execute("toggleImageCaption",{focusCaptionOnShow:!0});const n=i.getCaptionFromModelSelection(e.model.document.selection);if(n){const i=e.editing.mapper.toViewElement(n);t.scrollToTheSelection(),t.change((e=>{e.addClass("image__caption_highlighted",i)}))}e.editing.view.focus()})),a}))}}class z extends n.Sy{static get requires(){return[L,F]}static get pluginName(){return"ImageCaption"}}var H=i(1070);function W(e){const t=e.map((e=>e.replace("+","\\+")));return new RegExp(`^image\\/(${t.join("|")})$`)}function U(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class j extends n.Sy{static get pluginName(){return"ImageUploadUI"}init(){const e=this.editor,t=e.t,i=i=>{const o=new H.FileDialogButtonView(i),s=e.commands.get("uploadImage"),r=e.config.get("image.upload.types"),a=W(r);return o.set({acceptedType:r.map((e=>`image/${e}`)).join(","),allowMultipleFiles:!0}),o.buttonView.set({label:t("Insert image"),icon:n.icons.image,tooltip:!0}),o.buttonView.bind("isEnabled").to(s),o.on("done",((t,i)=>{const n=Array.from(i).filter((e=>a.test(e.type)));n.length&&(e.execute("uploadImage",{file:n}),e.editing.view.focus())})),o};e.ui.componentFactory.add("uploadImage",i),e.ui.componentFactory.add("imageUpload",i)}}class $ extends n.Sy{static get pluginName(){return"ImageUploadProgress"}constructor(e){super(e),this.uploadStatusChange=(e,t,i)=>{const n=this.editor,o=t.item,s=o.getAttribute("uploadId");if(!i.consumable.consume(t.item,e.name))return;const r=n.plugins.get("ImageUtils"),a=n.plugins.get(H.FileRepository),l=s?t.attributeNewValue:null,c=this.placeholder,d=n.editing.mapper.toViewElement(o),u=i.writer;if("reading"==l)return q(d,u),void K(r,c,d,u);if("uploading"==l){const e=a.loaders.get(s);return q(d,u),void(e?(Z(d,u),function(e,t,i,n){const o=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),o),i.on("change:uploadedPercent",((e,t,i)=>{n.change((e=>{e.setStyle("width",i+"%",o)}))}))}(d,u,e,n.editing.view),function(e,t,i,n){if(n.data){const o=e.findViewImgElement(t);i.setAttribute("src",n.data,o)}}(r,d,u,e)):K(r,c,d,u))}"complete"==l&&a.loaders.get(s)&&function(e,t,i){const n=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),n),setTimeout((()=>{i.change((e=>e.remove(e.createRangeOn(n))))}),3e3)}(d,u,n.editing.view),function(e,t){J(e,t,"progressBar")}(d,u),Z(d,u),function(e,t){t.removeClass("ck-appear",e)}(d,u)},this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",this.uploadStatusChange),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}}function q(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function K(e,t,i,n){i.hasClass("ck-image-upload-placeholder")||n.addClass("ck-image-upload-placeholder",i);const o=e.findViewImgElement(i);o.getAttribute("src")!==t&&n.setAttribute("src",t,o),G(i,"placeholder")||n.insert(n.createPositionAfter(o),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(n))}function Z(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),J(e,t,"placeholder")}function G(e,t){for(const i of e.getChildren())if(i.getCustomProperty(t))return i}function J(e,t,i){const n=G(e,i);n&&t.remove(t.createRangeOn(n))}class Y extends n.mY{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(i)}execute(e){const t=(0,l.qo)(e.file),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(i.getAttributes());t.forEach(((e,t)=>{const s=i.getSelectedElement();if(t&&s&&n.isImage(s)){const t=this.editor.model.createPositionAfter(s);this._uploadImage(e,o,t)}else this._uploadImage(e,o)}))}_uploadImage(e,t,i){const n=this.editor,o=n.plugins.get(H.FileRepository).createLoader(e),s=n.plugins.get("ImageUtils");o&&s.insertImage({...t,uploadId:o.id},i)}}class Q extends n.Sy{static get requires(){return[H.FileRepository,v.P_,o._l,m]}static get pluginName(){return"ImageUploadEditing"}constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const e=this.editor,t=e.model.document,i=e.conversion,n=e.plugins.get(H.FileRepository),o=e.plugins.get("ImageUtils"),r=e.plugins.get("ClipboardPipeline"),a=W(e.config.get("image.upload.types")),c=new Y(e);e.commands.add("uploadImage",c),e.commands.add("imageUpload",c),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,i)=>{if(n=i.dataTransfer,Array.from(n.types).includes("text/html")&&""!==n.getData("text/html"))return;var n;const o=Array.from(i.dataTransfer.files).filter((e=>!!e&&a.test(e.type)));o.length&&(t.stop(),e.model.change((t=>{i.targetRanges&&t.setSelection(i.targetRanges.map((t=>e.editing.mapper.toModelRange(t)))),e.model.enqueueChange((()=>{e.execute("uploadImage",{file:o})}))})))})),this.listenTo(r,"inputTransformation",((t,i)=>{const r=Array.from(e.editing.view.createRangeIn(i.content)).map((e=>e.item)).filter((e=>function(e,t){return!(!e.isInlineImageView(t)||!t.getAttribute("src")||!t.getAttribute("src").match(/^data:image\/\w+;base64,/g)&&!t.getAttribute("src").match(/^blob:/g))}(o,e)&&!e.getAttribute("uploadProcessed"))).map((e=>{return{promise:(t=e,new Promise(((e,i)=>{const n=t.getAttribute("src");fetch(n).then((e=>e.blob())).then((t=>{const i=U(t,n),o=i.replace("image/",""),s=new File([t],`image.${o}`,{type:i});e(s)})).catch((t=>t&&"TypeError"===t.name?function(e){return function(e){return new Promise(((t,i)=>{const n=l.CO.document.createElement("img");n.addEventListener("load",(()=>{const e=l.CO.document.createElement("canvas");e.width=n.width,e.height=n.height,e.getContext("2d").drawImage(n,0,0),e.toBlob((e=>e?t(e):i()))})),n.addEventListener("error",(()=>i())),n.src=e}))}(e).then((t=>{const i=U(t,e),n=i.replace("image/","");return new File([t],`image.${n}`,{type:i})}))}(n).then(e).catch(i):i(t)))}))),imageElement:e};var t}));if(!r.length)return;const a=new s.yj(e.editing.view.document);for(const e of r){a.setAttribute("uploadProcessed",!0,e.imageElement);const t=n.createLoader(e.promise);t&&(a.setAttribute("src","",e.imageElement),a.setAttribute("uploadId",t.id,e.imageElement))}})),e.editing.view.document.on("dragover",((e,t)=>{t.preventDefault()})),t.on("change",(()=>{const i=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),o=new Set;for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter,s="$graveyard"==t.position.root.rootName;for(const t of X(e,i)){const e=t.getAttribute("uploadId");if(!e)continue;const i=n.loaders.get(e);i&&(s?o.has(e)||i.abort():(o.add(e),this._uploadImageElements.set(e,t),"idle"==i.status&&this._readAndUpload(i)))}}})),this.on("uploadComplete",((e,{imageElement:t,data:i})=>{const n=i.urls?i.urls:i;this.editor.model.change((e=>{e.setAttribute("src",n.default,t),this._parseAndSetSrcsetAttributeOnImage(n,t,e)}))}),{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this.editor.plugins.has("ImageInlineEditing")&&e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]})}_readAndUpload(e){const t=this.editor,i=t.model,n=t.locale.t,o=t.plugins.get(H.FileRepository),s=t.plugins.get(v.P_),r=t.plugins.get("ImageUtils"),a=this._uploadImageElements;return i.enqueueChange({isUndoable:!1},(t=>{t.setAttribute("uploadStatus","reading",a.get(e.id))})),e.read().then((()=>{const n=e.upload(),o=a.get(e.id);if(l.OB.isSafari){const e=t.editing.mapper.toViewElement(o),i=r.findViewImgElement(e);t.editing.view.once("render",(()=>{if(!i.parent)return;const e=t.editing.view.domConverter.mapViewToDom(i.parent);if(!e)return;const n=e.style.display;e.style.display="none",e._ckHack=e.offsetHeight,e.style.display=n}))}return i.enqueueChange({isUndoable:!1},(e=>{e.setAttribute("uploadStatus","uploading",o)})),n})).then((t=>{i.enqueueChange({isUndoable:!1},(i=>{const n=a.get(e.id);i.setAttribute("uploadStatus","complete",n),this.fire("uploadComplete",{data:t,imageElement:n})})),c()})).catch((t=>{if("error"!==e.status&&"aborted"!==e.status)throw t;"error"==e.status&&t&&s.showWarning(t,{title:n("Upload failed"),namespace:"upload"}),i.enqueueChange({isUndoable:!1},(t=>{t.remove(a.get(e.id))})),c()}));function c(){i.enqueueChange({isUndoable:!1},(t=>{const i=a.get(e.id);t.removeAttribute("uploadId",i),t.removeAttribute("uploadStatus",i),a.delete(e.id)})),o.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let n=0;const o=Object.keys(e).filter((e=>{const t=parseInt(e,10);if(!isNaN(t))return n=Math.max(n,t),!0})).map((t=>`${e[t]} ${t}w`)).join(", ");""!=o&&i.setAttribute("srcset",{data:o,width:n},t)}}function X(e,t){const i=e.plugins.get("ImageUtils");return Array.from(e.model.createRangeOn(t)).filter((e=>i.isImage(e.item))).map((e=>e.item))}class ee extends n.Sy{static get pluginName(){return"ImageUpload"}static get requires(){return[Q,j,$]}}class te extends v.G7{constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("class",t.class||null),this.children=this.createCollection(),t.children&&t.children.forEach((e=>this.children.add(e))),this.set("_role",null),this.set("_ariaLabelledBy",null),t.labelView&&this.set({_role:"group",_ariaLabelledBy:t.labelView.id}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",i.to("class")],role:i.to("_role"),"aria-labelledby":i.to("_ariaLabelledBy")},children:this.children})}}class ie extends v.G7{constructor(e,t={}){super(e);const{insertButtonView:i,cancelButtonView:n}=this._createActionButtons(e);this.insertButtonView=i,this.cancelButtonView=n,this.set("imageURLInputValue",""),this.focusTracker=new l.Rh,this.keystrokes=new l.VD,this._focusables=new v.vX,this._focusCycler=new v.I0({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.set("_integrations",new l.FE);for(const[e,i]of Object.entries(t))"insertImageViaUrl"===e&&(i.fieldView.bind("value").to(this,"imageURLInputValue",(e=>e||"")),i.fieldView.on("input",(()=>{this.imageURLInputValue=i.fieldView.element.value.trim()}))),i.name=e,this._integrations.add(i);this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:"-1"},children:[...this._integrations,new te(e,{children:[this.insertButtonView,this.cancelButtonView],class:"ck-image-insert-form__action-row"})]})}render(){super.render(),(0,v.GI)({view:this}),[...this._integrations,this.insertButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}getIntegration(e){return this._integrations.find((t=>t.name===e))}_createActionButtons(e){const t=e.t,i=new v.r5(e),o=new v.r5(e);return i.set({label:t("Insert"),icon:n.icons.check,class:"ck-button-save",type:"submit",withText:!0,isEnabled:this.imageURLInputValue}),o.set({label:t("Cancel"),icon:n.icons.cancel,class:"ck-button-cancel",withText:!0}),i.bind("isEnabled").to(this,"imageURLInputValue",(e=>!!e)),i.delegate("execute").to(this,"submit"),o.delegate("execute").to(this,"cancel"),{insertButtonView:i,cancelButtonView:o}}focus(){this._focusCycler.focusFirst()}}function ne(e){const t=e.t,i=new v.KP(e,v.R);return i.set({label:t("Insert image via URL")}),i.fieldView.placeholder="https://example.com/image.png",i}class oe extends n.Sy{static get pluginName(){return"ImageInsertUI"}init(){const e=this.editor,t=e=>this._createDropdownView(e);e.ui.componentFactory.add("insertImage",t),e.ui.componentFactory.add("imageInsert",t)}_createDropdownView(e){const t=this.editor,i=e.t,o=t.commands.get("uploadImage"),s=t.commands.get("insertImage");this.dropdownView=(0,v.t9)(e,o?v.Rm:void 0);const r=this.dropdownView.buttonView,a=this.dropdownView.panelView;if(r.set({label:i("Insert image"),icon:n.icons.image,tooltip:!0}),a.extendTemplate({attributes:{class:"ck-image-insert__panel"}}),o){const e=this.dropdownView.buttonView;e.actionView=t.ui.componentFactory.create("uploadImage"),e.actionView.extendTemplate({attributes:{class:"ck ck-button ck-splitbutton__action"}})}return this._setUpDropdown(o||s)}_setUpDropdown(e){const t=this.editor,i=t.t,n=this.dropdownView,o=n.panelView,s=this.editor.plugins.get("ImageUtils"),r=t.commands.get("replaceImageSource");let a;function l(){t.editing.view.focus(),n.isOpen=!1}return n.bind("isEnabled").to(e),n.once("change:isOpen",(()=>{a=new ie(t.locale,function(e){const t=e.config.get("image.insert.integrations"),i=e.plugins.get("ImageInsertUI"),n={insertImageViaUrl:ne(e.locale)};if(!t)return n;if(t.find((e=>"openCKFinder"===e))&&e.ui.componentFactory.has("ckfinder")){const t=e.ui.componentFactory.create("ckfinder");t.set({withText:!0,class:"ck-image-insert__ck-finder-button"}),t.delegate("execute").to(i,"cancel"),n.openCKFinder=t}return t.reduce(((t,i)=>(n[i]?t[i]=n[i]:e.ui.componentFactory.has(i)&&(t[i]=e.ui.componentFactory.create(i)),t)),{})}(t)),a.delegate("submit","cancel").to(n),o.children.add(a)})),n.on("change:isOpen",(()=>{const e=t.model.document.selection.getSelectedElement(),o=a.insertButtonView,l=a.getIntegration("insertImageViaUrl");n.isOpen&&(s.isImage(e)?(a.imageURLInputValue=r.value,o.label=i("Update"),l.label=i("Update image URL")):(a.imageURLInputValue="",o.label=i("Insert"),l.label=i("Insert image via URL")))}),{priority:"low"}),this.delegate("cancel").to(n),n.on("submit",(()=>{l(),function(){const e=t.model.document.selection.getSelectedElement();s.isImage(e)?t.execute("replaceImageSource",{source:a.imageURLInputValue}):t.execute("insertImage",{source:a.imageURLInputValue})}()})),n.on("cancel",(()=>{l()})),n}}class se extends n.Sy{static get pluginName(){return"ImageInsertViaUrl"}static get requires(){return[oe]}}class re extends n.Sy{static get pluginName(){return"ImageInsert"}static get requires(){return[ee,se,oe]}}class ae extends n.mY{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);this.isEnabled=!!t,t&&t.hasAttribute("width")?this.value={width:t.getAttribute("width"),height:null}:this.value=null}execute(e){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils").getClosestSelectedImageElement(i.document.selection);this.value={width:e.width,height:null},n&&i.change((t=>{t.setAttribute("width",e.width,n)}))}}class le extends n.Sy{static get requires(){return[m]}static get pluginName(){return"ImageResizeEditing"}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}init(){const e=this.editor,t=new ae(e);this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline"),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:"width"}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:"width"})}_registerConverters(e){const t=this.editor;t.conversion.for("downcast").add((t=>t.on(`attribute:width:${e}`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewElement(t.item);null!==t.attributeNewValue?(n.setStyle("width",t.attributeNewValue,o),n.addClass("image_resized",o)):(n.removeStyle("width",o),n.removeClass("image_resized",o))})))),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{width:/.+/}},model:{key:"width",value:e=>e.getStyle("width")}})}}const ce={small:n.icons.objectSizeSmall,medium:n.icons.objectSizeMedium,large:n.icons.objectSizeLarge,original:n.icons.objectSizeFull};class de extends n.Sy{static get requires(){return[le]}static get pluginName(){return"ImageResizeButtons"}constructor(e){super(e),this._resizeUnit=e.config.get("image.resizeUnit")}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const e of t)this._registerImageResizeButton(e);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:n,icon:o}=e,s=n?n+this._resizeUnit:null;t.ui.componentFactory.add(i,(i=>{const n=new v.r5(i),r=t.commands.get("resizeImage"),a=this._getOptionLabelValue(e,!0);if(!ce[o])throw new l.Bb("imageresizebuttons-missing-icon",t,e);return n.set({label:a,icon:ce[o],tooltip:a,isToggleable:!0}),n.bind("isEnabled").to(this),n.bind("isOn").to(r,"value",ue(s)),this.listenTo(n,"execute",(()=>{t.execute("resizeImage",{width:s})})),n}))}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,n=e.find((e=>!e.value)),o=o=>{const s=t.commands.get("resizeImage"),r=(0,v.t9)(o,v.J0),a=r.buttonView,l=i("Resize image");return a.set({tooltip:l,commandValue:n.value,icon:ce.medium,isToggleable:!0,label:this._getOptionLabelValue(n),withText:!0,class:"ck-resize-image-button",ariaLabel:l,ariaLabelledBy:void 0}),a.bind("label").to(s,"value",(e=>e&&e.width?e.width:this._getOptionLabelValue(n))),r.bind("isEnabled").to(this),(0,v.Pm)(r,(()=>this._getResizeDropdownListItemDefinitions(e,s)),{ariaLabel:i("Image resize list"),role:"menu"}),this.listenTo(r,"execute",(e=>{t.execute(e.source.commandName,{width:e.source.commandValue}),t.editing.view.focus()})),r};t.ui.componentFactory.add("resizeImage",o),t.ui.componentFactory.add("imageResize",o)}_getOptionLabelValue(e,t=!1){const i=this.editor.t;return e.label?e.label:t?e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const i=new l.FE;return e.map((e=>{const n=e.value?e.value+this._resizeUnit:null,o={type:"button",model:new v.Hn({commandName:"resizeImage",commandValue:n,label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null})};o.model.bind("isOn").to(t,"value",ue(n)),i.add(o)})),i}}function ue(e){return t=>null===e&&t===e||null!==t&&t.width===e}const he=/(image|image-inline)/,me="image_resized";class ge extends n.Sy{static get requires(){return[c.WR]}static get pluginName(){return"ImageResizeHandles"}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view;t.addObserver(x),this.listenTo(t.document,"imageLoaded",((i,n)=>{if(!n.target.matches("figure.image.ck-widget > img,figure.image.ck-widget > picture > img,figure.image.ck-widget > a > img,figure.image.ck-widget > a > picture > img,span.image-inline.ck-widget > img,span.image-inline.ck-widget > picture > img"))return;const o=e.editing.view.domConverter,s=o.domToView(n.target).findAncestor({classes:he});let r=this.editor.plugins.get(c.WR).getResizerByViewElement(s);if(r)return void r.redraw();const a=e.editing.mapper,l=a.toModelElement(s);r=e.plugins.get(c.WR).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:l,viewElement:s,editor:e,getHandleHost:e=>e.querySelector("img"),getResizeHost:()=>o.mapViewToDom(a.toViewElement(l.parent)),isCentered(){const e=l.getAttribute("imageStyle");return!e||"block"==e||"alignCenter"==e},onCommit(i){t.change((e=>{e.removeClass(me,s)})),e.execute("resizeImage",{width:i})}}),r.on("updateSize",(()=>{s.hasClass(me)||t.change((e=>{e.addClass(me,s)}))})),r.bind("isEnabled").to(this)}))}}class fe extends n.Sy{static get requires(){return[le,ge,de]}static get pluginName(){return"ImageResize"}}class pe extends n.mY{constructor(e,t){super(e),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map((e=>{if(e.isDefault)for(const t of e.modelElements)this._defaultStyles[t]=e.name;return[e.name,e]})))}refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?e.hasAttribute("imageStyle")?this.value=e.getAttribute("imageStyle"):this.value=this._defaultStyles[e.name]:this.value=!1}execute(e={}){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils");i.change((t=>{const o=e.value;let s=n.getClosestSelectedImageElement(i.document.selection);o&&this.shouldConvertImageType(o,s)&&(this.editor.execute(n.isBlockImage(s)?"imageTypeInline":"imageTypeBlock"),s=n.getClosestSelectedImageElement(i.document.selection)),!o||this._styles.get(o).isDefault?t.removeAttribute("imageStyle",s):t.setAttribute("imageStyle",o,s)}))}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}}const{objectFullWidth:be,objectInline:we,objectLeft:ve,objectRight:_e,objectCenter:ye,objectBlockLeft:ke,objectBlockRight:Ce}=n.icons,Ae={get inline(){return{name:"inline",title:"In line",icon:we,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:ve,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:ke,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:ye,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:_e,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:Ce,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:ye,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:_e,modelElements:["imageBlock"],className:"image-style-side"}}},Ee={full:be,left:ke,right:Ce,center:ye,inlineLeft:ve,inlineRight:_e,inline:we},xe=[{name:"imageStyle:wrapText",title:"Wrap text",defaultItem:"imageStyle:alignLeft",items:["imageStyle:alignLeft","imageStyle:alignRight"]},{name:"imageStyle:breakText",title:"Break text",defaultItem:"imageStyle:block",items:["imageStyle:alignBlockLeft","imageStyle:block","imageStyle:alignBlockRight"]}];function Te(e){(0,l.KE)("image-style-configuration-definition-invalid",e)}const Se={normalizeStyles:function(e){return(e.configuredStyles.options||[]).map((e=>{return"string"==typeof(t="string"==typeof(t=e)?Ae[t]?{...Ae[t]}:{name:t}:function(e,t){const i={...t};for(const n in e)Object.prototype.hasOwnProperty.call(t,n)||(i[n]=e[n]);return i}(Ae[t.name],t)).icon&&(t.icon=Ee[t.icon]||t.icon),t;var t})).filter((t=>function(e,{isBlockPluginLoaded:t,isInlinePluginLoaded:i}){const{modelElements:n,name:o}=e;if(!(n&&n.length&&o))return Te({style:e}),!1;{const o=[t?"imageBlock":null,i?"imageInline":null];if(!n.some((e=>o.includes(e))))return(0,l.KE)("image-style-missing-dependency",{style:e,missingPlugins:n.map((e=>"imageBlock"===e?"ImageBlockEditing":"ImageInlineEditing"))}),!1}return!0}(t,e)))},getDefaultStylesConfiguration:function(e,t){return e&&t?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:e?{options:["block","side"]}:t?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(e){return e.has("ImageBlockEditing")&&e.has("ImageInlineEditing")?[...xe]:[]},warnInvalidStyle:Te,DEFAULT_OPTIONS:Ae,DEFAULT_ICONS:Ee,DEFAULT_DROPDOWN_DEFINITIONS:xe};function Pe(e,t){for(const i of t)if(i.name===e)return i}class Ie extends n.Sy{static get pluginName(){return"ImageStyleEditing"}static get requires(){return[m]}init(){const{normalizeStyles:e,getDefaultStylesConfiguration:t}=Se,i=this.editor,n=i.plugins.has("ImageBlockEditing"),o=i.plugins.has("ImageInlineEditing");i.config.define("image.styles",t(n,o)),this.normalizedStyles=e({configuredStyles:i.config.get("image.styles"),isBlockPluginLoaded:n,isInlinePluginLoaded:o}),this._setupConversion(n,o),this._setupPostFixer(),i.commands.add("imageStyle",new pe(i,this.normalizedStyles))}_setupConversion(e,t){const i=this.editor,n=i.model.schema,o=(s=this.normalizedStyles,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=Pe(t.attributeNewValue,s),o=Pe(t.attributeOldValue,s),r=i.mapper.toViewElement(t.item),a=i.writer;o&&a.removeClass(o.className,r),n&&a.addClass(n.className,r)});var s;const r=function(e){const t={imageInline:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageInline"))),imageBlock:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageBlock")))};return(e,i,n)=>{if(!i.modelRange)return;const o=i.viewItem,s=(0,l.Ps)(i.modelRange.getItems());if(s&&n.schema.checkAttribute(s,"imageStyle"))for(const e of t[s.name])n.consumable.consume(o,{classes:e.className})&&n.writer.setAttribute("imageStyle",e.name,s)}}(this.normalizedStyles);i.editing.downcastDispatcher.on("attribute:imageStyle",o),i.data.downcastDispatcher.on("attribute:imageStyle",o),e&&(n.extend("imageBlock",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:figure",r,{priority:"low"})),t&&(n.extend("imageInline",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:img",r,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,i=e.plugins.get(m),n=new Map(this.normalizedStyles.map((e=>[e.name,e])));t.registerPostFixer((e=>{let o=!1;for(const s of t.differ.getChanges())if("insert"==s.type||"attribute"==s.type&&"imageStyle"==s.attributeKey){let t="insert"==s.type?s.position.nodeAfter:s.range.start.nodeAfter;if(t&&t.is("element","paragraph")&&t.childCount>0&&(t=t.getChild(0)),!i.isImage(t))continue;const r=t.getAttribute("imageStyle");if(!r)continue;const a=n.get(r);a&&a.modelElements.includes(t.name)||(e.removeAttribute("imageStyle",t),o=!0)}return o}))}}var Ve=i(7226),Re=i(9203);class Oe extends n.Sy{static get requires(){return[Ie]}static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Wrap text":e("Wrap text"),"Break text":e("Break text"),"In line":e("In line"),"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=this.editor.plugins,t=this.editor.config.get("image.toolbar")||[],i=Be(e.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const e of i)this._createButton(e);const n=Be([...t.filter(Ve.Z),...Se.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const e of n)this._createDropdown(e,i)}_createDropdown(e,t){const i=this.editor.ui.componentFactory;i.add(e.name,(n=>{let o;const{defaultItem:s,items:r,title:a}=e,l=r.filter((e=>t.find((({name:t})=>Me(t)===e)))).map((e=>{const t=i.create(e);return e===s&&(o=t),t}));r.length!==l.length&&Se.warnInvalidStyle({dropdown:e});const c=(0,v.t9)(n,v.Rm),d=c.buttonView,u=d.arrowView;return(0,v.up)(c,l,{enableActiveItemFocusOnDropdownOpen:!0}),d.set({label:Ne(a,o.label),class:null,tooltip:!0}),u.unbind("label"),u.set({label:a}),d.bind("icon").toMany(l,"isOn",((...e)=>{const t=e.findIndex(Re.Z);return t<0?o.icon:l[t].icon})),d.bind("label").toMany(l,"isOn",((...e)=>{const t=e.findIndex(Re.Z);return Ne(a,t<0?o.label:l[t].label)})),d.bind("isOn").toMany(l,"isOn",((...e)=>e.some(Re.Z))),d.bind("class").toMany(l,"isOn",((...e)=>e.some(Re.Z)?"ck-splitbutton_flatten":void 0)),d.on("execute",(()=>{l.some((({isOn:e})=>e))?c.isOpen=!c.isOpen:o.fire("execute")})),c.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some(Re.Z))),this.listenTo(c,"execute",(()=>{this.editor.editing.view.focus()})),c}))}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(Me(t),(i=>{const n=this.editor.commands.get("imageStyle"),o=new v.r5(i);return o.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(n,"isEnabled"),o.bind("isOn").to(n,"value",(e=>e===t)),o.on("execute",this._executeCommand.bind(this,t)),o}))}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function Be(e,t){for(const i of e)t[i.title]&&(i.title=t[i.title]);return e}function Me(e){return`imageStyle:${e}`}function Ne(e,t){return(e?e+": ":"")+t}class De extends n.Sy{static get requires(){return[Ie,Oe]}static get pluginName(){return"ImageStyle"}}class Le extends n.Sy{static get requires(){return[c.e8,m]}static get pluginName(){return"ImageToolbar"}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(c.e8),n=e.plugins.get("ImageUtils");var o;i.register("image",{ariaLabel:t("Image toolbar"),items:(o=e.config.get("image.toolbar")||[],o.map((e=>(0,Ve.Z)(e)?e.name:e))),getRelatedElement:e=>n.getClosestSelectedImageWidget(e)})}}class Fe extends n.Sy{static get requires(){return[P,m]}static get pluginName(){return"PictureEditing"}afterInit(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:["sources"]}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:["sources"]}),this._setupConversion(),this._setupImageUploadEditingIntegration()}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("upcast").add(function(e){const t=["srcset","media","type","sizes"],i=(i,n,o)=>{const s=n.viewItem;if(!o.consumable.test(s,{name:!0}))return;const r=new Map;for(const e of s.getChildren())if(e.is("element","source")){const i={};for(const n of t)e.hasAttribute(n)&&o.consumable.test(e,{attributes:n})&&(i[n]=e.getAttribute(n));Object.keys(i).length&&r.set(e,i)}const a=e.findViewImgElement(s);if(!a)return;let c=n.modelCursor.parent;if(!c.is("element","imageBlock")){const e=o.convertItem(a,n.modelCursor);n.modelRange=e.modelRange,n.modelCursor=e.modelCursor,c=(0,l.Ps)(e.modelRange.getItems())}o.consumable.consume(s,{name:!0});for(const[e,t]of r)o.consumable.consume(e,{attributes:Object.keys(t)});r.size&&o.writer.setAttribute("sources",Array.from(r.values()),c),o.convertChildren(s,c)};return e=>{e.on("element:picture",i)}}(i)),t.for("downcast").add(function(e){const t=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const o=n.writer,s=n.mapper.toViewElement(i.item),r=e.findViewImgElement(s),a=i.attributeNewValue;if(a&&a.length){const e=o.createContainerElement("picture",null,a.map((e=>o.createEmptyElement("source",e)))),t=[];let i=r.parent;for(;i&&i.is("attributeElement");){const e=i.parent;o.unwrap(o.createRangeOn(r),i),t.unshift(i),i=e}o.insert(o.createPositionBefore(r),e),o.move(o.createRangeOn(r),o.createPositionAt(e,"end"));for(const i of t)o.wrap(o.createRangeOn(e),i)}else if(r.parent.is("element","picture")){const e=r.parent;o.move(o.createRangeOn(r),o.createPositionBefore(e)),o.remove(e)}};return e=>{e.on("attribute:sources:imageBlock",t),e.on("attribute:sources:imageInline",t)}}(i))}_setupImageUploadEditingIntegration(){const e=this.editor;if(!e.plugins.has("ImageUploadEditing"))return;const t=e.plugins.get("ImageUploadEditing");this.listenTo(t,"uploadComplete",((t,{imageElement:i,data:n})=>{const o=n.sources;o&&e.model.change((e=>{e.setAttributes({sources:o},i)}))}))}}},3531:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Indent:()=>c,IndentBlock:()=>p,IndentEditing:()=>o,IndentUI:()=>l});var n=i(6854);class o extends n.Sy{static get pluginName(){return"IndentEditing"}init(){const e=this.editor;e.commands.add("indent",new n.AJ(e)),e.commands.add("outdent",new n.AJ(e))}}var s=i(7095);const r='',a='';class l extends n.Sy{static get pluginName(){return"IndentUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?r:a,o="ltr"==t.uiLanguageDirection?a:r;this._defineButton("indent",i("Increase indent"),n),this._defineButton("outdent",i("Decrease indent"),o)}_defineButton(e,t,i){const n=this.editor;n.ui.componentFactory.add(e,(o=>{const r=n.commands.get(e),a=new s.r5(o);return a.set({label:t,icon:i,tooltip:!0}),a.bind("isEnabled").to(r,"isEnabled"),this.listenTo(a,"execute",(()=>{n.execute(e),n.editing.view.focus()})),a}))}}class c extends n.Sy{static get pluginName(){return"Indent"}static get requires(){return[o,l]}}var d=i(3291),u=i(6553);class h extends n.mY{constructor(e,t){super(e),this._indentBehavior=t}refresh(){const e=this.editor.model,t=(0,u.Ps)(e.document.selection.getSelectedBlocks());t&&e.schema.checkAttribute(t,"blockIndent")?this.isEnabled=this._indentBehavior.checkEnabled(t.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const e=this.editor.model,t=function(e){const t=e.document.selection,i=e.schema;return Array.from(t.getSelectedBlocks()).filter((e=>i.checkAttribute(e,"blockIndent")))}(e);e.change((e=>{for(const i of t){const t=i.getAttribute("blockIndent"),n=this._indentBehavior.getNextIndent(t);n?e.setAttribute("blockIndent",n,i):e.removeAttribute("blockIndent",i)}}))}}class m{constructor(e){this.isForward="forward"===e.direction,this.offset=e.offset,this.unit=e.unit}checkEnabled(e){const t=parseFloat(e||"0");return this.isForward||t>0}getNextIndent(e){const t=parseFloat(e||"0");if(e&&!e.endsWith(this.unit))return this.isForward?this.offset+this.unit:void 0;const i=t+(this.isForward?this.offset:-this.offset);return i>0?i+this.unit:void 0}}class g{constructor(e){this.isForward="forward"===e.direction,this.classes=e.classes}checkEnabled(e){const t=this.classes.indexOf(e);return this.isForward?t=0}getNextIndent(e){const t=this.classes.indexOf(e),i=this.isForward?1:-1;return this.classes[t+i]}}const f=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];class p extends n.Sy{constructor(e){super(e),e.config.define("indentBlock",{offset:40,unit:"px"})}static get pluginName(){return"IndentBlock"}init(){const e=this.editor,t=e.config.get("indentBlock");t.classes&&t.classes.length?(this._setupConversionUsingClasses(t.classes),e.commands.add("indentBlock",new h(e,new g({direction:"forward",classes:t.classes}))),e.commands.add("outdentBlock",new h(e,new g({direction:"backward",classes:t.classes})))):(e.data.addStyleProcessorRules(d.vt),this._setupConversionUsingOffset(),e.commands.add("indentBlock",new h(e,new m({direction:"forward",offset:t.offset,unit:t.unit}))),e.commands.add("outdentBlock",new h(e,new m({direction:"backward",offset:t.offset,unit:t.unit}))))}afterInit(){const e=this.editor,t=e.model.schema,i=e.commands.get("indent"),n=e.commands.get("outdent"),o=e.config.get("heading.options");(o&&o.map((e=>e.model))||f).forEach((e=>{t.isRegistered(e)&&t.extend(e,{allowAttributes:"blockIndent"})})),t.setAttributeProperties("blockIndent",{isFormatting:!0}),i.registerChildCommand(e.commands.get("indentBlock")),n.registerChildCommand(e.commands.get("outdentBlock"))}_setupConversionUsingOffset(){const e=this.editor.conversion,t="rtl"===this.editor.locale.contentLanguageDirection?"margin-right":"margin-left";e.for("upcast").attributeToAttribute({view:{styles:{[t]:/[\s\S]+/}},model:{key:"blockIndent",value:e=>e.getStyle(t)}}),e.for("downcast").attributeToAttribute({model:"blockIndent",view:e=>({key:"style",value:{[t]:e}})})}_setupConversionUsingClasses(e){const t={model:{key:"blockIndent",values:[]},view:{}};for(const i of e)t.model.values.push(i),t.view[i]={key:"class",value:[i]};this.editor.conversion.attributeToAttribute(t)}}},5127:(e,t,i)=>{"use strict";i.r(t),i.d(t,{AutoLink:()=>ne,Link:()=>se,LinkCommand:()=>L,LinkEditing:()=>j,LinkImage:()=>de,LinkImageEditing:()=>re,LinkImageUI:()=>ce,LinkUI:()=>ee,UnlinkCommand:()=>z});var n=i(6854),o=i(3291),s=i(5187),r=i(4079),a=i(6553);class l{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach((e=>this._definitions.add(e))):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",((e,t,i)=>{if(!i.consumable.test(t.item,"attribute:linkHref"))return;if(!t.item.is("selection")&&!i.schema.isInline(t.item))return;const n=i.writer,o=n.document.selection;for(const e of this._definitions){const s=n.createAttributeElement("a",e.attributes,{priority:5});e.classes&&n.addClass(e.classes,s);for(const t in e.styles)n.setStyle(t,e.styles[t],s);n.setCustomProperty("link",!0,s),e.callback(t.attributeNewValue)?t.item.is("selection")?n.wrap(o.getFirstRange(),s):n.wrap(i.mapper.toViewRange(t.range),s):n.unwrap(i.mapper.toViewRange(t.range),s)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",((e,t,{writer:i,mapper:n})=>{const o=n.toViewElement(t.item),s=Array.from(o.getChildren()).find((e=>e.is("element","a")));for(const e of this._definitions){const n=(0,a.qL)(e.attributes);if(e.callback(t.attributeNewValue)){for(const[e,t]of n)"class"===e?i.addClass(t,s):i.setAttribute(e,t,s);e.classes&&i.addClass(e.classes,s);for(const t in e.styles)i.setStyle(t,e.styles[t],s)}else{for(const[e,t]of n)"class"===e?i.removeClass(t,s):i.removeAttribute(e,s);e.classes&&i.removeClass(e.classes,s);for(const t in e.styles)i.removeStyle(t,s)}}}))}}}var c=i(7855);var d=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const u=function(e){return d.test(e)};var h="\\ud800-\\udfff",m="["+h+"]",g="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",f="\\ud83c[\\udffb-\\udfff]",p="[^"+h+"]",b="(?:\\ud83c[\\udde6-\\uddff]){2}",w="[\\ud800-\\udbff][\\udc00-\\udfff]",v="(?:"+g+"|"+f+")?",_="[\\ufe0e\\ufe0f]?",y=_+v+"(?:\\u200d(?:"+[p,b,w].join("|")+")"+_+v+")*",k="(?:"+[p+g+"?",g,b,w,m].join("|")+")",C=RegExp(f+"(?="+f+")|"+k+y,"g");const A=function(e){return u(e)?function(e){return e.match(C)||[]}(e):function(e){return e.split("")}(e)};var E=i(9939);const x=function(e){e=(0,E.Z)(e);var t,i,n,o,s=u(e)?A(e):void 0,r=s?s[0]:e.charAt(0),a=s?(t=s,i=1,o=t.length,n=void 0===n?o:n,!i&&n>=o?t:(0,c.Z)(t,i,n)).join(""):e.slice(1);return r.toUpperCase()+a},T=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,S=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,P=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,I=/^((\w+:(\/{2,})?)|(\W))/i,V="Ctrl+K";function R(e,{writer:t}){const i=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,i),i}function O(e){const t=String(e);return function(e){return!!e.replace(T,"").match(S)}(t)?t:"#"}function B(e,t){return!!e&&t.checkAttribute(e.name,"linkHref")}function M(e,t){const i=(n=e,P.test(n)?"mailto:":t);var n;const o=!!i&&!N(e);return e&&o?i+e:e}function N(e){return I.test(e)}function D(e){window.open(e,"_blank","noopener")}class L extends n.mY{constructor(){super(...arguments),this.manualDecorators=new a.FE,this.automaticDecorators=new l}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement()||(0,a.Ps)(t.getSelectedBlocks());B(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={}){const i=this.editor.model,n=i.document.selection,o=[],r=[];for(const e in t)t[e]?o.push(e):r.push(e);i.change((t=>{if(n.isCollapsed){const l=n.getFirstPosition();if(n.hasAttribute("linkHref")){const a=F(n);let c=(0,s.VD)(l,"linkHref",n.getAttribute("linkHref"),i);n.getAttribute("linkHref")===a&&(c=this._updateLinkContent(i,t,c,e)),t.setAttribute("linkHref",e,c),o.forEach((e=>{t.setAttribute(e,!0,c)})),r.forEach((e=>{t.removeAttribute(e,c)})),t.setSelection(t.createPositionAfter(c.end.nodeBefore))}else if(""!==e){const s=(0,a.qL)(n.getAttributes());s.set("linkHref",e),o.forEach((e=>{s.set(e,!0)}));const{end:r}=i.insertContent(t.createText(e,s),l);t.setSelection(r)}["linkHref",...o,...r].forEach((e=>{t.removeSelectionAttribute(e)}))}else{const s=i.schema.getValidRanges(n.getRanges(),"linkHref"),a=[];for(const e of n.getSelectedBlocks())i.schema.checkAttribute(e,"linkHref")&&a.push(t.createRangeOn(e));const l=a.slice();for(const e of s)this._isRangeToUpdate(e,a)&&l.push(e);for(const s of l){let a=s;if(1===l.length){const o=F(n);n.getAttribute("linkHref")===o&&(a=this._updateLinkContent(i,t,s,e),t.setSelection(t.createSelection(a)))}t.setAttribute("linkHref",e,a),o.forEach((e=>{t.setAttribute(e,!0,a)})),r.forEach((e=>{t.removeAttribute(e,a)}))}}}))}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,n=i.getSelectedElement();return B(n,t.schema)?n.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}_updateLinkContent(e,t,i,n){const o=t.createText(n,{linkHref:n});return e.insertContent(o,i)}}function F(e){if(e.isCollapsed){const t=e.getFirstPosition();return t.textNode&&t.textNode.data}{const t=Array.from(e.getFirstRange().getItems());if(t.length>1)return null;const i=t[0];return i.is("$text")||i.is("$textProxy")?i.data:null}}class z extends n.mY{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();B(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,n=e.commands.get("link");t.change((e=>{const o=i.isCollapsed?[(0,s.VD)(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const t of o)if(e.removeAttribute("linkHref",t),n)for(const i of n.manualDecorators)e.removeAttribute(i.id,t)}))}}class H extends((0,a.Re)()){constructor({id:e,label:t,attributes:i,classes:n,styles:o,defaultValue:s}){super(),this.id=e,this.set("value",void 0),this.defaultValue=s,this.label=t,this.attributes=i,this.classes=n,this.styles=o}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}const W="automatic",U=/^(https?:)?\/\//;class j extends n.Sy{static get pluginName(){return"LinkEditing"}static get requires(){return[s.mh,s.II,r._l]}constructor(e){super(e),e.config.define("link",{addTargetToExternalLinks:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:R}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,t)=>R(O(e),t)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new L(e)),e.commands.add("unlink",new z(e));const t=function(e,t){const i={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach((e=>("label"in e&&i[e.label]&&(e.label=i[e.label]),e))),t}(e.t,function(e){const t=[];if(e)for(const[i,n]of Object.entries(e)){const e=Object.assign({},n,{id:`link${x(i)}`});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(t.filter((e=>e.mode===W))),this._enableManualDecorators(t.filter((e=>"manual"===e.mode))),e.plugins.get(s.mh).registerAttribute("linkHref"),(0,s.Im)(e,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterLink(),this._enableTypingOverLink(),this._handleDeleteContentAfterLink(),this._enableClipboardIntegration()}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:W,callback:e=>!!e&&U.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(e),i.length&&t.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach((e=>{t.model.schema.extend("$text",{allowAttributes:e.id});const n=new H(e);i.add(n),t.conversion.for("downcast").attributeToElement({model:n.id,view:(e,{writer:t,schema:i},{item:o})=>{if((o.is("selection")||i.isInline(o))&&e){const e=t.createAttributeElement("a",n.attributes,{priority:5});n.classes&&t.addClass(n.classes,e);for(const i in n.styles)t.setStyle(i,n.styles[i],e);return t.setCustomProperty("link",!0,e),e}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...n._createPattern()},model:{key:n.id}})}))}_enableLinkOpen(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",((e,t)=>{if(!(a.OB.isMac?t.domEvent.metaKey:t.domEvent.ctrlKey))return;let i=t.domTarget;if("a"!=i.tagName.toLowerCase()&&(i=i.closest("a")),!i)return;const n=i.getAttribute("href");n&&(e.stop(),t.preventDefault(),D(n))}),{context:"$capture"}),this.listenTo(t,"keydown",((t,i)=>{const n=e.commands.get("link").value;n&&i.keyCode===a.Do.enter&&i.altKey&&(t.stop(),D(n))}))}_enableInsertContentSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;this.listenTo(e,"insertContent",(()=>{const i=t.anchor.nodeBefore,n=t.anchor.nodeAfter;t.hasAttribute("linkHref")&&i&&i.hasAttribute("linkHref")&&(n&&n.hasAttribute("linkHref")||e.change((t=>{$(t,K(e.schema))})))}),{priority:"low"})}_enableClickingAfterLink(){const e=this.editor,t=e.model;e.editing.view.addObserver(o.dM);let i=!1;this.listenTo(e.editing.view.document,"mousedown",(()=>{i=!0})),this.listenTo(e.editing.view.document,"selectionChange",(()=>{if(!i)return;i=!1;const e=t.document.selection;if(!e.isCollapsed)return;if(!e.hasAttribute("linkHref"))return;const n=e.getFirstPosition(),o=(0,s.VD)(n,"linkHref",e.getAttribute("linkHref"),t);(n.isTouching(o.start)||n.isTouching(o.end))&&t.change((e=>{$(e,K(t.schema))}))}))}_enableTypingOverLink(){const e=this.editor,t=e.editing.view;let i=null,n=!1;this.listenTo(t.document,"delete",(()=>{n=!0}),{priority:"high"}),this.listenTo(e.model,"deleteContent",(()=>{const t=e.model.document.selection;t.isCollapsed||(n?n=!1:q(e)&&function(e){const t=e.document.selection,i=t.getFirstPosition(),n=t.getLastPosition(),o=i.nodeAfter;if(!o)return!1;if(!o.is("$text"))return!1;if(!o.hasAttribute("linkHref"))return!1;return o===(n.textNode||n.nodeBefore)||(0,s.VD)(i,"linkHref",o.getAttribute("linkHref"),e).containsRange(e.createRange(i,n),!0)}(e.model)&&(i=t.getAttributes()))}),{priority:"high"}),this.listenTo(e.model,"insertContent",((t,[o])=>{n=!1,q(e)&&i&&(e.model.change((e=>{for(const[t,n]of i)e.setAttribute(t,n,o)})),i=null)}),{priority:"high"})}_handleDeleteContentAfterLink(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view;let o=!1,r=!1;this.listenTo(n.document,"delete",((e,t)=>{r="backward"===t.direction}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{o=!1;const e=i.getFirstPosition(),n=i.getAttribute("linkHref");if(!n)return;const r=(0,s.VD)(e,"linkHref",n,t);o=r.containsPosition(e)||r.end.isEqual(e)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{r&&(r=!1,o||e.model.enqueueChange((e=>{$(e,K(t.schema))})))}),{priority:"low"})}_enableClipboardIntegration(){const e=this.editor,t=e.model,i=this.editor.config.get("link.defaultProtocol");i&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",((e,n)=>{t.change((e=>{const t=e.createRangeIn(n.content);for(const n of t.getItems())if(n.hasAttribute("linkHref")){const t=M(n.getAttribute("linkHref"),i);e.setAttribute("linkHref",t,n)}}))}))}}function $(e,t){e.removeSelectionAttribute("linkHref");for(const i of t)e.removeSelectionAttribute(i)}function q(e){return e.model.change((e=>e.batch)).isTyping}function K(e){return e.getDefinition("$text").allowAttributes.filter((e=>e.startsWith("link")))}var Z=i(7095),G=i(5549);class J extends Z.G7{constructor(e,t){super(e),this.focusTracker=new a.Rh,this.keystrokes=new a.VD,this._focusables=new Z.vX;const i=e.t;this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(i("Save"),n.icons.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(i("Cancel"),n.icons.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusCycler=new Z.I0({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const o=["ck","ck-link-form","ck-responsive-form"];t.manualDecorators.length&&o.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:o,tabindex:"-1"},children:this.children})}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((e,t)=>(e[t.name]=t.isOn,e)),{})}render(){super.render(),(0,Z.GI)({view:this}),[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const e=this.locale.t,t=new Z.KP(this.locale,Z.R);return t.label=e("Link URL"),t}_createButton(e,t,i,n){const o=new Z.r5(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:i}}),n&&o.delegate("execute").to(this,n),o}_createManualDecoratorSwitches(e){const t=this.createCollection();for(const i of e.manualDecorators){const n=new Z.BM(this.locale);n.set({name:i.id,label:i.label,withText:!0}),n.bind("isOn").toMany([i,e],"value",((e,t)=>void 0===t&&void 0===e?!!i.defaultValue:!!e)),n.on("execute",(()=>{i.set("value",!n.isOn)})),t.add(n)}return t}_createFormChildren(e){const t=this.createCollection();if(t.add(this.urlInputView),e.length){const e=new Z.G7;e.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((e=>({tag:"li",children:[e],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),t.add(e)}return t.add(this.saveButtonView),t.add(this.cancelButtonView),t}}class Y extends Z.G7{constructor(e){super(e),this.focusTracker=new a.Rh,this.keystrokes=new a.VD,this._focusables=new Z.vX;const t=e.t;this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(t("Unlink"),'',"unlink"),this.editButtonView=this._createButton(t("Edit link"),n.icons.pencil,"edit"),this.set("href",void 0),this._focusCycler=new Z.I0({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-actions","ck-responsive-form"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}render(){super.render(),[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(e,t,i){const n=new Z.r5(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n.delegate("execute").to(this,i),n}_createPreviewButton(){const e=new Z.r5(this.locale),t=this.bindTemplate,i=this.t;return e.set({withText:!0,tooltip:i("Open link in new tab")}),e.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:t.to("href",(e=>e&&O(e))),target:"_blank",rel:"noopener noreferrer"}}),e.bind("label").to(this,"href",(e=>e||i("This link has no URL"))),e.bind("isEnabled").to(this,"href",(e=>!!e)),e.template.tag="a",e.template.eventListeners={},e}}const Q='',X="link-ui";class ee extends n.Sy{constructor(){super(...arguments),this.actionsView=null,this.formView=null}static get requires(){return[Z.WB]}static get pluginName(){return"LinkUI"}init(){const e=this.editor;e.editing.view.addObserver(o.KU),this._balloon=e.plugins.get(Z.WB),this._createToolbarLinkButton(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:X,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:X,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy(),this.formView&&this.formView.destroy(),this.actionsView&&this.actionsView.destroy()}_createViews(){this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createActionsView(){const e=this.editor,t=new Y(e.locale),i=e.commands.get("link"),n=e.commands.get("unlink");return t.bind("href").to(i,"value"),t.editButtonView.bind("isEnabled").to(i),t.unlinkButtonView.bind("isEnabled").to(n),this.listenTo(t,"edit",(()=>{this._addFormView()})),this.listenTo(t,"unlink",(()=>{e.execute("unlink"),this._hideUI()})),t.keystrokes.set("Esc",((e,t)=>{this._hideUI(),t()})),t.keystrokes.set(V,((e,t)=>{this._addFormView(),t()})),t}_createFormView(){const e=this.editor,t=e.commands.get("link"),i=e.config.get("link.defaultProtocol"),n=new((0,Z.RX)(J))(e.locale,t);return n.urlInputView.fieldView.bind("value").to(t,"value"),n.urlInputView.bind("isEnabled").to(t,"isEnabled"),n.saveButtonView.bind("isEnabled").to(t),this.listenTo(n,"submit",(()=>{const{value:t}=n.urlInputView.fieldView.element,o=M(t,i);e.execute("link",o,n.getDecoratorSwitchesState()),this._closeFormView()})),this.listenTo(n,"cancel",(()=>{this._closeFormView()})),n.keystrokes.set("Esc",((e,t)=>{this._closeFormView(),t()})),n}_createToolbarLinkButton(){const e=this.editor,t=e.commands.get("link"),i=e.t;e.ui.componentFactory.add("link",(e=>{const n=new Z.r5(e);return n.isEnabled=!0,n.label=i("Link"),n.icon=Q,n.keystroke=V,n.tooltip=!0,n.isToggleable=!0,n.bind("isEnabled").to(t,"isEnabled"),n.bind("isOn").to(t,"value",(e=>!!e)),this.listenTo(n,"execute",(()=>this._showUI(!0))),n}))}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),e.keystrokes.set(V,((t,i)=>{i(),e.commands.get("link").isEnabled&&this._showUI(!0)}))}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",((e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((e,t)=>{this._isUIVisible&&(this._hideUI(),t())})),(0,Z.eC)({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this.actionsView||this._createViews(),this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions(),this.formView.urlInputView.fieldView.element.value=e.value||""}_closeFormView(){const e=this.editor.commands.get("link");e.restoreManualDecoratorStates(),void 0!==e.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedLinkElement(),n=s();const o=()=>{const e=this._getSelectedLinkElement(),t=s();i&&!e||!i&&t!==n?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=e,n=t};function s(){return t.selection.focus.getAncestors().reverse().find((e=>e.is("element")))}this.listenTo(e.ui,"update",o),this.listenTo(this._balloon,"change:visibleView",o)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _areActionsInPanel(){return!!this.actionsView&&this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return!!this.actionsView&&this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){const e=this._balloon.visibleView;return!!this.formView&&e==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model,i=e.document;let n;if(t.markers.has(X)){const t=Array.from(this.editor.editing.mapper.markerNameToElements(X)),i=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));n=e.domConverter.viewRangeToDom(i)}else n=()=>{const t=this._getSelectedLinkElement();return t?e.domConverter.mapViewToDom(t):e.domConverter.viewRangeToDom(i.selection.getFirstRange())};return{target:n}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,i=t.getSelectedElement();if(t.isCollapsed||i&&(0,G.Qd)(i))return te(t.getFirstPosition());{const i=t.getFirstRange().getTrimmed(),n=te(i.start),o=te(i.end);return n&&n==o&&e.createRangeIn(n).getTrimmed().isEqual(i)?n:null}}_showFakeVisualSelection(){const e=this.editor.model;e.change((t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(X))t.updateMarker(X,{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition((({item:t})=>!e.schema.isContent(t)),{boundaries:i});t.addMarker(X,{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker(X,{usingOperation:!1,affectsData:!1,range:i})}))}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(X)&&e.change((e=>{e.removeMarker(X)}))}}function te(e){return e.getAncestors().find((e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t}))||null}const ie=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63})))(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i");class ne extends n.Sy{static get requires(){return[s.HG]}static get pluginName(){return"AutoLink"}init(){const e=this.editor.model.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling()}_enableTypingHandling(){const e=this.editor,t=new s.uL(e.model,(e=>{if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(e))return;const t=oe(e.substr(0,e.length-1));return t?{url:t}:void 0}));t.on("matched:data",((t,i)=>{const{batch:n,range:o,url:s}=i;if(!n.isTyping)return;const r=o.end.getShiftedBy(-1),a=r.getShiftedBy(-s.length),l=e.model.createRange(a,r);this._applyAutoLink(s,l)})),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition();if(!e.parent.previousSibling)return;const i=t.createRangeIn(e.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(i)}))}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition(),i=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(i)}))}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:n}=(0,s.Up)(e,t),o=oe(i);if(o){const e=t.createRange(n.end.getShiftedBy(-o.length),n.end);this._applyAutoLink(o,e)}}_applyAutoLink(e,t){const i=this.editor.model,n=M(e,this.editor.config.get("link.defaultProtocol"));this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}(t,i)&&N(n)&&!function(e){const t=e.start.nodeAfter;return!!t&&t.hasAttribute("linkHref")}(t)&&this._persistAutoLink(n,t)}_persistAutoLink(e,t){const i=this.editor.model,n=this.editor.plugins.get("Delete");i.enqueueChange((o=>{o.setAttribute("linkHref",e,t),i.enqueueChange((()=>{n.requestUndoOnBackspace()}))}))}}function oe(e){const t=ie.exec(e);return t?t[2]:null}class se extends n.Sy{static get requires(){return[j,ee,ne]}static get pluginName(){return"Link"}}class re extends n.Sy{static get requires(){return["ImageEditing","ImageUtils",j]}static get pluginName(){return"LinkImageEditing"}init(){const e=this.editor,t=e.model.schema;e.plugins.has("ImageBlockEditing")&&t.extend("imageBlock",{allowAttributes:["linkHref"]}),e.conversion.for("upcast").add(function(e){const t=e.plugins.has("ImageInlineEditing"),i=e.plugins.get("ImageUtils");return e=>{e.on("element:a",((e,n,o)=>{const s=n.viewItem,r=i.findViewImgElement(s);if(!r)return;const a=r.findAncestor((e=>i.isBlockImageView(e)));if(t&&!a)return;if(!o.consumable.consume(s,{attributes:["href"]}))return;const l=s.getAttribute("href");if(!l)return;let c=n.modelCursor.parent;if(!c.is("element","imageBlock")){const e=o.convertItem(r,n.modelCursor);n.modelRange=e.modelRange,n.modelCursor=e.modelCursor,c=n.modelCursor.nodeBefore}c&&c.is("element","imageBlock")&&o.writer.setAttribute("linkHref",l,c)}),{priority:"high"})}}(e)),e.conversion.for("downcast").add(function(e){const t=e.plugins.get("ImageUtils");return e=>{e.on("attribute:linkHref:imageBlock",((e,i,n)=>{if(!n.consumable.consume(i.item,e.name))return;const o=n.mapper.toViewElement(i.item),s=n.writer,r=Array.from(o.getChildren()).find((e=>e.is("element","a"))),a=t.findViewImgElement(o),l=a.parent.is("element","picture")?a.parent:a;if(r)i.attributeNewValue?s.setAttribute("href",i.attributeNewValue,r):(s.move(s.createRangeOn(l),s.createPositionAt(o,0)),s.remove(r));else{const e=s.createContainerElement("a",{href:i.attributeNewValue});s.insert(s.createPositionAt(o,0),e),s.move(s.createRangeOn(l),s.createPositionAt(e,0))}}),{priority:"high"})}}(e)),this._enableAutomaticDecorators(),this._enableManualDecorators()}_enableAutomaticDecorators(){const e=this.editor,t=e.commands.get("link").automaticDecorators;t.length&&e.conversion.for("downcast").add(t.getDispatcherForLinkedImage())}_enableManualDecorators(){const e=this.editor,t=e.commands.get("link");for(const i of t.manualDecorators)e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:i.id}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:i.id}),e.conversion.for("downcast").add(ae(i)),e.conversion.for("upcast").add(le(e,i))}}function ae(e){return t=>{t.on(`attribute:${e.id}:imageBlock`,((t,i,n)=>{const o=n.mapper.toViewElement(i.item),s=Array.from(o.getChildren()).find((e=>e.is("element","a")));if(s){for(const[t,i]of(0,a.qL)(e.attributes))n.writer.setAttribute(t,i,s);e.classes&&n.writer.addClass(e.classes,s);for(const t in e.styles)n.writer.setStyle(t,e.styles[t],s)}}))}}function le(e,t){const i=e.plugins.has("ImageInlineEditing"),n=e.plugins.get("ImageUtils");return e=>{e.on("element:a",((e,s,r)=>{const a=s.viewItem,l=n.findViewImgElement(a);if(!l)return;const c=l.findAncestor((e=>n.isBlockImageView(e)));if(i&&!c)return;const d=new o.xO(t._createPattern()).match(a);if(!d)return;if(!r.consumable.consume(a,d.match))return;const u=s.modelCursor.nodeBefore||s.modelCursor.parent;r.writer.setAttribute(t.id,!0,u)}),{priority:"high"})}}class ce extends n.Sy{static get requires(){return[j,ee,"ImageBlockEditing"]}static get pluginName(){return"LinkImageUI"}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",((t,i)=>{this._isSelectedLinkedImage(e.model.document.selection)&&(i.preventDefault(),t.stop())}),{priority:"high"}),this._createToolbarLinkImageButton()}_createToolbarLinkImageButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("linkImage",(i=>{const n=new Z.r5(i),o=e.plugins.get("LinkUI"),s=e.commands.get("link");return n.set({isEnabled:!0,label:t("Link image"),icon:Q,keystroke:V,tooltip:!0,isToggleable:!0}),n.bind("isEnabled").to(s,"isEnabled"),n.bind("isOn").to(s,"value",(e=>!!e)),this.listenTo(n,"execute",(()=>{this._isSelectedLinkedImage(e.model.document.selection)?o._addActionsView():o._showUI(!0)})),n}))}_isSelectedLinkedImage(e){const t=e.getSelectedElement();return this.editor.plugins.get("ImageUtils").isImage(t)&&t.hasAttribute("linkHref")}}class de extends n.Sy{static get requires(){return[re,ce]}static get pluginName(){return"LinkImage"}}},6144:(e,t,i)=>{"use strict";i.r(t),i.d(t,{AdjacentListsSupport:()=>he,DocumentList:()=>ue,DocumentListEditing:()=>q,DocumentListIndentCommand:()=>T,DocumentListProperties:()=>Be,DocumentListPropertiesEditing:()=>Se,DocumentListPropertiesUtils:()=>xe,DocumentListUtils:()=>R,IndentCommand:()=>Me,List:()=>tt,ListEditing:()=>Xe,ListProperties:()=>ht,ListPropertiesEditing:()=>rt,ListPropertiesUI:()=>Re,ListUI:()=>de,ListUtils:()=>Fe,TodoList:()=>kt,TodoListEditing:()=>_t,TodoListUI:()=>yt});var n=i(6854),o=i(5187),s=i(1863),r=i(6553);class a{constructor(e,t){this._startElement=e,this._referenceIndent=e.getAttribute("listIndent"),this._isForward="forward"==t.direction,this._includeSelf=!!t.includeSelf,this._sameAttributes=(0,r.qo)(t.sameAttributes||[]),this._sameIndent=!!t.sameIndent,this._lowerIndent=!!t.lowerIndent,this._higherIndent=!!t.higherIndent}static first(e,t){const i=new this(e,t)[Symbol.iterator]();return(0,r.Ps)(i)}*[Symbol.iterator](){const e=[];for(const{node:t}of l(this._getStartNode(),this._isForward?"forward":"backward")){const i=t.getAttribute("listIndent");if(ithis._referenceIndent){if(!this._higherIndent)continue;if(!this._isForward){e.push(t);continue}}else{if(!this._sameIndent){if(this._higherIndent){e.length&&(yield*e,e.length=0);break}continue}if(this._sameAttributes.some((e=>t.getAttribute(e)!==this._startElement.getAttribute(e))))break}e.length&&(yield*e,e.length=0),yield t}}_getStartNode(){return this._includeSelf?this._startElement:this._isForward?this._startElement.nextSibling:this._startElement.previousSibling}}function*l(e,t="forward"){const i="forward"==t;let n=null;for(;u(e);)yield{node:e,previous:n},n=e,e=i?e.nextSibling:e.previousSibling}class c{constructor(e){this._listHead=e}[Symbol.iterator](){return l(this._listHead,"forward")}}class d{static next(){return(0,r.hQ)()}}function u(e){return!!e&&e.is("element")&&e.hasAttribute("listItemId")}function h(e,t={}){return[...m(e,{...t,direction:"backward"}),...m(e,{...t,direction:"forward"})]}function m(e,t={}){const i="forward"==t.direction,n=Array.from(new a(e,{...t,includeSelf:i,sameIndent:!0,sameAttributes:"listItemId"}));return i?n:n.reverse()}function g(e){const t=new a(e,{sameIndent:!0,sameAttributes:"listType"}),i=new a(e,{sameIndent:!0,sameAttributes:"listType",includeSelf:!0,direction:"forward"});return[...Array.from(t).reverse(),...i]}function f(e){return!a.first(e,{sameIndent:!0,sameAttributes:"listItemId"})}function p(e){return!a.first(e,{direction:"forward",sameIndent:!0,sameAttributes:"listItemId"})}function b(e,t={}){e=(0,r.qo)(e);const i=!1!==t.withNested,n=new Set;for(const t of e)for(const e of h(t,{higherIndent:i}))n.add(e);return A(n)}function w(e){e=(0,r.qo)(e);const t=new Set;for(const i of e)for(const e of g(i))t.add(e);return A(t)}function v(e,t){const i=m(e,{direction:"forward"}),n=d.next();for(const e of i)t.setAttribute("listItemId",n,e);return i}function _(e,t,i){const n={};for(const[e,i]of t.getAttributes())e.startsWith("list")&&(n[e]=i);const o=m(e,{direction:"forward"});for(const e of o)i.setAttributes(n,e);return o}function y(e,t,{expand:i,indentBy:n=1}={}){e=(0,r.qo)(e);const o=i?b(e):e;for(const e of o){const i=e.getAttribute("listIndent")+n;i<0?k(e,t):t.setAttribute("listIndent",i,e)}return o}function k(e,t){e=(0,r.qo)(e);for(const i of e)for(const e of i.getAttributeKeys())e.startsWith("list")&&t.removeAttribute(e,i);return e}function C(e){if(!e.length)return!1;const t=e[0].getAttribute("listItemId");return!!t&&!e.some((e=>e.getAttribute("listItemId")!=t))}function A(e){return Array.from(e).filter((e=>"$graveyard"!==e.root.rootName)).sort(((e,t)=>e.index-t.index))}function E(e){const t=e.document.selection.getSelectedElement();return t&&e.schema.isObject(t)&&e.schema.isBlock(t)?t:null}function x(e,t,i){return m(t,{direction:"forward"}).pop().index>e.index?_(e,t,i):[]}class T extends n.mY{constructor(e,t){super(e),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=S(e.document.selection);e.change((e=>{const i=[];C(t)&&!f(t[0])?("forward"==this._direction&&i.push(...y(t,e)),i.push(...v(t[0],e))):"forward"==this._direction?i.push(...y(t,e,{expand:!0})):i.push(...function(e,t){const i=b(e=(0,r.qo)(e)),n=new Set,o=Math.min(...i.map((e=>e.getAttribute("listIndent")))),s=new Map;for(const e of i)s.set(e,a.first(e,{lowerIndent:!0}));for(const e of i){if(n.has(e))continue;n.add(e);const i=e.getAttribute("listIndent")-1;if(i<0)k(e,t);else{if(e.getAttribute("listIndent")==o){const i=x(e,s.get(e),t);for(const e of i)n.add(e);if(i.length)continue}t.setAttribute("listIndent",i,e)}}return A(n)}(t,e));for(const t of i){if(!t.hasAttribute("listType"))continue;const i=a.first(t,{sameIndent:!0});i&&e.setAttribute("listType",i.getAttribute("listType"),t)}this._fireAfterExecute(i)}))}_fireAfterExecute(e){this.fire("afterExecute",A(new Set(e)))}_checkEnabled(){let e=S(this.editor.model.document.selection),t=e[0];if(!t)return!1;if("backward"==this._direction)return!0;if(C(e)&&!f(e[0]))return!0;e=b(e),t=e[0];const i=a.first(t,{sameIndent:!0});return!!i&&i.getAttribute("listType")==t.getAttribute("listType")}}function S(e){const t=Array.from(e.getSelectedBlocks()),i=t.findIndex((e=>!u(e)));return-1!=i&&(t.length=i),t}class P extends n.mY{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,n=E(t),o=Array.from(i.selection.getSelectedBlocks()).filter((e=>t.schema.checkAttribute(e,"listType"))),s=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(s){const t=o[o.length-1],i=m(t,{direction:"forward"}),n=[];i.length>1&&n.push(...v(i[1],e)),n.push(...k(o,e)),n.push(...function(e,t){const i=[];let n=Number.POSITIVE_INFINITY;for(const{node:o}of l(e.nextSibling,"forward")){const e=o.getAttribute("listIndent");if(0==e)break;e{const{firstElement:s,lastElement:r}=this._getMergeSubjectElements(i,e),l=s.getAttribute("listIndent")||0,c=r.getAttribute("listIndent"),d=r.getAttribute("listItemId");if(l!=c){const e=(u=r,Array.from(new a(u,{direction:"forward",higherIndent:!0})));n.push(...y([r,...e],o,{indentBy:l-c,expand:l{const t=v(this._getStartBlock(),e);this._fireAfterExecute(t)}))}_fireAfterExecute(e){this.fire("afterExecute",A(new Set(e)))}_checkEnabled(){const e=this.editor.model.document.selection,t=this._getStartBlock();return e.isCollapsed&&u(t)&&!f(t)}_getStartBlock(){const e=this.editor.model.document.selection.getFirstPosition().parent;return"before"==this._direction?e:e.nextSibling}}class R extends n.Sy{static get pluginName(){return"DocumentListUtils"}expandListBlocksToCompleteList(e){return w(e)}isFirstBlockOfListItem(e){return f(e)}isListItemBlock(e){return u(e)}expandListBlocksToCompleteItems(e,t={}){return b(e,t)}}var O=i(3291);function B(e){return e.is("element","ol")||e.is("element","ul")}function M(e){return e.is("element","li")}function N(e){let t=0,i=e.parent;for(;i;){if(M(i))t++;else{const e=i.previousSibling;e&&M(e)&&t++}i=i.parent}return t}function D(e,t,i,n=z(i,t)){return e.createAttributeElement(F(i),null,{priority:2*t/100-100,id:n})}function L(e,t,i){return e.createAttributeElement("li",null,{priority:(2*t+1)/100-100,id:i})}function F(e){return"numbered"==e?"ol":"ul"}function z(e,t){return`list-${e}-${t}`}function H(e,t){const i=e.nodeBefore;if(u(i)){let e=i;for(const{node:i}of l(e,"backward"))if(e=i,t.has(e))return;t.set(i,e)}else{const i=e.nodeAfter;u(i)&&t.set(i,i)}}function W(){return(e,t,i)=>{if(!i.consumable.test(t.viewItem,{name:!0}))return;const n=new O.yj(t.viewItem.document);for(const e of Array.from(t.viewItem.getChildren()))M(e)||B(e)||n.remove(e)}}function U(e,{dataPipeline:t}={}){return(i,{writer:n})=>{if(!j(i,e))return null;if(!t)return n.createContainerElement("span",{class:"ck-list-bogus-paragraph"});const o=n.createContainerElement("p");return n.setCustomProperty("dataPipeline:transparentRendering",!0,o),o}}function j(e,t,i=h(e)){if(!u(e))return!1;for(const i of e.getAttributeKeys())if(!i.startsWith("selection:")&&!t.includes(i))return!1;return i.length<2}const $=["listType","listIndent","listItemId"];class q extends n.Sy{constructor(){super(...arguments),this._downcastStrategies=[]}static get pluginName(){return"DocumentListEditing"}static get requires(){return[s.C,o.HG,R]}init(){const e=this.editor,t=e.model;if(e.plugins.has("ListEditing"))throw new r.Bb("document-list-feature-conflict",this,{conflictPlugin:"ListEditing"});t.schema.extend("$container",{allowAttributes:$}),t.schema.extend("$block",{allowAttributes:$}),t.schema.extend("$blockObject",{allowAttributes:$});for(const e of $)t.schema.setAttributeProperties(e,{copyOnReplace:!0});e.commands.add("numberedList",new P(e,"numbered")),e.commands.add("bulletedList",new P(e,"bulleted")),e.commands.add("indentList",new T(e,"forward")),e.commands.add("outdentList",new T(e,"backward")),e.commands.add("mergeListItemBackward",new I(e,"backward")),e.commands.add("mergeListItemForward",new I(e,"forward")),e.commands.add("splitListItemBefore",new V(e,"before")),e.commands.add("splitListItemAfter",new V(e,"after")),this._setupDeleteIntegration(),this._setupEnterIntegration(),this._setupTabIntegration(),this._setupClipboardIntegration()}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList"),{priority:"high"}),i&&i.registerChildCommand(e.get("outdentList"),{priority:"lowest"}),this._setupModelPostFixing(),this._setupConversion()}registerDowncastStrategy(e){this._downcastStrategies.push(e)}_getListAttributeNames(){return[...$,...this._downcastStrategies.map((e=>e.attributeName))]}_setupDeleteIntegration(){const e=this.editor,t=e.commands.get("mergeListItemBackward"),i=e.commands.get("mergeListItemForward");this.listenTo(e.editing.view.document,"delete",((n,o)=>{const s=e.model.document.selection;E(e.model)||e.model.change((()=>{const r=s.getFirstPosition();if(s.isCollapsed&&"backward"==o.direction){if(!r.isAtStart)return;const i=r.parent;if(!u(i))return;if(a.first(i,{sameAttributes:"listType",sameIndent:!0})||0!==i.getAttribute("listIndent")){if(!t.isEnabled)return;t.execute({shouldMergeOnBlocksContentLevel:K(e.model,"backward")})}else p(i)||e.execute("splitListItemAfter"),e.execute("outdentList");o.preventDefault(),n.stop()}else{if(s.isCollapsed&&!s.getLastPosition().isAtEnd)return;if(!i.isEnabled)return;i.execute({shouldMergeOnBlocksContentLevel:K(e.model,"forward")}),o.preventDefault(),n.stop()}}))}),{context:"li"})}_setupEnterIntegration(){const e=this.editor,t=e.model,i=e.commands,n=i.get("enter");this.listenTo(e.editing.view.document,"enter",((i,n)=>{const o=t.document,s=o.selection.getFirstPosition().parent;if(o.selection.isCollapsed&&u(s)&&s.isEmpty&&!n.isSoft){const t=f(s),o=p(s);t&&o?(e.execute("outdentList"),n.preventDefault(),i.stop()):t&&!o?(e.execute("splitListItemAfter"),n.preventDefault(),i.stop()):o&&(e.execute("splitListItemBefore"),n.preventDefault(),i.stop())}}),{context:"li"}),this.listenTo(n,"afterExecute",(()=>{const t=i.get("splitListItemBefore");t.refresh(),t.isEnabled&&2===h(e.model.document.selection.getLastPosition().parent).length&&t.execute()}))}_setupTabIntegration(){const e=this.editor;this.listenTo(e.editing.view.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"li"})}_setupConversion(){const e=this.editor,t=e.model,i=this._getListAttributeNames();e.conversion.for("upcast").elementToElement({view:"li",model:"paragraph"}).add((e=>{e.on("element:li",((e,t,i)=>{const{writer:n,schema:o}=i;if(!t.modelRange)return;const s=Array.from(t.modelRange.getItems({shallow:!0})).filter((e=>o.checkAttribute(e,"listItemId")));if(!s.length)return;const r={listItemId:d.next(),listIndent:N(t.viewItem),listType:t.viewItem.parent&&t.viewItem.parent.is("element","ol")?"numbered":"bulleted"};for(const e of s)u(e)||n.setAttributes(r,e);s.length>1&&s[1].getAttribute("listItemId")!=r.listItemId&&i.keepEmptyElement(s[0])})),e.on("element:ul",W(),{priority:"high"}),e.on("element:ol",W(),{priority:"high"})})),e.conversion.for("editingDowncast").elementToElement({model:"paragraph",view:U(i),converterPriority:"high"}),e.conversion.for("dataDowncast").elementToElement({model:"paragraph",view:U(i,{dataPipeline:!0}),converterPriority:"high"}),e.conversion.for("downcast").add((e=>{e.on("attribute",function(e,t,i){const n=function(e){return(t,i)=>{const n=[];for(const i of e)t.hasAttribute(i)&&n.push(`attribute:${i}`);return!!n.every((e=>!1!==i.test(t,e)))&&(n.forEach((e=>i.consume(t,e))),!0)}}(e);return(o,s,r)=>{const{writer:l,mapper:c,consumable:d}=r,u=s.item;if(!e.includes(s.attributeKey))return;if(!n(u,d))return;const h=function(e,t,i){const n=i.createRangeOn(e);return t.toViewRange(n).getTrimmed().getContainedElement()}(u,c,i);!function(e,t){let i=e.parent;for(;i.is("attributeElement")&&["ul","ol","li"].includes(i.name);){const n=i.parent;t.unwrap(t.createRangeOn(e),i),i=n}}(h,l),function(e,t,i,n){if(!e.hasAttribute("listIndent"))return;const o=e.getAttribute("listIndent");let s=e;for(let e=o;e>=0;e--){const o=L(n,e,s.getAttribute("listItemId")),r=D(n,e,s.getAttribute("listType"));for(const e of i)s.hasAttribute(e.attributeName)&&e.setAttributeOnDowncast(n,s.getAttribute(e.attributeName),"list"==e.scope?r:o);if(t=n.wrap(t,o),t=n.wrap(t,r),0==e)break;if(s=a.first(s,{lowerIndent:!0}),!s)break}}(u,l.createRangeOn(h),t,l)}}(i,this._downcastStrategies,t))})),this.listenTo(t.document,"change:data",function(e,t,i,n){return()=>{const n=e.document.differ.getChanges(),r=[],a=new Map,l=new Set;for(const e of n)if("insert"==e.type&&"$text"!=e.name)H(e.position,a),e.attributes.has("listItemId")?l.add(e.position.nodeAfter):H(e.position.getShiftedBy(e.length),a);else if("remove"==e.type&&e.attributes.has("listItemId"))H(e.position,a);else if("attribute"==e.type){const t=e.range.start.nodeAfter;i.includes(e.attributeKey)?(H(e.range.start,a),null===e.attributeNewValue?(H(e.range.start.getShiftedBy(1),a),s(t)&&r.push(t)):l.add(t)):u(t)&&s(t)&&r.push(t)}for(const e of a.values())r.push(...o(e,l));for(const e of new Set(r))t.reconvertItem(e)};function o(e,t){const n=[],o=new Set,a=[];for(const{node:c,previous:d}of l(e,"forward")){if(o.has(c))continue;const e=c.getAttribute("listIndent");d&&ei.includes(e))));const l=m(c,{direction:"forward"});for(const e of l)o.add(e),(s(e,l)||r(e,a,t))&&n.push(e)}return n}function s(e,n){if(!e.is("element","paragraph"))return!1;const o=t.mapper.toViewElement(e);if(!o)return!1;const s=j(e,i,n);return!(!s||!o.is("element","p"))||!(s||!o.is("element","span"))}function r(e,i,o){if(o.has(e))return!1;const s=t.mapper.toViewElement(e);let r=i.length-1;for(let e=s.parent;!e.is("editableElement");e=e.parent){const t=M(e),o=B(e);if(!o&&!t)continue;const s="checkAttributes:"+(t?"item":"list");if(n.fire(s,{viewElement:e,modelAttributes:i[r]}))break;if(o&&(r--,r<0))return!1}return!0}}(t,e.editing,i,this),{priority:"high"}),this.on("checkAttributes:item",((e,{viewElement:t,modelAttributes:i})=>{t.id!=i.listItemId&&(e.return=!0,e.stop())})),this.on("checkAttributes:list",((e,{viewElement:t,modelAttributes:i})=>{t.name==F(i.listType)&&t.id==z(i.listType,i.listIndent)||(e.return=!0,e.stop())}))}_setupModelPostFixing(){const e=this.editor.model,t=this._getListAttributeNames();e.document.registerPostFixer((i=>function(e,t,i,n){const o=e.document.differ.getChanges(),s=new Map;let r=!1;for(const n of o)if("insert"==n.type&&"$text"!=n.name){const o=n.position.nodeAfter;if(!e.schema.checkAttribute(o,"listItemId"))for(const e of Array.from(o.getAttributeKeys()))i.includes(e)&&(t.removeAttribute(e,o),r=!0);H(n.position,s),n.attributes.has("listItemId")||H(n.position.getShiftedBy(n.length),s);for(const{item:t,previousPosition:i}of e.createRangeIn(o))u(t)&&H(i,s)}else"remove"==n.type?H(n.position,s):"attribute"==n.type&&i.includes(n.attributeKey)&&(H(n.range.start,s),null===n.attributeNewValue&&H(n.range.start.getShiftedBy(1),s));const a=new Set;for(const e of s.values())r=n.fire("postFixer",{listNodes:new c(e),listHead:e,writer:t,seenIds:a})||r;return r}(e,i,t,this))),this.on("postFixer",((e,{listNodes:t,writer:i})=>{e.return=function(e,t){let i=0,n=-1,o=null,s=!1;for(const{node:r}of e){const e=r.getAttribute("listIndent");if(e>i){let a;null===o?(o=e-i,a=i):(o>e&&(o=e),a=e-o),a>n+1&&(a=n+1),t.setAttribute("listIndent",a,r),s=!0,n=a}else o=null,i=e+1,n=e}return s}(t,i)||e.return}),{priority:"high"}),this.on("postFixer",((e,{listNodes:t,writer:i,seenIds:n})=>{e.return=function(e,t,i){const n=new Set;let o=!1;for(const{node:s}of e){if(n.has(s))continue;let e=s.getAttribute("listType"),r=s.getAttribute("listItemId");t.has(r)&&(r=d.next()),t.add(r);for(const t of m(s,{direction:"forward"}))n.add(t),t.getAttribute("listType")!=e&&(r=d.next(),e=t.getAttribute("listType")),t.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,t),o=!0)}return o}(t,n,i)||e.return}),{priority:"high"})}_setupClipboardIntegration(){const e=this.editor.model;this.listenTo(e,"insertContent",function(e){return(t,[i,n])=>{const o=i.is("documentFragment")?i.getChild(0):i;if(!u(o))return;let s;s=n?e.createSelection(n):e.document.selection;const r=s.getFirstPosition();let a=null;if(u(r.parent)?a=r.parent:u(r.nodeBefore)&&(a=r.nodeBefore),!a)return;const c=a.getAttribute("listIndent")-o.getAttribute("listIndent");c<=0||e.change((e=>{for(const{node:t}of l(o,"forward"))e.setAttribute("listIndent",t.getAttribute("listIndent")+c,t)}))}}(e),{priority:"high"}),this.listenTo(e,"getSelectedContent",((t,[i])=>{C(Array.from(i.getSelectedBlocks()))&&e.change((e=>k(Array.from(t.return.getChildren()),e)))}))}}function K(e,t){const i=e.document.selection;if(!i.isCollapsed)return!E(e);if("forward"===t)return!0;const n=i.getFirstPosition().parent,o=n.previousSibling;return!e.schema.isObject(o)&&(!!o.isEmpty||C([n,o]))}var Z=i(7095);function G(e,t){const i=t.mapper,n=t.writer,o="numbered"==e.getAttribute("listType")?"ol":"ul",s=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=ae,t}(n),r=n.createContainerElement(o,null);return n.insert(n.createPositionAt(r,0),s),i.bindElements(e,s),s}function J(e,t,i,n){const o=t.parent,s=i.mapper,r=i.writer;let a=s.toViewPosition(n.createPositionBefore(e));const l=X(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),c=e.previousSibling;if(l&&l.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=s.toViewElement(l);a=r.breakContainer(r.createPositionAfter(e))}else if(c&&"listItem"==c.name){a=s.toViewPosition(n.createPositionAt(c,"end"));const e=s.findMappedViewAncestor(a),t=te(e);a=t?r.createPositionBefore(t):r.createPositionAt(e,"end")}else a=s.toViewPosition(n.createPositionBefore(e));if(a=Q(a),r.insert(a,o),c&&"listItem"==c.name){const e=s.toViewElement(c),i=r.createRange(r.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of i)if(e.item.is("element","li")){const n=r.breakContainer(r.createPositionBefore(e.item)),o=e.item.parent,s=r.createPositionAt(t,"end");Y(r,s.nodeBefore,s.nodeAfter),r.move(r.createRangeOn(o),s),i._position=n}}else{const i=o.nextSibling;if(i&&(i.is("element","ul")||i.is("element","ol"))){let n=null;for(const t of i.getChildren()){const i=s.toModelElement(t);if(!(i&&i.getAttribute("listIndent")>e.getAttribute("listIndent")))break;n=t}n&&(r.breakContainer(r.createPositionAfter(n)),r.move(r.createRangeOn(n.parent),r.createPositionAt(t,"end")))}}Y(r,o,o.nextSibling),Y(r,o.previousSibling,o)}function Y(e,t,i){return!t||!i||"ul"!=t.name&&"ol"!=t.name||t.name!=i.name||t.getAttribute("class")!==i.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function Q(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function X(e,t){const i=!!t.sameIndent,n=!!t.smallerIndent,o=t.listIndent;let s=e;for(;s&&"listItem"==s.name;){const e=s.getAttribute("listIndent");if(i&&o==e||n&&o>e)return s;s="forward"===t.direction?s.nextSibling:s.previousSibling}return null}function ee(e,t,i,n){e.ui.componentFactory.add(t,(o=>{const s=e.commands.get(t),r=new Z.r5(o);return r.set({label:i,icon:n,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(s,"value","isEnabled"),r.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),r}))}function te(e){for(const t of e.getChildren())if("ul"==t.name||"ol"==t.name)return t;return null}function ie(e,t){const i=[],n=e.parent,o={ignoreElementEnd:!1,startPosition:e,shallow:!0,direction:t},s=n.getAttribute("listIndent"),r=[...new O.Po(o)].filter((e=>e.item.is("element"))).map((e=>e.item));for(const e of r){if(!e.is("element","listItem"))break;if(e.getAttribute("listIndent")s)){if(e.getAttribute("listType")!==n.getAttribute("listType"))break;if(e.getAttribute("listStyle")!==n.getAttribute("listStyle"))break;if(e.getAttribute("listReversed")!==n.getAttribute("listReversed"))break;if(e.getAttribute("listStart")!==n.getAttribute("listStart"))break;"backward"===t?i.unshift(e):i.push(e)}}return i}function ne(e){let t=[...e.document.selection.getSelectedBlocks()].filter((e=>e.is("element","listItem"))).map((t=>{const i=e.change((e=>e.createPositionAt(t,0)));return[...ie(i,"backward"),...ie(i,"forward")]})).flat();return t=[...new Set(t)],t}const oe=["disc","circle","square"],se=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function re(e){return oe.includes(e)?"bulleted":se.includes(e)?"numbered":null}function ae(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:O.YG.call(this)}const le='',ce='';class de extends n.Sy{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;ee(this.editor,"numberedList",e("Numbered List"),le),ee(this.editor,"bulletedList",e("Bulleted List"),ce)}}class ue extends n.Sy{static get requires(){return[q,de]}static get pluginName(){return"DocumentList"}}class he extends n.Sy{static get pluginName(){return"AdjacentListsSupport"}init(){const e=this.editor;e.model.schema.register("listSeparator",{allowWhere:"$block",isBlock:!0}),e.conversion.for("upcast").add((e=>{e.on("element:ol",me()),e.on("element:ul",me())})).elementToElement({model:"listSeparator",view:"ck-list-separator"}),e.conversion.for("editingDowncast").elementToElement({model:"listSeparator",view:{name:"div",classes:["ck-list-separator","ck-hidden"]}}),e.conversion.for("dataDowncast").elementToElement({model:"listSeparator",view:(e,t)=>{const i=t.writer.createContainerElement("ck-list-separator");return t.writer.setCustomProperty("dataPipeline:transparentRendering",!0,i),i.getFillerOffset=()=>null,i}})}}function me(){return(e,t,i)=>{const n=t.viewItem,o=n.nextSibling;if(!o)return;if(n.name!==o.name)return;t.modelRange||Object.assign(t,i.convertChildren(t.viewItem,t.modelCursor));const s=i.writer,r=s.createElement("listSeparator");if(!i.safeInsert(r,t.modelCursor))return;const a=i.getSplitParts(r);t.modelRange=s.createRange(t.modelRange.start,s.createPositionAfter(a[a.length-1])),i.updateConversionResult(r,t)}}class ge extends n.mY{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute({startIndex:e=1}={}){const t=this.editor.model,i=t.document;let n=Array.from(i.selection.getSelectedBlocks()).filter((e=>u(e)&&"numbered"==e.getAttribute("listType")));n=w(n),t.change((t=>{for(const i of n)t.setAttribute("listStart",e>=0?e:1,i)}))}_getValue(){const e=this.editor.model.document,t=(0,r.Ps)(e.selection.getSelectedBlocks());return t&&u(t)&&"numbered"==t.getAttribute("listType")?t.getAttribute("listStart"):null}}const fe={},pe={},be={},we=[{listStyle:"disc",typeAttribute:"disc",listType:"bulleted"},{listStyle:"circle",typeAttribute:"circle",listType:"bulleted"},{listStyle:"square",typeAttribute:"square",listType:"bulleted"},{listStyle:"decimal",typeAttribute:"1",listType:"numbered"},{listStyle:"decimal-leading-zero",typeAttribute:null,listType:"numbered"},{listStyle:"lower-roman",typeAttribute:"i",listType:"numbered"},{listStyle:"upper-roman",typeAttribute:"I",listType:"numbered"},{listStyle:"lower-alpha",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-alpha",typeAttribute:"A",listType:"numbered"},{listStyle:"lower-latin",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-latin",typeAttribute:"A",listType:"numbered"}];for(const{listStyle:e,typeAttribute:t,listType:i}of we)fe[e]=i,pe[e]=t,t&&(be[t]=e);function ve(){return we.map((e=>e.listStyle))}function _e(e){return fe[e]||null}function ye(e){return be[e]||null}function ke(e){return pe[e]||null}class Ce extends n.mY{constructor(e,t,i){super(e),this.defaultType=t,this._supportedTypes=i}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document;t.change((t=>{this._tryToConvertItemsToList(e);let n=Array.from(i.selection.getSelectedBlocks()).filter((e=>e.hasAttribute("listType")));if(n.length){n=w(n);for(const i of n)t.setAttribute("listStyle",e.type||this.defaultType,i)}}))}isStyleTypeSupported(e){return!this._supportedTypes||this._supportedTypes.includes(e)}_getValue(){const e=(0,r.Ps)(this.editor.model.document.selection.getSelectedBlocks());return u(e)?e.getAttribute("listStyle"):null}_checkEnabled(){const e=this.editor,t=e.commands.get("numberedList"),i=e.commands.get("bulletedList");return t.isEnabled||i.isEnabled}_tryToConvertItemsToList(e){if(!e.type)return;const t=_e(e.type);if(!t)return;const i=this.editor,n=`${t}List`;i.commands.get(n).value||i.execute(n)}}class Ae extends n.mY{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute(e={}){const t=this.editor.model,i=t.document;let n=Array.from(i.selection.getSelectedBlocks()).filter((e=>u(e)&&"numbered"==e.getAttribute("listType")));n=w(n),t.change((t=>{for(const i of n)t.setAttribute("listReversed",!!e.reversed,i)}))}_getValue(){const e=this.editor.model.document,t=(0,r.Ps)(e.selection.getSelectedBlocks());return u(t)&&"numbered"==t.getAttribute("listType")?t.getAttribute("listReversed"):null}}function Ee(e){return(t,i,n)=>{const{writer:o,schema:s,consumable:r}=n;if(!1===r.test(i.viewItem,e.viewConsumables))return;i.modelRange||Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor));let a=!1;for(const t of i.modelRange.getItems({shallow:!0}))s.checkAttribute(t,e.attributeName)&&e.appliesToListItem(t)&&(t.hasAttribute(e.attributeName)||(o.setAttribute(e.attributeName,e.getAttributeOnUpcast(i.viewItem),t),a=!0));a&&r.consume(i.viewItem,e.viewConsumables)}}class xe extends n.Sy{static get pluginName(){return"DocumentListPropertiesUtils"}getAllSupportedStyleTypes(){return ve()}getListTypeFromListStyleType(e){return _e(e)}getListStyleTypeFromTypeAttribute(e){return ye(e)}getTypeAttributeFromListStyleType(e){return ke(e)}}const Te="default";class Se extends n.Sy{static get requires(){return[q,xe]}static get pluginName(){return"DocumentListPropertiesEditing"}constructor(e){super(e),e.config.define("list",{properties:{styles:!0,startIndex:!1,reversed:!1}})}init(){const e=this.editor,t=e.model,i=e.plugins.get(q),n=function(e){const t=[];if(e.styles){const i="object"==typeof e.styles&&e.styles.useAttribute;t.push({attributeName:"listStyle",defaultValue:Te,viewConsumables:{styles:"list-style-type"},addCommand(e){let t=ve();i&&(t=t.filter((e=>!!ke(e)))),e.commands.add("listStyle",new Ce(e,Te,t))},appliesToListItem:()=>!0,hasValidAttribute(e){if(!e.hasAttribute("listStyle"))return!1;const t=e.getAttribute("listStyle");return t==Te||_e(t)==e.getAttribute("listType")},setAttributeOnDowncast(e,t,n){if(t&&t!==Te){if(!i)return void e.setStyle("list-style-type",t,n);{const i=ke(t);if(i)return void e.setAttribute("type",i,n)}}e.removeStyle("list-style-type",n),e.removeAttribute("type",n)},getAttributeOnUpcast(e){const t=e.getStyle("list-style-type");if(t)return t;const i=e.getAttribute("type");return i?ye(i):Te}})}return e.reversed&&t.push({attributeName:"listReversed",defaultValue:!1,viewConsumables:{attributes:"reversed"},addCommand(e){e.commands.add("listReversed",new Ae(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),hasValidAttribute(e){return this.appliesToListItem(e)==e.hasAttribute("listReversed")},setAttributeOnDowncast(e,t,i){t?e.setAttribute("reversed","reversed",i):e.removeAttribute("reversed",i)},getAttributeOnUpcast:e=>e.hasAttribute("reversed")}),e.startIndex&&t.push({attributeName:"listStart",defaultValue:1,viewConsumables:{attributes:"start"},addCommand(e){e.commands.add("listStart",new ge(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),hasValidAttribute(e){return this.appliesToListItem(e)==e.hasAttribute("listStart")},setAttributeOnDowncast(e,t,i){0==t||t>1?e.setAttribute("start",t,i):e.removeAttribute("start",i)},getAttributeOnUpcast(e){const t=e.getAttribute("start");return t>=0?t:1}}),t}(e.config.get("list.properties"));for(const o of n)o.addCommand(e),t.schema.extend("$container",{allowAttributes:o.attributeName}),t.schema.extend("$block",{allowAttributes:o.attributeName}),t.schema.extend("$blockObject",{allowAttributes:o.attributeName}),i.registerDowncastStrategy({scope:"list",attributeName:o.attributeName,setAttributeOnDowncast(e,t,i){o.setAttributeOnDowncast(e,t,i)}});e.conversion.for("upcast").add((e=>{for(const t of n)e.on("element:ol",Ee(t)),e.on("element:ul",Ee(t))})),i.on("checkAttributes:list",((e,{viewElement:t,modelAttributes:i})=>{for(const o of n)o.getAttributeOnUpcast(t)!=i[o.attributeName]&&(e.return=!0,e.stop())})),this.listenTo(e.commands.get("indentList"),"afterExecute",((e,i)=>{t.change((e=>{for(const t of i)for(const i of n)i.appliesToListItem(t)&&e.setAttribute(i.attributeName,i.defaultValue,t)}))})),i.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:o}of t)for(const t of n)t.hasValidAttribute(o)||(t.appliesToListItem(o)?i.setAttribute(t.attributeName,t.defaultValue,o):i.removeAttribute(t.attributeName,o),e.return=!0)})),i.on("postFixer",((e,{listNodes:t,writer:i})=>{const o=[];for(const{node:s,previous:r}of t){if(!r)continue;const t=s.getAttribute("listIndent"),a=r.getAttribute("listIndent");let l=null;if(t>a?o[a]=r:tString(e)))}}),e.bind("label").to(this),e.bind("isOn").to(this,"isCollapsed",(e=>!e)),e.on("execute",(()=>{this.isCollapsed=!this.isCollapsed})),e}}class Ve extends Z.G7{constructor(e,{enabledProperties:t,styleButtonViews:i,styleGridAriaLabel:n}){super(e),this.stylesView=null,this.additionalPropertiesCollapsibleView=null,this.startIndexFieldView=null,this.reversedSwitchButtonView=null,this.focusTracker=new r.Rh,this.keystrokes=new r.VD,this.focusables=new Z.vX;const o=["ck","ck-list-properties"];this.children=this.createCollection(),this.focusCycler=new Z.I0({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),t.styles?(this.stylesView=this._createStylesView(i,n),this.children.add(this.stylesView)):o.push("ck-list-properties_without-styles"),(t.startIndex||t.reversed)&&(this._addNumberedListPropertyViews(t),o.push("ck-list-properties_with-numbered-properties")),this.setTemplate({tag:"div",attributes:{class:o},children:this.children})}render(){if(super.render(),this.stylesView){this.focusables.add(this.stylesView),this.focusTracker.add(this.stylesView.element),(this.startIndexFieldView||this.reversedSwitchButtonView)&&(this.focusables.add(this.children.last.buttonView),this.focusTracker.add(this.children.last.buttonView.element));for(const e of this.stylesView.children)this.stylesView.focusTracker.add(e.element);(0,Z.IJ)({keystrokeHandler:this.stylesView.keystrokes,focusTracker:this.stylesView.focusTracker,gridItems:this.stylesView.children,numberOfColumns:()=>r.CO.window.getComputedStyle(this.stylesView.element).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}if(this.startIndexFieldView){this.focusables.add(this.startIndexFieldView),this.focusTracker.add(this.startIndexFieldView.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}this.reversedSwitchButtonView&&(this.focusables.add(this.reversedSwitchButtonView),this.focusTracker.add(this.reversedSwitchButtonView.element)),this.keystrokes.listenTo(this.element)}focus(){this.focusCycler.focusFirst()}focusLast(){this.focusCycler.focusLast()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createStylesView(e,t){const i=new Z.G7(this.locale);return i.children=i.createCollection(),i.children.addMany(e),i.setTemplate({tag:"div",attributes:{"aria-label":t,class:["ck","ck-list-styles-list"]},children:i.children}),i.children.delegate("execute").to(this),i.focus=function(){this.children.first.focus()},i.focusTracker=new r.Rh,i.keystrokes=new r.VD,i.render(),i.keystrokes.listenTo(i.element),i}_addNumberedListPropertyViews(e){const t=this.locale.t,i=[];e.startIndex&&(this.startIndexFieldView=this._createStartIndexField(),i.push(this.startIndexFieldView)),e.reversed&&(this.reversedSwitchButtonView=this._createReversedSwitchButton(),i.push(this.reversedSwitchButtonView)),e.styles?(this.additionalPropertiesCollapsibleView=new Ie(this.locale,i),this.additionalPropertiesCollapsibleView.set({label:t("List properties"),isCollapsed:!0}),this.additionalPropertiesCollapsibleView.buttonView.bind("isEnabled").toMany(i,"isEnabled",((...e)=>e.some((e=>e)))),this.additionalPropertiesCollapsibleView.buttonView.on("change:isEnabled",((e,t,i)=>{i||(this.additionalPropertiesCollapsibleView.isCollapsed=!0)})),this.children.add(this.additionalPropertiesCollapsibleView)):this.children.addMany(i)}_createStartIndexField(){const e=this.locale.t,t=new Z.KP(this.locale,Z.sh);return t.set({label:e("Start at"),class:"ck-numbered-list-properties__start-index"}),t.fieldView.set({min:0,step:1,value:1,inputMode:"numeric"}),t.fieldView.on("input",(()=>{const i=t.fieldView.element,n=i.valueAsNumber;Number.isNaN(n)||(i.checkValidity()?this.fire("listStart",{startIndex:n}):t.errorText=e("Start index must be greater than 0."))})),t}_createReversedSwitchButton(){const e=this.locale.t,t=new Z.BM(this.locale);return t.set({withText:!0,label:e("Reversed order"),class:"ck-numbered-list-properties__reversed-order"}),t.delegate("execute").to(this,"listReversed"),t}}class Re extends n.Sy{static get pluginName(){return"ListPropertiesUI"}init(){const e=this.editor,t=e.locale.t,i=e.config.get("list.properties");i.styles&&e.ui.componentFactory.add("bulletedList",Oe({editor:e,parentCommandName:"bulletedList",buttonLabel:t("Bulleted List"),buttonIcon:ce,styleGridAriaLabel:t("Bulleted list styles toolbar"),styleDefinitions:[{label:t("Toggle the disc list style"),tooltip:t("Disc"),type:"disc",icon:''},{label:t("Toggle the circle list style"),tooltip:t("Circle"),type:"circle",icon:''},{label:t("Toggle the square list style"),tooltip:t("Square"),type:"square",icon:''}]})),(i.styles||i.startIndex||i.reversed)&&e.ui.componentFactory.add("numberedList",Oe({editor:e,parentCommandName:"numberedList",buttonLabel:t("Numbered List"),buttonIcon:le,styleGridAriaLabel:t("Numbered list styles toolbar"),styleDefinitions:[{label:t("Toggle the decimal list style"),tooltip:t("Decimal"),type:"decimal",icon:''},{label:t("Toggle the decimal with leading zero list style"),tooltip:t("Decimal with leading zero"),type:"decimal-leading-zero",icon:''},{label:t("Toggle the lower–roman list style"),tooltip:t("Lower–roman"),type:"lower-roman",icon:''},{label:t("Toggle the upper–roman list style"),tooltip:t("Upper-roman"),type:"upper-roman",icon:''},{label:t("Toggle the lower–latin list style"),tooltip:t("Lower-latin"),type:"lower-latin",icon:''},{label:t("Toggle the upper–latin list style"),tooltip:t("Upper-latin"),type:"upper-latin",icon:''}]}))}}function Oe({editor:e,parentCommandName:t,buttonLabel:i,buttonIcon:n,styleGridAriaLabel:o,styleDefinitions:s}){const r=e.commands.get(t);return a=>{const l=(0,Z.t9)(a,Z.Rm),c=l.buttonView;return l.bind("isEnabled").to(r),l.class="ck-list-styles-dropdown",c.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),c.set({label:i,icon:n,tooltip:!0,isToggleable:!0}),c.bind("isOn").to(r,"value",(e=>!!e)),l.once("change:isOpen",(()=>{const i=function({editor:e,dropdownView:t,parentCommandName:i,styleDefinitions:n,styleGridAriaLabel:o}){const s=e.locale,r=e.config.get("list.properties");let a=null;if("numberedList"!=i&&(r.startIndex=!1,r.reversed=!1),r.styles){const t=e.commands.get("listStyle"),o=function({editor:e,listStyleCommand:t,parentCommandName:i}){const n=e.locale,o=e.commands.get(i);return({label:i,type:s,icon:r,tooltip:a})=>{const l=new Z.r5(n);return l.set({label:i,icon:r,tooltip:a}),t.on("change:value",(()=>{l.isOn=t.value===s})),l.on("execute",(()=>{o.value?t.value!==s?e.execute("listStyle",{type:s}):e.execute("listStyle",{type:t.defaultType}):e.model.change((()=>{e.execute("listStyle",{type:s})}))})),l}}({editor:e,parentCommandName:i,listStyleCommand:t}),s="function"==typeof t.isStyleTypeSupported?e=>t.isStyleTypeSupported(e.type):()=>!0;a=n.filter(s).map(o)}const l=new Ve(s,{styleGridAriaLabel:o,enabledProperties:r,styleButtonViews:a});if(r.styles&&(0,Z.Mh)(t,(()=>l.stylesView.children.find((e=>e.isOn)))),r.startIndex){const t=e.commands.get("listStart");l.startIndexFieldView.bind("isEnabled").to(t),l.startIndexFieldView.fieldView.bind("value").to(t),l.on("listStart",((t,i)=>e.execute("listStart",i)))}if(r.reversed){const t=e.commands.get("listReversed");l.reversedSwitchButtonView.bind("isEnabled").to(t),l.reversedSwitchButtonView.bind("isOn").to(t,"value",(e=>!!e)),l.on("listReversed",(()=>{const i=t.value;e.execute("listReversed",{reversed:!i})}))}return l.delegate("execute").to(t),l}({editor:e,dropdownView:l,parentCommandName:t,styleGridAriaLabel:o,styleDefinitions:s});l.panelView.children.add(i)})),l.on("execute",(()=>{e.editing.view.focus()})),l}}class Be extends n.Sy{static get requires(){return[Se,Re]}static get pluginName(){return"DocumentListProperties"}}class Me extends n.mY{constructor(e,t){super(e),this._indentBy="forward"==t?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document;let i=Array.from(t.selection.getSelectedBlocks());e.change((e=>{const t=i[i.length-1];let n=t.nextSibling;for(;n&&"listItem"==n.name&&n.getAttribute("listIndent")>t.getAttribute("listIndent");)i.push(n),n=n.nextSibling;this._indentBy<0&&(i=i.reverse());for(const t of i){const i=t.getAttribute("listIndent")+this._indentBy;i<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",i,t)}this.fire("_executeCleanup",i)}))}_checkEnabled(){const e=(0,r.Ps)(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("element","listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),i=e.getAttribute("listType");let n=e.previousSibling;for(;n&&n.is("element","listItem")&&n.getAttribute("listIndent")>=t;){if(n.getAttribute("listIndent")==t)return n.getAttribute("listType")==i;n=n.previousSibling}return!1}return!0}}class Ne extends n.mY{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,n=Array.from(i.selection.getSelectedBlocks()).filter((e=>Le(e,t.schema))),o=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(o){let t=n[n.length-1].nextSibling,i=Number.POSITIVE_INFINITY,o=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=i;)s>o.getAttribute("listIndent")&&(s=o.getAttribute("listIndent")),o.getAttribute("listIndent")==s&&e[t?"unshift":"push"](o),o=o[t?"previousSibling":"nextSibling"]}}function Le(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class Fe extends n.Sy{static get pluginName(){return"ListUtils"}getListTypeFromListStyleType(e){return re(e)}getSelectedListItems(e){return ne(e)}getSiblingNodes(e,t){return ie(e,t)}}function ze(e){return(t,i,n)=>{const o=n.consumable;if(!o.test(i.item,"insert")||!o.test(i.item,"attribute:listType")||!o.test(i.item,"attribute:listIndent"))return;o.consume(i.item,"insert"),o.consume(i.item,"attribute:listType"),o.consume(i.item,"attribute:listIndent");const s=i.item;J(s,G(s,n),n,e)}}const He=(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=i.mapper.toViewElement(t.item),o=i.writer;o.breakContainer(o.createPositionBefore(n)),o.breakContainer(o.createPositionAfter(n));const s=n.parent,r="numbered"==t.attributeNewValue?"ol":"ul";o.rename(r,s)},We=(e,t,i)=>{i.consumable.consume(t.item,e.name);const n=i.mapper.toViewElement(t.item).parent,o=i.writer;Y(o,n,n.nextSibling),Y(o,n.previousSibling,n)},Ue=(e,t,i)=>{if(i.consumable.test(t.item,e.name)&&"listItem"!=t.item.name){let e=i.mapper.toViewPosition(t.range.start);const n=i.writer,o=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=n.breakContainer(e),"li"==e.parent.name);){const t=e,i=n.createPositionAt(e.parent,"end");if(!t.isEqual(i)){const e=n.remove(n.createRange(t,i));o.push(e)}e=n.createPositionAfter(e.parent)}if(o.length>0){for(let t=0;t0){const t=Y(n,i,i.nextSibling);t&&t.parent==i&&e.offset--}}Y(n,e.nodeBefore,e.nodeAfter)}}},je=(e,t,i)=>{const n=i.mapper.toViewPosition(t.position),o=n.nodeBefore,s=n.nodeAfter;Y(i.writer,o,s)},$e=(e,t,i)=>{if(i.consumable.consume(t.viewItem,{name:!0})){const e=i.writer,n=e.createElement("listItem"),o=function(e){let t=0,i=e.parent;for(;i;){if(i.is("element","li"))t++;else{const e=i.previousSibling;e&&e.is("element","li")&&t++}i=i.parent}return t}(t.viewItem);e.setAttribute("listIndent",o,n);const s=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",s,n),!i.safeInsert(n,t.modelCursor))return;const r=function(e,t,i){const{writer:n,schema:o}=i;let s=n.createPositionAfter(e);for(const r of t)if("ul"==r.name||"ol"==r.name)s=i.convertItem(r,s).modelCursor;else{const t=i.convertItem(r,n.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:Je(t.modelCursor),s=n.createPositionAfter(e))}return s}(n,t.viewItem.getChildren(),i);t.modelRange=e.createRange(t.modelCursor,r),i.updateConversionResult(n,t)}},qe=(e,t,i)=>{if(i.consumable.test(t.viewItem,{name:!0})){const e=Array.from(t.viewItem.getChildren());for(const t of e)!t.is("element","li")&&!Qe(t)&&t._remove()}},Ke=(e,t,i)=>{if(i.consumable.test(t.viewItem,{name:!0})){if(0===t.viewItem.childCount)return;const e=[...t.viewItem.getChildren()];let i=!1;for(const t of e)i&&!Qe(t)&&t._remove(),Qe(t)&&(i=!0)}};function Ze(e){return(t,i)=>{if(i.isPhantom)return;const n=i.modelPosition.nodeBefore;if(n&&n.is("element","listItem")){const t=i.mapper.toViewElement(n),o=t.getAncestors().find(Qe),s=e.createPositionAt(t,0).getWalker();for(const e of s){if("elementStart"==e.type&&e.item.is("element","li")){i.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==o){i.viewPosition=e.nextPosition;break}}}}}const Ge=function(e,[t,i]){let n,o=t.is("documentFragment")?t.getChild(0):t;if(n=i?this.createSelection(i):this.document.selection,o&&o.is("element","listItem")){const e=n.getFirstPosition();let t=null;if(e.parent.is("element","listItem")?t=e.parent:e.nodeBefore&&e.nodeBefore.is("element","listItem")&&(t=e.nodeBefore),t){const e=t.getAttribute("listIndent");if(e>0)for(;o&&o.is("element","listItem");)o._setAttribute("listIndent",o.getAttribute("listIndent")+e),o=o.nextSibling}}};function Je(e){const t=new O.Po({startPosition:e});let i;do{i=t.next()}while(!i.value.item.is("element","listItem"));return i.value.item}function Ye(e,t,i,n,o,s){const r=X(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e}),a=o.mapper,l=o.writer,c=r?r.getAttribute("listIndent"):null;let d;if(r)if(c==e){const e=a.toViewElement(r).parent;d=l.createPositionAfter(e)}else{const e=s.createPositionAt(r,"end");d=a.toViewPosition(e)}else d=i;d=Q(d);for(const e of[...n.getChildren()])Qe(e)&&(d=l.move(l.createRangeOn(e),d).end,Y(l,e,e.nextSibling),Y(l,e.previousSibling,e))}function Qe(e){return e.is("element","ol")||e.is("element","ul")}class Xe extends n.Sy{static get pluginName(){return"ListEditing"}static get requires(){return[s.C,o.HG,Fe]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,i=e.editing;var n;e.model.document.registerPostFixer((t=>function(e,t){const i=e.document.differ.getChanges(),n=new Map;let o=!1;for(const n of i)if("insert"==n.type&&"listItem"==n.name)s(n.position);else if("insert"==n.type&&"listItem"!=n.name){if("$text"!=n.name){const i=n.position.nodeAfter;i.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",i),o=!0),i.hasAttribute("listType")&&(t.removeAttribute("listType",i),o=!0),i.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",i),o=!0),i.hasAttribute("listReversed")&&(t.removeAttribute("listReversed",i),o=!0),i.hasAttribute("listStart")&&(t.removeAttribute("listStart",i),o=!0);for(const t of Array.from(e.createRangeIn(i)).filter((e=>e.item.is("element","listItem"))))s(t.previousPosition)}s(n.position.getShiftedBy(n.length))}else"remove"==n.type&&"listItem"==n.name?s(n.position):("attribute"==n.type&&"listIndent"==n.attributeKey||"attribute"==n.type&&"listType"==n.attributeKey)&&s(n.range.start);for(const e of n.values())r(e),a(e);return o;function s(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(n.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,n.has(e))return;n.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&n.set(t,t)}}function r(e){let i=0,n=null;for(;e&&e.is("element","listItem");){const s=e.getAttribute("listIndent");if(s>i){let r;null===n?(n=s-i,r=i):(n>s&&(n=s),r=s-n),t.setAttribute("listIndent",r,e),o=!0}else n=null,i=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let i=[],n=null;for(;e&&e.is("element","listItem");){const s=e.getAttribute("listIndent");if(n&&n.getAttribute("listIndent")>s&&(i=i.slice(0,s+1)),0!=s)if(i[s]){const n=i[s];e.getAttribute("listType")!=n&&(t.setAttribute("listType",n,e),o=!0)}else i[s]=e.getAttribute("listType");n=e,e=e.nextSibling}}}(e.model,t))),i.mapper.registerViewToModelLength("li",et),t.mapper.registerViewToModelLength("li",et),i.mapper.on("modelToViewPosition",Ze(i.view)),i.mapper.on("viewToModelPosition",(n=e.model,(e,t)=>{const i=t.viewPosition,o=i.parent,s=t.mapper;if("ul"==o.name||"ol"==o.name){if(i.isAtEnd){const e=s.toModelElement(i.nodeBefore),o=s.getModelLength(i.nodeBefore);t.modelPosition=n.createPositionBefore(e).getShiftedBy(o)}else{const e=s.toModelElement(i.nodeAfter);t.modelPosition=n.createPositionBefore(e)}e.stop()}else if("li"==o.name&&i.nodeBefore&&("ul"==i.nodeBefore.name||"ol"==i.nodeBefore.name)){const r=s.toModelElement(o);let a=1,l=i.nodeBefore;for(;l&&Qe(l);)a+=s.getModelLength(l),l=l.previousSibling;t.modelPosition=n.createPositionBefore(r).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",Ze(i.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",Ue,{priority:"high"}),t.on("insert:listItem",ze(e.model)),t.on("attribute:listType:listItem",He,{priority:"high"}),t.on("attribute:listType:listItem",We,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,i,n)=>{if(!n.consumable.consume(i.item,"attribute:listIndent"))return;const o=n.mapper.toViewElement(i.item),s=n.writer;s.breakContainer(s.createPositionBefore(o)),s.breakContainer(s.createPositionAfter(o));const r=o.parent,a=r.previousSibling,l=s.createRangeOn(r);s.remove(l),a&&a.nextSibling&&Y(s,a,a.nextSibling),Ye(i.attributeOldValue+1,i.range.start,l.start,o,n,e),J(i.item,o,n,e);for(const e of i.item.getChildren())n.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,i,n)=>{const o=n.mapper.toViewPosition(i.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,s=n.writer;s.breakContainer(s.createPositionBefore(o)),s.breakContainer(s.createPositionAfter(o));const r=o.parent,a=r.previousSibling,l=s.createRangeOn(r),c=s.remove(l);a&&a.nextSibling&&Y(s,a,a.nextSibling),Ye(n.mapper.toModelElement(o).getAttribute("listIndent")+1,i.position,l.start,o,n,e);for(const e of s.createRangeIn(c).getItems())n.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",je,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",Ue,{priority:"high"}),t.on("insert:listItem",ze(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",qe,{priority:"high"}),e.on("element:ol",qe,{priority:"high"}),e.on("element:li",Ke,{priority:"high"}),e.on("element:li",$e)})),e.model.on("insertContent",Ge,{priority:"high"}),e.commands.add("numberedList",new Ne(e,"numbered")),e.commands.add("bulletedList",new Ne(e,"bulleted")),e.commands.add("indentList",new Me(e,"forward")),e.commands.add("outdentList",new Me(e,"backward"));const o=i.view.document;this.listenTo(o,"enter",((e,t)=>{const i=this.editor.model.document,n=i.selection.getLastPosition().parent;i.selection.isCollapsed&&"listItem"==n.name&&n.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(o,"delete",((e,t)=>{if("backward"!==t.direction)return;const i=this.editor.model.document.selection;if(!i.isCollapsed)return;const n=i.getFirstPosition();if(!n.isAtStart)return;const o=n.parent;"listItem"===o.name&&(o.previousSibling&&"listItem"===o.previousSibling.name||(this.editor.execute("outdentList"),t.preventDefault(),e.stop()))}),{context:"li"}),this.listenTo(e.editing.view.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"li"})}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),i&&i.registerChildCommand(e.get("outdentList"))}}function et(e){let t=1;for(const i of e.getChildren())if("ul"==i.name||"ol"==i.name)for(const e of i.getChildren())t+=et(e);return t}class tt extends n.Sy{static get requires(){return[Xe,de]}static get pluginName(){return"List"}}class it extends n.mY{constructor(e,t){super(e),this.defaultType=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){this._tryToConvertItemsToList(e);const t=this.editor.model,i=ne(t);i.length&&t.change((t=>{for(const n of i)t.setAttribute("listStyle",e.type||this.defaultType,n)}))}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")?e.getAttribute("listStyle"):null}_checkEnabled(){const e=this.editor,t=e.commands.get("numberedList"),i=e.commands.get("bulletedList");return t.isEnabled||i.isEnabled}_tryToConvertItemsToList(e){if(!e.type)return;const t=re(e.type);if(!t)return;const i=this.editor,n=`${t}List`;i.commands.get(n).value||i.execute(n)}}class nt extends n.mY{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute(e={}){const t=this.editor.model,i=ne(t).filter((e=>"numbered"==e.getAttribute("listType")));t.change((t=>{for(const n of i)t.setAttribute("listReversed",!!e.reversed,n)}))}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")&&"numbered"==e.getAttribute("listType")?e.getAttribute("listReversed"):null}}class ot extends n.mY{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute({startIndex:e=1}={}){const t=this.editor.model,i=ne(t).filter((e=>"numbered"==e.getAttribute("listType")));t.change((t=>{for(const n of i)t.setAttribute("listStart",e>=0?e:1,n)}))}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")&&"numbered"==e.getAttribute("listType")?e.getAttribute("listStart"):null}}const st="default";class rt extends n.Sy{static get requires(){return[Xe]}static get pluginName(){return"ListPropertiesEditing"}constructor(e){super(e),e.config.define("list",{properties:{styles:!0,startIndex:!1,reversed:!1}})}init(){const e=this.editor,t=e.model,i=function(e){const t=[];return e.styles&&t.push({attributeName:"listStyle",defaultValue:st,addCommand(e){e.commands.add("listStyle",new it(e,st))},appliesToListItem:()=>!0,setAttributeOnDowncast(e,t,i){t&&t!==st?e.setStyle("list-style-type",t,i):e.removeStyle("list-style-type",i)},getAttributeOnUpcast:e=>e.getStyle("list-style-type")||st}),e.reversed&&t.push({attributeName:"listReversed",defaultValue:!1,addCommand(e){e.commands.add("listReversed",new nt(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),setAttributeOnDowncast(e,t,i){t?e.setAttribute("reversed","reversed",i):e.removeAttribute("reversed",i)},getAttributeOnUpcast:e=>e.hasAttribute("reversed")}),e.startIndex&&t.push({attributeName:"listStart",defaultValue:1,addCommand(e){e.commands.add("listStart",new ot(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),setAttributeOnDowncast(e,t,i){0==t||t>1?e.setAttribute("start",t,i):e.removeAttribute("start",i)},getAttributeOnUpcast(e){const t=e.getAttribute("start");return t>=0?t:1}}),t}(e.config.get("list.properties"));t.schema.extend("listItem",{allowAttributes:i.map((e=>e.attributeName))});for(const t of i)t.addCommand(e);var n;this.listenTo(e.commands.get("indentList"),"_executeCleanup",function(e,t){return(i,n)=>{const o=n[0],s=o.getAttribute("listIndent"),r=n.filter((e=>e.getAttribute("listIndent")===s));let a=null;o.previousSibling.getAttribute("listIndent")+1!==s&&(a=X(o.previousSibling,{sameIndent:!0,direction:"backward",listIndent:s})),e.model.change((e=>{for(const i of r)for(const n of t)if(n.appliesToListItem(i)){const t=null==a?n.defaultValue:a.getAttribute(n.attributeName);e.setAttribute(n.attributeName,t,i)}}))}}(e,i)),this.listenTo(e.commands.get("outdentList"),"_executeCleanup",function(e,t){return(i,n)=>{if(!(n=n.reverse().filter((e=>e.is("element","listItem")))).length)return;const o=n[0].getAttribute("listIndent"),s=n[0].getAttribute("listType");let r=n[0].previousSibling;if(r.is("element","listItem"))for(;r.getAttribute("listIndent")!==o;)r=r.previousSibling;else r=null;r||(r=n[n.length-1].nextSibling),r&&r.is("element","listItem")&&r.getAttribute("listType")===s&&e.model.change((e=>{const i=n.filter((e=>e.getAttribute("listIndent")===o));for(const n of i)for(const i of t)if(i.appliesToListItem(n)){const t=i.attributeName,o=r.getAttribute(t);e.setAttribute(t,o,n)}}))}}(e,i)),this.listenTo(e.commands.get("bulletedList"),"_executeCleanup",ct(e)),this.listenTo(e.commands.get("numberedList"),"_executeCleanup",ct(e)),t.document.registerPostFixer(function(e,t){return i=>{let n=!1;const o=dt(e.model.document.differ.getChanges()).filter((e=>"todo"!==e.getAttribute("listType")));if(!o.length)return n;let s=o[o.length-1].nextSibling;if((!s||!s.is("element","listItem"))&&(s=o[0].previousSibling,s)){const e=o[0].getAttribute("listIndent");for(;s.is("element","listItem")&&s.getAttribute("listIndent")!==e&&(s=s.previousSibling,s););}for(const e of t){const t=e.attributeName;for(const r of o)if(e.appliesToListItem(r))if(r.hasAttribute(t)){const o=r.previousSibling;lt(o,r,e.attributeName)&&(i.setAttribute(t,o.getAttribute(t),r),n=!0)}else at(s,r,e)?i.setAttribute(t,s.getAttribute(t),r):i.setAttribute(t,e.defaultValue,r),n=!0;else i.removeAttribute(t,r)}return n}}(e,i)),e.conversion.for("upcast").add((n=i,e=>{e.on("element:li",((e,t,i)=>{if(!t.modelRange)return;const o=t.viewItem.parent,s=t.modelRange.start.nodeAfter||t.modelRange.end.nodeBefore;for(const e of n)if(e.appliesToListItem(s)){const t=e.getAttributeOnUpcast(o);i.writer.setAttribute(e.attributeName,t,s)}}),{priority:"low"})})),e.conversion.for("downcast").add(function(e){return t=>{for(const i of e)t.on(`attribute:${i.attributeName}:listItem`,((e,t,n)=>{const o=n.writer,s=t.item,r=X(s.previousSibling,{sameIndent:!0,listIndent:s.getAttribute("listIndent"),direction:"backward"}),a=n.mapper.toViewElement(s);var l,c;l=s,(c=r)&&l.getAttribute("listType")===c.getAttribute("listType")&&l.getAttribute("listIndent")===c.getAttribute("listIndent")&&l.getAttribute("listStyle")===c.getAttribute("listStyle")&&l.getAttribute("listReversed")===c.getAttribute("listReversed")&&l.getAttribute("listStart")===c.getAttribute("listStart")||o.breakContainer(o.createPositionBefore(a)),i.setAttributeOnDowncast(o,t.attributeNewValue,a.parent)}),{priority:"low"})}}(i)),this._mergeListAttributesWhileMergingLists(i)}afterInit(){const e=this.editor;e.commands.get("todoList")&&e.model.document.registerPostFixer(function(e){return t=>{const i=dt(e.model.document.differ.getChanges()).filter((e=>"todo"===e.getAttribute("listType")&&(e.hasAttribute("listStyle")||e.hasAttribute("listReversed")||e.hasAttribute("listStart"))));if(!i.length)return!1;for(const e of i)t.removeAttribute("listStyle",e),t.removeAttribute("listReversed",e),t.removeAttribute("listStart",e);return!0}}(e))}_mergeListAttributesWhileMergingLists(e){const t=this.editor.model;let i;this.listenTo(t,"deleteContent",((e,[t])=>{const n=t.getFirstPosition(),o=t.getLastPosition();if(n.parent===o.parent)return;if(!n.parent.is("element","listItem"))return;const s=o.parent.nextSibling;if(!s||!s.is("element","listItem"))return;const r=X(n.parent,{sameIndent:!0,listIndent:s.getAttribute("listIndent")});r&&r.getAttribute("listType")===s.getAttribute("listType")&&(i=r)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{i&&(t.change((t=>{const n=X(i.nextSibling,{sameIndent:!0,listIndent:i.getAttribute("listIndent"),direction:"forward"});if(!n)return void(i=null);const o=[n,...ie(t.createPositionAt(n,0),"forward")];for(const n of o)for(const o of e)if(o.appliesToListItem(n)){const e=o.attributeName,s=i.getAttribute(e);t.setAttribute(e,s,n)}})),i=null)}),{priority:"low"})}}function at(e,t,i){if(!e)return!1;const n=e.getAttribute(i.attributeName);return!!n&&n!=i.defaultValue&&e.getAttribute("listType")===t.getAttribute("listType")}function lt(e,t,i){if(!e||!e.is("element","listItem"))return!1;if(t.getAttribute("listType")!==e.getAttribute("listType"))return!1;const n=e.getAttribute("listIndent");if(n<1||n!==t.getAttribute("listIndent"))return!1;const o=e.getAttribute(i);return!(!o||o===t.getAttribute(i))}function ct(e){return(t,i)=>{i=i.filter((e=>e.is("element","listItem"))),e.model.change((e=>{for(const t of i)e.removeAttribute("listStyle",t)}))}}function dt(e){const t=[];for(const i of e){const e=ut(i);e&&e.is("element","listItem")&&t.push(e)}return t}function ut(e){return"attribute"===e.type?e.range.start.nodeAfter:"insert"===e.type?e.position.nodeAfter:null}class ht extends n.Sy{static get requires(){return[rt,Re]}static get pluginName(){return"ListProperties"}}const mt="todoListChecked";class gt extends n.mY{constructor(e){super(e),this._selectedElements=[],this.on("execute",(()=>{this.refresh()}),{priority:"highest"})}refresh(){this._selectedElements=this._getSelectedItems(),this.value=this._selectedElements.every((e=>!!e.getAttribute(mt))),this.isEnabled=!!this._selectedElements.length}_getSelectedItems(){const e=this.editor.model,t=e.schema,i=e.document.selection.getFirstRange(),n=i.start.parent,o=[];t.checkAttribute(n,mt)&&o.push(n);for(const e of i.getItems())t.checkAttribute(e,mt)&&!o.includes(e)&&o.push(e);return o}execute(e={}){this.editor.model.change((t=>{for(const i of this._selectedElements)(void 0===e.forceValue?!this.value:e.forceValue)?t.setAttribute(mt,!0,i):t.removeAttribute(mt,i)}))}}const ft=(e,t,i)=>{const n=t.modelCursor,o=n.parent,s=t.viewItem;if("checkbox"!=s.getAttribute("type")||"listItem"!=o.name||!n.isAtStart)return;if(!i.consumable.consume(s,{name:!0}))return;const r=i.writer;r.setAttribute("listType","todo",o),t.viewItem.hasAttribute("checked")&&r.setAttribute("todoListChecked",!0,o),t.modelRange=r.createRange(n)};function pt(e){return(t,i)=>{const n=i.modelPosition,o=n.parent;if(!o.is("element","listItem")||"todo"!=o.getAttribute("listType"))return;const s=wt(i.mapper.toViewElement(o),e);s&&(i.viewPosition=i.mapper.findPositionIn(s,n.offset))}}function bt(e,t,i,n){return t.createUIElement("label",{class:"todo-list__label",contenteditable:!1},(function(t){const o=(0,r.az)(document,"input",{type:"checkbox",tabindex:"-1"});i&&o.setAttribute("checked","checked"),o.addEventListener("change",(()=>n(e)));const s=this.toDomElement(t);return s.appendChild(o),s}))}function wt(e,t){const i=t.createRangeIn(e);for(const e of i)if(e.item.is("containerElement","span")&&e.item.hasClass("todo-list__label__description"))return e.item}const vt=(0,r.Zz)("Ctrl+Enter");class _t extends n.Sy{static get pluginName(){return"TodoListEditing"}static get requires(){return[Xe]}init(){const e=this.editor,{editing:t,data:i,model:n}=e;n.schema.extend("listItem",{allowAttributes:["todoListChecked"]}),n.schema.addAttributeCheck(((e,t)=>{const i=e.last;if("todoListChecked"==t&&"listItem"==i.name&&"todo"!=i.getAttribute("listType"))return!1})),e.commands.add("todoList",new Ne(e,"todo"));const o=new gt(e);var s,a;e.commands.add("checkTodoList",o),e.commands.add("todoListCheck",o),i.downcastDispatcher.on("insert:listItem",function(e){return(t,i,n)=>{const o=n.consumable;if(!o.test(i.item,"insert")||!o.test(i.item,"attribute:listType")||!o.test(i.item,"attribute:listIndent"))return;if("todo"!=i.item.getAttribute("listType"))return;const s=i.item;o.consume(s,"insert"),o.consume(s,"attribute:listType"),o.consume(s,"attribute:listIndent"),o.consume(s,"attribute:todoListChecked");const r=n.writer,a=G(s,n);r.addClass("todo-list",a.parent);const l=r.createContainerElement("label",{class:"todo-list__label"}),c=r.createEmptyElement("input",{type:"checkbox",disabled:"disabled"}),d=r.createContainerElement("span",{class:"todo-list__label__description"});s.getAttribute("todoListChecked")&&r.setAttribute("checked","checked",c),r.insert(r.createPositionAt(a,0),l),r.insert(r.createPositionAt(l,0),c),r.insert(r.createPositionAfter(c),d),J(s,a,n,e)}}(n),{priority:"high"}),i.upcastDispatcher.on("element:input",ft,{priority:"high"}),t.downcastDispatcher.on("insert:listItem",function(e,t){return(i,n,o)=>{const s=o.consumable;if(!s.test(n.item,"insert")||!s.test(n.item,"attribute:listType")||!s.test(n.item,"attribute:listIndent"))return;if("todo"!=n.item.getAttribute("listType"))return;const r=n.item;s.consume(r,"insert"),s.consume(r,"attribute:listType"),s.consume(r,"attribute:listIndent"),s.consume(r,"attribute:todoListChecked");const a=o.writer,l=G(r,o),c=!!r.getAttribute("todoListChecked"),d=bt(r,a,c,t),u=a.createContainerElement("span",{class:"todo-list__label__description"});a.addClass("todo-list",l.parent),a.insert(a.createPositionAt(l,0),d),a.insert(a.createPositionAfter(d),u),J(r,l,o,e)}}(n,(e=>this._handleCheckmarkChange(e))),{priority:"high"}),t.downcastDispatcher.on("attribute:listType:listItem",(s=e=>this._handleCheckmarkChange(e),a=t.view,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.mapper.toViewElement(t.item),o=i.writer,r=function(e,t){const i=t.createRangeIn(e);for(const e of i)if(e.item.is("uiElement","label"))return e.item}(n,a);if("todo"==t.attributeNewValue){const e=!!t.item.getAttribute("todoListChecked"),i=bt(t.item,o,e,s),r=o.createContainerElement("span",{class:"todo-list__label__description"}),a=o.createRangeIn(n),l=te(n),c=Q(a.start),d=l?o.createPositionBefore(l):a.end,u=o.createRange(c,d);o.addClass("todo-list",n.parent),o.move(u,o.createPositionAt(r,0)),o.insert(o.createPositionAt(n,0),i),o.insert(o.createPositionAfter(i),r)}else if("todo"==t.attributeOldValue){const e=wt(n,a);o.removeClass("todo-list",n.parent),o.remove(r),o.move(o.createRangeIn(e),o.createPositionBefore(e)),o.remove(e)}})),t.downcastDispatcher.on("attribute:todoListChecked:listItem",function(e){return(t,i,n)=>{if("todo"!=i.item.getAttribute("listType"))return;if(!n.consumable.consume(i.item,"attribute:todoListChecked"))return;const{mapper:o,writer:s}=n,r=!!i.item.getAttribute("todoListChecked"),a=o.toViewElement(i.item).getChild(0),l=bt(i.item,s,r,e);s.insert(s.createPositionAfter(a),l),s.remove(a)}}((e=>this._handleCheckmarkChange(e)))),t.mapper.on("modelToViewPosition",pt(t.view)),i.mapper.on("modelToViewPosition",pt(t.view)),this.listenTo(t.view.document,"arrowKey",function(e,t){return(i,n)=>{if("left"!=(0,r.mA)(n.keyCode,t.contentLanguageDirection))return;const o=e.schema,s=e.document.selection;if(!s.isCollapsed)return;const a=s.getFirstPosition(),l=a.parent;if("listItem"===l.name&&"todo"==l.getAttribute("listType")&&a.isAtStart){const t=o.getNearestSelectionRange(e.createPositionBefore(l),"backward");t&&e.change((e=>e.setSelection(t))),n.preventDefault(),n.stopPropagation(),i.stop()}}}(n,e.locale),{context:"li"}),this.listenTo(t.view.document,"keydown",((t,i)=>{(0,r.Cq)(i)===vt&&(e.execute("checkTodoList"),t.stop())}),{priority:"high"});const l=new Set;this.listenTo(n,"applyOperation",((e,t)=>{const i=t[0];if("rename"==i.type&&"listItem"==i.oldName){const e=i.position.nodeAfter;e.hasAttribute("todoListChecked")&&l.add(e)}else if("changeAttribute"==i.type&&"listType"==i.key&&"todo"===i.oldValue)for(const e of i.range.getItems())e.hasAttribute("todoListChecked")&&"todo"!==e.getAttribute("listType")&&l.add(e)})),n.document.registerPostFixer((e=>{let t=!1;for(const i of l)e.removeAttribute("todoListChecked",i),t=!0;return l.clear(),t}))}_handleCheckmarkChange(e){const t=this.editor,i=t.model,n=Array.from(i.document.selection.getRanges());i.change((i=>{i.setSelection(e,"end"),t.execute("checkTodoList"),i.setSelection(n)}))}}class yt extends n.Sy{static get pluginName(){return"TodoListUI"}init(){const e=this.editor.t;ee(this.editor,"todoList",e("To-do List"),'')}}class kt extends n.Sy{static get requires(){return[_t,yt]}static get pluginName(){return"TodoList"}}},6335:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Mention:()=>S,MentionEditing:()=>r,MentionUI:()=>y});var n=i(6854),o=i(6553);class s extends n.mY{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"mention")}execute(e){const t=this.editor.model,i=t.document.selection,n="string"==typeof e.mention?{id:e.mention}:e.mention,s=n.id,r=e.range||i.getFirstRange();if(!t.canEditAt(r))return;const l=e.text||s,c=a({_text:l,id:s},n);if(1!=e.marker.length)throw new o.Bb("mentioncommand-incorrect-marker",this);if(s.charAt(0)!=e.marker)throw new o.Bb("mentioncommand-incorrect-id",this);t.change((e=>{const n=(0,o.qL)(i.getAttributes()),s=new Map(n.entries());s.set("mention",c),t.insertContent(e.createText(l,s),r),t.insertContent(e.createText(" ",n),r.start.getShiftedBy(l.length))}))}}class r extends n.Sy{static get pluginName(){return"MentionEditing"}init(){const e=this.editor,t=e.model,i=t.document;t.schema.extend("$text",{allowAttributes:"mention"}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",key:"data-mention",classes:"mention"},model:{key:"mention",value:e=>l(e)}}),e.conversion.for("downcast").attributeToElement({model:"mention",view:d}),e.conversion.for("downcast").add(c),i.registerPostFixer((e=>function(e,t,i){const n=t.differ.getChanges();let o=!1;for(const t of n){if("attribute"==t.type)continue;const n=t.position;if("$text"==t.name){const t=n.textNode&&n.textNode.nextSibling;o=h(n.textNode,e)||o,o=h(t,e)||o,o=h(n.nodeBefore,e)||o,o=h(n.nodeAfter,e)||o}if("$text"!=t.name&&"insert"==t.type){const t=n.nodeAfter;for(const i of e.createRangeIn(t).getItems())o=h(i,e)||o}if("insert"==t.type&&i.isInline(t.name)){const t=n.nodeAfter&&n.nodeAfter.nextSibling;o=h(n.nodeBefore,e)||o,o=h(t,e)||o}}return o}(e,i,t.schema))),i.registerPostFixer((e=>function(e,t){const i=t.differ.getChanges();let n=!1;for(const t of i)if("attribute"===t.type&&"mention"!=t.attributeKey){const i=t.range.start.nodeBefore,o=t.range.end.nodeAfter;for(const s of[i,o])u(s)&&s.getAttribute(t.attributeKey)!=t.attributeNewValue&&(e.setAttribute(t.attributeKey,t.attributeNewValue,s),n=!0)}return n}(e,i))),i.registerPostFixer((e=>function(e,t){const i=t.selection,n=i.focus;return!!(i.isCollapsed&&i.hasAttribute("mention")&&function(e){const t=e.isAtStart;return e.nodeBefore&&e.nodeBefore.is("$text")||t}(n))&&(e.removeSelectionAttribute("mention"),!0)}(e,i))),e.commands.add("mention",new s(e))}}function a(e,t){return Object.assign({uid:(0,o.hQ)()},e,t||{})}function l(e,t){const i=e.getAttribute("data-mention"),n=e.getChild(0);if(n)return a({id:i,_text:n.data},t)}function c(e){e.on("attribute:mention",((e,t,i)=>{const n=t.attributeNewValue;if(!t.item.is("$textProxy")||!n)return;const o=t.range.start;(o.textNode||o.nodeAfter).data!=n._text&&i.consumable.consume(t.item,e.name)}),{priority:"highest"})}function d(e,{writer:t}){if(!e)return;const i={class:"mention","data-mention":e.id},n={id:e.uid,priority:20};return t.createAttributeElement("span",i,n)}function u(e){return!(!e||!e.is("$text")&&!e.is("$textProxy")||!e.hasAttribute("mention"))&&e.data!=e.getAttribute("mention")._text}function h(e,t){return!!u(e)&&(t.removeAttribute("mention",e),!0)}var m=i(7095),g=i(5187),f=i(6682);class p extends m.Bv{constructor(e){super(e),this.extendTemplate({attributes:{class:["ck-mentions"],tabindex:"-1"}})}selectFirst(){this.select(0)}selectNext(){const e=this.selected,t=this.items.getIndex(e);this.select(t+1)}selectPrevious(){const e=this.selected,t=this.items.getIndex(e);this.select(t-1)}select(e){let t=0;e>0&&e{i?(this.domElement.classList.add("ck-on"),this.domElement.classList.remove("ck-off")):(this.domElement.classList.add("ck-off"),this.domElement.classList.remove("ck-on"))})),this.listenTo(this.domElement,"click",(()=>{this.fire("execute")}))}render(){super.render(),this.element=this.domElement}}class w extends m.dn{highlight(){this.children.first.isOn=!0}removeHighlight(){this.children.first.isOn=!1}}const v=[o.Do.arrowup,o.Do.arrowdown,o.Do.esc],_=[o.Do.enter,o.Do.tab];class y extends n.Sy{static get pluginName(){return"MentionUI"}static get requires(){return[m.WB]}constructor(e){super(e),this._items=new o.FE,this._mentionsView=this._createMentionView(),this._mentionsConfigurations=new Map,this._requestFeedDebounced=(0,f.Z)(this._requestFeed,100),e.config.define("mention",{feeds:[]})}init(){const e=this.editor,t=e.config.get("mention.commitKeys")||_,i=v.concat(t);this._balloon=e.plugins.get(m.WB),e.editing.view.document.on("keydown",((e,n)=>{var s;s=n.keyCode,i.includes(s)&&this._isUIVisible&&(n.preventDefault(),e.stop(),n.keyCode==o.Do.arrowdown&&this._mentionsView.selectNext(),n.keyCode==o.Do.arrowup&&this._mentionsView.selectPrevious(),t.includes(n.keyCode)&&this._mentionsView.executeSelected(),n.keyCode==o.Do.esc&&this._hideUIAndRemoveMarker())}),{priority:"highest"}),(0,m.eC)({emitter:this._mentionsView,activator:()=>this._isUIVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUIAndRemoveMarker()});const n=e.config.get("mention.feeds");for(const e of n){const{feed:t,marker:i,dropdownLimit:n}=e;if(!x(i))throw new o.Bb("mentionconfig-incorrect-marker",null,{marker:i});const s={marker:i,feedCallback:"function"==typeof t?t.bind(this.editor):E(t),itemRenderer:e.itemRenderer,dropdownLimit:n};this._mentionsConfigurations.set(i,s)}this._setupTextWatcher(n),this.listenTo(e,"change:isReadOnly",(()=>{this._hideUIAndRemoveMarker()})),this.on("requestFeed:response",((e,t)=>this._handleFeedResponse(t))),this.on("requestFeed:error",(()=>this._hideUIAndRemoveMarker()))}destroy(){super.destroy(),this._mentionsView.destroy()}get _isUIVisible(){return this._balloon.visibleView===this._mentionsView}_createMentionView(){const e=this.editor.locale,t=new p(e);return t.items.bindTo(this._items).using((i=>{const{item:n,marker:o}=i,{dropdownLimit:s}=this._mentionsConfigurations.get(o),r=s||this.editor.config.get("mention.dropdownLimit")||10;if(t.items.length>=r)return null;const a=new w(e),l=this._renderItem(n,o);return l.delegate("execute").to(a),a.children.add(l),a.item=n,a.marker=o,a.on("execute",(()=>{t.fire("execute",{item:n,marker:o})})),a})),t.on("execute",((e,t)=>{const i=this.editor,n=i.model,o=t.item,s=t.marker,r=i.model.markers.get("mention"),a=n.createPositionAt(n.document.selection.focus),l=n.createPositionAt(r.getStart()),c=n.createRange(l,a);this._hideUIAndRemoveMarker(),i.execute("mention",{mention:o,text:o.text,marker:s,range:c}),i.editing.view.focus()})),t}_getItemRenderer(e){const{itemRenderer:t}=this._mentionsConfigurations.get(e);return t}_requestFeed(e,t){this._lastRequested=t;const{feedCallback:i}=this._mentionsConfigurations.get(e),n=i(t);n instanceof Promise?n.then((i=>{this._lastRequested==t?this.fire("requestFeed:response",{feed:i,marker:e,feedText:t}):this.fire("requestFeed:discarded",{feed:i,marker:e,feedText:t})})).catch((t=>{this.fire("requestFeed:error",{error:t}),(0,o.KE)("mention-feed-callback-error",{marker:e})})):this.fire("requestFeed:response",{feed:n,marker:e,feedText:t})}_setupTextWatcher(e){const t=this.editor,i=e.map((e=>({...e,pattern:A(e.marker,e.minimumCharacters||0)}))),n=new g.uL(t.model,function(e){return t=>{const i=C(e,t);if(!i)return!1;let n=0;0!==i.position&&(n=i.position-1);const o=t.substring(n);return i.pattern.test(o)}}(i));n.on("matched",((e,n)=>{const o=C(i,n.text),s=t.model.document.selection.focus,r=t.model.createPositionAt(s.parent,o.position);if(function(e){const t=e.textNode&&e.textNode.hasAttribute("mention"),i=e.nodeBefore;return t||i&&i.is("$text")&&i.hasAttribute("mention")}(s)||function(e){const t=e.nodeAfter;return t&&t.is("$text")&&t.hasAttribute("mention")}(r))return void this._hideUIAndRemoveMarker();const a=function(e,t){let i=0;0!==e.position&&(i=e.position-1);const n=A(e.marker,0);return t.substring(i).match(n)[2]}(o,n.text),l=o.marker.length+a.length,c=s.getShiftedBy(-l),d=s.getShiftedBy(-a.length),u=t.model.createRange(c,d);if(T(t)){const e=t.model.markers.get("mention");t.model.change((t=>{t.updateMarker(e,{range:u})}))}else t.model.change((e=>{e.addMarker("mention",{range:u,usingOperation:!1,affectsData:!1})}));this._requestFeedDebounced(o.marker,a)})),n.on("unmatched",(()=>{this._hideUIAndRemoveMarker()}));const o=t.commands.get("mention");return n.bind("isEnabled").to(o),n}_handleFeedResponse(e){const{feed:t,marker:i}=e;if(!T(this.editor))return;this._items.clear();for(const e of t){const t="object"!=typeof e?{id:e,text:e}:e;this._items.add({item:t,marker:i})}const n=this.editor.model.markers.get("mention");this._items.length?this._showOrUpdateUI(n):this._hideUIAndRemoveMarker()}_showOrUpdateUI(e){this._isUIVisible?this._balloon.updatePosition(this._getBalloonPanelPositionData(e,this._mentionsView.position)):this._balloon.add({view:this._mentionsView,position:this._getBalloonPanelPositionData(e,this._mentionsView.position),singleViewMode:!0}),this._mentionsView.position=this._balloon.view.position,this._mentionsView.selectFirst()}_hideUIAndRemoveMarker(){this._balloon.hasView(this._mentionsView)&&this._balloon.remove(this._mentionsView),T(this.editor)&&this.editor.model.change((e=>e.removeMarker("mention"))),this._mentionsView.position=void 0}_renderItem(e,t){const i=this.editor;let n,o=e.id;const s=this._getItemRenderer(t);if(s){const t=s(e);"string"!=typeof t?n=new b(i.locale,t):o=t}if(!n){const e=new m.r5(i.locale);e.label=o,e.withText=!0,n=e}return n}_getBalloonPanelPositionData(e,t){const i=this.editor,n=i.editing,s=n.view.domConverter,r=n.mapper;return{target:()=>{let t=e.getRange();"$graveyard"==t.start.root.rootName&&(t=i.model.document.selection.getFirstRange());const n=r.toViewRange(t);return o.UL.getDomRangeRects(s.viewRangeToDom(n)).pop()},limiter:()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},positions:k(t,i.locale.uiLanguageDirection)}}}function k(e,t){const i={caret_se:e=>({top:e.bottom+3,left:e.right,name:"caret_se",config:{withArrow:!1}}),caret_ne:(e,t)=>({top:e.top-t.height-3,left:e.right,name:"caret_ne",config:{withArrow:!1}}),caret_sw:(e,t)=>({top:e.bottom+3,left:e.right-t.width,name:"caret_sw",config:{withArrow:!1}}),caret_nw:(e,t)=>({top:e.top-t.height-3,left:e.right-t.width,name:"caret_nw",config:{withArrow:!1}})};return Object.prototype.hasOwnProperty.call(i,e)?[i[e]]:"rtl"!==t?[i.caret_se,i.caret_sw,i.caret_ne,i.caret_nw]:[i.caret_sw,i.caret_se,i.caret_nw,i.caret_ne]}function C(e,t){let i;for(const n of e){const e=t.lastIndexOf(n.marker);e>0&&!t.substring(e-1).match(n.pattern)||(!i||e>=i.position)&&(i={marker:n.marker,position:e,minimumCharacters:n.minimumCharacters,pattern:n.pattern})}return i}function A(e,t){const i=0==t?"*":`{${t},}`,n=o.OB.features.isRegExpUnicodePropertySupported?"\\p{Ps}\\p{Pi}\"'":"\\(\\[{\"'";return new RegExp(`(?:^|[ ${n}])([${e}])(.${i})$`,"u")}function E(e){return t=>e.filter((e=>("string"==typeof e?e:String(e.id)).toLowerCase().includes(t.toLowerCase())))}function x(e){return e&&1==e.length}function T(e){return e.model.markers.has("mention")}class S extends n.Sy{toMentionAttribute(e,t){return l(e,t)}static get pluginName(){return"Mention"}static get requires(){return[r,y]}}},4690:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Paragraph:()=>l,ParagraphButtonUI:()=>u});var n=i(7833),o=i(5044);class s extends n.Command{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document,i=(0,o.first)(t.selection.getSelectedBlocks());this.value=!!i&&i.is("element","paragraph"),this.isEnabled=!!i&&r(i,e.schema)}execute(e={}){const t=this.editor.model,i=t.document,n=e.selection||i.selection;t.canEditAt(n)&&t.change((e=>{const i=n.getSelectedBlocks();for(const n of i)!n.is("element","paragraph")&&r(n,t.schema)&&e.rename(n,"paragraph")}))}}function r(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class a extends n.Command{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,i=e.attributes;let n=e.position;t.canEditAt(n)&&t.change((e=>{const o=e.createElement("paragraph"),s=t.schema.findAllowedParent(n,o);if(!s)return;if(i&&t.schema.setAllowedAttributes(o,i,e),n.path.length<2)return t.insertContent(o,n),void e.setSelection(o,"in");const r=n.parent,a=r.isEmpty,l=n.isAtEnd&&!r.isEmpty,c=n.isAtStart&&!r.isEmpty,d=t.schema.checkChild(r,o);a||l?n=e.createPositionAfter(r):c?n=e.createPositionBefore(r):d||(n=e.split(n,s).position),t.insertContent(o,n),e.setSelection(o,"in")}))}}class l extends n.Plugin{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new s(e)),e.commands.add("insertParagraph",new a(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>l.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}l.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);var c=i(2692);const d=n.icons.paragraph;class u extends n.Plugin{static get requires(){return[l]}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("paragraph",(i=>{const n=new c.ButtonView(i),o=e.commands.get("paragraph");return n.label=t("Paragraph"),n.icon=d,n.tooltip=!0,n.isToggleable=!0,n.bind("isEnabled").to(o),n.bind("isOn").to(o,"value"),n.on("execute",(()=>{e.execute("paragraph")})),n}))}}},7983:(e,t,i)=>{"use strict";i.r(t),i.d(t,{MSWordNormalizer:()=>u,PasteFromOffice:()=>_,parseHtml:()=>v});var n=i(6854),o=i(4079),s=i(3291);function r(e){if(e.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(e){case"alpha-upper":return"upper-alpha";case"alpha-lower":return"lower-alpha";case"roman-upper":return"upper-roman";case"roman-lower":return"lower-roman";case"circle":case"disc":case"square":return e;default:return null}}function a(e,t,i){const n=t.parent,o=i.createElement(e.type),s=n.getChildIndex(t)+1;return i.insertChild(s,o,n),e.style&&i.setStyle("list-style-type",e.style,o),e.startIndex&&e.startIndex>1&&i.setAttribute("start",e.startIndex,o),o}function l(e){const t={},i=e.getStyle("mso-list");if(i){const e=i.match(/(^|\s{1,100})l(\d+)/i),n=i.match(/\s{0,100}lfo(\d+)/i),o=i.match(/\s{0,100}level(\d+)/i);e&&n&&o&&(t.id=e[2],t.order=n[1],t.indent=parseInt(o[1]))}return t}const c=//i,d=/xmlns:o="urn:schemas-microsoft-com/i;class u{constructor(e){this.document=e}isActive(e){return c.test(e)||d.test(e)}execute(e){const{body:t,stylesString:i}=e._parsedData;(function(e,t){if(!e.childCount)return;const i=new s.yj(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new s.xO({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),o=[];for(const e of i)if("elementStart"===e.type&&n.match(e.item)){const t=l(e.item);o.push({element:e.item,id:t.id,order:t.order,indent:t.indent})}return o}(e,i);if(!n.length)return;let o=null,c=1;n.forEach(((e,l)=>{const d=function(e,t){if(!e)return!0;if(e.id!==t.id)return t.indent-e.indent!=1;const i=t.element.previousSibling;return!i||!((n=i).is("element","ol")||n.is("element","ul"));var n}(n[l-1],e),u=(m=e,(h=d?null:n[l-1])?m.indent-h.indent:m.indent-1);var h,m;if(d&&(o=null,c=1),!o||0!==u){const n=function(e,t){const i=/mso-level-number-format:([^;]{0,100});/gi,n=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,o=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi").exec(t);let s="decimal",a="ol",l=null;if(o&&o[1]){const t=i.exec(o[1]);if(t&&t[1]&&(s=t[1].trim(),a="bullet"!==s&&"image"!==s?"ol":"ul"),"bullet"===s){const t=function(e){const t=function(e){if(e.getChild(0).is("$text"))return null;for(const t of e.getChildren()){if(!t.is("element","span"))continue;const e=t.getChild(0);if(e)return e.is("$text")?e:e.getChild(0)}return null}(e);if(!t)return null;const i=t._data;return"o"===i?"circle":"·"===i?"disc":"§"===i?"square":null}(e.element);t&&(s=t)}else{const e=n.exec(o[1]);e&&e[1]&&(l=parseInt(e[1]))}}return{type:a,startIndex:l,style:r(s)}}(e,t);if(o){if(e.indent>c){const e=o.getChild(o.childCount-1),t=e.getChild(e.childCount-1);o=a(n,t,i),c+=1}else if(e.indente.indexOf(t)>-1))?r.push(i):i.getAttribute("src")||r.push(i)}for(const e of r)i.remove(e)}(n,e,i),function(e,t,i){const n=i.createRangeIn(t),o=[];for(const t of n)if("elementStart"==t.type&&t.item.is("element","v:shape")){const i=t.item.getAttribute("id");if(e.includes(i))continue;s(t.item.parent.getChildren(),i)||o.push(t.item)}for(const e of o){const t={src:r(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const n=i.createElement("img",t);i.insertChild(e.index+1,n,e.parent)}function s(e,t){for(const i of e)if(i.is("element")){if("img"==i.name&&i.getAttribute("v:shapes")==t)return!0;if(s(i.getChildren(),t))return!0}return!1}function r(e){for(const t of e.getChildren())if(t.is("element")&&t.getAttribute("src"))return t.getAttribute("src")}}(n,e,i),function(e,t){const i=t.createRangeIn(e),n=new s.xO({name:/v:(.+)/}),o=[];for(const e of i)"elementStart"==e.type&&n.match(e.item)&&o.push(e.item);for(const e of o)t.remove(e)}(e,i);const o=function(e,t){const i=t.createRangeIn(e),n=new s.xO({name:"img"}),o=[];for(const e of i)e.item.is("element")&&n.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&o.push(e.item);return o}(e,i);o.length&&function(e,t,i){if(e.length===t.length)for(let o=0;oString.fromCharCode(parseInt(e,16)))).join(""))}`;i.setAttribute("src",s,e[o])}var n}(o,function(e){if(!e)return[];const t=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,i=new RegExp("(?:("+t.source+"))([\\da-fA-F\\s]+)\\}","g"),n=e.match(i),o=[];if(n)for(const e of n){let i=!1;e.includes("\\pngblip")?i="image/png":e.includes("\\jpegblip")&&(i="image/jpeg"),i&&o.push({hex:e.replace(t,"").replace(/[^\da-fA-F]/g,""),type:i})}return o}(t),i)}(t,e.dataTransfer.getData("text/rtf")),function(e){const t=new s.yj(e.document);for(const i of e.getChildren()){if(!i.is("element"))continue;if(i.is("element","table")){t.setAttribute("align","left",i);continue}const e=i.getAttribute("align"),n=i.getChild(0);"div"===i.name&&e&&n&&n.is("element","table")&&t.setAttribute("align","center"===e?"none":e,n)}}(t),e.content=t}}function h(e,t,i,{blockElements:n,inlineObjectElements:o}){let s=i.createPositionAt(e,"forward"==t?"after":"before");return s=s.getLastMatchingPosition((({item:e})=>e.is("element")&&!n.includes(e.name)&&!o.includes(e.name)),{direction:t}),"forward"==t?s.nodeAfter:s.nodeBefore}function m(e,t){return!!e&&e.is("element")&&t.includes(e.name)}const g=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class f{constructor(e){this.document=e}isActive(e){return g.test(e)}execute(e){const t=new s.yj(this.document),{body:i}=e._parsedData;!function(e,t){for(const i of e.getChildren())if(i.is("element","b")&&"normal"===i.getStyle("font-weight")){const n=e.getChildIndex(i);t.remove(i),t.insertChild(n,i.getChildren(),e)}}(i,t),function(e,t){for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","li")){const i=e.getChild(0);i&&i.is("element","p")&&t.unwrapElement(i)}}}(i,t),function(e,t){const i=new s.Ux(t.document.stylesProcessor),n=new s.pG(i,{renderingMode:"data"}),o=n.blockElements,r=n.inlineObjectElements,a=[];for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","br")){const i=h(e,"forward",t,{blockElements:o,inlineObjectElements:r}),n=h(e,"backward",t,{blockElements:o,inlineObjectElements:r}),s=m(i,o);(m(n,o)||s)&&a.push(e)}}for(const e of a)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(i,t),e.content=i}}const p=/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length)))}function v(e,t){const i=new DOMParser,n=function(e){return w(w(e)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/()[\r\n]+(<\/span>)/g,"$1 $2").replace(/ <\//g," <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(e){const t="",i=e.indexOf(t);if(i<0)return e;const n=e.indexOf("",i+7);return e.substring(0,i+7)+(n>=0?e.substring(n):"")}(e=e.replace(//g,"")}(n.getData("text/html")):n.getData("text/plain")&&(((r=(r=n.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),s=this.editor.data.htmlProcessor.toView(e)}var r;const a=new o.EventInfo(this,"inputTransformation");this.fire(a,{content:s,dataTransfer:n,targetRanges:t.targetRanges,method:t.method}),a.stop.called&&e.stop(),i.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,i)=>{if(i.content.isEmpty)return;const n=this.editor.data.toModel(i.content,"$clipboardHolder");0!=n.childCount&&(e.stop(),t.change((()=>{this.fire("contentInsertion",{content:n,method:i.method,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,i)=>{i.resultRange=t.insertContent(i.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,n=(n,o)=>{const s=o.dataTransfer;o.preventDefault();const r=e.data.toView(e.model.getSelectedContent(t.selection));i.fire("clipboardOutput",{dataTransfer:s,content:r,method:n.name})};this.listenTo(i,"copy",n,{priority:"low"}),this.listenTo(i,"cut",((t,i)=>{e.model.canEditAt(e.model.document.selection)?n(t,i):i.preventDefault()}),{priority:"low"}),this.listenTo(i,"clipboardOutput",((i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",l(n.content))),"cut"==n.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}var d=i(1460),u=i(111);class h extends n.Plugin{static get pluginName(){return"DragDrop"}static get requires(){return[c,d.Widget]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=(0,u.Z)((e=>this._updateDropMarker(e)),40),this._removeDropMarkerDelayed=(0,o.delay)((()=>this._removeDropMarker()),40),this._clearDraggableAttributesDelayed=(0,o.delay)((()=>this._clearDraggableAttributes()),40),e.plugins.has("DragDropExperimental")?this.forceDisabled("DragDropExperimental"):(t.addObserver(r),t.addObserver(s.MouseObserver),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",((e,t,i)=>{i?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((e,t,i)=>{i||this._finalizeDragging(!1)})),o.env.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,i=t.document,n=e.editing.view,r=n.document;this.listenTo(r,"dragstart",((n,a)=>{const l=i.selection;if(a.target&&a.target.is("editableElement"))return void a.preventDefault();const c=a.target?f(a.target):null;if(c){const i=e.editing.mapper.toModelElement(c);this._draggedRange=s.LiveRange.fromRange(t.createRangeOn(i)),e.plugins.has("WidgetToolbarRepository")&&e.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}else if(!r.selection.isCollapsed){const e=r.selection.getSelectedElement();e&&(0,d.isWidget)(e)||(this._draggedRange=s.LiveRange.fromRange(l.getFirstRange()))}if(!this._draggedRange)return void a.preventDefault();this._draggingUid=(0,o.uid)();const u=this.isEnabled&&e.model.canEditAt(this._draggedRange);a.dataTransfer.effectAllowed=u?"copyMove":"copy",a.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const h=t.createSelection(this._draggedRange.toRange()),m=e.data.toView(t.getSelectedContent(h));r.fire("clipboardOutput",{dataTransfer:a.dataTransfer,content:m,method:"dragstart"}),u||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(r,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this.listenTo(r,"dragenter",(()=>{this.isEnabled&&n.focus()})),this.listenTo(r,"dragleave",(()=>{this._removeDropMarkerDelayed()})),this.listenTo(r,"dragging",((t,i)=>{if(!this.isEnabled)return void(i.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const n=m(e,i.targetRanges,i.target);e.model.canEditAt(n)?(this._draggedRange||(i.dataTransfer.dropEffect="copy"),o.env.isGecko||("copy"==i.dataTransfer.effectAllowed?i.dataTransfer.dropEffect="copy":["all","copyMove"].includes(i.dataTransfer.effectAllowed)&&(i.dataTransfer.dropEffect="move")),n&&this._updateDropMarkerThrottled(n)):i.dataTransfer.dropEffect="none"}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"clipboardInput",((t,i)=>{if("drop"!=i.method)return;const n=m(e,i.targetRanges,i.target);return this._removeDropMarker(),n&&e.model.canEditAt(n)?(this._draggedRange&&this._draggingUid!=i.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid=""),"move"==g(i.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(n,!0)?(this._finalizeDragging(!1),void t.stop()):void(i.targetRanges=[e.editing.mapper.toViewRange(n)])):(this._finalizeDragging(!1),void t.stop())}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(c);e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i=t.targetRanges.map((e=>this.editor.editing.mapper.toModelRange(e)));this.editor.model.change((e=>e.setSelection(i)))}),{priority:"high"}),e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i="move"==g(t.dataTransfer),n=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(n&&i)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"mousedown",((n,s)=>{if(o.env.isAndroid||!s)return;this._clearDraggableAttributesDelayed.cancel();let r=f(s.target);if(o.env.isBlink&&!r&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();if(!e||!(0,d.isWidget)(e)){const e=i.selection.editableElement;e&&!e.isReadOnly&&(r=e)}}r&&(t.change((e=>{e.setAttribute("draggable","true",r)})),this._draggableElement=e.editing.mapper.toModelElement(r))})),this.listenTo(i,"mouseup",(()=>{o.env.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:i})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return i.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,i=t.model.markers;t.model.change((t=>{i.has("drop-target")?i.get("drop-target").getRange().isEqual(e)||t.updateMarker("drop-target",{range:e}):t.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})}))}_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,i=t.model;this._removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._draggedRange&&(e&&this.isEnabled&&i.deleteContent(i.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function m(e,t,i){const n=e.model,s=e.editing.mapper;let r=null;const a=t?t[0].start:null;if(i.is("uiElement")&&(i=i.parent),r=function(e,t){const i=e.model,n=e.editing.mapper;if((0,d.isWidget)(t))return i.createRangeOn(n.toModelElement(t));if(!t.is("editableElement")){const e=t.findAncestor((e=>(0,d.isWidget)(e)||e.is("editableElement")));if((0,d.isWidget)(e))return i.createRangeOn(n.toModelElement(e))}return null}(e,i),r)return r;const l=function(e,t){const i=e.editing.mapper,n=e.editing.view,o=i.toModelElement(t);if(o)return o;const s=n.createPositionBefore(t),r=i.findMappedViewAncestor(s);return i.toModelElement(r)}(e,i),c=a?s.toModelPosition(a):null;return c?(r=function(e,t,i){const n=e.model;if(!n.schema.checkChild(i,"$block"))return null;const o=n.createPositionAt(i,0),s=t.path.slice(0,o.path.length),r=n.createPositionFromPath(t.root,s).nodeAfter;return r&&n.schema.isObject(r)?n.createRangeOn(r):null}(e,c,l),r||(r=n.schema.getNearestSelectionRange(c,o.env.isGecko?"forward":"backward"),r||function(e,t){const i=e.model;let n=t;for(;n;){if(i.schema.isObject(n))return i.createRangeOn(n);n=n.parent}return null}(e,c.parent))):function(e,t){const i=e.model,n=i.schema,o=i.createPositionAt(t,0);return n.getNearestSelectionRange(o,"forward")}(e,l)}function g(e){return o.env.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function f(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(d.isWidget);if((0,d.isWidget)(e))return e;const t=e.findAncestor((e=>(0,d.isWidget)(e)||e.is("editableElement")));return(0,d.isWidget)(t)?t:null}class p extends n.Plugin{static get pluginName(){return"PastePlainText"}static get requires(){return[c]}init(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,o=t.document.selection;let s=!1;i.addObserver(r),this.listenTo(n,"keydown",((e,t)=>{s=t.shiftKey})),e.plugins.get(c).on("contentInsertion",((e,i)=>{(s||function(e,t){if(e.childCount>1)return!1;const i=e.getChild(0);return!t.isObject(i)&&0==Array.from(i.getAttributeKeys()).length}(i.content,t.schema))&&t.change((e=>{const n=Array.from(o.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0}),n.push(...o.getAttributes());const s=e.createRangeIn(i.content);for(const t of s.getItems())t.is("$textProxy")&&e.setAttributes(n,t)}))}))}}class b extends n.Plugin{static get pluginName(){return"Clipboard"}static get requires(){return[c,h,p]}}i(2692),(0,o.toUnit)("px")},6854:(e,t,i)=>{"use strict";i.d(t,{AJ:()=>n.MultiCommand,ML:()=>n.Editor,P$:()=>n.attachToForm,Sy:()=>n.Plugin,W9:()=>n.DataApiMixin,_y:()=>n.Context,icons:()=>n.icons,lR:()=>n.PendingActions,mY:()=>n.Command,xK:()=>n.ElementApiMixin});var n=i(7833)},3291:(e,t,i)=>{"use strict";i.d(t,{$_:()=>n.hidePlaceholder,D5:()=>n.isColor,G9:()=>n.isLength,ID:()=>n.enablePlaceholder,J8:()=>n.addPaddingRules,KU:()=>n.ClickObserver,NJ:()=>n.showPlaceholder,Po:()=>n.TreeWalker,Q7:()=>n.needsPlaceholder,QR:()=>n.addBackgroundRules,Qj:()=>n.Observer,Ux:()=>n.ViewDocument,W_:()=>n.Element,YG:()=>n.getFillerOffset,dM:()=>n.MouseObserver,iE:()=>n.LiveRange,jP:()=>n.LivePosition,pG:()=>n.DomConverter,qD:()=>n.DowncastWriter,qZ:()=>n.DomEventObserver,sI:()=>n.addBorderRules,vt:()=>n.addMarginRules,xO:()=>n.Matcher,yj:()=>n.UpcastWriter,zz:()=>n.isPercentage});var n=i(6243)},1863:(e,t,i)=>{"use strict";i.d(t,{C:()=>n.C,G:()=>n.G});var n=i(5725)},5187:(e,t,i)=>{"use strict";i.d(t,{HG:()=>n.HG,II:()=>n.II,Im:()=>n.Im,Mq:()=>n.Mq,Up:()=>n.Up,VD:()=>n.VD,mh:()=>n.mh,uL:()=>n.uL});var n=i(3701)},7095:(e,t,i)=>{"use strict";i.d(t,{$y:()=>n.ToolbarSeparatorView,BM:()=>n.SwitchButtonView,Bv:()=>n.ListView,Dn:()=>n.LabelView,FH:()=>n.createLabeledDropdown,G7:()=>n.View,GI:()=>n.submitHandler,Gp:()=>n.FormHeaderView,Hn:()=>n.Model,I0:()=>n.FocusCycler,IJ:()=>n.addKeyboardHandlingForGrid,J0:()=>n.DropdownButtonView,KP:()=>n.LabeledFieldView,MI:()=>n.ColorSelectorView,Mh:()=>n.focusChildOnDropdownOpen,P_:()=>n.Notification,Pm:()=>n.addListToDropdown,R:()=>n.createLabeledInputText,RX:()=>n.CssTransitionDisablerMixin,Rm:()=>n.SplitButtonView,S1:()=>n.normalizeColorOptions,S8:()=>n.EditorUI,WB:()=>n.ContextualBalloon,dn:()=>n.ListItemView,eC:()=>n.clickOutsideHandler,iw:()=>n.normalizeToolbarConfig,jB:()=>n.ToolbarView,k6:()=>n.getLocalizedColorOptions,lp:()=>n.StickyPanelView,no:()=>n.BalloonPanelView,pq:()=>n.InputTextView,py:()=>n.BoxedEditorUIView,r1:()=>n.InlineEditableUIView,r5:()=>n.ButtonView,sh:()=>n.createLabeledInputNumber,t9:()=>n.createDropdown,up:()=>n.addToolbarToDropdown,vX:()=>n.ViewCollection});var n=i(2692)},1903:(e,t,i)=>{"use strict";i.d(t,{WP:()=>n.Undo});var n=i(8779)},6553:(e,t,i)=>{"use strict";i.d(t,{Bb:()=>n.CKEditorError,CO:()=>n.global,Cq:()=>n.getCode,Do:()=>n.keyCodes,FE:()=>n.Collection,KE:()=>n.logWarning,OB:()=>n.env,Ps:()=>n.first,Re:()=>n.ObservableMixin,Rh:()=>n.FocusTracker,UL:()=>n.Rect,VD:()=>n.KeystrokeHandler,Xu:()=>n.DomEmitterMixin,Zz:()=>n.parseKeystroke,a6:()=>n.ElementReplacer,az:()=>n.createElement,hQ:()=>n.uid,mA:()=>n.getLocalizedArrowKeyCodeDirection,qL:()=>n.toMap,qo:()=>n.toArray,tA:()=>n.priorities,yy:()=>n.getDataFromElement});var n=i(5044)},5549:(e,t,i)=>{"use strict";i.d(t,{$L:()=>n.Widget,KT:()=>n.findOptimalInsertionRange,Qd:()=>n.isWidget,WR:()=>n.WidgetResize,XC:()=>n.toWidget,e8:()=>n.WidgetToolbarRepository,sC:()=>n.toWidgetEditable});var n=i(1460)},8168:(e,t,i)=>{const n=i(8874),o={};for(const e of Object.keys(n))o[n[e]]=e;const s={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};e.exports=s;for(const e of Object.keys(s)){if(!("channels"in s[e]))throw new Error("missing channels property: "+e);if(!("labels"in s[e]))throw new Error("missing channel labels property: "+e);if(s[e].labels.length!==s[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:i}=s[e];delete s[e].channels,delete s[e].labels,Object.defineProperty(s[e],"channels",{value:t}),Object.defineProperty(s[e],"labels",{value:i})}s.rgb.hsl=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,o=Math.min(t,i,n),s=Math.max(t,i,n),r=s-o;let a,l;s===o?a=0:t===s?a=(i-n)/r:i===s?a=2+(n-t)/r:n===s&&(a=4+(t-i)/r),a=Math.min(60*a,360),a<0&&(a+=360);const c=(o+s)/2;return l=s===o?0:c<=.5?r/(s+o):r/(2-s-o),[a,100*l,100*c]},s.rgb.hsv=function(e){let t,i,n,o,s;const r=e[0]/255,a=e[1]/255,l=e[2]/255,c=Math.max(r,a,l),d=c-Math.min(r,a,l),u=function(e){return(c-e)/6/d+.5};return 0===d?(o=0,s=0):(s=d/c,t=u(r),i=u(a),n=u(l),r===c?o=n-i:a===c?o=1/3+t-n:l===c&&(o=2/3+i-t),o<0?o+=1:o>1&&(o-=1)),[360*o,100*s,100*c]},s.rgb.hwb=function(e){const t=e[0],i=e[1];let n=e[2];const o=s.rgb.hsl(e)[0],r=1/255*Math.min(t,Math.min(i,n));return n=1-1/255*Math.max(t,Math.max(i,n)),[o,100*r,100*n]},s.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,o=Math.min(1-t,1-i,1-n);return[100*((1-t-o)/(1-o)||0),100*((1-i-o)/(1-o)||0),100*((1-n-o)/(1-o)||0),100*o]},s.rgb.keyword=function(e){const t=o[e];if(t)return t;let i,s=1/0;for(const t of Object.keys(n)){const o=(a=n[t],((r=e)[0]-a[0])**2+(r[1]-a[1])**2+(r[2]-a[2])**2);o.04045?((t+.055)/1.055)**2.4:t/12.92,i=i>.04045?((i+.055)/1.055)**2.4:i/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,[100*(.4124*t+.3576*i+.1805*n),100*(.2126*t+.7152*i+.0722*n),100*(.0193*t+.1192*i+.9505*n)]},s.rgb.lab=function(e){const t=s.rgb.xyz(e);let i=t[0],n=t[1],o=t[2];return i/=95.047,n/=100,o/=108.883,i=i>.008856?i**(1/3):7.787*i+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,o=o>.008856?o**(1/3):7.787*o+16/116,[116*n-16,500*(i-n),200*(n-o)]},s.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;let o,s,r;if(0===i)return r=255*n,[r,r,r];o=n<.5?n*(1+i):n+i-n*i;const a=2*n-o,l=[0,0,0];for(let e=0;e<3;e++)s=t+1/3*-(e-1),s<0&&s++,s>1&&s--,r=6*s<1?a+6*(o-a)*s:2*s<1?o:3*s<2?a+(o-a)*(2/3-s)*6:a,l[e]=255*r;return l},s.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,n=e[2]/100,o=i;const s=Math.max(n,.01);return n*=2,i*=n<=1?n:2-n,o*=s<=1?s:2-s,[t,100*(0===n?2*o/(s+o):2*i/(n+i)),(n+i)/2*100]},s.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let n=e[2]/100;const o=Math.floor(t)%6,s=t-Math.floor(t),r=255*n*(1-i),a=255*n*(1-i*s),l=255*n*(1-i*(1-s));switch(n*=255,o){case 0:return[n,l,r];case 1:return[a,n,r];case 2:return[r,n,l];case 3:return[r,a,n];case 4:return[l,r,n];case 5:return[n,r,a]}},s.hsv.hsl=function(e){const t=e[0],i=e[1]/100,n=e[2]/100,o=Math.max(n,.01);let s,r;r=(2-i)*n;const a=(2-i)*o;return s=i*o,s/=a<=1?a:2-a,s=s||0,r/=2,[t,100*s,100*r]},s.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,n=e[2]/100;const o=i+n;let s;o>1&&(i/=o,n/=o);const r=Math.floor(6*t),a=1-n;s=6*t-r,0!=(1&r)&&(s=1-s);const l=i+s*(a-i);let c,d,u;switch(r){default:case 6:case 0:c=a,d=l,u=i;break;case 1:c=l,d=a,u=i;break;case 2:c=i,d=a,u=l;break;case 3:c=i,d=l,u=a;break;case 4:c=l,d=i,u=a;break;case 5:c=a,d=i,u=l}return[255*c,255*d,255*u]},s.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,o=e[3]/100;return[255*(1-Math.min(1,t*(1-o)+o)),255*(1-Math.min(1,i*(1-o)+o)),255*(1-Math.min(1,n*(1-o)+o))]},s.xyz.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100;let o,s,r;return o=3.2406*t+-1.5372*i+-.4986*n,s=-.9689*t+1.8758*i+.0415*n,r=.0557*t+-.204*i+1.057*n,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,r=r>.0031308?1.055*r**(1/2.4)-.055:12.92*r,o=Math.min(Math.max(0,o),1),s=Math.min(Math.max(0,s),1),r=Math.min(Math.max(0,r),1),[255*o,255*s,255*r]},s.xyz.lab=function(e){let t=e[0],i=e[1],n=e[2];return t/=95.047,i/=100,n/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,i=i>.008856?i**(1/3):7.787*i+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,[116*i-16,500*(t-i),200*(i-n)]},s.lab.xyz=function(e){let t,i,n;i=(e[0]+16)/116,t=e[1]/500+i,n=i-e[2]/200;const o=i**3,s=t**3,r=n**3;return i=o>.008856?o:(i-16/116)/7.787,t=s>.008856?s:(t-16/116)/7.787,n=r>.008856?r:(n-16/116)/7.787,t*=95.047,i*=100,n*=108.883,[t,i,n]},s.lab.lch=function(e){const t=e[0],i=e[1],n=e[2];let o;return o=360*Math.atan2(n,i)/2/Math.PI,o<0&&(o+=360),[t,Math.sqrt(i*i+n*n),o]},s.lch.lab=function(e){const t=e[0],i=e[1],n=e[2]/360*2*Math.PI;return[t,i*Math.cos(n),i*Math.sin(n)]},s.rgb.ansi16=function(e,t=null){const[i,n,o]=e;let r=null===t?s.rgb.hsv(e)[2]:t;if(r=Math.round(r/50),0===r)return 30;let a=30+(Math.round(o/255)<<2|Math.round(n/255)<<1|Math.round(i/255));return 2===r&&(a+=60),a},s.hsv.ansi16=function(e){return s.rgb.ansi16(s.hsv.rgb(e),e[2])},s.rgb.ansi256=function(e){const t=e[0],i=e[1],n=e[2];return t===i&&i===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)},s.ansi16.rgb=function(e){let t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const i=.5*(1+~~(e>50));return[(1&t)*i*255,(t>>1&1)*i*255,(t>>2&1)*i*255]},s.ansi256.rgb=function(e){if(e>=232){const t=10*(e-232)+8;return[t,t,t]}let t;return e-=16,[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},s.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},s.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let i=t[0];3===t[0].length&&(i=i.split("").map((e=>e+e)).join(""));const n=parseInt(i,16);return[n>>16&255,n>>8&255,255&n]},s.rgb.hcg=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,o=Math.max(Math.max(t,i),n),s=Math.min(Math.min(t,i),n),r=o-s;let a,l;return a=r<1?s/(1-r):0,l=r<=0?0:o===t?(i-n)/r%6:o===i?2+(n-t)/r:4+(t-i)/r,l/=6,l%=1,[360*l,100*r,100*a]},s.hsl.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=i<.5?2*t*i:2*t*(1-i);let o=0;return n<1&&(o=(i-.5*n)/(1-n)),[e[0],100*n,100*o]},s.hsv.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=t*i;let o=0;return n<1&&(o=(i-n)/(1-n)),[e[0],100*n,100*o]},s.hcg.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;if(0===i)return[255*n,255*n,255*n];const o=[0,0,0],s=t%1*6,r=s%1,a=1-r;let l=0;switch(Math.floor(s)){case 0:o[0]=1,o[1]=r,o[2]=0;break;case 1:o[0]=a,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=r;break;case 3:o[0]=0,o[1]=a,o[2]=1;break;case 4:o[0]=r,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=a}return l=(1-i)*n,[255*(i*o[0]+l),255*(i*o[1]+l),255*(i*o[2]+l)]},s.hcg.hsv=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);let n=0;return i>0&&(n=t/i),[e[0],100*n,100*i]},s.hcg.hsl=function(e){const t=e[1]/100,i=e[2]/100*(1-t)+.5*t;let n=0;return i>0&&i<.5?n=t/(2*i):i>=.5&&i<1&&(n=t/(2*(1-i))),[e[0],100*n,100*i]},s.hcg.hwb=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);return[e[0],100*(i-t),100*(1-i)]},s.hwb.hcg=function(e){const t=e[1]/100,i=1-e[2]/100,n=i-t;let o=0;return n<1&&(o=(i-n)/(1-n)),[e[0],100*n,100*o]},s.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},s.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},s.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},s.gray.hsl=function(e){return[0,0,e[0]]},s.gray.hsv=s.gray.hsl,s.gray.hwb=function(e){return[0,100,e[0]]},s.gray.cmyk=function(e){return[0,0,0,e[0]]},s.gray.lab=function(e){return[e[0],0,0]},s.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(i.length)+i},s.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}},2085:(e,t,i)=>{const n=i(8168),o=i(4111),s={};Object.keys(n).forEach((e=>{s[e]={},Object.defineProperty(s[e],"channels",{value:n[e].channels}),Object.defineProperty(s[e],"labels",{value:n[e].labels});const t=o(e);Object.keys(t).forEach((i=>{const n=t[i];s[e][i]=function(e){const t=function(...t){const i=t[0];if(null==i)return i;i.length>1&&(t=i);const n=e(t);if("object"==typeof n)for(let e=n.length,t=0;t1&&(t=i),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(n)}))})),e.exports=s},4111:(e,t,i)=>{const n=i(8168);function o(e,t){return function(i){return t(e(i))}}function s(e,t){const i=[t[e].parent,e];let s=n[t[e].parent][e],r=t[e].parent;for(;t[r].parent;)i.unshift(t[r].parent),s=o(n[t[r].parent][r],s),r=t[r].parent;return s.conversion=i,s}e.exports=function(e){const t=function(e){const t=function(){const e={},t=Object.keys(n);for(let i=t.length,n=0;n{"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},3905:(e,t,i)=>{"use strict";i.r(t)},6961:(e,t,i)=>{"use strict";i.r(t)},2170:(e,t,i)=>{"use strict";i.r(t)},6677:(e,t,i)=>{"use strict";i.r(t)},5253:(e,t,i)=>{"use strict";i.r(t)},2946:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=''},7630:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=''},5270:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=''},8217:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=''},366:(e,t,i)=>{var n,o;n=[i,t,i(511),i(6549),i(7971),i(3306),i(6597),i(7833),i(5480),i(1638),i(3457),i(8107),i(5242),i(8691),i(2337),i(7261),i(3531),i(5127),i(6144),i(6335),i(4690),i(7983),i(9501),i(5247),i(8779),i(766),i(9910),i(2823),i(8029),i(3706),i(5600),i(1294),i(8206),i(5825),i(9782),i(4201),i(7080),i(8427),i(5469),i(9402),i(8152)],o=function(e,t,i,n,o,s,r,a,l,c,d,u,h,m,g,f,p,b,w,v,_,y,k,C,A,E,x,T,S,P,I,V,R,O,B,M,N,D,L,F,z){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=void 0;const H={plugins:[n.Autosave,c.Essentials,p.Indent,v.Mention,_.Paragraph,y.PasteFromOffice,A.Undo,i.Alignment,o.Bold,o.Code,d.FontColor,d.FontFamily,d.FontSize,u.Heading,h.Highlight,o.Italic,k.RemoveFormat,o.Strikethrough,o.Subscript,o.Superscript,o.Underline,s.BlockQuote,r.CodeBlock,m.HtmlEmbed,g.HorizontalLine,f.Image,f.ImageInsertUI,f.ImageToolbar,f.ImageResizeEditing,f.ImageResizeHandles,f.ImageStyle,f.ImageUpload,f.ImageUploadUI,b.Link,b.LinkImage,w.List,C.Table,C.TableToolbar,E.WoltlabAttachment,x.WoltlabAutosave,S.WoltlabBlockQuote,T.WoltlabBbcode,P.WoltlabCode,I.WoltlabCodeBlock,V.WoltlabHtmlEmbed,R.WoltlabImage,O.WoltlabMagicParagraph,B.WoltlabMedia,M.WoltlabMention,N.WoltlabMetacode,D.WoltlabSmiley,L.WoltlabSpoiler,F.WoltlabToolbarGroup,z.WoltlabUpload]};t.create=async function(e,t){const i=(t=Object.assign(t,H)).removePlugins||[];i.includes("Image")||(t.image={insert:{integrations:["insertImageViaUrl"],type:"inline"},toolbar:["imageStyle:inline","imageStyle:sideLeft","imageStyle:block","imageStyle:side"],resizeUnit:"px",styles:{options:["inline",{name:"sideLeft",title:"Left aligned image",icon:a.icons.objectLeft,modelElements:["imageBlock"],className:"image-style-side-left"},"block","side"]}},i.includes("Link")||t.image.toolbar.push("|","linkImage")),i.includes("Table")||(t.table={contentToolbar:["tableColumn","tableRow","mergeTableCells"]});const n=await l.ClassicEditor.create(e,t),o=n.plugins.get(b.AutoLink);return o?.forceDisabled("app.ts"),n}}.apply(t,n),void 0===o||(e.exports=o)},766:(e,t,i)=>{var n,o;n=[i,t,i(4815)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabAttachment=void 0,Object.defineProperty(t,"WoltlabAttachment",{enumerable:!0,get:function(){return i.WoltlabAttachment}})}.apply(t,n),void 0===o||(e.exports=o)},4815:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(7261)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabAttachment=void 0;class o extends i.Plugin{static get pluginName(){return"WoltlabAttachment"}static get requires(){return[n.Image]}init(){const{conversion:e,model:t,plugins:i}=this.editor,{schema:n}=t,o=["imageBlock","imageInline"];o.forEach((e=>{n.extend(e,{allowAttributes:["attachmentId"]})}));const s=new Map([["attachmentId","data-attachment-id"]]);Array.from(s.entries()).forEach((([t,i])=>{e.for("upcast").attributeToAttribute({view:i,model:t}),e.for("downcast").add((e=>{o.forEach((n=>{e.on(`attribute:${t}:${n}`,((e,t,n)=>{if(!n.consumable.consume(t.item,e.name))return;const o=n.writer;let s=n.mapper.toViewElement(t.item);s.is("element","figure")&&(s=s.getChild(0)),s.is("element","img")&&(null!==t.attributeNewValue?(o.setAttribute(i,t.attributeNewValue,s),o.addClass("woltlabAttachment",s)):o.removeAttribute(i,s))}))}))}))})),i.get("ImageUploadEditing").on("uploadComplete",((e,{data:i,imageElement:n})=>{t.change((e=>{e.setAttribute("attachmentId",i["data-attachment-id"],n)}))})),this.#e()}#e(){const e=this.editor.config.get("woltlabAttachment");this.editor.plugins.get("WoltlabMetacode").on("upcast",((t,i)=>{if("attach"!==i.name)return;const n=parseInt(i.attributes[0].toString());if(Number.isNaN(n))return;if(!e.inlineImageIds.includes(n))return;let o=i.attributes[1]?i.attributes[1].toString():"none";"left"!==o&&"right"!==o&&"none"!==o&&(o="none");let s=i.attributes[2],r="auto";"boolean"!=typeof s&&("string"==typeof s||"number"==typeof s?"true"===s?s=!0:("false"===s||(s=parseInt(s.toString()),Number.isNaN(s)||0===s||(r=`${s}px`)),s=!1):s=!1),this.#t(i,e.resolveAttachmentUrl,n,o,s,r)&&t.stop()}))}#t(e,t,i,n,o,s){const{conversionApi:r,data:a}=e,{consumable:l,writer:c}=r,{viewItem:d}=a;let u="imageInline",h={attachmentId:i,src:t(i,o),width:s};"left"===n?(u="imageBlock",h.imageStyle="sideLeft"):"right"===n&&(u="imageBlock",h.imageStyle="side");const m=c.createElement(u);return c.setAttributes(h,m),r.convertChildren(d,m),!!r.safeInsert(m,a.modelCursor)&&(l.consume(d,{name:!0}),r.updateConversionResult(m,a),!0)}}t.WoltlabAttachment=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},9910:(e,t,i)=>{var n,o;n=[i,t,i(6076)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabAutosave=void 0,Object.defineProperty(t,"WoltlabAutosave",{enumerable:!0,get:function(){return i.WoltlabAutosave}})}.apply(t,n),void 0===o||(e.exports=o)},6076:(e,t,i)=>{var n,o;n=[i,t,i(6549),i(7833)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabAutosave=void 0;class o extends n.Plugin{static get pluginName(){return"WoltlabAutosave"}static get requires(){return[i.Autosave]}init(){const e=this.editor.plugins.get("PendingActions");e.hasAny=!1,e.on("set:hasAny",(e=>{e.return=!1,e.stop()}),{priority:"highest"})}}t.WoltlabAutosave=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},2823:(e,t,i)=>{var n,o;n=[i,t,i(9800),i(7489)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBbcodeCommand=t.WoltlabBbcode=void 0,Object.defineProperty(t,"WoltlabBbcode",{enumerable:!0,get:function(){return i.WoltlabBbcode}}),Object.defineProperty(t,"WoltlabBbcodeCommand",{enumerable:!0,get:function(){return n.WoltlabBbcodeCommand}})}.apply(t,n),void 0===o||(e.exports=o)},9800:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(2692),i(7489)],o=function(e,t,i,n,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBbcode=void 0;class s extends i.Plugin{static get pluginName(){return"WoltlabBbcode"}init(){const{componentFactory:e}=this.editor.ui,t=this.editor.config.get("woltlabBbcode");if(!t)return;const i=new o.default(this.editor);this.editor.commands.add("insertBbcode",i);for(const n of t)this.#i(n,e,i)}#i(e,t,i){const{icon:o,name:s,label:r}=e;t.add(`woltlabBbcode_${s}`,(()=>{const e=new n.ButtonView;if(e.label=r,e.tooltip=!0,e.withText=!0,o)if(o.includes(";")){const[t,i]=o.split(";",2);let n={name:t};"true"===i&&(n.solid="true"),e.labelView.setTemplate({tag:"fa-icon",attributes:n})}else e.labelView.setTemplate({tag:"img",attributes:{src:o}});return e.bind("isEnabled").to(i,"isEnabled"),this.listenTo(e,"execute",(()=>{this.editor.execute("insertBbcode",s)})),e}))}}t.WoltlabBbcode=s,t.default=s}.apply(t,n),void 0===o||(e.exports=o)},7489:(e,t,i)=>{var n,o;n=[i,t,i(7833)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBbcodeCommand=void 0;class n extends i.Command{execute(e){const{editing:t,model:i}=this.editor,n=this.editor.sourceElement,o=new CustomEvent("ckeditor5:bbcode",{cancelable:!0,detail:{bbcode:e}});n.dispatchEvent(o),o.defaultPrevented||i.change((n=>{const o=i.document.selection,s=n.createText(`[${e}]`),r=i.insertContent(s,o.getFirstPosition()),a=i.insertContent(n.createText(`[/${e}]`),o.isCollapsed?r.end:o.getLastPosition()),l=n.createRange(a.start);n.setSelection(l),t.view.focus()}))}refresh(){this.isEnabled=this.#n()}#n(){const{document:e,schema:t}=this.editor.model,{selection:i}=e;return t.checkAttributeInSelection(i,"bold")}}t.WoltlabBbcodeCommand=n,t.default=n}.apply(t,n),void 0===o||(e.exports=o)},8029:(e,t,i)=>{var n,o;n=[i,t,i(4587)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBlockQuote=void 0,Object.defineProperty(t,"WoltlabBlockQuote",{enumerable:!0,get:function(){return i.WoltlabBlockQuote}})}.apply(t,n),void 0===o||(e.exports=o)},6812:(e,t,i)=>{var n,o;n=[i,t,i(2692),i(6961)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBlockQuoteFormRowView=void 0;class n extends i.View{children;constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("class",t.class||""),this.children=this.createCollection(),t.children&&t.children.forEach((e=>this.children.add(e))),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",i.to("class")]},children:this.children})}}t.WoltlabBlockQuoteFormRowView=n,t.default=n}.apply(t,n),void 0===o||(e.exports=o)},8668:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(2692),i(5044),i(6812)],o=function(e,t,i,n,o,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBlockQuotePanelView=void 0;class r extends n.View{#o;#s;#r;#a;focusTracker;keystrokes;#l;#c;constructor(e){const{locale:t}=e;super(t),this.set("author",""),this.set("link",""),this.focusTracker=new o.FocusTracker,this.keystrokes=new o.KeystrokeHandler,this.#l=new n.ViewCollection,this.#c=this.#d();const i=this.#u(t);this.#r=i.fieldView;const s=this.#h(t);this.#a=s.fieldView,this.#o=this.#m(t),this.#s=this.#g(t),this.#f(t,i,s)}render(){super.render(),(0,n.submitHandler)({view:this});const e=[this.#r,this.#a,this.#o,this.#s];e.forEach((e=>{this.#l.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",(e=>e.stopPropagation())),this.keystrokes.set("arrowleft",(e=>e.stopPropagation())),this.keystrokes.set("arrowup",(e=>e.stopPropagation())),this.keystrokes.set("arrowdown",(e=>e.stopPropagation())),this.listenTo(e[0].element,"selectstart",((e,t)=>{t.stopPropagation()}),{priority:"high"}),this.on("submit",(()=>{this.fire("execute")}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.#c.focusFirst()}#u(e){const t=e.t,i=new n.LabeledFieldView(e,n.createLabeledInputText);return i.label=t("Author"),i.fieldView.bind("value").to(this,"author",(e=>e||"")),i.fieldView.on("input",(()=>{this.author=i.fieldView.element.value})),i}#h(e){const t=e.t,i=new n.LabeledFieldView(e,n.createLabeledInputText);return i.label=t("Link"),i.fieldView.bind("value").to(this,"link",(e=>e||"")),i.fieldView.on("input",(()=>{this.link=i.fieldView.element.value})),i}#m(e){const t=e.t,o=new n.ButtonView(e);return o.set({label:t("Insert"),icon:i.icons.check,class:"ck-button-save",type:"submit",withText:!0,isEnabled:!0}),o}#g(e){const t=e.t,o=new n.ButtonView(e);return o.set({label:t("Cancel"),icon:i.icons.cancel,class:"ck-button-cancel",withText:!0}),o.delegate("execute").to(this,"cancel"),o}#f(e,t,i){this.setTemplate({tag:"form",attributes:{class:["ck","ck-vertical-form","ck-woltlabblockquote-insert-form"],tabindex:"-1"},children:[t,i,new s.default(e,{children:[this.#o,this.#s],class:"ck-woltlabblockquote-insert-form__action-row"})]})}#d(){return new n.FocusCycler({focusables:this.#l,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}})}}t.WoltlabBlockQuotePanelView=r,t.default=r}.apply(t,n),void 0===o||(e.exports=o)},4587:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(2692),i(5044),i(8668),i(3905)],o=function(e,t,i,n,o,s){"use strict";function r(e){switch(typeof e){case"string":return e;case"number":case"boolean":return e.toString();default:return""}}Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBlockQuote=void 0;class a extends i.Plugin{#p=void 0;static get pluginName(){return"WoltlabBlockQuote"}init(){const e=this.editor;e.model.schema.extend("blockQuote",{allowAttributes:["author","link"]});const t=e.commands.get("blockQuote");this.#b(t),this.#w(),this.#v(),this.#_(),this.listenTo(t,"execute",(()=>{this.#y(this.#p)}))}#b(e){const t=this.editor,o=t.t;this.editor.ui.componentFactory.add("blockQuote",(a=>{const l=(0,n.createDropdown)(a,n.SplitButtonView),c=l.buttonView;c.set({label:o("Block quote"),tooltip:!0,icon:i.icons.quote,isToggleable:!0}),c.bind("isOn").to(e,"value",(e=>!!e)),c.on("execute",(()=>{t.execute("blockQuote"),t.editing.view.focus()})),l.on("submit",(e=>{const i=e.path.find((e=>e instanceof s.WoltlabBlockQuotePanelView));i instanceof s.WoltlabBlockQuotePanelView&&(this.#p=i,t.execute("blockQuote",{forceValue:!0}),this.#p=void 0,t.editing.view.focus(),l.isOpen=!1)})),l.on("cancel",(()=>{t.editing.view.focus(),l.isOpen=!1})),l.bind("isEnabled").to(e);const d=new s.WoltlabBlockQuotePanelView(t);return l.on("change:isOpen",(()=>{if(l.isOpen){const e=this.#k();e?(d.author=r(e.getAttribute("author")),d.link=r(e.getAttribute("link"))):(d.author="",d.link="")}})),l.panelView.children.add(d),d.delegate("submit","cancel").to(l),l}))}#w(){this.editor.data.upcastDispatcher.on("element:woltlab-quote",((e,t,i)=>{const{viewItem:n}=t,{consumable:o,writer:s}=i,r=s.createElement("blockQuote");s.setAttributes({author:n.getAttribute("data-author")||"",link:n.getAttribute("data-link")||""},r),i.convertChildren(n,r),i.safeInsert(r,t.modelCursor)&&(o.consume(n,{name:!0}),i.updateConversionResult(r,t))}),{priority:"high"})}#_(){this.editor.editing.downcastDispatcher.on("insert:blockQuote",((e,t,i)=>{const{writer:n,mapper:o,consumable:s}=i;if(!s.consume(t.item,"insert"))return;const a=r(t.item.getAttribute("author")),l=r(t.item.getAttribute("link")),c=this.getSource(a,l),d={};""!==c&&(d["data-source"]=c);const u=n.createContainerElement("blockquote",d),h=o.toViewPosition(this.editor.model.createPositionBefore(t.item));n.insert(h,u),o.bindElements(t.item,u)}),{priority:"high"}),this.editor.editing.downcastDispatcher.on("attribute:author:blockQuote",((e,t,i)=>{const{writer:n,mapper:o}=i,s=r(t.attributeNewValue),a=r(t.item.getAttribute("link")),l=this.getSource(s,a),c=o.toViewElement(t.item);""===l?n.removeAttribute("data-source",c):n.setAttribute("data-source",l,c)})),this.editor.editing.downcastDispatcher.on("attribute:link:blockQuote",((e,t,i)=>{const{writer:n,mapper:o}=i,s=r(t.item.getAttribute("author")),a=r(t.attributeNewValue),l=this.getSource(s,a),c=o.toViewElement(t.item);""===l?n.removeAttribute("data-source",c):n.setAttribute("data-source",l,c)}))}#v(){this.editor.data.downcastDispatcher.on("insert:blockQuote",((e,t,i)=>{const{writer:n,mapper:o,consumable:s}=i;if(!s.consume(t.item,"insert"))return;const a=r(t.item.getAttribute("author")),l=r(t.item.getAttribute("link")),c=o.toViewPosition(this.editor.model.createPositionBefore(t.item)),d=n.createContainerElement("woltlab-quote",{"data-author":a,"data-link":l});n.insert(c,d),o.bindElements(t.item,d)}),{priority:"high"})}#y(e){const t=this.#k();t&&void 0!==e&&this.editor.model.change((i=>{i.setAttribute("author",e.author,t),i.setAttribute("link",e.link,t)}))}#k(){const e=this.editor.model.document.selection,t=(0,o.first)(e.getSelectedBlocks());return this.#C(t)}#C(e){return e.is("element","blockQuote")?e:e.parent&&!e.parent.is("element","$root")?this.#C(e.parent):null}getSource(e,t){const{t:i}=this.editor;return e?i("Quote from %0",e):i("Quote")}}t.WoltlabBlockQuote=a,t.default=a}.apply(t,n),void 0===o||(e.exports=o)},5600:(e,t,i)=>{var n,o;n=[i,t,i(2806)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabCodeBlock=void 0,Object.defineProperty(t,"WoltlabCodeBlock",{enumerable:!0,get:function(){return i.WoltlabCodeBlock}})}.apply(t,n),void 0===o||(e.exports=o)},8649:(e,t,i)=>{var n,o;n=[i,t,i(2692),i(2170)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabCodeBlockFormRowView=void 0;class n extends i.View{children;constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("class",t.class||""),this.children=this.createCollection(),t.children&&t.children.forEach((e=>this.children.add(e))),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",i.to("class")]},children:this.children})}}t.WoltlabCodeBlockFormRowView=n,t.default=n}.apply(t,n),void 0===o||(e.exports=o)},3953:(e,t,i)=>{var n,o;n=[i,t,i(4934),i(7833),i(2692),i(5044),i(8649)],o=function(e,t,i,n,o,s,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabCodeBlockPanelView=void 0;class a extends o.View{#o;#s;#A;#E;#x;focusTracker;keystrokes;#l;#c;constructor(e){const{locale:t}=e;super(t),this.set("file",""),this.set("highlighter",""),this.set("line",""),this.focusTracker=new s.FocusTracker,this.keystrokes=new s.KeystrokeHandler,this.#l=new o.ViewCollection,this.#c=this.#d();const n=(0,i.getNormalizedAndLocalizedLanguageDefinitions)(e);this.#A=this.#T(t,n);const r=this.#S(t);this.#E=r.fieldView;const a=this.#h(t);this.#x=a.fieldView,this.#o=this.#m(t),this.#s=this.#g(t),this.#f(t,r,a)}render(){super.render(),(0,o.submitHandler)({view:this});const e=[this.#A,this.#E,this.#x,this.#o,this.#s];e.forEach((e=>{this.#l.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",(e=>e.stopPropagation())),this.keystrokes.set("arrowleft",(e=>e.stopPropagation())),this.keystrokes.set("arrowup",(e=>e.stopPropagation())),this.keystrokes.set("arrowdown",(e=>e.stopPropagation())),this.listenTo(e[0].element,"selectstart",((e,t)=>{t.stopPropagation()}),{priority:"high"}),this.on("submit",(()=>{this.fire("execute")}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.#c.focusFirst()}#T(e,t){const i=e.t,n=(0,o.createDropdown)(e),s=this.#P(t);return this.highlighter=s.first.model._codeBlockLanguage,n.buttonView.bind("label").to(this,"highlighter",(e=>{const i=e?e.toString():"";return t.find((e=>e.language==i)).label})),n.buttonView.set({isOn:!1,withText:!0,tooltip:i("Language"),class:["ck-dropdown__button_label-width_auto"]}),n.on("execute",(e=>{this.highlighter=e.source._codeBlockLanguage})),(0,o.addListToDropdown)(n,s),n}#S(e){const t=e.t,i=new o.LabeledFieldView(e,o.createLabeledInputNumber);i.label=t("Line number");const{fieldView:n}=i;return n.min=0,n.bind("value").to(this,"line",(e=>e||"")),n.on("input",(()=>{this.line=n.element.value})),i}#h(e){const t=e.t,i=new o.LabeledFieldView(e,o.createLabeledInputText);return i.label=t("Filename"),i.fieldView.bind("value").to(this,"file",(e=>e||"")),i.fieldView.on("input",(()=>{this.file=i.fieldView.element.value})),i}#P(e){const t=new s.Collection;for(const i of e){const e={type:"button",model:new o.Model({_codeBlockLanguage:i.language,label:i.label,withText:!0})};e.model.bind("isOn").to(this,"highlighter",(t=>t===e.model._codeBlockLanguage)),t.add(e)}return t}#m(e){const t=e.t,i=new o.ButtonView(e);return i.set({label:t("Insert"),icon:n.icons.check,class:"ck-button-save",type:"submit",withText:!0,isEnabled:!0}),i}#g(e){const t=e.t,i=new o.ButtonView(e);return i.set({label:t("Cancel"),icon:n.icons.cancel,class:"ck-button-cancel",withText:!0}),i.delegate("execute").to(this,"cancel"),i}#f(e,t,i){this.setTemplate({tag:"form",attributes:{class:["ck","ck-vertical-form","ck-woltlabcodeblock-insert-form"],tabindex:"-1"},children:[this.#A,t,i,new r.default(e,{children:[this.#o,this.#s],class:"ck-woltlabcodeblock-insert-form__action-row"})]})}#d(){return new o.FocusCycler({focusables:this.#l,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}})}}t.WoltlabCodeBlockPanelView=a,t.default=a}.apply(t,n),void 0===o||(e.exports=o)},2806:(e,t,i)=>{var n,o;n=[i,t,i(4934),i(7833),i(2692),i(5044),i(3953)],o=function(e,t,i,n,o,s,r){"use strict";function a(e){switch(typeof e){case"string":return e;case"number":case"boolean":return e.toString();default:return""}}Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabCodeBlock=void 0;class l extends n.Plugin{#I;#p=void 0;static get pluginName(){return"WoltlabCodeBlock"}init(){const e=this.editor;this.#I=e.commands.get("codeBlock"),e.model.schema.extend("codeBlock",{allowAttributes:["file","line"]}),this.#V(),this.#w(),this.#v(),this.#_(),this.#R(),this.listenTo(this.#I,"execute",(()=>{this.#y(this.#p)}))}#V(){const e=this.editor,t=e.t;e.ui.componentFactory.add("codeBlock",(i=>{const n=(0,o.createDropdown)(i,o.SplitButtonView),s=n.buttonView;s.set({label:t("Insert code block"),tooltip:!0,icon:'',isToggleable:!0}),s.bind("isOn").to(this.#I,"value",(e=>!!e)),s.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!1}),e.editing.view.focus()})),n.on("submit",(t=>{const i=t.path.find((e=>e instanceof r.WoltlabCodeBlockPanelView));i instanceof r.WoltlabCodeBlockPanelView&&(this.#p=i,e.execute("codeBlock",{language:i.highlighter,forceValue:!0}),this.#p=void 0,e.editing.view.focus(),n.isOpen=!1)})),n.on("cancel",(()=>{e.editing.view.focus(),n.isOpen=!1})),n.bind("isEnabled").to(this.#I);const l=new r.WoltlabCodeBlockPanelView(e);return n.on("change:isOpen",(()=>{if(n.isOpen){const e=this.#O();e?(l.file=a(e.getAttribute("file")),l.highlighter=a(e.getAttribute("language")),l.line=a(e.getAttribute("line"))):(l.file="",l.highlighter="",l.line="")}})),n.panelView.children.add(l),l.delegate("submit","cancel").to(n),n}))}#w(){this.editor.data.upcastDispatcher.on("element:pre",((e,t,i)=>{const{viewItem:n}=t,{consumable:o,writer:s}=i;if(n.hasClass("woltlabHtml"))return;const r=s.createElement("codeBlock");s.setAttributes({file:n.getAttribute("data-file")||"",language:n.getAttribute("data-highlighter")||"",line:n.getAttribute("data-line")||""},r),i.convertChildren(n,r),i.safeInsert(r,t.modelCursor)&&(o.consume(n,{name:!0}),i.updateConversionResult(r,t))}),{priority:"high"})}#_(){const e=(0,i.getNormalizedAndLocalizedLanguageDefinitions)(this.editor);this.editor.editing.downcastDispatcher.on("insert:codeBlock",((t,i,n)=>{const{writer:o,mapper:s,consumable:r}=n;if(!r.consume(i.item,"insert"))return;const l=a(i.item.getAttribute("file")),c=a(i.item.getAttribute("language")),d=a(i.item.getAttribute("line")),u=o.createContainerElement("code",{class:`language-${c}`});let h="";const m=e.find((e=>e.language===c));h+=m?m.label:`Unknown (${c})`,(l||d)&&(h+=" (",l&&(h+=l),d&&(l&&(h+=" "),h+=`@ ${d}`),h+=")");const g=o.createContainerElement("pre",{"data-language":h,spellcheck:"false"},u),f=s.toViewPosition(this.editor.model.createPositionBefore(i.item));o.insert(f,g),s.bindElements(i.item,u)}),{priority:"high"})}#v(){this.editor.data.downcastDispatcher.on("insert:codeBlock",((e,t,i)=>{const{writer:n,mapper:o,consumable:s}=i;if(!s.consume(t.item,"insert"))return;const r=a(t.item.getAttribute("file")),l=a(t.item.getAttribute("language")),c=a(t.item.getAttribute("line")),d=o.toViewPosition(this.editor.model.createPositionBefore(t.item)),u=n.createContainerElement("pre",{"data-file":r,"data-highlighter":l,"data-line":c});n.insert(d,u),o.bindElements(t.item,u)}),{priority:"high"})}#y(e){const t=this.#O();t&&void 0!==e&&this.editor.model.change((i=>{i.setAttribute("file",e.file,t),i.setAttribute("line",e.line,t)}))}#R(){const e=(0,i.getNormalizedAndLocalizedLanguageDefinitions)(this.editor),t=["file","line"];for(const i of t)this.editor.editing.downcastDispatcher.on(`attribute:${i}:codeBlock`,((t,i,n)=>{const{mapper:o}=n,s=o.toViewElement(i.item);if(void 0===s)return;const r=s.getAncestors(),l=r[r.length-1];if(!l.is("element","pre"))return;const c=a(i.item.getAttribute("file")),d=a(i.item.getAttribute("language")),u=a(i.item.getAttribute("line"));let h="";const m=e.find((e=>e.language===d));h+=m?m.label:`Unknown (${d})`,(c||u)&&(h+=" (",c&&(h+=c),u&&(c&&(h+=" "),h+=`@ ${u}`),h+=")"),this.editor.editing.view.change((e=>{e.setAttribute("data-language",h,l)}))}))}#O(){const e=this.editor.model.document.selection,t=(0,s.first)(e.getSelectedBlocks());return t&&t.is("element","codeBlock")?t:null}}t.WoltlabCodeBlock=l,t.default=l}.apply(t,n),void 0===o||(e.exports=o)},3706:(e,t,i)=>{var n,o;n=[i,t,i(2379)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabCode=void 0,Object.defineProperty(t,"WoltlabCode",{enumerable:!0,get:function(){return i.WoltlabCode}})}.apply(t,n),void 0===o||(e.exports=o)},2379:(e,t,i)=>{var n,o;n=[i,t,i(7971),i(7833)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabCode=void 0;class o extends n.Plugin{static get pluginName(){return"WoltlabCode"}static get requires(){return[i.Code]}init(){const{conversion:e}=this.editor;e.for("upcast").elementToAttribute({view:"kbd",model:"code",converterPriority:"high"}),e.for("dataDowncast").attributeToElement({model:"code",view:"kbd",converterPriority:"high"})}}t.WoltlabCode=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},1294:(e,t,i)=>{var n,o;n=[i,t,i(6091)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabHtmlEmbed=void 0,Object.defineProperty(t,"WoltlabHtmlEmbed",{enumerable:!0,get:function(){return i.WoltlabHtmlEmbed}})}.apply(t,n),void 0===o||(e.exports=o)},6091:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(8691)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabHtmlEmbed=void 0;class o extends i.Plugin{static get pluginName(){return"WoltlabHtmlEmbed"}static get requires(){return[n.HtmlEmbed]}init(){const{conversion:e,data:t}=this.editor;t.registerRawContentMatcher({name:"pre",classes:"woltlabHtml"}),e.for("upcast").elementToElement({view:{name:"pre",classes:"woltlabHtml"},model:(e,{writer:t})=>{let i=e.getCustomProperty("$rawContent");return i="string"==typeof i?this.#B(i):"",t.createElement("rawHtml",{value:i})},converterPriority:"high"}),e.for("dataDowncast").elementToElement({model:"rawHtml",view:(e,{writer:t})=>t.createRawElement("pre",{class:"woltlabHtml"},(function(t){t.textContent=e.getAttribute("value")||""})),converterPriority:"high"})}#B(e){return String(e).replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}}t.WoltlabHtmlEmbed=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},8206:(e,t,i)=>{var n,o;n=[i,t,i(2265)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabImage=void 0,Object.defineProperty(t,"WoltlabImage",{enumerable:!0,get:function(){return i.WoltlabImage}})}.apply(t,n),void 0===o||(e.exports=o)},2265:(e,t,i)=>{var n,o;n=[i,t,i(7833)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabImage=void 0;class n extends i.Plugin{static get pluginName(){return"WoltlabImage"}init(){const{conversion:e}=this.editor,t=["imageBlock","imageInline"];for(const i of t)e.for("dataDowncast").add((e=>{e.on(`insert:${i}`,((e,t,i)=>{const{item:n}=t;if(!n.is("element"))return;const o=n.getAttribute("width");if("string"!=typeof o)return;const{mapper:s,writer:r}=i,a=s.toViewElement(n);void 0!==a&&r.setAttribute("data-width",o,a)}),{priority:"lowest"})})),e.for("editingDowncast").add((e=>{e.on(`insert:${i}`,((e,{item:t},i)=>{const{mapper:n,writer:o}=i,{domConverter:s}=this.editor.editing.view,r=n.toViewElement(t);if(!r||!r.is("containerElement")||1!==r.childCount)return;const a=r.getChild(0);if(!a.is("element"))return;const l=s.viewToDom(a);if(!(l instanceof HTMLImageElement))return;const c=()=>{o.setStyle("max-width",`${l.naturalWidth}px`,r)};l.complete&&0!==l.naturalHeight?c():l.addEventListener("load",(()=>c()),{once:!0})}))}))}}t.WoltlabImage=n,t.default=n}.apply(t,n),void 0===o||(e.exports=o)},5825:(e,t,i)=>{var n,o;n=[i,t,i(4413)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMagicParagraph=void 0,Object.defineProperty(t,"WoltlabMagicParagraph",{enumerable:!0,get:function(){return i.WoltlabMagicParagraph}})}.apply(t,n),void 0===o||(e.exports=o)},4413:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(6243)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMagicParagraph=void 0;class o extends i.Plugin{static blockModels=["blockQuote","codeBlock","spoiler","table"];static get pluginName(){return"WoltlabMagicParagraph"}init(){const{mapper:e,view:t}=this.editor.editing,{document:i,domConverter:s}=t;t.addObserver(n.ClickObserver),this.listenTo(i,"click",((t,n)=>{const{domEvent:r,target:a}=n;if(void 0===a)return;const l=a.getAncestors();l.push(a);for(const e of l)if(e.is("element","p")||e.is("element","li"))return;const{clientY:c}=r,d=i.getRoot(),u=d.getChild(0);if(void 0!==u){if(u.is("containerElement")){let i=u,n=e.toModelElement(i);if(void 0===n&&i.childCount>0){const t=i.getChild(0);t.is("containerElement")&&(i=t,n=e.toModelElement(i))}if(n&&o.blockModels.includes(n.name)){const e=s.mapViewToDom(i),{top:n}=e.getBoundingClientRect();if(c<=n)return t.stop(),void this.#M(i)}}if(0!==d.childCount){const i=d.getChild(d.childCount-1);if(i.is("containerElement")){let n=i,r=e.toModelElement(n);if(void 0===r&&n.childCount>0){const t=n.getChild(n.childCount-1);t.is("containerElement")&&(n=t,r=e.toModelElement(n))}if(r&&o.blockModels.includes(r.name)){const e=s.mapViewToDom(n),{bottom:i}=e.getBoundingClientRect();if(c>=i)return t.stop(),void this.#N(n)}}}for(const e of this.#D()){const i=s.mapViewToDom(e),{bottom:n,top:o}=i.getBoundingClientRect(),{marginBottom:r,marginTop:a}=window.getComputedStyle(i),l=o-parseInt(a),d=n+parseInt(r);if(c=l&&c<=o)return this.#M(e),void t.stop();if(c>=n&&c<=d)return this.#N(e),void t.stop()}}}))}#M(e){const{mapper:t}=this.editor.editing;let i;i=e.previousSibling&&e.previousSibling.is("element","p")?t.toModelElement(e.previousSibling):void 0,this.editor.model.change((n=>{if(void 0===i){i=n.createElement("paragraph");const o=n.createPositionBefore(t.toModelElement(e));n.insert(i,o)}n.setSelection(i,"end")}))}#N(e){const{mapper:t}=this.editor.editing;let i;i=e.nextSibling&&e.nextSibling.is("element","p")?t.toModelElement(e.nextSibling):void 0,this.editor.model.change((n=>{if(void 0===i){i=n.createElement("paragraph");const o=n.createPositionAfter(t.toModelElement(e));n.insert(i,o)}n.setSelection(i,"end")}))}*#D(){const{mapper:e,view:t}=this.editor.editing,i=t.document.getRoot(),n=t.createRangeIn(i);for(const t of n.getWalker({ignoreElementEnd:!0})){const i=t.item;if(!i.is("containerElement"))continue;const n=e.toModelElement(i);void 0!==n&&o.blockModels.includes(n.name)&&(yield i)}}}t.WoltlabMagicParagraph=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},9782:(e,t,i)=>{var n,o;n=[i,t,i(6761)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMedia=void 0,Object.defineProperty(t,"WoltlabMedia",{enumerable:!0,get:function(){return i.WoltlabMedia}})}.apply(t,n),void 0===o||(e.exports=o)},6761:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(7261),i(7080)],o=function(e,t,i,n,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMedia=void 0;class s extends i.Plugin{static get pluginName(){return"WoltlabMedia"}static get requires(){return[n.Image,o.WoltlabMetacode]}init(){this.#L(),this.#F()}#L(){const{conversion:e,model:t}=this.editor,{schema:i}=t,n=["imageBlock","imageInline"];n.forEach((e=>{i.extend(e,{allowAttributes:["mediaId","mediaSize"]})})),e.attributeToAttribute({model:{key:"classList",values:["woltlabSuiteMedia"]},view:{woltlabSuiteMedia:{name:"img",key:"class",value:"woltlabSuiteMedia"}}});const o=new Map([["mediaId","data-media-id"],["mediaSize","data-media-size"]]);Array.from(o.entries()).forEach((([t,i])=>{e.for("upcast").attributeToAttribute({view:i,model:t}),e.for("downcast").add((e=>{n.forEach((n=>{e.on(`attribute:${t}:${n}`,((e,t,n)=>{if(!n.consumable.consume(t.item,e.name))return;const o=n.writer;let s=n.mapper.toViewElement(t.item);s.is("element","figure")&&(s=s.getChild(0)),s.is("element","img")&&(null!==t.attributeNewValue?o.setAttribute(i,t.attributeNewValue,s):o.removeAttribute(i,s))}))}))}))}))}#F(){const e=this.editor.config.get("woltlabMedia");this.editor.plugins.get("WoltlabMetacode").on("upcast",((t,i)=>{if("wsm"===i.name){const n=parseInt(i.attributes[0].toString());if(Number.isNaN(n))return;const o=i.attributes[1]?i.attributes[1].toString():"original";this.#z(i,e.resolveMediaUrl,n,o)&&t.stop()}}))}#z(e,t,i,n){const{conversionApi:o,data:s}=e,{consumable:r,writer:a}=o,{viewItem:l}=s,c=a.createElement("imageInline");return a.setAttributes({src:t(i,n),mediaId:i,mediaSize:n},c),o.convertChildren(l,c),!!o.safeInsert(c,s.modelCursor)&&(r.consume(l,{name:!0}),o.updateConversionResult(c,s),!0)}}t.WoltlabMedia=s,t.default=s}.apply(t,n),void 0===o||(e.exports=o)},4201:(e,t,i)=>{var n,o;n=[i,t,i(644)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMention=void 0,Object.defineProperty(t,"WoltlabMention",{enumerable:!0,get:function(){return i.WoltlabMention}})}.apply(t,n),void 0===o||(e.exports=o)},644:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(6335),i(7080),i(5044)],o=function(e,t,i,n,o,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMention=void 0;class r extends i.Plugin{static get pluginName(){return"WoltlabMention"}static get requires(){return[n.Mention,o.WoltlabMetacode]}init(){this.editor.plugins.get("WoltlabMetacode").on("upcast",((e,t)=>{"user"===t.name&&1===t.attributes.length&&(Number.isNaN(parseInt(t.attributes[0].toString()))||(e.stop(),this.#H(t)))})),this.#v()}#H(e){const{attributes:t,conversionApi:i,data:n,name:o}=e,{writer:r}=i,{viewItem:a}=n,l=a.getChild(0);Object.assign(n,i.convertChildren(n.viewItem,n.modelCursor));for(const e of Array.from(n.modelRange.getItems()))(e.is("$text")||e.is("$textProxy"))&&r.setAttribute("mention",{id:t[0].toString(),objectId:t[0],type:o,uid:(0,s.uid)(),_text:l.data},e)}#v(){this.editor.conversion.for("dataDowncast").attributeToElement({model:"mention",view:(e,{writer:t})=>{if(!e)return;const i=e.objectId;return t.createAttributeElement("woltlab-metacode",{"data-name":e.type,"data-attributes":btoa(JSON.stringify([i]))},{priority:20,id:e.uid})},converterPriority:"high"})}}t.WoltlabMention=r,t.default=r}.apply(t,n),void 0===o||(e.exports=o)},7080:(e,t,i)=>{var n,o;n=[i,t,i(2505)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMetacode=void 0,Object.defineProperty(t,"WoltlabMetacode",{enumerable:!0,get:function(){return i.WoltlabMetacode}})}.apply(t,n),void 0===o||(e.exports=o)},2505:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(5044)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMetacode=void 0;class o extends i.Plugin{static get pluginName(){return"WoltlabMetacode"}init(){this.#W()}#W(){this.editor.conversion.for("upcast").add((e=>{e.on("element:woltlab-metacode",((e,t,i)=>{const{consumable:o,convertChildren:s,writer:r}=i,{viewItem:a}=t;if(!o.test(a,{name:!0}))return;const l=a.getAttribute("data-name");if(void 0===l)return;const c=this.#U(a.getAttribute("data-attributes")||""),d=new n.EventInfo(this,"upcast"),u={attributes:c,conversionApi:i,data:t,name:l};if(this.fire(d,u),d.stop.called)return;let{modelCursor:h}=t;const m=this.#j(c),g=r.createText(`[${l}${m}]`),f=r.createText(`[/${l}]`);let p=!1;const b=h.getAncestors();if("$root"===b[b.length-1].name)p=!0;else for(const e of a.getChildren())if(e.is("containerElement")){p=!0;break}if(p){let e=r.createElement("paragraph");r.insert(g,e),r.insert(e,h),h=r.createPositionAfter(e);const i=s(a,h);e=r.createElement("paragraph"),r.insert(f,e),r.insert(e,i.modelCursor),t.modelCursor=r.createPositionAfter(e)}else{r.insert(g,h),h=h.getShiftedBy(g.offsetSize);const e=s(a,h);r.insert(f,e.modelCursor),t.modelCursor=e.modelCursor.getShiftedBy(f.offsetSize)}}))}))}#U(e){if(""===e)return[];const t=atob(e);let i;try{i=JSON.parse(t)}catch(e){return[]}return i}#j(e){return 0===e.length?"":"="+e.map((e=>"number"==typeof e?e.toString():`'${e}'`)).join(",")}}t.WoltlabMetacode=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},8427:(e,t,i)=>{var n,o;n=[i,t,i(4054)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabSmiley=void 0,Object.defineProperty(t,"WoltlabSmiley",{enumerable:!0,get:function(){return i.WoltlabSmiley}})}.apply(t,n),void 0===o||(e.exports=o)},4054:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(7261),i(6677)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabSmiley=void 0;class o extends i.Plugin{static get pluginName(){return"WoltlabSmiley"}static get requires(){return[n.Image]}init(){const{conversion:e,model:t}=this.editor,i=["imageBlock","imageInline"];for(const e of i)t.schema.extend(e,{allowAttributes:["classList"]});e.attributeToAttribute({model:{key:"classList",values:["smiley"]},view:{smiley:{name:"img",key:"class",value:"smiley"}}}),e.for("editingDowncast").add((e=>{e.on("insert:imageInline",((e,t,i)=>{const{item:n}=t;if("smiley"!==n.getAttribute("classList"))return;if(!n.is("element"))return;const{consumable:o,mapper:s,writer:r}=i;if(!o.test(n,"insert"))return;o.consume(n,"insert");const a=r.createEmptyElement("img");r.setAttribute("translate","no",a);const l=s.toViewPosition(this.editor.model.createPositionBefore(n));r.insert(l,a),s.bindElements(n,a)}),{priority:"high"})}))}}t.WoltlabSmiley=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},5469:(e,t,i)=>{var n,o;n=[i,t,i(7591),i(2553)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabSpoilerCommand=t.WoltlabSpoiler=void 0,Object.defineProperty(t,"WoltlabSpoiler",{enumerable:!0,get:function(){return i.WoltlabSpoiler}}),Object.defineProperty(t,"WoltlabSpoilerCommand",{enumerable:!0,get:function(){return n.WoltlabSpoilerCommand}})}.apply(t,n),void 0===o||(e.exports=o)},7591:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(6004)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabSpoiler=void 0;class o extends i.Plugin{static get requires(){return[n.default]}static get pluginName(){return"WoltlabSpoiler"}}t.WoltlabSpoiler=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},2553:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(6243),i(5044)],o=function(e,t,i,n,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabSpoilerCommand=void 0;class s extends i.Command{execute(){const{model:e}=this.editor,{schema:t}=e,{selection:i}=e.document,n=Array.from(i.getSelectedBlocks());e.change((e=>{if(this.value)this.#$(e,n);else{const i=n.filter((e=>this.#q(e)||this.#K(t,e)));this.#Z(e,i)}}))}refresh(){this.value=this.#G(),this.isEnabled=this.#n()}#$(e,t){for(const i of t){const t=this.#q(i);if(null===t)continue;const o=t.previousSibling;if(null===o||!o.is("element","spoilerTitle"))throw new Error("Invalid structure, expected a `` adjacent to ``",{cause:{spoilerTitle:o}});const s=t.parent;if(!(s instanceof n.Element&&s.is("element","spoiler")))throw new Error("Invalid structure, expected a `` as the parent of a ``",{cause:{spoiler:s}});e.remove(o),e.unwrap(s),e.unwrap(t)}}#Z(e,t){const i=[];this.#J(e,t).reverse().forEach((t=>{let n=this.#q(t.start);n||(n=this.#Y(e,t)),i.push(n.parent)})),i.reverse().reduce(((t,i)=>{if(t.nextSibling===i){const n=t.getChild(1),o=i.getChild(1);return e.move(e.createRangeIn(o),e.createPositionAt(n,"end")),e.remove(i),t}return i}))}#J(e,t){let i=null,n=0;const o=[];for(;n{var n,o;n=[i,t,i(7833),i(1460),i(6243),i(2692),i(2553),i(5253)],o=function(e,t,i,n,o,s,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabSpoilerEditing=void 0;class a extends i.Plugin{static get pluginName(){return"WoltlabSpoilerEditing"}static get requires(){return[n.Widget]}init(){this.#Q(),this.#W(),this.editor.commands.add("insertSpoiler",new r.default(this.editor)),this.#X()}#X(){const{t:e}=this.editor.locale;this.editor.ui.componentFactory.add("spoiler",(t=>{const i=this.editor.commands.get("insertSpoiler"),n=new s.ButtonView(t);return n.set({label:e("Spoiler"),tooltip:!0,withText:!0}),n.labelView.setTemplate({tag:"fa-icon",attributes:{name:"eye-slash"}}),n.bind("isOn").to(i,"value"),n.bind("isEnabled").to(i,"isEnabled"),this.listenTo(n,"execute",(()=>this.editor.execute("insertSpoiler"))),n}))}#Q(){const{schema:e}=this.editor.model;e.register("spoiler",{allowWhere:"$block",isObject:!0}),e.register("spoilerTitle",{allowChildren:"$text",allowIn:"spoiler",isLimit:!0}),e.register("spoilerContent",{allowContentOf:"$root",allowIn:"spoiler",isLimit:!0}),e.addChildCheck(((e,t)=>("spoiler"!==t.name||!Array.from(e.getNames()).includes("spoiler"))&&(!e.endsWith("spoilerContent")||"spoiler"!==t.name)&&(!e.endsWith("spoilerTitle")||"$text"===t.name)&&void 0)),e.addAttributeCheck((e=>{if(e.endsWith("spoilerTitle $text"))return!1}))}#W(){const{conversion:e}=this.editor,{t}=this.editor.locale;e.for("upcast").add((e=>{e.on("element:woltlab-spoiler",((e,t,i)=>{const{consumable:n,writer:o,safeInsert:s,convertChildren:r,updateConversionResult:a}=i,{viewItem:l}=t,c={name:!0};if(!n.test(l,c))return;const d=o.createElement("spoiler"),u=o.createElement("spoilerTitle");o.append(u,d);const h=(l.getAttribute("data-label")||"").trim();o.appendText(h,u);const m=o.createElement("spoilerContent");o.append(m,d),s(d,t.modelCursor)&&(n.consume(l,c),r(l,m),a(d,t))}))})),e.for("dataDowncast").add((e=>{e.on("insert:spoiler",((e,t,i)=>{const{item:n}=t,{consumable:o,mapper:s,writer:r}=i;if(2!==n.childCount)return null;const a=n.getChild(0);if(!a.is("element","spoilerTitle"))return null;if(!o.consume(n,"insert"))return;o.consume(a,"insert");let l="";if(1===a.childCount){const e=a.getChild(0);e.is("$text")&&(l=e.data)}const c=r.createContainerElement("woltlab-spoiler",{"data-label":l}),d=s.toViewPosition(this.editor.model.createPositionBefore(n));r.insert(d,c),s.bindElements(n,c),s.bindElements(a,c);const u=n.getChild(1);u.is("element","spoilerContent")&&(s.bindElements(u,c),o.consume(u,"insert"))})),e.on("insert:$text",((e,t,i)=>{const n=t.item.parent;n&&n.is("element","spoilerTitle")&&i.consumable.consume(t.item,"insert")}))})),e.for("editingDowncast").elementToElement({model:"spoiler",view:(e,{writer:t})=>{const i=t.createContainerElement("div",{class:"ck-woltlabspoiler"});return(0,n.toWidget)(i,t,{hasSelectionHandle:!0,label:"spoiler widget"})}}).elementToElement({model:"spoilerTitle",view:(e,{writer:i})=>{const s=i.createEditableElement("div",{class:"ck-woltlabspoiler__title","data-label":t("Spoiler")});return s.placeholder=t("Type your title"),(0,o.enablePlaceholder)({view:this.editor.editing.view,element:s,keepOnFocus:!0}),(0,n.toWidgetEditable)(s,i)}}).elementToElement({model:"spoilerContent",view:(e,{writer:t})=>{const i=t.createEditableElement("div",{class:"ck-woltlabspoiler__content"});return(0,n.toWidgetEditable)(i,t)}})}}t.WoltlabSpoilerEditing=a,t.default=a}.apply(t,n),void 0===o||(e.exports=o)},9402:(e,t,i)=>{var n,o;n=[i,t,i(6909)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabToolbarGroup=void 0,Object.defineProperty(t,"WoltlabToolbarGroup",{enumerable:!0,get:function(){return i.WoltlabToolbarGroup}})}.apply(t,n),void 0===o||(e.exports=o)},6909:(e,t,i)=>{var n,o;n=[i,t,i(7833)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabToolbarGroup=void 0;class n extends i.Plugin{static get pluginName(){return"WoltlabToolbarGroup"}init(){const e=this.editor.config.get("woltlabToolbarGroup");e&&this.editor.once("ready",(()=>{const t=this.editor.ui.view.toolbar.items;Object.entries(e).forEach((([e,i])=>{const n=t.find((t=>null!==t.element?.querySelector(`[data-cke-tooltip-text="woltlabToolbarGroup_${e}"]`))),o=n.element,s=o.querySelector(".ck-button__icon"),[r,a]=i.icon.split(";",2),l=document.createElement("fa-icon");l.setIcon(r,"true"===a),s.replaceWith(l),n.buttonView.label=i.label,o.dataset.ckeTooltipText=i.label}))}))}}t.WoltlabToolbarGroup=n,t.default=n}.apply(t,n),void 0===o||(e.exports=o)},8152:(e,t,i)=>{var n,o;n=[i,t,i(6916)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabUpload=void 0,Object.defineProperty(t,"WoltlabUpload",{enumerable:!0,get:function(){return i.WoltlabUpload}})}.apply(t,n),void 0===o||(e.exports=o)},6916:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(1070),i(2263)],o=function(e,t,i,n,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabUpload=void 0;class s extends i.Plugin{static get pluginName(){return"WoltlabUpload"}static get requires(){return[n.FileRepository]}init(){const{config:e,editing:t,plugins:i}=this.editor,s=e.get("woltlabUpload");s&&"function"==typeof s.uploadImage&&(i.get(n.FileRepository).createUploadAdapter=e=>new o.WoltlabUploadAdapter(e,s),"function"==typeof s.uploadOther&&this.listenTo(t.view.document,"clipboardInput",((e,t)=>{if(e.stop.called)return;const{dataTransfer:i,method:n}=t;if("drop"===n){for(const e of i.files)null!==e&&s.uploadOther(e);e.stop()}}),{priority:"lowest"}))}}t.WoltlabUpload=s,t.default=s}.apply(t,n),void 0===o||(e.exports=o)},2263:(e,t,i)=>{var n;n=function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabUploadAdapter=void 0;class i{#ee;#te;#ie;constructor(e,t){this.#ee=e,this.#te=t}abort(){this.#ie?.abort()}async upload(){const e=await this.#ee.file;return this.#ie=new AbortController,this.#te.uploadImage(e,this.#ie)}}t.WoltlabUploadAdapter=i,t.default=i}.apply(t,[i,t]),void 0===n||(e.exports=n)},2536:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var n=i(9651);const o=function(e,t){for(var i=e.length;i--;)if((0,n.Z)(e[i][0],t))return i;return-1};var s=Array.prototype.splice;function r(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t-1},r.prototype.set=function(e,t){var i=this.__data__,n=o(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this};const a=r},6183:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(2119),o=i(6092);const s=(0,n.Z)(o.Z,"Map")},520:(e,t,i)=>{"use strict";i.d(t,{Z:()=>h});const n=(0,i(2119).Z)(Object,"create");var o=Object.prototype.hasOwnProperty;var s=Object.prototype.hasOwnProperty;function r(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t{"use strict";i.d(t,{Z:()=>a});var n=i(2536);var o=i(6183),s=i(520);function r(e){var t=this.__data__=new n.Z(e);this.size=t.size}r.prototype.clear=function(){this.__data__=new n.Z,this.size=0},r.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},r.prototype.get=function(e){return this.__data__.get(e)},r.prototype.has=function(e){return this.__data__.has(e)},r.prototype.set=function(e,t){var i=this.__data__;if(i instanceof n.Z){var r=i.__data__;if(!o.Z||r.length<199)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new s.Z(r)}return i.set(e,t),this.size=i.size,this};const a=r},7685:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=i(6092).Z.Symbol},4073:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=i(6092).Z.Uint8Array},9001:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c});var n=i(4732),o=i(7771),s=i(6706),r=i(6009),a=i(7212),l=Object.prototype.hasOwnProperty;const c=function(e,t){var i=(0,o.Z)(e),c=!i&&(0,n.Z)(e),d=!i&&!c&&(0,s.Z)(e),u=!i&&!c&&!d&&(0,a.Z)(e),h=i||c||d||u,m=h?function(e,t){for(var i=-1,n=Array(e);++i{"use strict";i.d(t,{Z:()=>n});const n=function(e,t){for(var i=-1,n=t.length,o=e.length;++i{"use strict";i.d(t,{Z:()=>r});var n=i(4752),o=i(9651),s=Object.prototype.hasOwnProperty;const r=function(e,t,i){var r=e[t];s.call(e,t)&&(0,o.Z)(r,i)&&(void 0!==i||t in e)||(0,n.Z)(e,t,i)}},4752:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=i(7904);const o=function(e,t,i){"__proto__"==t&&n.Z?(0,n.Z)(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}},9256:(e,t,i)=>{"use strict";i.d(t,{Z:()=>W});var n=i(5365);var o=i(2954),s=i(1899),r=i(703);var a=i(7590);var l=i(1050),c=i(7215),d=i(3573);var u=i(8694),h=i(2513),m=i(532);const g=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)(0,u.Z)(t,(0,d.Z)(e)),e=(0,h.Z)(e);return t}:m.Z;var f=i(1808),p=i(3327);const b=function(e){return(0,p.Z)(e,a.Z,g)};var w=i(4158),v=Object.prototype.hasOwnProperty;var _=i(1884);var y=/\w*$/;var k=i(7685),C=k.Z?k.Z.prototype:void 0,A=C?C.valueOf:void 0;var E=i(2701);const x=function(e,t,i){var n,o,s,r=e.constructor;switch(t){case"[object ArrayBuffer]":return(0,_.Z)(e);case"[object Boolean]":case"[object Date]":return new r(+e);case"[object DataView]":return function(e,t){var i=t?(0,_.Z)(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}(e,i);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return(0,E.Z)(e,i);case"[object Map]":case"[object Set]":return new r;case"[object Number]":case"[object String]":return new r(e);case"[object RegExp]":return(s=new(o=e).constructor(o.source,y.exec(o))).lastIndex=o.lastIndex,s;case"[object Symbol]":return n=e,A?Object(A.call(n)):{}}};var T=i(5418),S=i(7771),P=i(6706),I=i(8533);var V=i(1162),R=i(8351),O=R.Z&&R.Z.isMap;const B=O?(0,V.Z)(O):function(e){return(0,I.Z)(e)&&"[object Map]"==(0,w.Z)(e)};var M=i(7226);var N=R.Z&&R.Z.isSet;const D=N?(0,V.Z)(N):function(e){return(0,I.Z)(e)&&"[object Set]"==(0,w.Z)(e)};var L="[object Arguments]",F="[object Function]",z="[object Object]",H={};H[L]=H["[object Array]"]=H["[object ArrayBuffer]"]=H["[object DataView]"]=H["[object Boolean]"]=H["[object Date]"]=H["[object Float32Array]"]=H["[object Float64Array]"]=H["[object Int8Array]"]=H["[object Int16Array]"]=H["[object Int32Array]"]=H["[object Map]"]=H["[object Number]"]=H[z]=H["[object RegExp]"]=H["[object Set]"]=H["[object String]"]=H["[object Symbol]"]=H["[object Uint8Array]"]=H["[object Uint8ClampedArray]"]=H["[object Uint16Array]"]=H["[object Uint32Array]"]=!0,H["[object Error]"]=H[F]=H["[object WeakMap]"]=!1;const W=function e(t,i,u,h,m,p){var _,y=1&i,k=2&i,C=4&i;if(u&&(_=m?u(t,h,m,p):u(t)),void 0!==_)return _;if(!(0,M.Z)(t))return t;var A=(0,S.Z)(t);if(A){if(_=function(e){var t=e.length,i=new e.constructor(t);return t&&"string"==typeof e[0]&&v.call(e,"index")&&(i.index=e.index,i.input=e.input),i}(t),!y)return(0,c.Z)(t,_)}else{var E=(0,w.Z)(t),I=E==F||"[object GeneratorFunction]"==E;if((0,P.Z)(t))return(0,l.Z)(t,y);if(E==z||E==L||I&&!m){if(_=k||I?{}:(0,T.Z)(t),!y)return k?function(e,t){return(0,s.Z)(e,g(e),t)}(t,function(e,t){return e&&(0,s.Z)(t,(0,a.Z)(t),e)}(_,t)):function(e,t){return(0,s.Z)(e,(0,d.Z)(e),t)}(t,function(e,t){return e&&(0,s.Z)(t,(0,r.Z)(t),e)}(_,t))}else{if(!H[E])return m?t:{};_=x(t,E,y)}}p||(p=new n.Z);var V=p.get(t);if(V)return V;p.set(t,_),D(t)?t.forEach((function(n){_.add(e(n,i,u,n,t,p))})):B(t)&&t.forEach((function(n,o){_.set(o,e(n,i,u,o,t,p))}));var R=C?k?b:f.Z:k?a.Z:r.Z,O=A?void 0:R(t);return function(e,t){for(var i=-1,n=null==e?0:e.length;++i{"use strict";i.d(t,{Z:()=>s});var n=i(8694),o=i(7771);const s=function(e,t,i){var s=t(e);return(0,o.Z)(e)?s:(0,n.Z)(s,i(e))}},3243:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var n=i(7685),o=Object.prototype,s=o.hasOwnProperty,r=o.toString,a=n.Z?n.Z.toStringTag:void 0;var l=Object.prototype.toString;var c=n.Z?n.Z.toStringTag:void 0;const d=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":c&&c in Object(e)?function(e){var t=s.call(e,a),i=e[a];try{e[a]=void 0;var n=!0}catch(e){}var o=r.call(e);return n&&(t?e[a]=i:delete e[a]),o}(e):function(e){return l.call(e)}(e)}},1152:(e,t,i)=>{"use strict";i.d(t,{Z:()=>S});var n=i(5365),o=i(520);function s(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new o.Z;++tc))return!1;var u=s.get(e),h=s.get(t);if(u&&h)return u==t&&h==e;var m=-1,g=!0,f=2&i?new r:void 0;for(s.set(e,t),s.set(t,e);++m{"use strict";i.d(t,{Z:()=>n});const n=function(e,t,i){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),(i=i>o?o:i)<0&&(i+=o),o=t>i?0:i-t>>>0,t>>>=0;for(var s=Array(o);++n{"use strict";i.d(t,{Z:()=>n});const n=function(e){return function(t){return e(t)}}},1884:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=i(4073);const o=function(e){var t=new e.constructor(e.byteLength);return new n.Z(t).set(new n.Z(e)),t}},1050:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l});var n=i(6092),o="object"==typeof exports&&exports&&!exports.nodeType&&exports,s=o&&"object"==typeof module&&module&&!module.nodeType&&module,r=s&&s.exports===o?n.Z.Buffer:void 0,a=r?r.allocUnsafe:void 0;const l=function(e,t){if(t)return e.slice();var i=e.length,n=a?a(i):new e.constructor(i);return e.copy(n),n}},2701:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=i(1884);const o=function(e,t){var i=t?(0,n.Z)(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}},7215:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e,t){var i=-1,n=e.length;for(t||(t=Array(n));++i{"use strict";i.d(t,{Z:()=>s});var n=i(2954),o=i(4752);const s=function(e,t,i,s){var r=!i;i||(i={});for(var a=-1,l=t.length;++a{"use strict";i.d(t,{Z:()=>b});var n=i(9203);var o=Math.max;var s=i(7904);const r=s.Z?function(e,t){return(0,s.Z)(e,"toString",{configurable:!0,enumerable:!1,value:(i=t,function(){return i}),writable:!0});var i}:n.Z;var a=Date.now;const l=(c=r,d=0,u=0,function(){var e=a(),t=16-(e-u);if(u=e,t>0){if(++d>=800)return arguments[0]}else d=0;return c.apply(void 0,arguments)});var c,d,u;const h=function(e,t){return l(function(e,t,i){return t=o(void 0===t?e.length-1:t,0),function(){for(var n=arguments,s=-1,r=o(n.length-t,0),a=Array(r);++s1?i[o-1]:void 0,r=o>2?i[2]:void 0;for(s=e.length>3&&"function"==typeof s?(o--,s):void 0,r&&function(e,t,i){if(!(0,p.Z)(i))return!1;var n=typeof t;return!!("number"==n?(0,g.Z)(i)&&(0,f.Z)(t,i.length):"string"==n&&t in i)&&(0,m.Z)(i[t],e)}(i[0],i[1],r)&&(s=o<3?void 0:s,o=1),t=Object(t);++n{"use strict";i.d(t,{Z:()=>o});var n=i(2119);const o=function(){try{var e=(0,n.Z)(Object,"defineProperty");return e({},"",{}),e}catch(e){}}()},3413:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n="object"==typeof global&&global&&global.Object===Object&&global},1808:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var n=i(3327),o=i(3573),s=i(703);const r=function(e){return(0,n.Z)(e,s.Z,o.Z)}},2119:(e,t,i)=>{"use strict";i.d(t,{Z:()=>p});var n=i(3234);const o=i(6092).Z["__core-js_shared__"];var s,r=(s=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+s:"";var a=i(7226),l=i(19),c=/^\[object .+?Constructor\]$/,d=Function.prototype,u=Object.prototype,h=d.toString,m=u.hasOwnProperty,g=RegExp("^"+h.call(m).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const f=function(e){return!(!(0,a.Z)(e)||(t=e,r&&r in t))&&((0,n.Z)(e)?g:c).test((0,l.Z)(e));var t},p=function(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return f(i)?i:void 0}},2513:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=(0,i(1851).Z)(Object.getPrototypeOf,Object)},3573:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var n=i(532),o=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols;const r=s?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var i=-1,n=null==e?0:e.length,o=0,s=[];++i{"use strict";i.d(t,{Z:()=>C});var n=i(2119),o=i(6092);const s=(0,n.Z)(o.Z,"DataView");var r=i(6183);const a=(0,n.Z)(o.Z,"Promise"),l=(0,n.Z)(o.Z,"Set"),c=(0,n.Z)(o.Z,"WeakMap");var d=i(3243),u=i(19),h="[object Map]",m="[object Promise]",g="[object Set]",f="[object WeakMap]",p="[object DataView]",b=(0,u.Z)(s),w=(0,u.Z)(r.Z),v=(0,u.Z)(a),_=(0,u.Z)(l),y=(0,u.Z)(c),k=d.Z;(s&&k(new s(new ArrayBuffer(1)))!=p||r.Z&&k(new r.Z)!=h||a&&k(a.resolve())!=m||l&&k(new l)!=g||c&&k(new c)!=f)&&(k=function(e){var t=(0,d.Z)(e),i="[object Object]"==t?e.constructor:void 0,n=i?(0,u.Z)(i):"";if(n)switch(n){case b:return p;case w:return h;case v:return m;case _:return g;case y:return f}return t});const C=k},5418:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l});var n=i(7226),o=Object.create;const s=function(){function e(){}return function(t){if(!(0,n.Z)(t))return{};if(o)return o(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}();var r=i(2513),a=i(2764);const l=function(e){return"function"!=typeof e.constructor||(0,a.Z)(e)?{}:s((0,r.Z)(e))}},6009:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=/^(?:0|[1-9]\d*)$/;const o=function(e,t){var i=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==i||"symbol"!=i&&n.test(e))&&e>-1&&e%1==0&&e{"use strict";i.d(t,{Z:()=>o});var n=Object.prototype;const o=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||n)}},8351:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var n=i(3413),o="object"==typeof exports&&exports&&!exports.nodeType&&exports,s=o&&"object"==typeof module&&module&&!module.nodeType&&module,r=s&&s.exports===o&&n.Z.process;const a=function(){try{return s&&s.require&&s.require("util").types||r&&r.binding&&r.binding("util")}catch(e){}}()},1851:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e,t){return function(i){return e(t(i))}}},6092:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(3413),o="object"==typeof self&&self&&self.Object===Object&&self;const s=n.Z||o||Function("return this")()},19:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=Function.prototype.toString;const o=function(e){if(null!=e){try{return n.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},207:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var n=i(1899),o=i(288),s=i(7590);const r=(0,o.Z)((function(e,t){(0,n.Z)(t,(0,s.Z)(t),e)}))},4612:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=i(9256);const o=function(e,t){return t="function"==typeof t?t:void 0,(0,n.Z)(e,5,t)}},6682:(e,t,i)=>{"use strict";i.d(t,{Z:()=>b});var n=i(7226),o=i(6092);const s=function(){return o.Z.Date.now()};var r=/\s/;var a=/^\s+/;const l=function(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&r.test(e.charAt(t)););return t}(e)+1).replace(a,""):e};var c=i(2714),d=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,h=/^0o[0-7]+$/i,m=parseInt;const g=function(e){if("number"==typeof e)return e;if((0,c.Z)(e))return NaN;if((0,n.Z)(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=(0,n.Z)(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=l(e);var i=u.test(e);return i||h.test(e)?m(e.slice(2),i?2:8):d.test(e)?NaN:+e};var f=Math.max,p=Math.min;const b=function(e,t,i){var o,r,a,l,c,d,u=0,h=!1,m=!1,b=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function w(t){var i=o,n=r;return o=r=void 0,u=t,l=e.apply(n,i)}function v(e){var i=e-d;return void 0===d||i>=t||i<0||m&&e-u>=a}function _(){var e=s();if(v(e))return y(e);c=setTimeout(_,function(e){var i=t-(e-d);return m?p(i,a-(e-u)):i}(e))}function y(e){return c=void 0,b&&o?w(e):(o=r=void 0,l)}function k(){var e=s(),i=v(e);if(o=arguments,r=this,d=e,i){if(void 0===c)return function(e){return u=e,c=setTimeout(_,t),h?w(e):l}(d);if(m)return clearTimeout(c),c=setTimeout(_,t),w(d)}return void 0===c&&(c=setTimeout(_,t)),l}return t=g(t)||0,(0,n.Z)(i)&&(h=!!i.leading,a=(m="maxWait"in i)?f(g(i.maxWait)||0,t):a,b="trailing"in i?!!i.trailing:b),k.cancel=function(){void 0!==c&&clearTimeout(c),u=0,o=d=r=c=void 0},k.flush=function(){return void 0===c?l:y(s())},k}},9651:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e,t){return e===t||e!=e&&t!=t}},9203:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e){return e}},4732:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c});var n=i(3243),o=i(8533);const s=function(e){return(0,o.Z)(e)&&"[object Arguments]"==(0,n.Z)(e)};var r=Object.prototype,a=r.hasOwnProperty,l=r.propertyIsEnumerable;const c=s(function(){return arguments}())?s:function(e){return(0,o.Z)(e)&&a.call(e,"callee")&&!l.call(e,"callee")}},7771:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=Array.isArray},585:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(3234),o=i(1656);const s=function(e){return null!=e&&(0,o.Z)(e.length)&&!(0,n.Z)(e)}},6706:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var n=i(6092);var o="object"==typeof exports&&exports&&!exports.nodeType&&exports,s=o&&"object"==typeof module&&module&&!module.nodeType&&module,r=s&&s.exports===o?n.Z.Buffer:void 0;const a=(r?r.isBuffer:void 0)||function(){return!1}},3251:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(8533),o=i(7514);const s=function(e){return(0,n.Z)(e)&&1===e.nodeType&&!(0,o.Z)(e)}},576:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=i(1152);const o=function(e,t){return(0,n.Z)(e,t)}},3234:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(3243),o=i(7226);const s=function(e){if(!(0,o.Z)(e))return!1;var t=(0,n.Z)(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},1656:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},7226:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},8533:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e){return null!=e&&"object"==typeof e}},7514:(e,t,i)=>{"use strict";i.d(t,{Z:()=>u});var n=i(3243),o=i(2513),s=i(8533),r=Function.prototype,a=Object.prototype,l=r.toString,c=a.hasOwnProperty,d=l.call(Object);const u=function(e){if(!(0,s.Z)(e)||"[object Object]"!=(0,n.Z)(e))return!1;var t=(0,o.Z)(e);if(null===t)return!0;var i=c.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&l.call(i)==d}},2714:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(3243),o=i(8533);const s=function(e){return"symbol"==typeof e||(0,o.Z)(e)&&"[object Symbol]"==(0,n.Z)(e)}},7212:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var n=i(3243),o=i(1656),s=i(8533),r={};r["[object Float32Array]"]=r["[object Float64Array]"]=r["[object Int8Array]"]=r["[object Int16Array]"]=r["[object Int32Array]"]=r["[object Uint8Array]"]=r["[object Uint8ClampedArray]"]=r["[object Uint16Array]"]=r["[object Uint32Array]"]=!0,r["[object Arguments]"]=r["[object Array]"]=r["[object ArrayBuffer]"]=r["[object Boolean]"]=r["[object DataView]"]=r["[object Date]"]=r["[object Error]"]=r["[object Function]"]=r["[object Map]"]=r["[object Number]"]=r["[object Object]"]=r["[object RegExp]"]=r["[object Set]"]=r["[object String]"]=r["[object WeakMap]"]=!1;var a=i(1162),l=i(8351),c=l.Z&&l.Z.isTypedArray;const d=c?(0,a.Z)(c):function(e){return(0,s.Z)(e)&&(0,o.Z)(e.length)&&!!r[(0,n.Z)(e)]}},703:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l});var n=i(9001),o=i(2764);const s=(0,i(1851).Z)(Object.keys,Object);var r=Object.prototype.hasOwnProperty;var a=i(585);const l=function(e){return(0,a.Z)(e)?(0,n.Z)(e):function(e){if(!(0,o.Z)(e))return s(e);var t=[];for(var i in Object(e))r.call(e,i)&&"constructor"!=i&&t.push(i);return t}(e)}},7590:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c});var n=i(9001),o=i(7226),s=i(2764);var r=Object.prototype.hasOwnProperty;const a=function(e){if(!(0,o.Z)(e))return function(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t}(e);var t=(0,s.Z)(e),i=[];for(var n in e)("constructor"!=n||!t&&r.call(e,n))&&i.push(n);return i};var l=i(585);const c=function(e){return(0,l.Z)(e)?(0,n.Z)(e,!0):a(e)}},532:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(){return[]}},111:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(6682),o=i(7226);const s=function(e,t,i){var s=!0,r=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return(0,o.Z)(i)&&(s="leading"in i?!!i.leading:s,r="trailing"in i?!!i.trailing:r),(0,n.Z)(e,t,{leading:s,maxWait:t,trailing:r})}},9939:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c});var n=i(7685);var o=i(7771),s=i(2714),r=n.Z?n.Z.prototype:void 0,a=r?r.toString:void 0;const l=function e(t){if("string"==typeof t)return t;if((0,o.Z)(t))return function(e,t){for(var i=-1,n=null==e?0:e.length,o=Array(n);++i{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n=i(366);CKEditor5=n})(); \ No newline at end of file +var CKEditor5;!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"%0 of %1",Accept:"Accept","Align cell text to the bottom":"Align cell text to the bottom","Align cell text to the center":"Align cell text to the center","Align cell text to the left":"Align cell text to the left","Align cell text to the middle":"Align cell text to the middle","Align cell text to the right":"Align cell text to the right","Align cell text to the top":"Align cell text to the top","Align center":"Align center","Align left":"Align left","Align right":"Align right","Align table to the left":"Align table to the left","Align table to the right":"Align table to the right",Alignment:"Alignment",Aquamarine:"Aquamarine",Background:"Background",Big:"Big",Black:"Black","Block quote":"Block quote",Blue:"Blue","Blue marker":"Blue marker",Bold:"Bold",Border:"Border","Break text":"Break text","Bulleted List":"Bulleted List","Bulleted list styles toolbar":"Bulleted list styles toolbar",Cancel:"Cancel","Caption for image: %0":"Caption for image: %0","Caption for the image":"Caption for the image","Cell properties":"Cell properties","Center table":"Center table","Centered image":"Centered image","Change image text alternative":"Change image text alternative","Choose heading":"Choose heading",Circle:"Circle",Code:"Code",Color:"Color","Color picker":"Color picker",Column:"Column",Dashed:"Dashed",Decimal:"Decimal","Decimal with leading zero":"Decimal with leading zero","Decrease indent":"Decrease indent",Default:"Default","Delete column":"Delete column","Delete row":"Delete row","Dim grey":"Dim grey",Dimensions:"Dimensions",Disc:"Disc","Document colors":"Document colors",Dotted:"Dotted",Double:"Double",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","Enter table caption":"Enter table 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","Green marker":"Green marker","Green pen":"Green pen",Grey:"Grey",Groove:"Groove","Header column":"Header column","Header row":"Header row",Heading:"Heading","Heading 1":"Heading 1","Heading 2":"Heading 2","Heading 3":"Heading 3","Heading 4":"Heading 4","Heading 5":"Heading 5","Heading 6":"Heading 6",Height:"Height",HEX:"HEX",Highlight:"Highlight","Horizontal line":"Horizontal line","Horizontal text alignment toolbar":"Horizontal text alignment toolbar","HTML snippet":"HTML snippet",Huge:"Huge","Image resize list":"Image resize list","Image toolbar":"Image toolbar","image widget":"image widget","In line":"In line","Increase indent":"Increase indent",Insert:"Insert","Insert code block":"Insert code block","Insert column left":"Insert column left","Insert column right":"Insert column right","Insert HTML":"Insert HTML","Insert image":"Insert image","Insert image via URL":"Insert image via URL","Insert 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",Inset:"Inset",Italic:"Italic",Justify:"Justify","Justify cell text":"Justify cell text","Left aligned image":"Left aligned image","Light blue":"Light blue","Light green":"Light green","Light grey":"Light grey",Link:"Link","Link image":"Link image","Link URL":"Link URL","List properties":"List properties","Lower-latin":"Lower-latin","Lower–roman":"Lower–roman","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",None:"None","Numbered List":"Numbered List","Numbered list styles toolbar":"Numbered list styles toolbar","Open in a new tab":"Open in a new tab","Open link in new tab":"Open link in new tab",Orange:"Orange",Original:"Original",Outset:"Outset",Padding:"Padding",Paragraph:"Paragraph","Paste raw HTML here...":"Paste raw HTML here...","Pink marker":"Pink marker","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","Red pen":"Red pen",Redo:"Redo","Remove color":"Remove color","Remove Format":"Remove Format","Remove highlight":"Remove highlight","Resize image":"Resize image","Resize image to %0":"Resize image to %0","Resize image to the original size":"Resize image to the original size","Restore default":"Restore default","Reversed order":"Reversed order","Rich Text Editor":"Rich Text Editor",Ridge:"Ridge","Right aligned image":"Right aligned image",Row:"Row",Save:"Save","Save changes":"Save changes","Saving changes":"Saving 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",Solid:"Solid","Split cell horizontally":"Split cell horizontally","Split cell vertically":"Split cell vertically",Square:"Square","Start at":"Start at","Start index must be greater than 0.":"Start index must be greater than 0.",Strikethrough:"Strikethrough",Style:"Style",Subscript:"Subscript",Superscript:"Superscript","Table alignment toolbar":"Table alignment toolbar","Table cell text alignment":"Table cell text alignment","Table properties":"Table properties","Table toolbar":"Table toolbar","Text alignment":"Text alignment","Text alignment toolbar":"Text alignment toolbar","Text alternative":"Text alternative","Text highlight toolbar":"Text highlight toolbar",'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".':'The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".','The value is invalid. Try "10px" or "2em" or simply "2".':'The value is invalid. Try "10px" or "2em" or simply "2".',"This link has no URL":"This link has no URL",Tiny:"Tiny","To-do List":"To-do List","Toggle caption off":"Toggle caption off","Toggle caption on":"Toggle caption on","Toggle the circle list style":"Toggle the circle list style","Toggle the decimal list style":"Toggle the decimal list style","Toggle the decimal with leading zero list style":"Toggle the decimal with leading zero list style","Toggle the disc list style":"Toggle the disc list style","Toggle the lower–latin list style":"Toggle the lower–latin list style","Toggle the lower–roman list style":"Toggle the lower–roman list style","Toggle the square list style":"Toggle the square list style","Toggle the upper–latin list style":"Toggle the upper–latin list style","Toggle the upper–roman list style":"Toggle the upper–roman list style",Turquoise:"Turquoise","Type or paste your content here.":"Type or paste your content here.","Type your title":"Type your title",Underline:"Underline",Undo:"Undo",Unlink:"Unlink",Update:"Update","Update image URL":"Update image URL","Upload failed":"Upload failed","Upload in progress":"Upload in progress","Upper-latin":"Upper-latin","Upper-roman":"Upper-roman","Vertical text alignment toolbar":"Vertical text alignment toolbar",White:"White","Widget toolbar":"Widget toolbar",Width:"Width","Wrap text":"Wrap text",Yellow:"Yellow","Yellow marker":"Yellow marker"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),(()=>{var e={511:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Alignment:()=>f,AlignmentEditing:()=>u,AlignmentUI:()=>g});var n=i(6854),o=i(6553);const s=["left","right","center","justify"];function r(e){return s.includes(e)}function a(e,t){return"rtl"==t.contentLanguageDirection?"right"===e:"left"===e}function l(e){const t=e.map((e=>{let t;return t="string"==typeof e?{name:e}:e,t})).filter((e=>{const t=s.includes(e.name);return t||(0,o.KE)("alignment-config-name-not-recognized",{option:e}),t})),i=t.filter((e=>Boolean(e.className))).length;if(i&&i{const s=n.slice(i+1);if(s.some((e=>e.name==t.name)))throw new o.Bb("alignment-config-name-already-defined",{option:t,configuredOptions:e});if(t.className&&s.some((e=>e.className==t.className)))throw new o.Bb("alignment-config-classname-already-defined",{option:t,configuredOptions:e})})),t}const c="alignment";class d extends n.mY{refresh(){const e=this.editor.locale,t=(0,o.Ps)(this.editor.model.document.selection.getSelectedBlocks());this.isEnabled=Boolean(t)&&this._canBeAligned(t),this.isEnabled&&t.hasAttribute("alignment")?this.value=t.getAttribute("alignment"):this.value="rtl"===e.contentLanguageDirection?"right":"left"}execute(e={}){const t=this.editor,i=t.locale,n=t.model,o=n.document,s=e.value;n.change((e=>{const t=Array.from(o.selection.getSelectedBlocks()).filter((e=>this._canBeAligned(e))),n=t[0].getAttribute("alignment");a(s,i)||n===s||!s?function(e,t){for(const i of e)t.removeAttribute(c,i)}(t,e):function(e,t,i){for(const n of e)t.setAttribute(c,i,n)}(t,e,s)}))}_canBeAligned(e){return this.editor.model.schema.checkAttribute(e,c)}}class u extends n.Sy{static get pluginName(){return"AlignmentEditing"}constructor(e){super(e),e.config.define("alignment",{options:s.map((e=>({name:e})))})}init(){const e=this.editor,t=e.locale,i=e.model.schema,n=l(e.config.get("alignment.options")).filter((e=>r(e.name)&&!a(e.name,t))),o=n.some((e=>!!e.className));i.extend("$block",{allowAttributes:"alignment"}),e.model.schema.setAttributeProperties("alignment",{isFormatting:!0}),o?e.conversion.attributeToAttribute(function(e){const t={};for(const i of e)t[i.name]={key:"class",value:i.className};return{model:{key:"alignment",values:e.map((e=>e.name))},view:t}}(n)):e.conversion.for("downcast").attributeToAttribute(function(e){const t={};for(const{name:i}of e)t[i]={key:"style",value:{"text-align":i}};return{model:{key:"alignment",values:e.map((e=>e.name))},view:t}}(n));const s=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"style",value:{"text-align":i}},model:{key:"alignment",value:i}});return t}(n);for(const t of s)e.conversion.for("upcast").attributeToAttribute(t);const c=function(e){const t=[];for(const{name:i}of e)t.push({view:{key:"align",value:i},model:{key:"alignment",value:i}});return t}(n);for(const t of c)e.conversion.for("upcast").attributeToAttribute(t);e.commands.add("alignment",new d(e))}}var h=i(7095);const m=new Map([["left",n.icons.alignLeft],["right",n.icons.alignRight],["center",n.icons.alignCenter],["justify",n.icons.alignJustify]]);class g extends n.Sy{get localizedOptionTitles(){const e=this.editor.t;return{left:e("Align left"),right:e("Align right"),center:e("Align center"),justify:e("Justify")}}static get pluginName(){return"AlignmentUI"}init(){const e=this.editor,t=e.ui.componentFactory,i=e.t,n=l(e.config.get("alignment.options"));n.map((e=>e.name)).filter(r).forEach((e=>this._addButton(e))),t.add("alignment",(o=>{const s=(0,h.t9)(o);(0,h.up)(s,(()=>n.map((e=>t.create(`alignment:${e.name}`)))),{enableActiveItemFocusOnDropdownOpen:!0,isVertical:!0,ariaLabel:i("Text alignment toolbar")}),s.buttonView.set({label:i("Text alignment"),tooltip:!0}),s.extendTemplate({attributes:{class:"ck-alignment-dropdown"}});const r="rtl"===o.contentLanguageDirection?m.get("right"):m.get("left"),a=e.commands.get("alignment");return s.buttonView.bind("icon").to(a,"value",(e=>m.get(e)||r)),s.bind("isEnabled").to(a,"isEnabled"),this.listenTo(s,"execute",(()=>{e.editing.view.focus()})),s}))}_addButton(e){const t=this.editor;t.ui.componentFactory.add(`alignment:${e}`,(i=>{const n=t.commands.get("alignment"),o=new h.r5(i);return o.set({label:this.localizedOptionTitles[e],icon:m.get(e),tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(n),o.bind("isOn").to(n,"value",(t=>t===e)),this.listenTo(o,"execute",(()=>{t.execute("alignment",{value:e}),t.editing.view.focus()})),o}))}}class f extends n.Sy{static get requires(){return[u,g]}static get pluginName(){return"Alignment"}}},6549:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Autosave:()=>r});var n=i(6854),o=i(6553),s=i(6682);class r extends n.Sy{static get pluginName(){return"Autosave"}static get requires(){return[n.lR]}constructor(e){super(e),this._action=null;const t=e.config.get("autosave")||{},i=t.waitingTime||1e3;this.set("state","synchronized"),this._debouncedSave=(0,s.Z)(this._save.bind(this),i),this._lastDocumentVersion=e.model.document.version,this._savePromise=null,this._domEmitter=new((0,o.Xu)()),this._config=t,this._pendingActions=e.plugins.get(n.lR),this._makeImmediateSave=!1}init(){const e=this.editor,t=e.model.document;this.listenTo(e,"ready",(()=>{this.listenTo(t,"change:data",((e,t)=>{this._saveCallbacks.length&&t.isLocal&&("synchronized"===this.state&&(this.state="waiting",this._setPendingAction()),"waiting"===this.state&&this._debouncedSave())}))})),this.listenTo(e,"destroy",(()=>this._flush()),{priority:"highest"}),this._domEmitter.listenTo(window,"beforeunload",((e,t)=>{this._pendingActions.hasAny&&(t.returnValue=this._pendingActions.first.message)}))}destroy(){this._domEmitter.stopListening(),super.destroy()}save(){return this._debouncedSave.cancel(),this._save()}_flush(){this._debouncedSave.flush()}_save(){return this._savePromise?(this._makeImmediateSave=this.editor.model.document.version>this._lastDocumentVersion,this._savePromise):(this._setPendingAction(),this.state="saving",this._lastDocumentVersion=this.editor.model.document.version,this._savePromise=Promise.resolve().then((()=>Promise.all(this._saveCallbacks.map((e=>e(this.editor)))))).finally((()=>{this._savePromise=null})).then((()=>{if(this._makeImmediateSave)return this._makeImmediateSave=!1,this._save();this.editor.model.document.version>this._lastDocumentVersion?(this.state="waiting",this._debouncedSave()):(this.state="synchronized",this._pendingActions.remove(this._action),this._action=null)})).catch((e=>{throw this.state="error",this.state="saving",this._debouncedSave(),e})),this._savePromise)}_setPendingAction(){const e=this.editor.t;this._action||(this._action=this._pendingActions.add(e("Saving changes")))}get _saveCallbacks(){const e=[];return this.adapter&&this.adapter.save&&e.push(this.adapter.save),this._config.save&&e.push(this._config.save),e}}},7971:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Bold:()=>d,BoldEditing:()=>r,BoldUI:()=>c,Code:()=>p,CodeEditing:()=>m,CodeUI:()=>f,Italic:()=>y,ItalicEditing:()=>w,ItalicUI:()=>_,Strikethrough:()=>x,StrikethroughEditing:()=>C,StrikethroughUI:()=>E,Subscript:()=>V,SubscriptEditing:()=>S,SubscriptUI:()=>I,Superscript:()=>N,SuperscriptEditing:()=>O,SuperscriptUI:()=>M,Underline:()=>H,UnderlineEditing:()=>L,UnderlineUI:()=>z});var n=i(6854);class o extends n.mY{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,!0):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of o)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,i=e.document.selection;if(i.isCollapsed)return i.hasAttribute(this.attributeKey);for(const e of i.getRanges())for(const i of e.getItems())if(t.checkAttribute(i,this.attributeKey))return i.hasAttribute(this.attributeKey);return!1}}const s="bold";class r extends n.Sy{static get pluginName(){return"BoldEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:s}),e.model.schema.setAttributeProperties(s,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:s,view:"strong",upcastAlso:["b",e=>{const t=e.getStyle("font-weight");return t&&("bold"==t||Number(t)>=600)?{name:!0,styles:["font-weight"]}:null}]}),e.commands.add(s,new o(e,s)),e.keystrokes.set("CTRL+B",s)}}var a=i(7095);const l="bold";class c extends n.Sy{static get pluginName(){return"BoldUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(l,(i=>{const o=e.commands.get(l),s=new a.r5(i);return s.set({label:t("Bold"),icon:n.icons.bold,keystroke:"CTRL+B",tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(s,"execute",(()=>{e.execute(l),e.editing.view.focus()})),s}))}}class d extends n.Sy{static get requires(){return[r,c]}static get pluginName(){return"Bold"}}var u=i(5187);const h="code";class m extends n.Sy{static get pluginName(){return"CodeEditing"}static get requires(){return[u.mh]}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:h}),e.model.schema.setAttributeProperties(h,{isFormatting:!0,copyOnEnter:!1}),e.conversion.attributeToElement({model:h,view:"code",upcastAlso:{styles:{"word-wrap":"break-word"}}}),e.commands.add(h,new o(e,h)),e.plugins.get(u.mh).registerAttribute(h),(0,u.Im)(e,h,"code","ck-code_selected")}}const g="code";class f extends n.Sy{static get pluginName(){return"CodeUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(g,(i=>{const n=e.commands.get(g),o=new a.r5(i);return o.set({label:t("Code"),icon:'',tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(g),e.editing.view.focus()})),o}))}}class p extends n.Sy{static get requires(){return[m,f]}static get pluginName(){return"Code"}}const b="italic";class w extends n.Sy{static get pluginName(){return"ItalicEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:b}),e.model.schema.setAttributeProperties(b,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:b,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add(b,new o(e,b)),e.keystrokes.set("CTRL+I",b)}}const v="italic";class _ extends n.Sy{static get pluginName(){return"ItalicUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(v,(i=>{const n=e.commands.get(v),o=new a.r5(i);return o.set({label:t("Italic"),icon:'',keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(v),e.editing.view.focus()})),o}))}}class y extends n.Sy{static get requires(){return[w,_]}static get pluginName(){return"Italic"}}const k="strikethrough";class C extends n.Sy{static get pluginName(){return"StrikethroughEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:k}),e.model.schema.setAttributeProperties(k,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:k,view:"s",upcastAlso:["del","strike",{styles:{"text-decoration":"line-through"}}]}),e.commands.add(k,new o(e,k)),e.keystrokes.set("CTRL+SHIFT+X","strikethrough")}}const A="strikethrough";class E extends n.Sy{static get pluginName(){return"StrikethroughUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(A,(i=>{const n=e.commands.get(A),o=new a.r5(i);return o.set({label:t("Strikethrough"),icon:'',keystroke:"CTRL+SHIFT+X",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(A),e.editing.view.focus()})),o}))}}class x extends n.Sy{static get requires(){return[C,E]}static get pluginName(){return"Strikethrough"}}const T="subscript";class S extends n.Sy{static get pluginName(){return"SubscriptEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:T}),e.model.schema.setAttributeProperties(T,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:T,view:"sub",upcastAlso:[{styles:{"vertical-align":"sub"}}]}),e.commands.add(T,new o(e,T))}}const P="subscript";class I extends n.Sy{static get pluginName(){return"SubscriptUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(P,(i=>{const n=e.commands.get(P),o=new a.r5(i);return o.set({label:t("Subscript"),icon:'',tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(P),e.editing.view.focus()})),o}))}}class V extends n.Sy{static get requires(){return[S,I]}static get pluginName(){return"Subscript"}}const R="superscript";class O extends n.Sy{static get pluginName(){return"SuperscriptEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:R}),e.model.schema.setAttributeProperties(R,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:R,view:"sup",upcastAlso:[{styles:{"vertical-align":"super"}}]}),e.commands.add(R,new o(e,R))}}const B="superscript";class M extends n.Sy{static get pluginName(){return"SuperscriptUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(B,(i=>{const n=e.commands.get(B),o=new a.r5(i);return o.set({label:t("Superscript"),icon:'',tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(B),e.editing.view.focus()})),o}))}}class N extends n.Sy{static get requires(){return[O,M]}static get pluginName(){return"Superscript"}}const D="underline";class L extends n.Sy{static get pluginName(){return"UnderlineEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:D}),e.model.schema.setAttributeProperties(D,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:D,view:"u",upcastAlso:{styles:{"text-decoration":"underline"}}}),e.commands.add(D,new o(e,D)),e.keystrokes.set("CTRL+U","underline")}}const F="underline";class z extends n.Sy{static get pluginName(){return"UnderlineUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(F,(i=>{const n=e.commands.get(F),o=new a.r5(i);return o.set({label:t("Underline"),icon:'',keystroke:"CTRL+U",tooltip:!0,isToggleable:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{e.execute(F),e.editing.view.focus()})),o}))}}class H extends n.Sy{static get requires(){return[L,z]}static get pluginName(){return"Underline"}}},3306:(e,t,i)=>{"use strict";i.r(t),i.d(t,{BlockQuote:()=>g,BlockQuoteEditing:()=>u,BlockQuoteUI:()=>m});var n=i(6854),o=i(1863),s=i(5187),r=i(6553);class a extends n.mY{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.schema,n=t.document.selection,o=Array.from(n.getSelectedBlocks()),s=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(s){const t=o.filter((e=>l(e)||d(i,e)));this._applyQuote(e,t)}else this._removeQuote(e,o.filter(l))}))}_getValue(){const e=this.editor.model.document.selection,t=(0,r.Ps)(e.getSelectedBlocks());return!(!t||!l(t))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=(0,r.Ps)(e.getSelectedBlocks());return!!i&&d(t,i)}_removeQuote(e,t){c(e,t).reverse().forEach((t=>{if(t.start.isAtStart&&t.end.isAtEnd)return void e.unwrap(t.start.parent);if(t.start.isAtStart){const i=e.createPositionBefore(t.start.parent);return void e.move(t,i)}t.end.isAtEnd||e.split(t.end);const i=e.createPositionAfter(t.end.parent);e.move(t,i)}))}_applyQuote(e,t){const i=[];c(e,t).reverse().forEach((t=>{let n=l(t.start);n||(n=e.createElement("blockQuote"),e.wrap(t,n)),i.push(n)})),i.reverse().reduce(((t,i)=>t.nextSibling==i?(e.merge(e.createPositionAfter(t)),t):i))}}function l(e){return"blockQuote"==e.parent.name?e.parent:null}function c(e,t){let i,n=0;const o=[];for(;n{const n=e.model.document.differ.getChanges();for(const e of n)if("insert"==e.type){const n=e.position.nodeAfter;if(!n)continue;if(n.is("element","blockQuote")&&n.isEmpty)return i.remove(n),!0;if(n.is("element","blockQuote")&&!t.checkChild(e.position,n))return i.unwrap(n),!0;if(n.is("element")){const e=i.createRangeIn(n);for(const n of e.getItems())if(n.is("element","blockQuote")&&!t.checkChild(i.createPositionBefore(n),n))return i.unwrap(n),!0}}else if("remove"==e.type){const t=e.position.parent;if(t.is("element","blockQuote")&&t.isEmpty)return i.remove(t),!0}return!1}));const i=this.editor.editing.view.document,n=e.model.document.selection,o=e.commands.get("blockQuote");this.listenTo(i,"enter",((t,i)=>{n.isCollapsed&&o.value&&n.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"}),this.listenTo(i,"delete",((t,i)=>{if("backward"!=i.direction||!n.isCollapsed||!o.value)return;const s=n.getLastPosition().parent;s.isEmpty&&!s.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),i.preventDefault(),t.stop())}),{context:"blockquote"})}}var h=i(7095);class m extends n.Sy{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",(i=>{const o=e.commands.get("blockQuote"),s=new h.r5(i);return s.set({label:t("Block quote"),icon:n.icons.quote,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(s,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),s}))}}class g extends n.Sy{static get requires(){return[u,m]}static get pluginName(){return"BlockQuote"}}},6597:(e,t,i)=>{"use strict";i.r(t),i.d(t,{CodeBlock:()=>v,CodeBlockEditing:()=>g,CodeBlockUI:()=>w});var n=i(6854),o=i(1863),s=i(3291),r=i(6553),a=i(4934);class l extends n.mY{constructor(e){super(e),this._lastLanguage=null}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor,i=t.model,n=i.document.selection,o=(0,a.getNormalizedAndLocalizedLanguageDefinitions)(t)[0],s=Array.from(n.getSelectedBlocks()),r=null==e.forceValue?!this.value:e.forceValue,l=function(e,t,i){return e.language?e.language:e.usePreviousLanguageChoice&&t?t:i}(e,this._lastLanguage,o.language);i.change((e=>{r?this._applyCodeBlock(e,s,l):this._removeCodeBlock(e,s)}))}_getValue(){const e=this.editor.model.document.selection,t=(0,r.Ps)(e.getSelectedBlocks());return!(!t||!t.is("element","codeBlock"))&&t.getAttribute("language")}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,i=(0,r.Ps)(e.getSelectedBlocks());return!!i&&(0,a.canBeCodeBlock)(t,i)}_applyCodeBlock(e,t,i){this._lastLanguage=i;const n=this.editor.model.schema,o=t.filter((e=>(0,a.canBeCodeBlock)(n,e)));for(const t of o)e.rename(t,"codeBlock"),e.setAttribute("language",i,t),n.removeDisallowedAttributes([t],e),Array.from(t.getChildren()).filter((e=>!n.checkChild(t,e))).forEach((t=>e.remove(t)));o.reverse().forEach(((t,i)=>{const n=o[i+1];t.previousSibling===n&&(e.appendElement("softBreak",n),e.merge(e.createPositionBefore(t)))}))}_removeCodeBlock(e,t){const i=t.filter((e=>e.is("element","codeBlock")));for(const t of i){const i=e.createRangeOn(t);for(const t of Array.from(i.getItems()).reverse())if(t.is("element","softBreak")&&t.parent.is("element","codeBlock")){const{position:i}=e.split(e.createPositionBefore(t)),n=i.nodeAfter;e.rename(n,"paragraph"),e.removeAttribute("language",n),e.remove(t)}e.rename(t,"paragraph"),e.removeAttribute("language",t)}}}class c extends n.mY{constructor(e){super(e),this._indentSequence=e.config.get("codeBlock.indentSequence")}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model;e.change((t=>{const i=(0,a.getIndentOutdentPositions)(e);for(const n of i){const i=t.createText(this._indentSequence);e.insertContent(i,n)}}))}_checkEnabled(){return!!this._indentSequence&&(0,a.isModelSelectionInCodeBlock)(this.editor.model.document.selection)}}class d extends n.mY{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=(0,a.getIndentOutdentPositions)(e);for(const i of t){const t=u(e,i,this._indentSequence);t&&e.deleteContent(e.createSelection(t))}}))}_checkEnabled(){if(!this._indentSequence)return!1;const e=this.editor.model;return!!(0,a.isModelSelectionInCodeBlock)(e.document.selection)&&(0,a.getIndentOutdentPositions)(e).some((t=>u(e,t,this._indentSequence)))}}function u(e,t,i){const n=function(e){let t=e.parent.getChild(e.index);return t&&!t.is("element","softBreak")||(t=e.nodeBefore),!t||t.is("element","softBreak")?null:t}(t);if(!n)return null;const o=(0,a.getLeadingWhiteSpaces)(n),s=o.lastIndexOf(i);if(s+i.length!==o.length)return null;if(-1===s)return null;const{parent:r,startOffset:l}=n;return e.createRange(e.createPositionAt(r,l+s),e.createPositionAt(r,l+s+i.length))}function h(e,t,i=!1){const n=(0,a.getPropertyAssociation)(t,"language","class"),o=(0,a.getPropertyAssociation)(t,"language","label");return(t,s,r)=>{const{writer:a,mapper:l,consumable:c}=r;if(!c.consume(s.item,"insert"))return;const d=s.item.getAttribute("language"),u=l.toViewPosition(e.createPositionBefore(s.item)),h={};i&&(h["data-language"]=o[d],h.spellcheck="false");const m=n[d]?{class:n[d]}:void 0,g=a.createContainerElement("code",m),f=a.createContainerElement("pre",h,g);a.insert(u,f),l.bindElements(s.item,g)}}const m="paragraph";class g extends n.Sy{static get pluginName(){return"CodeBlockEditing"}static get requires(){return[o.G]}constructor(e){super(e),e.config.define("codeBlock",{languages:[{language:"plaintext",label:"Plain text"},{language:"c",label:"C"},{language:"cs",label:"C#"},{language:"cpp",label:"C++"},{language:"css",label:"CSS"},{language:"diff",label:"Diff"},{language:"html",label:"HTML"},{language:"java",label:"Java"},{language:"javascript",label:"JavaScript"},{language:"php",label:"PHP"},{language:"python",label:"Python"},{language:"ruby",label:"Ruby"},{language:"typescript",label:"TypeScript"},{language:"xml",label:"XML"}],indentSequence:"\t"})}init(){const e=this.editor,t=e.model.schema,i=e.model,n=e.editing.view,o=e.plugins.has("DocumentListEditing"),r=(0,a.getNormalizedAndLocalizedLanguageDefinitions)(e);e.commands.add("codeBlock",new l(e)),e.commands.add("indentCodeBlock",new c(e)),e.commands.add("outdentCodeBlock",new d(e)),this.listenTo(n.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentCodeBlock":"indentCodeBlock";e.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"pre"}),t.register("codeBlock",{allowWhere:"$block",allowChildren:"$text",isBlock:!0,allowAttributes:["language"]}),t.addAttributeCheck(((e,t)=>{const i=e.endsWith("codeBlock")&&t.startsWith("list")&&"list"!==t;return!(!o||!i)||!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",h(i,r,!0)),e.data.downcastDispatcher.on("insert:codeBlock",h(i,r)),e.data.downcastDispatcher.on("insert:softBreak",function(e){return(t,i,n)=>{if("codeBlock"!==i.item.parent.name)return;const{writer:o,mapper:s,consumable:r}=n;if(!r.consume(i.item,"insert"))return;const a=s.toViewPosition(e.createPositionBefore(i.item));o.insert(a,o.createText("\n"))}}(i),{priority:"high"}),e.data.upcastDispatcher.on("element:code",function(e,t){const i=(0,a.getPropertyAssociation)(t,"class","language"),n=t[0].language;return(e,t,o)=>{const s=t.viewItem,r=s.parent;if(!r||!r.is("element","pre"))return;if(t.modelCursor.findAncestor("codeBlock"))return;const{consumable:a,writer:l}=o;if(!a.test(s,{name:!0}))return;const c=l.createElement("codeBlock"),d=[...s.getClassNames()];d.length||d.push("");for(const e of d){const t=i[e];if(t){l.setAttribute("language",t,c);break}}c.hasAttribute("language")||l.setAttribute("language",n,c),o.convertChildren(s,c),o.safeInsert(c,t.modelCursor)&&(a.consume(s,{name:!0}),o.updateConversionResult(c,t))}}(0,r)),e.data.upcastDispatcher.on("text",((e,t,{consumable:i,writer:n})=>{let o=t.modelCursor;if(!i.test(t.viewItem))return;if(!o.findAncestor("codeBlock"))return;i.consume(t.viewItem);const s=t.viewItem.data.split("\n").map((e=>n.createText(e))),r=s[s.length-1];for(const e of s)if(n.insert(e,o),o=o.getShiftedBy(e.offsetSize),e!==r){const e=n.createElement("softBreak");n.insert(e,o),o=n.createPositionAfter(e)}t.modelRange=n.createRange(t.modelCursor,o),t.modelCursor=o})),e.data.upcastDispatcher.on("element:pre",((e,t,{consumable:i})=>{const n=t.viewItem;if(n.findAncestor("pre"))return;const o=Array.from(n.getChildren()),s=o.find((e=>e.is("element","code")));if(s)for(const e of o)e!==s&&e.is("$text")&&i.consume(e,{name:!0})}),{priority:"high"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,n)=>{let o=i.createRange(i.document.selection.anchor);if(n.targetRanges&&(o=e.editing.mapper.toModelRange(n.targetRanges[0])),!o.start.parent.is("element","codeBlock"))return;const r=n.dataTransfer.getData("text/plain"),l=new s.yj(e.editing.view.document);n.content=(0,a.rawSnippetTextToViewDocumentFragment)(l,r)})),this.listenTo(i,"getSelectedContent",((e,[n])=>{const o=n.anchor;!n.isCollapsed&&o.parent.is("element","codeBlock")&&o.hasSameParentAs(n.focus)&&i.change((i=>{const s=e.return;if(o.parent.is("element")&&(s.childCount>1||n.containsEntireContent(o.parent))){const t=i.createElement("codeBlock",o.parent.getAttributes());i.append(s,t);const n=i.createDocumentFragment();return i.append(t,n),void(e.return=n)}const r=s.getChild(0);t.checkAttribute(r,"code")&&i.setAttribute("code",!0,r)}))}))}afterInit(){const e=this.editor,t=e.commands,i=t.get("indent"),n=t.get("outdent");i&&i.registerChildCommand(t.get("indentCodeBlock"),{priority:"highest"}),n&&n.registerChildCommand(t.get("outdentCodeBlock")),this.listenTo(e.editing.view.document,"enter",((t,i)=>{e.model.document.selection.getLastPosition().parent.is("element","codeBlock")&&(function(e,t){const i=e.model.document,n=e.editing.view,o=i.selection.getLastPosition(),s=o.nodeAfter;return!(t||!i.selection.isCollapsed||!o.isAtStart)&&(!!p(s)&&(e.model.change((t=>{e.execute("enter");const n=i.selection.anchor.parent.previousSibling;t.rename(n,m),t.setSelection(n,"in"),e.model.schema.removeDisallowedAttributes([n],t),t.remove(s)})),n.scrollToTheSelection(),!0))}(e,i.isSoft)||function(e,t){const i=e.model,n=i.document,o=e.editing.view,s=n.selection.getLastPosition(),r=s.nodeBefore;let a;if(t||!n.selection.isCollapsed||!s.isAtEnd||!r||!r.previousSibling)return!1;if(p(r)&&p(r.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling),i.createPositionAfter(r));else if(f(r)&&p(r.previousSibling)&&p(r.previousSibling.previousSibling))a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling),i.createPositionAfter(r));else{if(!(f(r)&&p(r.previousSibling)&&f(r.previousSibling.previousSibling)&&r.previousSibling.previousSibling&&p(r.previousSibling.previousSibling.previousSibling)))return!1;a=i.createRange(i.createPositionBefore(r.previousSibling.previousSibling.previousSibling),i.createPositionAfter(r))}return e.model.change((t=>{t.remove(a),e.execute("enter");const i=n.selection.anchor.parent;t.rename(i,m),e.model.schema.removeDisallowedAttributes([i],t)})),o.scrollToTheSelection(),!0}(e,i.isSoft)||function(e){const t=e.model.document,i=t.selection.getLastPosition(),n=i.nodeBefore||i.textNode;let o;n&&n.is("$text")&&(o=(0,a.getLeadingWhiteSpaces)(n)),e.model.change((i=>{e.execute("shiftEnter"),o&&i.insertText(o,t.selection.anchor)}))}(e),i.preventDefault(),t.stop())}),{context:"pre"})}}function f(e){return e&&e.is("$text")&&!e.data.match(/\S/)}function p(e){return e&&e.is("element","softBreak")}var b=i(7095);class w extends n.Sy{static get pluginName(){return"CodeBlockUI"}init(){const e=this.editor,t=e.t,i=e.ui.componentFactory,n=(0,a.getNormalizedAndLocalizedLanguageDefinitions)(e);i.add("codeBlock",(i=>{const o=e.commands.get("codeBlock"),s=(0,b.t9)(i,b.Rm),r=s.buttonView,a=t("Insert code block");return r.set({label:a,tooltip:!0,icon:'',isToggleable:!0}),r.bind("isOn").to(o,"value",(e=>!!e)),r.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!0}),e.editing.view.focus()})),s.on("execute",(t=>{e.execute("codeBlock",{language:t.source._codeBlockLanguage,forceValue:!0}),e.editing.view.focus()})),s.class="ck-code-block-dropdown",s.bind("isEnabled").to(o),(0,b.Pm)(s,(()=>this._getLanguageListItemDefinitions(n)),{role:"menu",ariaLabel:a}),s}))}_getLanguageListItemDefinitions(e){const t=this.editor.commands.get("codeBlock"),i=new r.FE;for(const n of e){const e={type:"button",model:new b.Hn({_codeBlockLanguage:n.language,label:n.label,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(t=>t===e.model._codeBlockLanguage)),i.add(e)}return i}}class v extends n.Sy{static get requires(){return[g,w]}static get pluginName(){return"CodeBlock"}}},4934:(e,t,i)=>{"use strict";i.r(t),i.d(t,{canBeCodeBlock:()=>d,getIndentOutdentPositions:()=>l,getLeadingWhiteSpaces:()=>r,getNormalizedAndLocalizedLanguageDefinitions:()=>o,getPropertyAssociation:()=>s,isModelSelectionInCodeBlock:()=>c,rawSnippetTextToViewDocumentFragment:()=>a});var n=i(6553);function o(e){const t=e.t,i=e.config.get("codeBlock.languages");for(const e of i)"Plain text"===e.label&&(e.label=t("Plain text")),void 0===e.class&&(e.class=`language-${e.language}`);return i}function s(e,t,i){const n={};for(const o of e)"class"===t?n[o[t].split(" ").shift()]=o[i]:n[o[t]]=o[i];return n}function r(e){return e.data.match(/^(\s*)/)[0]}function a(e,t){const i=e.createDocumentFragment(),n=t.split("\n"),o=n.reduce(((t,i,o)=>(t.push(i),o{"use strict";i.r(t),i.d(t,{Command:()=>r,Context:()=>d,ContextPlugin:()=>u,DataApiMixin:()=>w,Editor:()=>f,ElementApiMixin:()=>v,MultiCommand:()=>l,PendingActions:()=>y,Plugin:()=>o,attachToForm:()=>b,icons:()=>E,secureSourceElement:()=>_});var n=i(5044);class o extends((0,n.ObservableMixin)()){constructor(e){super(),this._disableStack=new Set,this.editor=e,this.set("isEnabled",!0)}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",s,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",s),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}}function s(e){e.return=!1,e.stop()}class r extends((0,n.ObservableMixin)()){constructor(e){super(),this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this._affectsData=!0,this._isEnabledBasedOnSelection=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",(()=>{this.refresh()})),this.listenTo(e,"change:isReadOnly",(()=>{this.refresh()})),this.on("set:isEnabled",(t=>{if(!this.affectsData)return;const i=e.model.document.selection,n=!("$graveyard"==i.getFirstPosition().root.rootName)&&e.model.canEditAt(i);(e.isReadOnly||this._isEnabledBasedOnSelection&&!n)&&(t.return=!1,t.stop())}),{priority:"highest"}),this.on("execute",(e=>{this.isEnabled||e.stop()}),{priority:"high"})}get affectsData(){return this._affectsData}set affectsData(e){this._affectsData=e}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",a,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",a),this.refresh())}execute(...e){}destroy(){this.stopListening()}}function a(e){e.return=!1,e.stop()}class l extends r{constructor(){super(...arguments),this._childCommandsDefinitions=[]}refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={}){(0,n.insertToPriorityArray)(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 c extends((0,n.EmitterMixin)()){constructor(e,t=[],i=[]){super(),this._plugins=new Map,this._context=e,this._availablePlugins=new Map;for(const e of t)e.pluginName&&this._availablePlugins.set(e.pluginName,e);this._contextPlugins=new Map;for(const[e,t]of i)this._contextPlugins.set(e,t),this._contextPlugins.set(t,e),e.pluginName&&this._availablePlugins.set(e.pluginName,e)}*[Symbol.iterator](){for(const e of this._plugins)"function"==typeof e[0]&&(yield e)}get(e){const t=this._plugins.get(e);if(!t){let t=e;throw"function"==typeof e&&(t=e.pluginName||e.name),new n.CKEditorError("plugincollection-plugin-not-loaded",this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}init(e,t=[],i=[]){const o=this,s=this._context;!function e(t,i=new Set){t.forEach((t=>{l(t)&&(i.has(t)||(i.add(t),t.pluginName&&!o._availablePlugins.has(t.pluginName)&&o._availablePlugins.set(t.pluginName,t),t.requires&&e(t.requires,i)))}))}(e),h(e);const r=[...function e(t,i=new Set){return t.map((e=>l(e)?e:o._availablePlugins.get(e))).reduce(((t,n)=>i.has(n)?t:(i.add(n),n.requires&&(h(n.requires,n),e(n.requires,i).forEach((e=>t.add(e)))),t.add(n))),new Set)}(e.filter((e=>!d(e,t))))];!function(e,t){for(const i of t){if("function"!=typeof i)throw new n.CKEditorError("plugincollection-replace-plugin-invalid-type",null,{pluginItem:i});const t=i.pluginName;if(!t)throw new n.CKEditorError("plugincollection-replace-plugin-missing-name",null,{pluginItem:i});if(i.requires&&i.requires.length)throw new n.CKEditorError("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const s=o._availablePlugins.get(t);if(!s)throw new n.CKEditorError("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:t});const r=e.indexOf(s);if(-1===r){if(o._contextPlugins.has(s))return;throw new n.CKEditorError("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:t})}if(s.requires&&s.requires.length)throw new n.CKEditorError("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:t});e.splice(r,1,i),o._availablePlugins.set(t,i)}}(r,i);const a=function(e){return e.map((e=>{let t=o._contextPlugins.get(e);return t=t||new e(s),o._add(e,t),t}))}(r);return m(a,"init").then((()=>m(a,"afterInit"))).then((()=>a));function l(e){return"function"==typeof e}function c(e){return l(e)&&!!e.isContextPlugin}function d(e,t){return t.some((t=>t===e||u(e)===t||u(t)===e))}function u(e){return l(e)?e.pluginName||e.name:e}function h(e,i=null){e.map((e=>l(e)?e:o._availablePlugins.get(e)||e)).forEach((e=>{!function(e,t){if(!l(e)){if(t)throw new n.CKEditorError("plugincollection-soft-required",s,{missingPlugin:e,requiredBy:u(t)});throw new n.CKEditorError("plugincollection-plugin-not-found",s,{plugin:e})}}(e,i),function(e,t){if(c(t)&&!c(e))throw new n.CKEditorError("plugincollection-context-required",s,{plugin:u(e),requiredBy:u(t)})}(e,i),function(e,i){if(i&&d(e,t))throw new n.CKEditorError("plugincollection-required",s,{plugin:u(e),requiredBy:u(i)})}(e,i)}))}function m(e,t){return e.reduce(((e,i)=>i[t]?o._contextPlugins.has(i)?e:e.then(i[t].bind(i)):e),Promise.resolve())}}destroy(){const e=[];for(const[,t]of this)"function"!=typeof t.destroy||this._contextPlugins.has(t)||e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);const i=e.pluginName;if(i){if(this._plugins.has(i))throw new n.CKEditorError("plugincollection-plugin-name-conflict",null,{pluginName:i,plugin1:this._plugins.get(i).constructor,plugin2:e});this._plugins.set(i,t)}}}class d{constructor(e){this._contextOwner=null,this.config=new n.Config(e,this.constructor.defaultConfig);const t=this.constructor.builtinPlugins;this.config.define("plugins",t),this.plugins=new c(this,t);const i=this.config.get("language")||{};this.locale=new n.Locale({uiLanguage:"string"==typeof i?i:i.ui,contentLanguage:this.config.get("language.content")}),this.t=this.locale.t,this.editors=new n.Collection}initPlugins(){const e=this.config.get("plugins")||[],t=this.config.get("substitutePlugins")||[];for(const i of e.concat(t)){if("function"!=typeof i)throw new n.CKEditorError("context-initplugins-constructor-only",null,{Plugin:i});if(!0!==i.isContextPlugin)throw new n.CKEditorError("context-initplugins-invalid-plugin",null,{Plugin:i})}return this.plugins.init(e,[],t)}destroy(){return Promise.all(Array.from(this.editors,(e=>e.destroy()))).then((()=>this.plugins.destroy()))}_addEditor(e,t){if(this._contextOwner)throw new n.CKEditorError("context-addeditor-private-context");this.editors.add(e),t&&(this._contextOwner=e)}_removeEditor(e){return this.editors.has(e)&&this.editors.remove(e),this._contextOwner===e?this.destroy():Promise.resolve()}_getEditorConfig(){const e={};for(const t of this.config.names())["plugins","removePlugins","extraPlugins"].includes(t)||(e[t]=this.config.get(t));return e}static create(e){return new Promise((t=>{const i=new this(e);t(i.initPlugins().then((()=>i)))}))}}class u extends((0,n.ObservableMixin)()){constructor(e){super(),this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}var h=i(6243);class m{constructor(){this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){const i=this.get(e);if(!i)throw new n.CKEditorError("commandcollection-command-not-found",this,{commandName:e});return i.execute(...t)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const e of this.commands())e.destroy()}}class g extends n.KeystrokeHandler{constructor(e){super(),this.editor=e}set(e,t,i={}){if("string"==typeof t){const e=t;t=(t,i)=>{this.editor.execute(e),i()}}super.set(e,t,i)}}class f extends((0,n.ObservableMixin)()){constructor(e={}){super();const t=this.constructor,i=e.language||t.defaultConfig&&t.defaultConfig.language;this._context=e.context||new d({language:i}),this._context._addEditor(this,!e.context);const o=Array.from(t.builtinPlugins||[]);this.config=new n.Config(e,t.defaultConfig),this.config.define("plugins",o),this.config.define(this._context._getEditorConfig()),this.plugins=new c(this,o,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new m,this.set("state","initializing"),this.once("ready",(()=>this.state="ready"),{priority:"high"}),this.once("destroy",(()=>this.state="destroyed"),{priority:"high"}),this.model=new h.Model,this.on("change:isReadOnly",(()=>{this.model.document.isReadOnly=this.isReadOnly}));const s=new h.StylesProcessor;this.data=new h.DataController(this.model,s),this.editing=new h.EditingController(this.model,s),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new h.Conversion([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 g(this),this.keystrokes.listenTo(this.editing.view.document)}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new n.CKEditorError("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new n.CKEditorError("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 n.CKEditorError("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),0===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!1,!0))}initPlugins(){const e=this.config,t=e.get("plugins"),i=e.get("removePlugins")||[],n=e.get("extraPlugins")||[],o=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(n),i,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){n.CKEditorError.rethrowUnexpectedError(e,this)}}focus(){this.editing.view.focus()}static create(...e){throw new Error("This is an abstract method.")}}var p=i(3234);function b(e){if(!(0,p.Z)(e.updateSourceElement))throw new n.CKEditorError("attachtoform-missing-elementapi-interface",e);const t=e.sourceElement;if(function(e){return!!e&&"textarea"===e.tagName.toLowerCase()}(t)&&t.form){let i;const n=t.form,o=()=>e.updateSourceElement();(0,p.Z)(n.submit)&&(i=n.submit,n.submit=()=>{o(),i.apply(n)}),n.addEventListener("submit",o),e.on("destroy",(()=>{n.removeEventListener("submit",o),i&&(n.submit=i)}))}}function w(e){return class extends e{setData(e){this.data.set(e)}getData(e){return this.data.get(e)}}}{const e=w(Object);w.setData=e.prototype.setData,w.getData=e.prototype.getData}function v(e){return class extends e{updateSourceElement(e=this.data.get()){if(!this.sourceElement)throw new n.CKEditorError("editor-missing-sourceelement",this);const t=this.config.get("updateSourceElementOnDestroy"),i=this.sourceElement instanceof HTMLTextAreaElement;t||i?(0,n.setDataInElement)(this.sourceElement,e):(0,n.setDataInElement)(this.sourceElement,"")}}}function _(e,t){if(t.ckeditorInstance)throw new n.CKEditorError("editor-source-element-already-used",e);t.ckeditorInstance=e,e.once("destroy",(()=>{delete t.ckeditorInstance}))}v.updateSourceElement=v(Object).prototype.updateSourceElement;class y extends u{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new n.Collection({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new n.CKEditorError("pendingactions-add-invalid-message",this);const t=new((0,n.ObservableMixin)());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]()}}var k=i(2946),C=i(7630),A=i(5270);const E={bold:'',cancel:k.Z,caption:'',check:C.Z,cog:'',eraser:A.Z,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:''}},5480:(e,t,i)=>{"use strict";i.r(t),i.d(t,{ClassicEditor:()=>y});var n=i(7095),o=i(3291),s=i(6553);class r extends n.S8{constructor(e,t){super(e),this.view=t,this._toolbarConfig=(0,n.iw)(e.config.get("toolbar")),this._elementReplacer=new s.a6,this.listenTo(e.editing.view,"scrollToTheSelection",this._handleScrollToTheSelectionWithStickyPanel.bind(this))}get element(){return this.view.element}init(e){const t=this.editor,i=this.view,n=t.editing.view,o=i.editable,s=n.document.getRoot();o.name=s.rootName,i.render();const r=o.element;this.setEditableElement(o.name,r),i.editable.bind("isFocused").to(this.focusTracker),n.attachDomRoot(r),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){super.destroy();const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),t.detachDomRoot(e.editable.name),e.destroy()}_initToolbar(){const e=this.view;e.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),e.stickyPanel.limiterElement=e.element,e.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",(({top:e})=>e||0)),e.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),this.addToolbar(e.toolbar)}_initPlaceholder(){const e=this.editor,t=e.editing.view,i=t.document.getRoot(),n=e.sourceElement;let s;const r=e.config.get("placeholder");r&&(s="string"==typeof r?r:r[this.view.editable.name]),!s&&n&&"textarea"===n.tagName.toLowerCase()&&(s=n.getAttribute("placeholder")),s&&(i.placeholder=s),(0,o.ID)({view:t,element:i,isDirectHost:!1,keepOnFocus:!0})}_handleScrollToTheSelectionWithStickyPanel(e,t,i){const n=this.view.stickyPanel;if(n.isSticky){const e=new s.UL(n.element).height;t.viewportOffset.top+=e}else{const e=()=>{this.editor.editing.view.scrollToTheSelection(i)};this.listenTo(n,"change:isSticky",e),setTimeout((()=>{this.stopListening(n,"change:isSticky",e)}),20)}}}class a extends n.py{constructor(e,t,i={}){super(e),this.stickyPanel=new n.lp(e),this.toolbar=new n.jB(e,{shouldGroupWhenFull:i.shouldToolbarGroupWhenFull}),this.editable=new n.r1(e,t)}render(){super.render(),this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}var l=i(6854);class c{constructor(e){if(this.crashes=[],this.state="initializing",this._now=Date.now,this.crashes=[],this._crashNumberLimit="number"==typeof e.crashNumberLimit?e.crashNumberLimit:3,this._minimumNonErrorTimePeriod="number"==typeof e.minimumNonErrorTimePeriod?e.minimumNonErrorTimePeriod:5e3,this._boundErrorHandler=e=>{const t="error"in e?e.error:e.reason;t instanceof Error&&this._handleError(t,e)},this._listeners={},!this._restart)throw new Error("The Watchdog class was split into the abstract `Watchdog` class and the `EditorWatchdog` class. Please, use `EditorWatchdog` if you have used the `Watchdog` class previously.")}destroy(){this._stopErrorHandling(),this._listeners={}}on(e,t){this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t)}off(e,t){this._listeners[e]=this._listeners[e].filter((e=>e!==t))}_fire(e,...t){const i=this._listeners[e]||[];for(const e of i)e.apply(this,[null,...t])}_startErrorHandling(){window.addEventListener("error",this._boundErrorHandler),window.addEventListener("unhandledrejection",this._boundErrorHandler)}_stopErrorHandling(){window.removeEventListener("error",this._boundErrorHandler),window.removeEventListener("unhandledrejection",this._boundErrorHandler)}_handleError(e,t){if(this._shouldReactToError(e)){this.crashes.push({message:e.message,stack:e.stack,filename:t instanceof ErrorEvent?t.filename:void 0,lineno:t instanceof ErrorEvent?t.lineno:void 0,colno:t instanceof ErrorEvent?t.colno:void 0,date:this._now()});const i=this._shouldRestart();this.state="crashed",this._fire("stateChange"),this._fire("error",{error:e,causesRestart:i}),i?this._restart():(this.state="crashedPermanently",this._fire("stateChange"))}}_shouldReactToError(e){return e.is&&e.is("CKEditorError")&&void 0!==e.context&&null!==e.context&&"ready"===this.state&&this._isErrorComingFromThisItem(e)}_shouldRestart(){return this.crashes.length<=this._crashNumberLimit||(this.crashes[this.crashes.length-1].date-this.crashes[this.crashes.length-1-this._crashNumberLimit].date)/this._crashNumberLimit>this._minimumNonErrorTimePeriod}}function d(e,t=new Set){const i=[e],n=new Set;let o=0;for(;i.length>o;){const e=i[o++];if(!n.has(e)&&u(e)&&!t.has(e))if(n.add(e),Symbol.iterator in e)try{for(const t of e)i.push(t)}catch(e){}else for(const t in e)"defaultValue"!==t&&i.push(e[t])}return n}function u(e){const t=Object.prototype.toString.call(e),i=typeof e;return!("number"===i||"boolean"===i||"string"===i||"symbol"===i||"function"===i||"[object Date]"===t||"[object RegExp]"===t||"[object Module]"===t||null==e||e._watchdogExcluded||e instanceof EventTarget||e instanceof Event)}function h(e,t,i=new Set){if(e===t&&"object"==typeof(n=e)&&null!==n)return!0;var n;const o=d(e,i),s=d(t,i);for(const e of o)if(s.has(e))return!0;return!1}var m=i(111),g=i(3251),f=i(4612);class p extends c{constructor(e,t={}){super(t),this._editor=null,this._initUsingData=!0,this._editables={},this._throttledSave=(0,m.Z)(this._save.bind(this),"number"==typeof t.saveInterval?t.saveInterval:5e3),e&&(this._creator=(t,i)=>e.create(t,i)),this._destructor=e=>e.destroy()}get editor(){return this._editor}get _item(){return this._editor}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}_restart(){return Promise.resolve().then((()=>(this.state="initializing",this._fire("stateChange"),this._destroy()))).catch((e=>{console.error("An error happened during the editor destroying.",e)})).then((()=>{const e={},t=[],i=this._config.rootsAttributes||{},n={};for(const[o,s]of Object.entries(this._data.roots))s.isLoaded?(e[o]="",n[o]=i[o]||{}):t.push(o);const o={...this._config,extraPlugins:this._config.extraPlugins||[],lazyRoots:t,rootsAttributes:n,_watchdogInitialData:this._data};return delete o.initialData,o.extraPlugins.push(b),this._initUsingData?this.create(e,o,o.context):(0,g.Z)(this._elementOrData)?this.create(this._elementOrData,o,o.context):this.create(this._editables,o,o.context)})).then((()=>{this._fire("restart")}))}create(e=this._elementOrData,t=this._config,i){return Promise.resolve().then((()=>(super._startErrorHandling(),this._elementOrData=e,this._initUsingData="string"==typeof e||Object.keys(e).length>0&&"string"==typeof Object.values(e)[0],this._config=this._cloneEditorConfiguration(t)||{},this._config.context=i,this._creator(e,this._config)))).then((e=>{this._editor=e,e.model.document.on("change:data",this._throttledSave),this._lastDocumentVersion=e.model.document.version,this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this.state="ready",this._fire("stateChange")}))}destroy(){return Promise.resolve().then((()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling(),this._throttledSave.cancel();const e=this._editor;return this._editor=null,e.model.document.off("change:data",this._throttledSave),this._destructor(e)}))}_save(){const e=this._editor.model.document.version;try{this._data=this._getData(),this._initUsingData||(this._editables=this._getEditables()),this._lastDocumentVersion=e}catch(e){console.error(e,"An error happened during restoring editor data. Editor will be restored from the previously saved data.")}}_setExcludedProperties(e){this._excludedProps=e}_getData(){const e=this._editor,t=e.model.document.roots.filter((e=>e.isAttached()&&"$graveyard"!=e.rootName)),{plugins:i}=e,n=i.has("CommentsRepository")&&i.get("CommentsRepository"),o=i.has("TrackChanges")&&i.get("TrackChanges"),s={roots:{},markers:{},commentThreads:JSON.stringify([]),suggestions:JSON.stringify([])};t.forEach((e=>{s.roots[e.rootName]={content:JSON.stringify(Array.from(e.getChildren())),attributes:JSON.stringify(Array.from(e.getAttributes())),isLoaded:e._isLoaded}}));for(const t of e.model.markers)t._affectsData&&(s.markers[t.name]={rangeJSON:t.getRange().toJSON(),usingOperation:t._managedUsingOperations,affectsData:t._affectsData});return n&&(s.commentThreads=JSON.stringify(n.getCommentThreads({toJSON:!0,skipNotAttached:!0}))),o&&(s.suggestions=JSON.stringify(o.getSuggestions({toJSON:!0,skipNotAttached:!0}))),s}_getEditables(){const e={};for(const t of this.editor.model.document.getRootNames()){const i=this.editor.ui.getEditableElement(t);i&&(e[t]=i)}return e}_isErrorComingFromThisItem(e){return h(this._editor,e.context,this._excludedProps)}_cloneEditorConfiguration(e){return(0,f.Z)(e,((e,t)=>(0,g.Z)(e)||"context"===t?e:void 0))}}class b{constructor(e){this.editor=e,this._data=e.config.get("_watchdogInitialData")}init(){this.editor.data.on("init",(e=>{e.stop(),this.editor.model.enqueueChange({isUndoable:!1},(e=>{this._restoreCollaborationData(),this._restoreEditorData(e)})),this.editor.data.fire("ready")}),{priority:999})}_createNode(e,t){if("name"in t){const i=e.createElement(t.name,t.attributes);if(t.children)for(const n of t.children)i._appendChild(this._createNode(e,n));return i}return e.createText(t.data,t.attributes)}_restoreEditorData(e){const t=this.editor;Object.entries(this._data.roots).forEach((([i,{content:n,attributes:o}])=>{const s=JSON.parse(n),r=JSON.parse(o),a=t.model.document.getRoot(i);for(const[t,i]of r)e.setAttribute(t,i,a);for(const t of s){const i=this._createNode(e,t);e.insert(i,a,"end")}})),Object.entries(this._data.markers).forEach((([i,n])=>{const{document:o}=t.model,{rangeJSON:{start:s,end:r},...a}=n,l=o.getRoot(s.root),c=e.createPositionFromPath(l,s.path,s.stickiness),d=e.createPositionFromPath(l,r.path,r.stickiness),u=e.createRange(c,d);e.addMarker(i,{range:u,...a})}))}_restoreCollaborationData(){const e=JSON.parse(this._data.commentThreads),t=JSON.parse(this._data.suggestions);e.forEach((e=>{const t=this.editor.config.get("collaboration.channelId"),i=this.editor.plugins.get("CommentsRepository");i.hasCommentThread(e.threadId)&&i.getCommentThread(e.threadId).remove(),i.addCommentThread({channelId:t,...e})})),t.forEach((e=>{const t=this.editor.plugins.get("TrackChangesEditing");t.hasSuggestion(e.id)?t.getSuggestion(e.id).attributes=e.attributes:t.addSuggestionData(e)}))}}const w=Symbol("MainQueueId");class v{constructor(){this._onEmptyCallbacks=[],this._queues=new Map,this._activeActions=0}onEmpty(e){this._onEmptyCallbacks.push(e)}enqueue(e,t){const i=e===w;this._activeActions++,this._queues.get(e)||this._queues.set(e,Promise.resolve());const n=(i?Promise.all(this._queues.values()):Promise.all([this._queues.get(w),this._queues.get(e)])).then(t),o=n.catch((()=>{}));return this._queues.set(e,o),n.finally((()=>{this._activeActions--,this._queues.get(e)===o&&0===this._activeActions&&this._onEmptyCallbacks.forEach((e=>e()))}))}}function _(e){return Array.isArray(e)?e:[e]}class y extends((0,l.W9)((0,l.xK)(l.ML))){constructor(e,t={}){if(!k(e)&&void 0!==t.initialData)throw new s.Bb("editor-create-initial-data",null);super(t),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return k(e)?(0,s.yy)(e):e}(e)),k(e)&&(this.sourceElement=e),this.model.document.createRoot();const i=!this.config.get("toolbar.shouldNotGroupWhenFull"),n=new a(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:i});this.ui=new r(this,n),(0,l.P$)(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise((i=>{const n=new this(e,t);i(n.initPlugins().then((()=>n.ui.init(k(e)?e:null))).then((()=>n.data.init(n.config.get("initialData")))).then((()=>n.fire("ready"))).then((()=>n)))}))}}function k(e){return(0,g.Z)(e)}y.Context=l._y,y.EditorWatchdog=p,y.ContextWatchdog=class extends c{constructor(e,t={}){super(t),this._watchdogs=new Map,this._context=null,this._contextProps=new Set,this._actionQueues=new v,this._watchdogConfig=t,this._creator=t=>e.create(t),this._destructor=e=>e.destroy(),this._actionQueues.onEmpty((()=>{"initializing"===this.state&&(this.state="ready",this._fire("stateChange"))}))}setCreator(e){this._creator=e}setDestructor(e){this._destructor=e}get context(){return this._context}create(e={}){return this._actionQueues.enqueue(w,(()=>(this._contextConfig=e,this._create())))}getItem(e){return this._getWatchdog(e)._item}getItemState(e){return this._getWatchdog(e).state}add(e){const t=_(e);return Promise.all(t.map((e=>this._actionQueues.enqueue(e.id,(()=>{if("destroyed"===this.state)throw new Error("Cannot add items to destroyed watchdog.");if(!this._context)throw new Error("Context was not created yet. You should call the `ContextWatchdog#create()` method first.");let t;if(this._watchdogs.has(e.id))throw new Error(`Item with the given id is already added: '${e.id}'.`);if("editor"===e.type)return t=new p(null,this._watchdogConfig),t.setCreator(e.creator),t._setExcludedProperties(this._contextProps),e.destructor&&t.setDestructor(e.destructor),this._watchdogs.set(e.id,t),t.on("error",((i,{error:n,causesRestart:o})=>{this._fire("itemError",{itemId:e.id,error:n}),o&&this._actionQueues.enqueue(e.id,(()=>new Promise((i=>{const n=()=>{t.off("restart",n),this._fire("itemRestart",{itemId:e.id}),i()};t.on("restart",n)}))))})),t.create(e.sourceElementOrData,e.config,this._context);throw new Error(`Not supported item type: '${e.type}'.`)})))))}remove(e){const t=_(e);return Promise.all(t.map((e=>this._actionQueues.enqueue(e,(()=>{const t=this._getWatchdog(e);return this._watchdogs.delete(e),t.destroy()})))))}destroy(){return this._actionQueues.enqueue(w,(()=>(this.state="destroyed",this._fire("stateChange"),super.destroy(),this._destroy())))}_restart(){return this._actionQueues.enqueue(w,(()=>(this.state="initializing",this._fire("stateChange"),this._destroy().catch((e=>{console.error("An error happened during destroying the context or items.",e)})).then((()=>this._create())).then((()=>this._fire("restart"))))))}_create(){return Promise.resolve().then((()=>(this._startErrorHandling(),this._creator(this._contextConfig)))).then((e=>(this._context=e,this._contextProps=d(this._context),Promise.all(Array.from(this._watchdogs.values()).map((e=>(e._setExcludedProperties(this._contextProps),e.create(void 0,void 0,this._context))))))))}_destroy(){return Promise.resolve().then((()=>{this._stopErrorHandling();const e=this._context;return this._context=null,this._contextProps=new Set,Promise.all(Array.from(this._watchdogs.values()).map((e=>e.destroy()))).then((()=>this._destructor(e)))}))}_getWatchdog(e){const t=this._watchdogs.get(e);if(!t)throw new Error(`Item with the given id was not registered: ${e}.`);return t}_isErrorComingFromThisItem(e){for(const t of this._watchdogs.values())if(t._isErrorComingFromThisItem(e))return!1;return h(this._context,e.context)}}},6243:(e,t,i)=>{"use strict";i.r(t),i.d(t,{AttributeElement:()=>Le,AttributeOperation:()=>$n,BubblingEventInfo:()=>Ie,ClickObserver:()=>Go,Conversion:()=>Sn,DataController:()=>Tn,DataTransfer:()=>Ut,DocumentFragment:()=>xo,DocumentSelection:()=>Si,DomConverter:()=>At,DomEventData:()=>Vt,DomEventObserver:()=>Rt,DowncastWriter:()=>Ze,EditingController:()=>sn,Element:()=>ti,FocusObserver:()=>zt,History:()=>wo,HtmlDataProcessor:()=>xn,InsertOperation:()=>zn,LivePosition:()=>co,LiveRange:()=>Ai,MarkerOperation:()=>Un,Matcher:()=>y,MergeOperation:()=>Wn,Model:()=>Ko,MouseObserver:()=>Jo,MoveOperation:()=>Fn,NoOperation:()=>qn,Observer:()=>Pt,OperationFactory:()=>Yn,Position:()=>oi,Range:()=>di,RenameOperation:()=>Kn,Renderer:()=>mt,RootAttributeOperation:()=>Zn,RootOperation:()=>Gn,SplitOperation:()=>Hn,StylesProcessor:()=>ge,TabObserver:()=>Kt,Text:()=>Xt,TextProxy:()=>ei,TreeWalker:()=>ii,UpcastWriter:()=>Yo,View:()=>Gt,ViewAttributeElement:()=>Le,ViewContainerElement:()=>ve,ViewDocument:()=>De,ViewDocumentFragment:()=>Ke,ViewEditableElement:()=>ye,ViewElement:()=>be,ViewEmptyElement:()=>He,ViewRawElement:()=>$e,ViewRootEditableElement:()=>Ce,ViewText:()=>w,ViewTreeWalker:()=>Ae,ViewUIElement:()=>Ue,addBackgroundRules:()=>Es,addBorderRules:()=>xs,addMarginRules:()=>Ns,addPaddingRules:()=>Ds,disablePlaceholder:()=>a,enablePlaceholder:()=>r,findOptimalInsertionRange:()=>Ho,getBoxSidesShorthandValue:()=>ks,getBoxSidesValueReducer:()=>ys,getBoxSidesValues:()=>_s,getFillerOffset:()=>_e,getPositionShorthandNormalizer:()=>Cs,getShorthandValues:()=>As,hidePlaceholder:()=>c,isAttachment:()=>bs,isColor:()=>ss,isLength:()=>cs,isLineStyle:()=>as,isPercentage:()=>us,isPosition:()=>fs,isRepeat:()=>ms,isURL:()=>vs,needsPlaceholder:()=>d,showPlaceholder:()=>l,transformSets:()=>io});var n=i(5044);const o=new WeakMap;let s=!1;function r({view:e,element:t,text:i,isDirectHost:r=!0,keepOnFocus:a=!1}){const l=e.document;function c(i){o.get(l).set(t,{text:i,isDirectHost:r,keepOnFocus:a,hostElement:r?t:null}),e.change((e=>u(l,e)))}o.has(l)||(o.set(l,new Map),l.registerPostFixer((e=>u(l,e))),l.on("change:isComposing",(()=>{e.change((e=>u(l,e)))}),{priority:"high"})),t.is("editableElement")&&t.on("change:placeholder",((e,t,i)=>{c(i)})),t.placeholder?c(t.placeholder):i&&c(i),i&&(s||(0,n.logWarning)("enableplaceholder-deprecated-text-option"),s=!0)}function a(e,t){const i=t.document;o.has(i)&&e.change((e=>{const n=o.get(i),s=n.get(t);e.removeAttribute("data-placeholder",s.hostElement),c(e,s.hostElement),n.delete(t)}))}function l(e,t){return!t.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",t),!0)}function c(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function d(e,t){if(!e.isAttached())return!1;const i=Array.from(e.getChildren()).some((e=>!e.is("uiElement")));if(i)return!1;const n=e.document,o=n.selection.anchor;return!(n.isComposing&&o&&o.parent===e||!t&&n.isFocused&&(!o||o.parent===e))}function u(e,t){const i=o.get(e),n=[];let s=!1;for(const[e,o]of i)o.isDirectHost&&(n.push(e),h(t,e,o)&&(s=!0));for(const[e,o]of i){if(o.isDirectHost)continue;const i=m(e);i&&(n.includes(i)||(o.hostElement=i,h(t,e,o)&&(s=!0)))}return s}function h(e,t,i){const{text:n,isDirectHost:o,hostElement:s}=i;let r=!1;return s.getAttribute("data-placeholder")!==n&&(e.setAttribute("data-placeholder",n,s),r=!0),(o||1==t.childCount)&&d(s,i.keepOnFocus)?l(e,s)&&(r=!0):c(e,s)&&(r=!0),r}function m(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}class g{is(){throw new Error("is() method is abstract")}}var f=i(9256);const p=function(e){return(0,f.Z)(e,4)};i(9807);class b extends((0,n.EmitterMixin)(g)){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 n.CKEditorError("view-node-not-found-in-parent",this);return e}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.root.is("rootElement")}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.index),t=t.parent;return e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let o=0;for(;i[o]==n[o]&&i[o];)o++;return 0===o?null:i[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),o=(0,n.compareArrays)(t,i);switch(o){case"prefix":return!0;case"extension":return!1;default:return t[o]e.data.length)throw new n.CKEditorError("view-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.data.length)throw new n.CKEditorError("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}getAncestors(e={}){const t=[];let i=e.includeSelf?this.textNode:this.parent;for(;null!==i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}}v.prototype.is=function(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e};var _=i(7514);class y{constructor(...e){this._patterns=[],this.add(...e)}add(...e){for(let t of e)("string"==typeof t||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(const t of e)for(const e of this._patterns){const i=k(t,e);if(i)return{element:t,pattern:e,match:i}}return null}matchAll(...e){const t=[];for(const i of e)for(const e of this._patterns){const n=k(i,e);n&&t.push({element:i,pattern:e,match:n})}return t.length>0?t:null}getElementName(){if(1!==this._patterns.length)return null;const e=this._patterns[0],t=e.name;return"function"==typeof e||!t||t instanceof RegExp?null:t}}function k(e,t){if("function"==typeof t)return t(e);const i={};return t.name&&(i.name=function(e,t){return e instanceof RegExp?!!t.match(e):e===t}(t.name,e.name),!i.name)||t.attributes&&(i.attributes=function(e,t){const i=new Set(t.getAttributeKeys());return(0,_.Z)(e)?(void 0!==e.style&&(0,n.logWarning)("matcher-pattern-deprecated-attributes-style-key",e),void 0!==e.class&&(0,n.logWarning)("matcher-pattern-deprecated-attributes-class-key",e)):(i.delete("style"),i.delete("class")),C(e,i,(e=>t.getAttribute(e)))}(t.attributes,e),!i.attributes)||t.classes&&(i.classes=function(e,t){return C(e,t.getClassNames(),(()=>{}))}(t.classes,e),!i.classes)||t.styles&&(i.styles=function(e,t){return C(e,t.getStyleNames(!0),(e=>t.getStyle(e)))}(t.styles,e),!i.styles)?null:i}function C(e,t,i){const o=function(e){return Array.isArray(e)?e.map((e=>(0,_.Z)(e)?(void 0!==e.key&&void 0!==e.value||(0,n.logWarning)("matcher-pattern-missing-key-or-value",e),[e.key,e.value]):[e,!0])):(0,_.Z)(e)?Object.entries(e):[[e,!0]]}(e),s=Array.from(t),r=[];if(o.forEach((([e,t])=>{s.forEach((n=>{(function(e,t){return!0===e||e===t||e instanceof RegExp&&t.match(e)})(e,n)&&function(e,t,i){if(!0===e)return!0;const n=i(t);return e===n||e instanceof RegExp&&!!String(n).match(e)}(t,n,i)&&r.push(n)}))})),o.length&&!(r.lengtht===e));return Array.isArray(t)}set(e,t){if((0,A.Z)(e))for(const[t,i]of Object.entries(e))this._styleProcessor.toNormalizedForm(t,i,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t=fe(e);(function(e,t){null==e||H(e,t)})(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]&&!(0,A.Z)(this._styles[e]))return this._styles[e];const t=this._styleProcessor.getReducedForm(e,this._styles).find((([t])=>t===e));return Array.isArray(t)?t[1]:void 0}getStyleNames(e=!1){return this.isEmpty?[]:e?this._styleProcessor.getStyleNames(this._styles):this._getStylesEntries().map((([e])=>e))}clear(){this._styles={}}_getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const i of t)e.push(...this._styleProcessor.getReducedForm(i,this._styles));return e}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const i=t.splice(0,t.length-1).join("."),n=W(this._styles,i);n&&!Array.from(Object.keys(n)).length&&this.remove(i)}}class ge{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,i){if((0,A.Z)(t))pe(i,fe(e),t);else if(this._normalizers.has(e)){const n=this._normalizers.get(e),{path:o,value:s}=n(t);pe(i,o,s)}else pe(i,e,t)}getNormalized(e,t){if(!e)return ce({},t);if(void 0!==t[e])return t[e];if(this._extractors.has(e)){const i=this._extractors.get(e);if("string"==typeof i)return W(t,i);const n=i(e,t);if(n)return n}return W(t,fe(e))}getReducedForm(e,t){const i=this.getNormalized(e,t);return void 0===i?[]:this._reducers.has(e)?this._reducers.get(e)(i):[[e,i]]}getStyleNames(e){const t=Array.from(this._consumables.keys()).filter((t=>{const i=this.getNormalized(t,e);return i&&"object"==typeof i?Object.keys(i).length:i})),i=new Set([...t,...Object.keys(e)]);return Array.from(i.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 i of t)this._mapStyleNames(i,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function fe(e){return e.replace("-",".")}function pe(e,t,i){let n=i;(0,A.Z)(i)&&(n=ce({},W(e,t),i)),he(e,t,n)}class be extends b{constructor(e,t,i,o){if(super(e),this._unsafeAttributesToRender=[],this._customProperties=new Map,this.name=t,this._attrs=function(e){const t=(0,n.toMap)(e);for(const[e,i]of t)null===i?t.delete(e):"string"!=typeof i&&t.set(e,String(i));return t}(i),this._children=[],o&&this._insertChild(0,o),this._classes=new Set,this._attrs.has("class")){const e=this._attrs.get("class");we(this._classes,e),this._attrs.delete("class")}this._styles=new me(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style"))}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes.size>0&&(yield"class"),this._styles.isEmpty||(yield"style"),yield*this._attrs.keys()}*getAttributes(){yield*this._attrs.entries(),this._classes.size>0&&(yield["class",this.getAttribute("class")]),this._styles.isEmpty||(yield["style",this.getAttribute("style")])}getAttribute(e){if("class"==e)return this._classes.size>0?[...this._classes].join(" "):void 0;if("style"==e){const e=this._styles.toString();return""==e?void 0:e}return this._attrs.get(e)}hasAttribute(e){return"class"==e?this._classes.size>0:"style"==e?!this._styles.isEmpty:this._attrs.has(e)}isSimilar(e){if(!(e instanceof be))return!1;if(this===e)return!0;if(this.name!=e.name)return!1;if(this._attrs.size!==e._attrs.size||this._classes.size!==e._classes.size||this._styles.size!==e._styles.size)return!1;for(const[t,i]of this._attrs)if(!e._attrs.has(t)||e._attrs.get(t)!==i)return!1;for(const t of this._classes)if(!e._classes.has(t))return!1;for(const t of this._styles.getStyleNames())if(!e._styles.has(t)||e._styles.getAsString(t)!==this._styles.getAsString(t))return!1;return!0}hasClass(...e){for(const t of e)if(!this._classes.has(t))return!1;return!0}getClassNames(){return this._classes.keys()}getStyle(e){return this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles.getNormalized(e)}getStyleNames(e){return this._styles.getStyleNames(e)}hasStyle(...e){for(const t of e)if(!this._styles.has(t))return!1;return!0}findAncestor(...e){const t=new y(...e);let i=this.parent;for(;i&&!i.is("documentFragment");){if(t.match(i))return i;i=i.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=Array.from(this._classes).sort().join(","),t=this._styles.toString(),i=Array.from(this._attrs).map((e=>`${e[0]}="${e[1]}"`)).sort().join(" ");return this.name+(""==e?"":` class="${e}"`)+(t?` style="${t}"`:"")+(""==i?"":` ${i}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(e=!1){const t=[];if(e)for(const i of this.getChildren())t.push(i._clone(e));const i=new this.constructor(this.document,this.name,this._attrs,t);return i._classes=new Set(this._classes),i._styles.set(this._styles.getNormalized()),i._customProperties=new Map(this._customProperties),i.getFillerOffset=this.getFillerOffset,i._unsafeAttributesToRender=this._unsafeAttributesToRender,i}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this);let i=0;const o=function(e,t){return"string"==typeof t?[new w(e,t)]:((0,n.isIterable)(t)||(t=[t]),Array.from(t).map((t=>"string"==typeof t?new w(e,t):t instanceof v?new w(e,t.data):t)))}(this.document,t);for(const t of o)null!==t.parent&&t._remove(),t.parent=this,t.document=this.document,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this);for(let i=e;i0&&(this._classes.clear(),!0):"style"==e?!this._styles.isEmpty&&(this._styles.clear(),!0):this._attrs.delete(e)}_addClass(e){this._fireChange("attributes",this);for(const t of(0,n.toArray)(e))this._classes.add(t)}_removeClass(e){this._fireChange("attributes",this);for(const t of(0,n.toArray)(e))this._classes.delete(t)}_setStyle(e,t){this._fireChange("attributes",this),"string"!=typeof e?this._styles.set(e):this._styles.set(e,t)}_removeStyle(e){this._fireChange("attributes",this);for(const t of(0,n.toArray)(e))this._styles.remove(t)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}}function we(e,t){const i=t.split(/\s+/);e.clear(),i.forEach((t=>e.add(t)))}be.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 ve extends be{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=_e}}function _e(){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}ve.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 ye extends((0,n.ObservableMixin)(ve)){constructor(e,t,i,n){super(e,t,i,n),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("placeholder",void 0),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",(t=>t&&e.selection.editableElement==this)),this.listenTo(e.selection,"change",(()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this}))}destroy(){this.stopListening()}}ye.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 ke=Symbol("rootName");class Ce extends ye{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(ke)}set rootName(e){this._setCustomProperty(ke,e)}set _name(e){this.name=e}}Ce.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 Ae{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new n.CKEditorError("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new n.CKEditorError("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=Ee._createAt(e.startPosition):this._position=Ee._createAt(e.boundaries["backward"==e.direction?"end":"start"]),this.direction=e.direction||"forward",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i;do{i=this.position,t=this.next()}while(!t.done&&e(t.value));t.done||(this._position=i)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&e.offset===i.childCount)return{done:!0,value:void 0};if(i===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let n;if(i instanceof w){if(e.isAtEnd)return this._position=Ee._createAfter(i),this._next();n=i.data[e.offset]}else n=i.getChild(e.offset);if(n instanceof be){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}else e=new Ee(n,0);return this._position=e,this._formatReturnValue("elementStart",n,t,e,1)}if(n instanceof w){if(this.singleCharacters)return e=new Ee(n,0),this._position=e,this._next();let i,o=n.data.length;return n==this._boundaryEndParent?(o=this.boundaries.end.offset,i=new v(n,0,o),e=Ee._createAfter(i)):(i=new v(n,0,n.data.length),e.offset++),this._position=e,this._formatReturnValue("text",i,t,e,o)}if("string"==typeof n){let n;n=this.singleCharacters?1:(i===this._boundaryEndParent?this.boundaries.end.offset:i.data.length)-e.offset;const o=new v(i,e.offset,n);return e.offset+=n,this._position=e,this._formatReturnValue("text",o,t,e,n)}return e=Ee._createAfter(i),this._position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",i,t,e)}_previous(){let e=this.position.clone();const t=this.position,i=e.parent;if(null===i.parent&&0===e.offset)return{done:!0,value:void 0};if(i==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let n;if(i instanceof w){if(e.isAtStart)return this._position=Ee._createBefore(i),this._previous();n=i.data[e.offset-1]}else n=i.getChild(e.offset-1);if(n instanceof be)return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",n,t,e,1)):(e=new Ee(n,n.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",n,t,e));if(n instanceof w){if(this.singleCharacters)return e=new Ee(n,n.data.length),this._position=e,this._previous();let i,o=n.data.length;if(n==this._boundaryStartParent){const t=this.boundaries.start.offset;i=new v(n,t,n.data.length-t),o=i.data.length,e=Ee._createBefore(i)}else i=new v(n,0,n.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",i,t,e,o)}if("string"==typeof n){let n;if(this.singleCharacters)n=1;else{const t=i===this._boundaryStartParent?this.boundaries.start.offset:0;n=e.offset-t}e.offset-=n;const o=new v(i,e.offset,n);return this._position=e,this._formatReturnValue("text",o,t,e,n)}return e=Ee._createBefore(i),this._position=e,this._formatReturnValue("elementStart",i,t,e,1)}_formatReturnValue(e,t,i,n,o){return t instanceof v&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?i=Ee._createAfter(t.textNode):(n=Ee._createAfter(t.textNode),this._position=n)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?i=Ee._createBefore(t.textNode):(n=Ee._createBefore(t.textNode),this._position=n))),{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:o}}}}class Ee extends g{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 ye);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(e){const t=Ee._createAt(this),i=t.offset+e;return t.offset=i<0?0:i,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const i=new Ae(t);return i.skip(e),i.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),i=e.getAncestors();let n=0;for(;t[n]==i[n]&&t[n];)n++;return 0===n?null:t[n-1]}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return"before"==this.compareWith(e)}isAfter(e){return"after"==this.compareWith(e)}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";const t=this.parent.is("node")?this.parent.getPath():[],i=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),i.push(e.offset);const o=(0,n.compareArrays)(t,i);switch(o){case"prefix":return"before";case"extension":return"after";default:return t[o]0?new this(i,n):new this(n,i)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(Ee._createBefore(e),t)}}function Te(e){return!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))}xe.prototype.is=function(e){return"range"===e||"view:range"===e};class Se extends((0,n.EmitterMixin)(g)){constructor(...e){super(),this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",e.length&&this.setTo(...e)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return 1===this.rangeCount&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(const t of this._ranges)e&&!t.start.isBefore(e.start)||(e=t);return e?e.clone():null}getLastRange(){let e=null;for(const t of this._ranges)e&&!t.end.isAfter(e.end)||(e=t);return e?e.clone():null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake)return!1;if(this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel)return!1;if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=(0,n.count)(this.getRanges());if(t!=(0,n.count)(e.getRanges()))return!1;if(0==t)return!0;for(let t of this.getRanges()){t=t.getTrimmed();let i=!1;for(let n of e.getRanges())if(n=n.getTrimmed(),t.start.isEqual(n.start)&&t.end.isEqual(n.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,i,o]=e;if("object"==typeof i&&(o=i,i=void 0),null===t)this._setRanges([]),this._setFakeOptions(o);else if(t instanceof Se||t instanceof Pe)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof xe)this._setRanges([t],o&&o.backward),this._setFakeOptions(o);else if(t instanceof Ee)this._setRanges([new xe(t)]),this._setFakeOptions(o);else if(t instanceof b){const e=!!o&&!!o.backward;let s;if(void 0===i)throw new n.CKEditorError("view-selection-setto-required-second-parameter",this);s="in"==i?xe._createIn(t):"on"==i?xe._createOn(t):new xe(Ee._createAt(t,i)),this._setRanges([s],e),this._setFakeOptions(o)}else{if(!(0,n.isIterable)(t))throw new n.CKEditorError("view-selection-setto-not-selectable",this);this._setRanges(t,o&&o.backward),this._setFakeOptions(o)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new n.CKEditorError("view-selection-setfocus-no-ranges",this);const i=Ee._createAt(e,t);if("same"==i.compareWith(this.focus))return;const o=this.anchor;this._ranges.pop(),"before"==i.compareWith(o)?this._addRange(new xe(i,o),!0):this._addRange(new xe(o,i)),this.fire("change")}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(const t of e)this._addRange(t);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,t=!1){if(!(e instanceof xe))throw new n.CKEditorError("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 n.CKEditorError("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new xe(e.start,e.end))}}Se.prototype.is=function(e){return"selection"===e||"view:selection"===e};class Pe extends((0,n.EmitterMixin)(g)){constructor(...e){super(),this._selection=new Se,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)}}Pe.prototype.is=function(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e};class Ie extends n.EventInfo{constructor(e,t,i){super(e,t),this.startRange=i,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const Ve=Symbol("bubbling contexts");function Re(e){return class extends e{fire(e,...t){try{const i=e instanceof n.EventInfo?e:new n.EventInfo(this,e),o=Ne(this);if(!o.size)return;if(Oe(i,"capturing",this),Be(o,"$capture",i,...t))return i.return;const s=i.startRange||this.selection.getFirstRange(),r=s?s.getContainedElement():null,a=!!r&&Boolean(Me(o,r));let l=r||function(e){if(!e)return null;const t=e.start.parent,i=e.end.parent,n=t.getPath(),o=i.getPath();return n.length>o.length?t:i}(s);if(Oe(i,"atTarget",l),!a){if(Be(o,"$text",i,...t))return i.return;Oe(i,"bubbling",l)}for(;l;){if(l.is("rootElement")){if(Be(o,"$root",i,...t))return i.return}else if(l.is("element")&&Be(o,l.name,i,...t))return i.return;if(Be(o,l,i,...t))return i.return;l=l.parent,Oe(i,"bubbling",l)}return Oe(i,"bubbling",this),Be(o,"$document",i,...t),i.return}catch(e){n.CKEditorError.rethrowUnexpectedError(e,this)}}_addEventListener(e,t,i){const o=(0,n.toArray)(i.context||"$document"),s=Ne(this);for(const r of o){let o=s.get(r);o||(o=new((0,n.EmitterMixin)()),s.set(r,o)),this.listenTo(o,e,t,i)}}_removeEventListener(e,t){const i=Ne(this);for(const n of i.values())this.stopListening(n,e,t)}}}{const e=Re(Object);["fire","_addEventListener","_removeEventListener"].forEach((t=>{Re[t]=e.prototype[t]}))}function Oe(e,t,i){e instanceof Ie&&(e._eventPhase=t,e._currentTarget=i)}function Be(e,t,i,...n){const o="string"==typeof t?e.get(t):Me(e,t);return!!o&&(o.fire(i,...n),i.stop.called)}function Me(e,t){for(const[i,n]of e)if("function"==typeof i&&i(t))return n;return null}function Ne(e){return e[Ve]||(e[Ve]=new Map),e[Ve]}class De extends(Re((0,n.ObservableMixin)())){constructor(e){super(),this._postFixers=new Set,this.selection=new Pe,this.roots=new n.Collection({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.map((e=>e.destroy())),this.stopListening()}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(t=i(e),t)break}while(t)}}class Le extends be{constructor(e,t,i,n){super(e,t,i,n),this._priority=10,this._id=null,this._clonesGroup=null,this.getFillerOffset=Fe}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new n.CKEditorError("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 Fe(){if(ze(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(ze(e)>1)return null;e=e.parent}return!e||ze(e)>1?null:this.childCount}function ze(e){return Array.from(e.getChildren()).filter((e=>!e.is("uiElement"))).length}Le.DEFAULT_PRIORITY=10,Le.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 He extends be{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=We}_insertChild(e,t){if(t&&(t instanceof b||Array.from(t).length>0))throw new n.CKEditorError("view-emptyelement-cannot-add",[this,t]);return 0}}function We(){return null}He.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 Ue extends be{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=je}_insertChild(e,t){if(t&&(t instanceof b||Array.from(t).length>0))throw new n.CKEditorError("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 je(){return null}Ue.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 $e extends be{constructor(e,t,i,n){super(e,t,i,n),this.getFillerOffset=qe}_insertChild(e,t){if(t&&(t instanceof b||Array.from(t).length>0))throw new n.CKEditorError("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}function qe(){return null}$e.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 Ke extends((0,n.EmitterMixin)(g)){constructor(e,t){super(),this._children=[],this._customProperties=new Map,this.document=e,t&&this._insertChild(0,t)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return 0===this.childCount}get root(){return this}get parent(){return null}get name(){}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,t){this._fireChange("children",this);let i=0;const o=function(e,t){return"string"==typeof t?[new w(e,t)]:((0,n.isIterable)(t)||(t=[t]),Array.from(t).map((t=>"string"==typeof t?new w(e,t):t instanceof v?new w(e,t.data):t)))}(this.document,t);for(const t of o)null!==t.parent&&t._remove(),t.parent=this,this._children.splice(e,0,t),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this);for(let i=e;i{const i=e[e.length-1],n=!t.is("uiElement");return i&&i.breakAttributes==n?i.nodes.push(t):e.push({breakAttributes:n,nodes:[t]}),e}),[]);let o=null,s=e;for(const{nodes:e,breakAttributes:t}of i){const i=this._insertNodes(s,e,t);o||(o=i.start),s=i.end}return o?new xe(o,s):new xe(e)}remove(e){const t=e instanceof xe?e:xe._createOn(e);if(it(t,this.document),t.isCollapsed)return new Ke(this.document);const{start:i,end:n}=this._breakAttributesRange(t,!0),o=i.parent,s=n.offset-i.offset,r=o._removeChildren(i.offset,s);for(const e of r)this._removeFromClonedElementsGroup(e);const a=this.mergeAttributes(i);return t.start=a,t.end=a.clone(),new Ke(this.document,r)}clear(e,t){it(e,this.document);const i=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const n of i){const i=n.item;let o;if(i.is("element")&&t.isSimilar(i))o=xe._createOn(i);else if(!n.nextPosition.isAfter(e.start)&&i.is("$textProxy")){const e=i.getAncestors().find((e=>e.is("element")&&t.isSimilar(e)));e&&(o=xe._createIn(e))}o&&(o.end.isAfter(e.end)&&(o.end=e.end),o.start.isBefore(e.start)&&(o.start=e.start),this.remove(o))}}move(e,t){let i;if(t.isAfter(e.end)){const n=(t=this._breakAttributes(t,!0)).parent,o=n.childCount;e=this._breakAttributesRange(e,!0),i=this.remove(e),t.offset+=n.childCount-o}else i=this.remove(e);return this.insert(t,i)}wrap(e,t){if(!(t instanceof Le))throw new n.CKEditorError("view-writer-wrap-invalid-attribute",this.document);if(it(e,this.document),e.isCollapsed){let n=e.start;n.parent.is("element")&&(i=n.parent,!Array.from(i.getChildren()).some((e=>!e.is("uiElement"))))&&(n=n.getLastMatchingPosition((e=>e.item.is("uiElement")))),n=this._wrapPosition(n,t);const o=this.document.selection;return o.isCollapsed&&o.getFirstPosition().isEqual(e.start)&&this.setSelection(n),new xe(n)}return this._wrapRange(e,t);var i}unwrap(e,t){if(!(t instanceof Le))throw new n.CKEditorError("view-writer-unwrap-invalid-attribute",this.document);if(it(e,this.document),e.isCollapsed)return e;const{start:i,end:o}=this._breakAttributesRange(e,!0),s=i.parent,r=this._unwrapChildren(s,i.offset,o.offset,t),a=this.mergeAttributes(r.start);a.isEqual(r.start)||r.end.offset--;const l=this.mergeAttributes(r.end);return new xe(a,l)}rename(e,t){const i=new ve(this.document,e,t.getAttributes());return this.insert(Ee._createAfter(t),i),this.move(xe._createIn(t),Ee._createAt(i,0)),this.remove(xe._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return Ee._createAt(e,t)}createPositionAfter(e){return Ee._createAfter(e)}createPositionBefore(e){return Ee._createBefore(e)}createRange(e,t){return new xe(e,t)}createRangeOn(e){return xe._createOn(e)}createRangeIn(e){return xe._createIn(e)}createSelection(...e){return new Se(...e)}createSlot(e="children"){if(!this._slotFactory)throw new n.CKEditorError("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,i){let o,s;if(o=i?Ge(e):e.parent.is("$text")?e.parent.parent:e.parent,!o)throw new n.CKEditorError("view-writer-invalid-position-container",this.document);s=i?this._breakAttributes(e,!0):e.parent.is("$text")?Ye(e):e;const r=o._insertChild(s.offset,t);for(const e of t)this._addToClonedElementsGroup(e);const a=s.getShiftedBy(r),l=this.mergeAttributes(s);l.isEqual(s)||a.offset--;const c=this.mergeAttributes(a);return new xe(l,c)}_wrapChildren(e,t,i,n){let o=t;const s=[];for(;oa.priority)&&r.getIdentity()!1,e.parent._insertChild(e.offset,i);const n=new xe(e,e.getShiftedBy(1));this.wrap(n,t);const o=new Ee(i.parent,i.index);i._remove();const s=o.nodeBefore,r=o.nodeAfter;return s instanceof w&&r instanceof w?Qe(s,r):Je(o)}_wrapAttributeElement(e,t){if(!nt(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&t.hasAttribute(i)&&t.getAttribute(i)!==e.getAttribute(i))return!1;for(const i of e.getStyleNames())if(t.hasStyle(i)&&t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&(t.hasAttribute(i)||this.setAttribute(i,e.getAttribute(i),t));for(const i of e.getStyleNames())t.hasStyle(i)||this.setStyle(i,e.getStyle(i),t);for(const i of e.getClassNames())t.hasClass(i)||this.addClass(i,t);return!0}_unwrapAttributeElement(e,t){if(!nt(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const i of e.getAttributeKeys())if("class"!==i&&"style"!==i&&(!t.hasAttribute(i)||t.getAttribute(i)!==e.getAttribute(i)))return!1;if(!t.hasClass(...e.getClassNames()))return!1;for(const i of e.getStyleNames())if(!t.hasStyle(i)||t.getStyle(i)!==e.getStyle(i))return!1;for(const i of e.getAttributeKeys())"class"!==i&&"style"!==i&&this.removeAttribute(i,t);return this.removeClass(Array.from(e.getClassNames()),t),this.removeStyle(Array.from(e.getStyleNames()),t),!0}_breakAttributesRange(e,t=!1){const i=e.start,n=e.end;if(it(e,this.document),e.isCollapsed){const i=this._breakAttributes(e.start,t);return new xe(i,i)}const o=this._breakAttributes(n,t),s=o.parent.childCount,r=this._breakAttributes(i,t);return o.offset+=o.parent.childCount-s,new xe(r,o)}_breakAttributes(e,t=!1){const i=e.offset,o=e.parent;if(e.parent.is("emptyElement"))throw new n.CKEditorError("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new n.CKEditorError("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new n.CKEditorError("view-writer-cannot-break-raw-element",this.document);if(!t&&o.is("$text")&&tt(o.parent))return e.clone();if(tt(o))return e.clone();if(o.is("$text"))return this._breakAttributes(Ye(e),t);if(i==o.childCount){const e=new Ee(o.parent,o.index+1);return this._breakAttributes(e,t)}if(0===i){const e=new Ee(o.parent,o.index);return this._breakAttributes(e,t)}{const e=o.index+1,n=o._clone();o.parent._insertChild(e,n),this._addToClonedElementsGroup(n);const s=o.childCount-i,r=o._removeChildren(i,s);n._appendChild(r);const a=new Ee(o.parent,e);return this._breakAttributes(a,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const t of e.getChildren())this._addToClonedElementsGroup(t);const t=e.id;if(!t)return;let i=this._cloneGroups.get(t);i||(i=new Set,this._cloneGroups.set(t,i)),i.add(e),e._clonesGroup=i}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const t of e.getChildren())this._removeFromClonedElementsGroup(t);const t=e.id;if(!t)return;const i=this._cloneGroups.get(t);i&&i.delete(e)}}function Ge(e){let t=e.parent;for(;!tt(t);){if(!t)return;t=t.parent}return t}function Je(e){const t=e.nodeBefore;if(t&&t.is("$text"))return new Ee(t,t.data.length);const i=e.nodeAfter;return i&&i.is("$text")?new Ee(i,0):e}function Ye(e){if(e.offset==e.parent.data.length)return new Ee(e.parent.parent,e.parent.index+1);if(0===e.offset)return new Ee(e.parent.parent,e.parent.index);const t=e.parent.data.slice(e.offset);return e.parent._data=e.parent.data.slice(0,e.offset),e.parent.parent._insertChild(e.parent.index+1,new w(e.root.document,t)),new Ee(e.parent.parent,e.parent.index+1)}function Qe(e,t){const i=e.data.length;return e._data+=t.data,t._remove(),new Ee(e,i)}const Xe=[w,Le,ve,He,$e,Ue];function et(e,t){for(const i of e){if(!Xe.some((e=>i instanceof e)))throw new n.CKEditorError("view-writer-insert-invalid-node-type",t);i.is("$text")||et(i.getChildren(),t)}}function tt(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function it(e,t){const i=Ge(e.start),o=Ge(e.end);if(!i||!o||i!==o)throw new n.CKEditorError("view-writer-invalid-range-container",t)}function nt(e,t){return null===e.id&&null===t.id}const ot=e=>e.createTextNode(" "),st=e=>{const t=e.createElement("span");return t.dataset.ckeFiller="true",t.innerText=" ",t},rt=e=>{const t=e.createElement("br");return t.dataset.ckeFiller="true",t},at=7,lt="⁠".repeat(at);function ct(e){return"string"==typeof e?e.substr(0,at)===lt:(0,n.isText)(e)&&e.data.substr(0,at)===lt}function dt(e){return e.data.length==at&&ct(e)}function ut(e){const t="string"==typeof e?e:e.data;return ct(e)?t.slice(at):t}function ht(e,t){if(t.keyCode==n.keyCodes.arrowleft){const e=t.domTarget.ownerDocument.defaultView.getSelection();if(1==e.rangeCount&&e.getRangeAt(0).collapsed){const t=e.getRangeAt(0).startContainer,i=e.getRangeAt(0).startOffset;ct(t)&&i<=at&&e.collapse(t,0)}}}class mt extends((0,n.ObservableMixin)()){constructor(e,t){super(),this.domDocuments=new Set,this.markedAttributes=new Set,this.markedChildren=new Set,this.markedTexts=new Set,this._inlineFiller=null,this._fakeSelectionContainer=null,this.domConverter=e,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),n.env.isBlink&&!n.env.isAndroid&&this.on("change:isSelecting",(()=>{this.isSelecting||this.render()})),this.set("isComposing",!1),this.on("change:isComposing",(()=>{this.isComposing||this.render()}))}markToSync(e,t){if("text"===e)this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if("attributes"===e)this.markedAttributes.add(t);else{if("children"!==e)throw new n.CKEditorError("view-renderer-unknown-type",this);this.markedChildren.add(t)}}}render(){if(this.isComposing&&!n.env.isAndroid)return;let e=null;const t=!(n.env.isBlink&&!n.env.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=Ee._createBefore(e.parent)));for(const e of this.markedAttributes)this._updateAttrs(e);for(const t of this.markedChildren)this._updateChildren(t,{inlineFillerPosition:e});for(const t of this.markedTexts)!this.markedChildren.has(t.parent)&&this.domConverter.mapViewToDom(t.parent)&&this._updateText(t,{inlineFillerPosition:e});if(t)if(e){const t=this.domConverter.viewPositionToDom(e),i=t.parent.ownerDocument;ct(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=gt(i,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),i=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),o=this._diffNodeLists(t,i),s=this._findUpdateActions(o,t,i,ft);if(-1!==s.indexOf("update")){const o={equal:0,insert:0,delete:0};for(const r of s)if("update"===r){const s=o.equal+o.insert,r=o.equal+o.delete,a=e.getChild(s);!a||a.is("uiElement")||a.is("rawElement")||this._updateElementMappings(a,t[r]),(0,n.remove)(i[s]),o.equal++}else o[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")?Ee._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&&(0,n.isText)(t.parent)&&ct(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!ct(e))throw new n.CKEditorError("view-renderer-filler-was-lost",this);dt(e)?e.remove():e.data=e.data.substr(at),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,i=e.offset;if(!this.domConverter.mapViewToDom(t.root))return!1;if(!t.is("element"))return!1;if(!function(e){if("false"==e.getAttribute("contenteditable"))return!1;const t=e.findAncestor((e=>e.hasAttribute("contenteditable")));return!t||"true"==t.getAttribute("contenteditable")}(t))return!1;if(i===t.getFillerOffset())return!1;const o=e.nodeBefore,s=e.nodeAfter;return!(o instanceof w||s instanceof w||n.env.isAndroid&&(o||s))}_updateText(e,t){const i=this.domConverter.findCorrespondingDomText(e);let n=this.domConverter.viewToDom(e).data;const o=t.inlineFillerPosition;o&&o.parent==e.parent&&o.offset==e.index&&(n=lt+n),wt(i,n)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const i=Array.from(t.attributes).map((e=>e.name)),n=e.getAttributeKeys();for(const i of n)this.domConverter.setDomElementAttribute(t,i,e.getAttribute(i),e);for(const n of i)e.hasAttribute(n)||this.domConverter.removeDomElementAttribute(t,n)}_updateChildren(e,t){const i=this.domConverter.mapViewToDom(e);if(!i)return;if(n.env.isAndroid){let e=null;for(const t of Array.from(i.childNodes)){if(e&&(0,n.isText)(e)&&(0,n.isText)(t)){i.normalize();break}e=t}}const o=t.inlineFillerPosition,s=i.childNodes,r=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));o&&o.parent===e&>(i.ownerDocument,r,o.offset);const a=this._diffNodeLists(s,r),l=this._findUpdateActions(a,s,r,pt);let c=0;const d=new Set;for(const e of l)"delete"===e?(d.add(s[c]),(0,n.remove)(s[c])):"equal"!==e&&"update"!==e||c++;c=0;for(const e of l)"insert"===e?((0,n.insertAt)(i,c,r[c]),c++):"update"===e?(wt(s[c],r[c].data),c++):"equal"===e&&(this._markDescendantTextToSync(this.domConverter.domToView(r[c])),c++);for(const e of d)e.parentNode||this.domConverter.unbindDomElement(e)}_diffNodeLists(e,t){return e=function(e,t){const i=Array.from(e);if(0==i.length||!t)return i;return i[i.length-1]==t&&i.pop(),i}(e,this._fakeSelectionContainer),(0,n.diff)(e,t,bt.bind(null,this.domConverter))}_findUpdateActions(e,t,i,o){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let s=[],r=[],a=[];const l={equal:0,insert:0,delete:0};for(const c of e)"insert"===c?a.push(i[l.equal+l.insert]):"delete"===c?r.push(t[l.equal+l.delete]):(s=s.concat((0,n.diff)(r,a,o).map((e=>"equal"===e?"update":e))),s.push("equal"),r=[],a=[]),l[c]++;return s.concat((0,n.diff)(r,a,o).map((e=>"equal"===e?"update":e)))}_markDescendantTextToSync(e){if(e)if(e.is("$text"))this.markedTexts.add(e);else if(e.is("element"))for(const t of e.getChildren())this._markDescendantTextToSync(t)}_updateSelection(){if(n.env.isBlink&&!n.env.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(0===this.selection.rangeCount)return this._removeDomSelection(),void this._removeFakeSelection();const e=this.domConverter.mapViewToDom(this.selection.editableElement);this.isFocused&&e&&(this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&n.env.isAndroid||this._updateDomSelection(e))}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=function(e){const t=e.createElement("div");return t.className="ck-fake-selection-container",Object.assign(t.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),t.textContent=" ",t}(t));const i=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(i,this.selection),!this._fakeSelectionNeedsUpdate(e))return;i.parentElement&&i.parentElement==e||e.appendChild(i),i.textContent=this.selection.fakeSelectionLabel||" ";const n=t.getSelection(),o=t.createRange();n.removeAllRanges(),o.selectNodeContents(i),n.addRange(o)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const i=this.domConverter.viewPositionToDom(this.selection.anchor),o=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(i.parent,i.offset,o.parent,o.offset),n.env.isGecko&&function(e,t){const i=e.parent;if(i.nodeType!=Node.ELEMENT_NODE||e.offset!=i.childNodes.length-1)return;const n=i.childNodes[e.offset];n&&"BR"==n.tagName&&t.addRange(t.getRangeAt(0))}(o,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return!(t&&this.selection.isEqual(t)||!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,i=e.ownerDocument.getSelection();return!t||t.parentElement!==e||i.anchorNode!==t&&!t.contains(i.anchorNode)||t.textContent!==this.selection.fakeSelectionLabel}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const i=e.activeElement,n=this.domConverter.mapDomToView(i);i&&n&&t.removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function gt(e,t,i){const o=t instanceof Array?t:t.childNodes,s=o[i];if((0,n.isText)(s))return s.data=lt+s.data,s;{const s=e.createTextNode(lt);return Array.isArray(t)?o.splice(i,0,s):(0,n.insertAt)(t,i,s),s}}function ft(e,t){return(0,n.isNode)(e)&&(0,n.isNode)(t)&&!(0,n.isText)(e)&&!(0,n.isText)(t)&&!(0,n.isComment)(e)&&!(0,n.isComment)(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function pt(e,t){return(0,n.isNode)(e)&&(0,n.isNode)(t)&&(0,n.isText)(e)&&(0,n.isText)(t)}function bt(e,t,i){return t===i||((0,n.isText)(t)&&(0,n.isText)(i)?t.data===i.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(i)))}function wt(e,t){const i=e.data;if(i==t)return;const o=(0,n.fastDiff)(i,t);for(const t of o)"insert"===t.type?e.insertData(t.index,t.values.join("")):e.deleteData(t.index,t.howMany)}const vt=rt(n.global.document),_t=ot(n.global.document),yt=st(n.global.document),kt="data-ck-unsafe-attribute-",Ct="data-ck-unsafe-element";class At{constructor(e,{blockFillerMode:t,renderingMode:i="editing"}={}){this._domToViewMapping=new WeakMap,this._viewToDomMapping=new WeakMap,this._fakeSelectionMapping=new WeakMap,this._rawContentElementMatcher=new y,this._inlineObjectElementMatcher=new y,this.document=e,this.renderingMode=i,this.blockFillerMode=t||("editing"===i?"br":"nbsp"),this.preElements=["pre"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this.unsafeElements=["script","style"],this._domDocument="editing"===this.renderingMode?n.global.document:n.global.document.implementation.createHTMLDocument("")}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new Se(t))}fakeSelectionToView(e){return this._fakeSelectionMapping.get(e)}bindElements(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}unbindDomElement(e){const t=this._domToViewMapping.get(e);if(t){this._domToViewMapping.delete(e),this._viewToDomMapping.delete(t);for(const t of Array.from(e.children))this.unbindDomElement(t)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,i){return"data"===this.renderingMode||!(e=e.toLowerCase()).startsWith("on")&&("srcdoc"!==e||!t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i))&&("img"===i&&("src"===e||"srcset"===e)||"source"===i&&"srcset"===e||!t.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))}setContentOf(e,t){if("data"===this.renderingMode)return void(e.innerHTML=t);const i=(new DOMParser).parseFromString(t,"text/html"),n=i.createDocumentFragment(),o=i.body.childNodes;for(;o.length>0;)n.appendChild(o[0]);const s=i.createTreeWalker(n,NodeFilter.SHOW_ELEMENT),r=[];let a;for(;a=s.nextNode();)r.push(a);for(const e of r){for(const t of e.getAttributeNames())this.setDomElementAttribute(e,t,e.getAttribute(t));const t=e.tagName.toLowerCase();this._shouldRenameElement(t)&&(St(t),e.replaceWith(this._createReplacementDomElement(t,e)))}for(;e.firstChild;)e.firstChild.remove();e.append(n)}viewToDom(e,t={}){if(e.is("$text")){const t=this._processDataFromViewText(e);return this._domDocument.createTextNode(t)}{if(this.mapViewToDom(e))return this.mapViewToDom(e);let i;if(e.is("documentFragment"))i=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(i,e);else{if(e.is("uiElement"))return i="$comment"===e.name?this._domDocument.createComment(e.getCustomProperty("$rawContent")):e.render(this._domDocument,this),t.bind&&this.bindElements(i,e),i;this._shouldRenameElement(e.name)?(St(e.name),i=this._createReplacementDomElement(e.name)):i=e.hasAttribute("xmlns")?this._domDocument.createElementNS(e.getAttribute("xmlns"),e.name):this._domDocument.createElement(e.name),e.is("rawElement")&&e.render(i,this),t.bind&&this.bindElements(i,e);for(const t of e.getAttributeKeys())this.setDomElementAttribute(i,t,e.getAttribute(t),e)}if(!1!==t.withChildren)for(const n of this.viewChildrenToDom(e,t))i.appendChild(n);return i}}setDomElementAttribute(e,t,i,o){const s=this.shouldRenderAttribute(t,i,e.tagName.toLowerCase())||o&&o.shouldRenderUnsafeAttribute(t);s||(0,n.logWarning)("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:i}),(0,n.isValidAttributeName)(t)?(e.hasAttribute(t)&&!s?e.removeAttribute(t):e.hasAttribute(kt+t)&&s&&e.removeAttribute(kt+t),e.setAttribute(s?t:kt+t,i)):(0,n.logWarning)("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:i})}removeDomElementAttribute(e,t){t!=Ct&&(e.removeAttribute(t),e.removeAttribute(kt+t))}*viewChildrenToDom(e,t={}){const i=e.getFillerOffset&&e.getFillerOffset();let o=0;for(const s of e.getChildren()){i===o&&(yield this._getBlockFiller());const e=s.is("element")&&!!s.getCustomProperty("dataPipeline:transparentRendering")&&!(0,n.first)(s.getAttributes());e&&"data"==this.renderingMode?yield*this.viewChildrenToDom(s,t):(e&&(0,n.logWarning)("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:s}),yield this.viewToDom(s,t)),o++}i===o&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),i=this.viewPositionToDom(e.end),n=this._domDocument.createRange();return n.setStart(t.parent,t.offset),n.setEnd(i.parent,i.offset),n}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const i=this.findCorrespondingDomText(t);if(!i)return null;let n=e.offset;return ct(i)&&(n+=at),{parent:i,offset:n}}{let i,o,s;if(0===e.offset){if(i=this.mapViewToDom(t),!i)return null;s=i.childNodes[0]}else{const t=e.nodeBefore;if(o=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(t),!o)return null;i=o.parentNode,s=o.nextSibling}return(0,n.isText)(s)&&ct(s)?{parent:s,offset:at}:{parent:i,offset:o?(0,n.indexOf)(o)+1:0}}}domToView(e,t={}){const i=[],n=this._domToView(e,t,i),o=n.next().value;return o?(n.next(),this._processDomInlineNodes(null,i,t),o.is("$text")&&0==o.data.length?null:o):null}*domChildrenToView(e,t={},i=[]){for(let n=0;n{const{scrollLeft:t,scrollTop:i}=e;o.push([t,i])})),t.focus(),xt(t,(e=>{const[t,i]=o.shift();e.scrollLeft=t,e.scrollTop=i})),n.global.window.scrollTo(e,i)}}_clearDomSelection(){const e=this.mapViewToDom(this.document.selection.editableElement);if(!e)return;const t=e.ownerDocument.defaultView.getSelection(),i=this.domSelectionToView(t);i&&i.rangeCount>0&&t.removeAllRanges()}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(e){return"br"==this.blockFillerMode?e.isEqualNode(vt):!("BR"!==e.tagName||!Tt(e,this.blockElements)||1!==e.parentNode.childNodes.length)||e.isEqualNode(yt)||function(e,t){return e.isEqualNode(_t)&&Tt(e,t)&&1===e.parentNode.childNodes.length}(e,this.blockElements)}isDomSelectionBackward(e){if(e.isCollapsed)return!1;const t=this._domDocument.createRange();try{t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset)}catch(e){return!1}const i=t.collapsed;return t.detach(),i}getHostViewElement(e){const t=(0,n.getAncestors)(e);for(t.pop();t.length;){const e=t.pop(),i=this._domToViewMapping.get(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return i}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}registerInlineObjectMatcher(e){this._inlineObjectElementMatcher.add(e)}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return ot(this._domDocument);case"markedNbsp":return st(this._domDocument);case"br":return rt(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if((0,n.isText)(e)&&ct(e)&&t0?t[e-1]:null,l=e+1this.preElements.includes(e.name))))return t;if(" "==t.charAt(0)){const i=this._getTouchingInlineViewNode(e,!1);!(i&&i.is("$textProxy")&&this._nodeEndsWithSpace(i))&&i||(t=" "+t.substr(1))}if(" "==t.charAt(t.length-1)){const i=this._getTouchingInlineViewNode(e,!0),n=i&&i.is("$textProxy")&&" "==i.data.charAt(0);" "!=t.charAt(t.length-2)&&i&&!n||(t=t.substr(0,t.length-1)+" ")}return t.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(e){if(e.getAncestors().some((e=>this.preElements.includes(e.name))))return!1;const t=this._processDataFromViewText(e);return" "==t.charAt(t.length-1)}_getTouchingInlineViewNode(e,t){const i=new Ae({startPosition:t?Ee._createAfter(e):Ee._createBefore(e),direction:t?"forward":"backward"});for(const e of i){if(e.item.is("element","br"))return null;if(this._isInlineObjectElement(e.item))return e.item;if(e.item.is("containerElement"))return null;if(e.item.is("$textProxy"))return e.item}return null}_isBlockDomElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isBlockViewElement(e){return e.is("element")&&this.blockElements.includes(e.name)}_isInlineObjectElement(e){return!!e.is("element")&&("br"==e.name||this.inlineObjectElements.includes(e.name)||!!this._inlineObjectElementMatcher.match(e))}_createViewElement(e,t){if((0,n.isComment)(e))return new Ue(this.document,"$comment");const i=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new be(this.document,i)}_isViewElementWithRawContent(e,t){return!1!==t.withChildren&&e.is("element")&&!!this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return"editing"===this.renderingMode&&this.unsafeElements.includes(t)}_createReplacementDomElement(e,t){const i=this._domDocument.createElement("span");if(i.setAttribute(Ct,e),t){for(;t.firstChild;)i.appendChild(t.firstChild);for(const e of t.getAttributeNames())i.setAttribute(e,t.getAttribute(e))}return i}}function Et(e,t){return e.getAncestors().some((e=>e.is("element")&&t.includes(e.name)))}function xt(e,t){let i=e;for(;i;)t(i),i=i.parentElement}function Tt(e,t){const i=e.parentNode;return!!i&&!!i.tagName&&t.includes(i.tagName.toLowerCase())}function St(e){"script"===e&&(0,n.logWarning)("domconverter-unsafe-script-element-detected"),"style"===e&&(0,n.logWarning)("domconverter-unsafe-style-element-detected")}class Pt extends((0,n.DomEmitterMixin)()){constructor(e){super(),this._isEnabled=!1,this.view=e,this.document=e.document}get isEnabled(){return this._isEnabled}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(e){return e&&3===e.nodeType&&(e=e.parentNode),!(!e||1!==e.nodeType)&&e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}var It=i(207);class Vt{constructor(e,t,i){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,(0,It.Z)(this,i)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class Rt extends Pt{constructor(){super(...arguments),this.useCapture=!1}observe(e){("string"==typeof this.domEventType?[this.domEventType]:this.domEventType).forEach((t=>{this.listenTo(e,t,((e,t)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(t.target)&&this.onDomEvent(t)}),{useCapture:this.useCapture})}))}stopObserving(e){this.stopListening(e)}fire(e,t,i){this.isEnabled&&this.document.fire(e,new Vt(this.view,t,i))}}class Ot extends Rt{constructor(){super(...arguments),this.domEventType=["keydown","keyup"]}onDomEvent(e){const t={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return(0,n.getCode)(this)}};this.fire(e.type,e,t)}}var Bt=i(6682);class Mt extends Pt{constructor(e){super(e),this._fireSelectionChangeDoneDebounced=(0,Bt.Z)((e=>{this.document.fire("selectionChangeDone",e)}),200)}observe(){const e=this.document;e.on("arrowKey",((t,i)=>{e.selection.isFake&&this.isEnabled&&i.preventDefault()}),{context:"$capture"}),e.on("arrowKey",((t,i)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(i.keyCode)}),{priority:"lowest"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,i=new Se(t.getRanges(),{backward:t.isBackward,fake:!1});e!=n.keyCodes.arrowleft&&e!=n.keyCodes.arrowup||i.setTo(i.getFirstPosition()),e!=n.keyCodes.arrowright&&e!=n.keyCodes.arrowdown||i.setTo(i.getLastPosition());const o={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",o),this._fireSelectionChangeDoneDebounced(o)}}var Nt=i(1152);const Dt=function(e,t,i){var n=(i="function"==typeof i?i:void 0)?i(e,t):void 0;return void 0===n?(0,Nt.Z)(e,t,void 0,i):!!n};class Lt extends Pt{constructor(e){super(e),this._config={childList:!0,characterData:!0,subtree:!0},this.domConverter=e.domConverter,this.renderer=e._renderer,this._domElements=new Set,this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(e){this._domElements.add(e),this.isEnabled&&this._mutationObserver.observe(e,this._config)}stopObserving(e){if(this._domElements.delete(e),this.isEnabled){this._mutationObserver.disconnect();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}}enable(){super.enable();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}disable(){super.disable(),this._mutationObserver.disconnect()}destroy(){super.destroy(),this._mutationObserver.disconnect()}_onMutations(e){if(0===e.length)return;const t=this.domConverter,i=new Set,n=new Set;for(const i of e){const e=t.mapDomToView(i.target);e&&(e.is("uiElement")||e.is("rawElement")||"childList"!==i.type||this._isBogusBrMutation(i)||n.add(e))}for(const o of e){const e=t.mapDomToView(o.target);if((!e||!e.is("uiElement")&&!e.is("rawElement"))&&"characterData"===o.type){const e=t.findCorrespondingViewText(o.target);e&&!n.has(e.parent)?i.add(e):!e&&ct(o.target)&&n.add(t.mapDomToView(o.target.parentNode))}}let o=!1;for(const e of i)o=!0,this.renderer.markToSync("text",e);for(const e of n){const i=t.mapViewToDom(e),n=Array.from(e.getChildren()),s=Array.from(t.domChildrenToView(i,{withChildren:!1}));Dt(n,s,Ft)||(o=!0,this.renderer.markToSync("children",e))}o&&this.view.forceRender()}_isBogusBrMutation(e){let t=null;return null===e.nextSibling&&0===e.removedNodes.length&&1==e.addedNodes.length&&(t=this.domConverter.domToView(e.addedNodes[0],{withChildren:!1})),t&&t.is("element","br")}}function Ft(e,t){if(!Array.isArray(e))return e===t||!(!e.is("$text")||!t.is("$text"))&&e.data===t.data}class zt extends Rt{constructor(e){super(e),this._isFocusChanging=!1,this.domEventType=["focus","blur"],this.useCapture=!0;const t=this.document;t.on("focus",(()=>{this._isFocusChanging=!0,this._renderTimeoutId=setTimeout((()=>{this.flush(),e.change((()=>{}))}),50)})),t.on("blur",((i,n)=>{const o=t.selection.editableElement;null!==o&&o!==n.target||(t.isFocused=!1,this._isFocusChanging=!1,e.change((()=>{})))}))}flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),super.destroy()}}class Ht extends Pt{constructor(e){super(e),this.mutationObserver=e.getObserver(Lt),this.focusObserver=e.getObserver(zt),this.selection=this.document.selection,this.domConverter=e.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=(0,Bt.Z)((e=>{this.document.fire("selectionChangeDone",e)}),200),this._clearInfiniteLoopInterval=setInterval((()=>this._clearInfiniteLoop()),1e3),this._documentIsSelectingInactivityTimeoutDebounced=(0,Bt.Z)((()=>this.document.isSelecting=!1),5e3),this._loopbackCounter=0}observe(e){const t=e.ownerDocument,i=()=>{this.document.isSelecting&&(this._handleSelectionChange(null,t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",(()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()}),{priority:"highest"}),this.listenTo(e,"keydown",i,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",i,{priority:"highest",useCapture:!0}),this._documents.has(t)||(this.listenTo(t,"mouseup",i,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",((e,i)=>{this.document.isComposing&&!n.env.isAndroid||(this._handleSelectionChange(i,t),this._documentIsSelectingInactivityTimeoutDebounced())})),this._documents.add(t))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e,t){if(!this.isEnabled)return;const i=t.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(i.anchorNode))return;this.mutationObserver.flush();const n=this.domConverter.domSelectionToView(i);if(0!=n.rangeCount){if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.selection.isEqual(n)||!this.domConverter.isDomSelectionCorrect(i))if(++this._loopbackCounter>60)this._reportInfiniteLoop();else if(this.selection.isSimilar(n))this.view.forceRender();else{const e={oldSelection:this.selection,newSelection:n,domSelection:i};this.document.fire("selectionChange",e),this._fireSelectionChangeDoneDebounced(e)}}else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}}class Wt extends Rt{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 Ut{constructor(e,t={}){this._files=t.cacheFiles?jt(e):null,this._native=e}get files(){return this._files||(this._files=jt(this._native)),this._files}get types(){return this._native.types}getData(e){return this._native.getData(e)}setData(e,t){this._native.setData(e,t)}set effectAllowed(e){this._native.effectAllowed=e}get effectAllowed(){return this._native.effectAllowed}set dropEffect(e){this._native.dropEffect=e}get dropEffect(){return this._native.dropEffect}setDragImage(e,t,i){this._native.setDragImage(e,t,i)}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}function jt(e){const t=Array.from(e.files||[]),i=Array.from(e.items||[]);return t.length?t:i.filter((e=>"file"===e.kind)).map((e=>e.getAsFile()))}class $t extends Rt{constructor(){super(...arguments),this.domEventType="beforeinput"}onDomEvent(e){const t=e.getTargetRanges(),i=this.view,o=i.document;let s=null,r=null,a=[];if(e.dataTransfer&&(s=new Ut(e.dataTransfer)),null!==e.data?r=e.data:s&&(r=s.getData("text/plain")),o.selection.isFake)a=Array.from(o.selection.getRanges());else if(t.length)a=t.map((e=>{const t=i.domConverter.domPositionToView(e.startContainer,e.startOffset),n=i.domConverter.domPositionToView(e.endContainer,e.endOffset);return t?i.createRange(t,n):n?i.createRange(n):void 0})).filter((e=>!!e));else if(n.env.isAndroid){const t=e.target.ownerDocument.defaultView.getSelection();a=Array.from(i.domConverter.domSelectionToView(t).getRanges())}if(n.env.isAndroid&&"insertCompositionText"==e.inputType&&r&&r.endsWith("\n"))this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[i.createRange(a[0].end)]});else if("insertText"==e.inputType&&r&&r.includes("\n")){const t=r.split(/\n{1,2}/g);let i=a;for(let n=0;n{if(this.isEnabled&&(0,n.isArrowKeyCode)(t.keyCode)){const i=new Ie(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(i,t),i.stop.called&&e.stop()}}))}observe(){}stopObserving(){}}class Kt extends Pt{constructor(e){super(e);const t=this.document;t.on("keydown",((e,i)=>{if(!this.isEnabled||i.keyCode!=n.keyCodes.tab||i.ctrlKey)return;const o=new Ie(t,"tab",t.selection.getFirstRange());t.fire(o,i),o.stop.called&&e.stop()}))}observe(){}stopObserving(){}}const Zt=function(e){return(0,f.Z)(e,5)};class Gt extends((0,n.ObservableMixin)()){constructor(e){var t;super(),this.domRoots=new Map,this._initialDomRootAttributes=new WeakMap,this._observers=new Map,this._ongoingChange=!1,this._postFixersInProgress=!1,this._renderingDisabled=!1,this._hasChangedSinceTheLastRendering=!1,this.document=new De(e),this.domConverter=new At(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new mt(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new Ze(this.document),this.addObserver(Lt),this.addObserver(zt),this.addObserver(Ht),this.addObserver(Ot),this.addObserver(Mt),this.addObserver(Wt),this.addObserver(qt),this.addObserver($t),this.addObserver(Kt),this.document.on("arrowKey",ht,{priority:"low"}),(t=this).document.on("arrowKey",((e,i)=>function(e,t,i){if(t.keyCode==n.keyCodes.arrowright){const e=t.domTarget.ownerDocument.defaultView.getSelection(),n=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(n||t.shiftKey){const t=e.focusNode,o=e.focusOffset,s=i.domPositionToView(t,o);if(null===s)return;let r=!1;const a=s.getLastMatchingPosition((e=>(e.item.is("uiElement")&&(r=!0),!(!e.item.is("uiElement")&&!e.item.is("attributeElement")))));if(r){const t=i.viewPositionToDom(a);n?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}}(0,i,t.domConverter)),{priority:"low"}),this.on("render",(()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1})),this.listenTo(this.document.selection,"change",(()=>{this._hasChangedSinceTheLastRendering=!0})),this.listenTo(this.document,"change:isFocused",(()=>{this._hasChangedSinceTheLastRendering=!0})),n.env.isiOS&&this.listenTo(this.document,"blur",((e,t)=>{this.domConverter.mapDomToView(t.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}))}attachDomRoot(e,t="main"){const i=this.document.getRoot(t);i._name=e.tagName.toLowerCase();const n={};for(const{name:t,value:o}of Array.from(e.attributes))n[t]=o,"class"===t?this._writer.addClass(o.split(" "),i):this._writer.setAttribute(t,o,i);this._initialDomRootAttributes.set(e,n);const o=()=>{this._writer.setAttribute("contenteditable",(!i.isReadOnly).toString(),i),i.isReadOnly?this._writer.addClass("ck-read-only",i):this._writer.removeClass("ck-read-only",i)};o(),this.domRoots.set(t,e),this.domConverter.bindElements(e,i),this._renderer.markToSync("children",i),this._renderer.markToSync("attributes",i),this._renderer.domDocuments.add(e.ownerDocument),i.on("change:children",((e,t)=>this._renderer.markToSync("children",t))),i.on("change:attributes",((e,t)=>this._renderer.markToSync("attributes",t))),i.on("change:text",((e,t)=>this._renderer.markToSync("text",t))),i.on("change:isReadOnly",(()=>this.change(o))),i.on("change",(()=>{this._hasChangedSinceTheLastRendering=!0}));for(const i of this._observers.values())i.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach((({name:e})=>t.removeAttribute(e)));const i=this._initialDomRootAttributes.get(t);for(const e in i)t.setAttribute(e,i[e]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t);for(const e of this._observers.values())e.stopObserving(t)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;t=new e(this),this._observers.set(e,t);for(const[e,i]of this.domRoots)t.observe(i,e);return t.enable(),t}getObserver(e){return this._observers.get(e)}disableObservers(){for(const e of this._observers.values())e.disable()}enableObservers(){for(const e of this._observers.values())e.enable()}scrollToTheSelection({alignToTop:e,forceScroll:t,viewportOffset:i=20,ancestorOffset:o=20}={}){const s=this.document.selection.getFirstRange();if(!s)return;const r=Zt({alignToTop:e,forceScroll:t,viewportOffset:i,ancestorOffset:o});"number"==typeof i&&(i={top:i,bottom:i,left:i,right:i});const a={target:this.domConverter.viewRangeToDom(s),viewportOffset:i,ancestorOffset:o,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",a,r),(0,n.scrollViewportToShowTarget)(a)}focus(){if(!this.document.isFocused){const e=this.document.selection.editableElement;e&&(this.domConverter.focus(e),this.forceRender())}}change(e){if(this.isRenderingInProgress||this._postFixersInProgress)throw new n.CKEditorError("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){n.CKEditorError.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(zt).flush(),this.change((()=>{}))}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return Ee._createAt(e,t)}createPositionAfter(e){return Ee._createAfter(e)}createPositionBefore(e){return Ee._createBefore(e)}createRange(e,t){return new xe(e,t)}createRangeOn(e){return xe._createOn(e)}createRangeIn(e){return xe._createIn(e)}createSelection(...e){return new Se(...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 Jt{is(){throw new Error("is() method is abstract")}}class Yt extends Jt{constructor(e){super(),this.parent=null,this._attrs=(0,n.toMap)(e)}get document(){return null}get index(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildIndex(this)))throw new n.CKEditorError("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 n.CKEditorError("model-node-not-found-in-parent",this);return e}get offsetSize(){return 1}get endOffset(){return this.parent?this.startOffset+this.offsetSize:null}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return null!==this.parent&&this.root.isAttached()}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){const i=this.getAncestors(t),n=e.getAncestors(t);let o=0;for(;i[o]==n[o]&&i[o];)o++;return 0===o?null:i[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),i=e.getPath(),o=(0,n.compareArrays)(t,i);switch(o){case"prefix":return!0;case"extension":return!1;default:return t[o](e[t[0]]=t[1],e)),{})),e}_clone(e){return new this.constructor(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,t){this._attrs.set(e,t)}_setAttributesTo(e){this._attrs=(0,n.toMap)(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}Yt.prototype.is=function(e){return"node"===e||"model:node"===e};class Qt{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 n.CKEditorError("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){let t=0;for(const i of this._nodes){if(e>=t&&ee.toJSON()))}}class Xt extends Yt{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 Xt(this.data,this.getAttributes())}static fromJSON(e){return new Xt(e.data,e.attributes)}}Xt.prototype.is=function(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e};class ei extends Jt{constructor(e,t,i){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new n.CKEditorError("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new n.CKEditorError("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get startOffset(){return null!==this.textNode.startOffset?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return null!==this.startOffset?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}getPath(){const e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={}){const t=[];let i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}ei.prototype.is=function(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e};class ti extends Yt{constructor(e,t,i){super(t),this._children=new Qt,this.name=e,i&&this._insertChild(0,i)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let t=this;for(const i of e)t=t.getChild(t.offsetToIndex(i));return t}findAncestor(e,t={}){let i=t.includeSelf?this:this.parent;for(;i;){if(i.name===e)return i;i=i.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?Array.from(this._children).map((e=>e._clone(!0))):void 0;return new ti(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){return"string"==typeof e?[new Xt(e)]:((0,n.isIterable)(e)||(e=[e]),Array.from(e).map((e=>"string"==typeof e?new Xt(e):e instanceof ei?new Xt(e.data,e.getAttributes()):e)))}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}static fromJSON(e){let t;if(e.children){t=[];for(const i of e.children)i.name?t.push(ti.fromJSON(i)):t.push(Xt.fromJSON(i))}return new ti(e.name,e.attributes,t)}}ti.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 ii{constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new n.CKEditorError("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new n.CKEditorError("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=oi._createAt(this.boundaries["backward"==this.direction?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null,this._visitedParent=this.position.parent}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i,n,o;do{n=this.position,o=this._visitedParent,({done:t,value:i}=this.next())}while(!t&&e(i));t||(this._position=n,this._visitedParent=o)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),i=this._visitedParent;if(null===i.parent&&t.offset===i.maxOffset)return{done:!0,value:void 0};if(i===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const n=si(t,i),o=n||ri(t,i,n);if(o instanceof ti){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}else t.path.push(0),this._visitedParent=o;return this._position=t,ni("elementStart",o,e,t,1)}if(o instanceof Xt){let n;if(this.singleCharacters)n=1;else{let e=o.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offsete&&(e=this.boundaries.start.offset),n=t.offset-e}const o=t.offset-s.startOffset,r=new ei(s,o-n,n);return t.offset-=n,this._position=t,ni("text",r,e,t,n)}return t.path.pop(),this._position=t,this._visitedParent=i.parent,ni("elementStart",i,e,t,1)}}function ni(e,t,i,n,o){return{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:n,length:o}}}class oi extends Jt{constructor(e,t,i="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new n.CKEditorError("model-position-root-invalid",e);if(!(t instanceof Array)||0===t.length)throw new n.CKEditorError("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=i}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;t1)return!1;if(1===t)return li(e,this,i);if(-1===t)return li(this,e,i)}return this.path.length===e.path.length||(this.path.length>e.path.length?ci(this.path,t):ci(e.path,t))}hasSameParentAs(e){if(this.root!==e.root)return!1;const t=this.getParentPath(),i=e.getParentPath();return"same"==(0,n.compareArrays)(t,i)}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=oi._createAt(this)}return t}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){const t=e.movedRange;return t.containsPosition(this)||t.start.isEqual(this)&&"toNext"==this.stickiness?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(e){const t=e.movedRange;let i;return t.containsPosition(this)||t.start.isEqual(this)?(i=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(i=i._getTransformedByDeletion(e.deletionPosition,1))):i=this.isEqual(e.deletionPosition)?oi._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),i}_getTransformedByDeletion(e,t){const i=oi._createAt(this);if(this.root!=e.root)return i;if("same"==(0,n.compareArrays)(e.getParentPath(),this.getParentPath())){if(e.offsetthis.offset)return null;i.offset-=t}}else if("prefix"==(0,n.compareArrays)(e.getParentPath(),this.getParentPath())){const n=e.path.length-1;if(e.offset<=this.path[n]){if(e.offset+t>this.path[n])return null;i.path[n]-=t}}return i}_getTransformedByInsertion(e,t){const i=oi._createAt(this);if(this.root!=e.root)return i;if("same"==(0,n.compareArrays)(e.getParentPath(),this.getParentPath()))(e.offset=t;){if(e.path[n]+o!==i.maxOffset)return!1;o=1,n--,i=i.parent}return!0}(e,i+1)}function ci(e,t){for(;tt+1;){const t=n.maxOffset-i.offset;0!==t&&e.push(new di(i,i.getShiftedBy(t))),i.path=i.path.slice(0,-1),i.offset++,n=n.parent}for(;i.path.length<=this.end.path.length;){const t=this.end.path[i.path.length-1],n=t-i.offset;0!==n&&e.push(new di(i,i.getShiftedBy(n))),i.offset=t,i.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new ii(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new ii(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new ii(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 di(this.start,this.end)]}getTransformedByOperations(e){const t=[new di(this.start,this.end)];for(const i of e)for(let e=0;e0?new this(i,n):new this(n,i)}static _createIn(e){return new this(oi._createAt(e,0),oi._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(oi._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new n.CKEditorError("range-create-from-ranges-empty-array",null);if(1==e.length)return e[0].clone();const t=e[0];e.sort(((e,t)=>e.start.isAfter(t.start)?1:-1));const i=e.indexOf(t),o=new this(t.start,t.end);if(i>0)for(let t=i-1;e[t].end.isEqual(o.start);t++)o.start=oi._createAt(e[t].start);for(let t=i+1;t{if(t.viewPosition)return;const i=this._modelToViewMapping.get(t.modelPosition.parent);if(!i)throw new n.CKEditorError("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(i,t.modelPosition.offset)}),{priority:"low"}),this.on("viewToModelPosition",((e,t)=>{if(t.modelPosition)return;const i=this.findMappedViewAncestor(t.viewPosition),n=this._viewToModelMapping.get(i),o=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,i);t.modelPosition=oi._createAt(n,o)}),{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const i=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const t of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(t);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e),this._modelToViewMapping.get(i)==e&&this._modelToViewMapping.delete(i))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)}bindElementToMarker(e,t){const i=this._markerNameToElements.get(t)||new Set;i.add(e);const n=this._elementToMarkerNames.get(e)||new Set;n.add(t),this._markerNameToElements.set(t,i),this._elementToMarkerNames.set(e,n)}unbindElementFromMarkerName(e,t){const i=this._markerNameToElements.get(t);i&&(i.delete(e),0==i.size&&this._markerNameToElements.delete(t));const n=this._elementToMarkerNames.get(e);n&&(n.delete(t),0==n.size&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){const e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(const[e,t]of this._deferredBindingRemovals)e.root==t&&this.unbindViewElement(e);this._deferredBindingRemovals=new Map}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this._deferredBindingRemovals=new Map}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new di(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new xe(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){const t={viewPosition:e,mapper:this};return this.fire("viewToModelPosition",t),t.modelPosition}toViewPosition(e,t={}){const i={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",i),i.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const i=new Set;for(const e of t)if(e.is("attributeElement"))for(const t of e.getElementsWithSameId())i.add(t);else i.add(e);return i}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,i){if(i!=e)return this._toModelOffset(e.parent,e.index,i)+this._toModelOffset(e,t,e);if(e.is("$text"))return t;let n=0;for(let i=0;i1?t[0]+":"+t[1]:t[0]}class gi extends((0,n.EmitterMixin)()){constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,i){const n=this._createConversionApi(i,e.getRefreshedItems());for(const t of e.getMarkersToRemove())this._convertMarkerRemove(t.name,t.range,n);const o=this._reduceChanges(e.getChanges());for(const e of o)"insert"===e.type?this._convertInsert(di._createFromPositionAndShift(e.position,e.length),n):"reinsert"===e.type?this._convertReinsert(di._createFromPositionAndShift(e.position,e.length),n):"remove"===e.type?this._convertRemove(e.position,e.length,e.name,n):this._convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,n);for(const e of n.mapper.flushUnboundMarkerNames()){const i=t.get(e).getRange();this._convertMarkerRemove(e,i,n),this._convertMarkerAdd(e,i,n)}for(const t of e.getMarkersToAdd())this._convertMarkerAdd(t.name,t.range,n);n.mapper.flushDeferredBindings(),n.consumable.verifyAllConsumed("insert")}convert(e,t,i,n={}){const o=this._createConversionApi(i,void 0,n);this._convertInsert(e,o);for(const[e,i]of t)this._convertMarkerAdd(e,i,o);o.consumable.verifyAllConsumed("insert")}convertSelection(e,t,i){const n=this._createConversionApi(i);this.fire("cleanSelection",{selection:e},n);const o=e.getFirstPosition().root;if(!n.mapper.toViewElement(o))return;const s=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(n.consumable,e,s),this.fire("selection",{selection:e},n),e.isCollapsed){for(const t of s)if(n.consumable.test(e,"addMarker:"+t.name)){const i=t.getRange();if(!fi(e.getFirstPosition(),t,n.mapper))continue;const o={item:e,markerName:t.name,markerRange:i};this.fire(`addMarker:${t.name}`,o,n)}for(const t of e.getAttributeKeys())if(n.consumable.test(e,"attribute:"+t)){const i={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};this.fire(`attribute:${t}:$text`,i,n)}}}_convertInsert(e,t,i={}){i.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,Array.from(e));for(const i of Array.from(e.getWalker({shallow:!0})).map(pi))this._testAndFire("insert",i,t)}_convertRemove(e,t,i,n){this.fire(`remove:${i}`,{position:e,length:t},n)}_convertAttribute(e,t,i,n,o){this._addConsumablesForRange(o.consumable,e,`attribute:${t}`);for(const s of e){const e={item:s.item,range:di._createFromPositionAndShift(s.previousPosition,s.length),attributeKey:t,attributeOldValue:i,attributeNewValue:n};this._testAndFire(`attribute:${t}`,e,o)}}_convertReinsert(e,t){const i=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,i);for(const e of i.map(pi))this._testAndFire("insert",{...e,reconversion:!0},t)}_convertMarkerAdd(e,t,i){if("$graveyard"==t.root.rootName)return;const n=`addMarker:${e}`;if(i.consumable.add(t,n),this.fire(n,{markerName:e,markerRange:t},i),i.consumable.consume(t,n)){this._addConsumablesForRange(i.consumable,t,n);for(const o of t.getItems()){if(!i.consumable.test(o,n))continue;const s={item:o,range:di._createOn(o),markerName:e,markerRange:t};this.fire(n,s,i)}}}_convertMarkerRemove(e,t,i){"$graveyard"!=t.root.rootName&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},i)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.changes}_addConsumablesForInsert(e,t){for(const i of t){const t=i.item;if(null===e.test(t,"insert")){e.add(t,"insert");for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i)}}return e}_addConsumablesForRange(e,t,i){for(const n of t.getItems())e.add(n,i);return e}_addConsumablesForSelection(e,t,i){e.add(t,"selection");for(const n of i)e.add(t,"addMarker:"+n.name);for(const i of t.getAttributeKeys())e.add(t,"attribute:"+i);return e}_testAndFire(e,t,i){const n=function(e,t){return`${e}:${t.item.is("element")?t.item.name:"$text"}`}(e,t),o=t.item.is("$textProxy")?i.consumable._getSymbolForTextProxy(t.item):t.item,s=this._firedEventsMap.get(i),r=s.get(o);if(r){if(r.has(n))return;r.add(n)}else s.set(o,new Set([n]));this.fire(n,t,i)}_testAndFireAddAttributes(e,t){const i={item:e,range:di._createOn(e)};for(const e of i.item.getAttributeKeys())i.attributeKey=e,i.attributeOldValue=null,i.attributeNewValue=i.item.getAttribute(e),this._testAndFire(`attribute:${e}`,i,t)}_createConversionApi(e,t=new Set,i={}){const n={...this._conversionApi,consumable:new hi,writer:e,options:i,convertItem:e=>this._convertInsert(di._createOn(e),n),convertChildren:e=>this._convertInsert(di._createIn(e),n,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,n),canReuseView:e=>!t.has(n.mapper.toModelElement(e))};return this._firedEventsMap.set(n,new Map),n}}function fi(e,t,i){const n=t.getRange(),o=Array.from(e.getAncestors());return o.shift(),o.reverse(),!o.some((e=>{if(n.containsItem(e))return!!i.toViewElement(e).getCustomProperty("addHighlight")}))}function pi(e){return{item:e.item,range:di._createFromPositionAndShift(e.previousPosition,e.length)}}class bi extends((0,n.EmitterMixin)(Jt)){constructor(...e){super(),this._lastRangeBackward=!1,this._attrs=new Map,this._ranges=[],e.length&&this.setTo(...e)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return 1===this._ranges.length&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let i=!1;for(const n of e._ranges)if(t.isEqual(n)){i=!0;break}if(!i)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new di(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 di(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 di(e.start,e.end):null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}setTo(...e){let[t,i,o]=e;if("object"==typeof i&&(o=i,i=void 0),null===t)this._setRanges([]);else if(t instanceof bi)this._setRanges(t.getRanges(),t.isBackward);else if(t&&"function"==typeof t.getRanges)this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof di)this._setRanges([t],!!o&&!!o.backward);else if(t instanceof oi)this._setRanges([new di(t)]);else if(t instanceof Yt){const e=!!o&&!!o.backward;let s;if("in"==i)s=di._createIn(t);else if("on"==i)s=di._createOn(t);else{if(void 0===i)throw new n.CKEditorError("model-selection-setto-required-second-parameter",[this,t]);s=new di(oi._createAt(t,i))}this._setRanges([s],e)}else{if(!(0,n.isIterable)(t))throw new n.CKEditorError("model-selection-setto-not-selectable",[this,t]);this._setRanges(t,o&&!!o.backward)}}_setRanges(e,t=!1){const i=Array.from(e),o=i.some((t=>{if(!(t instanceof di))throw new n.CKEditorError("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every((e=>!e.isEqual(t)))}));(i.length!==this._ranges.length||o)&&(this._replaceAllRanges(i),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(null===this.anchor)throw new n.CKEditorError("model-selection-setfocus-no-ranges",[this,e]);const i=oi._createAt(e,t);if("same"==i.compareWith(this.focus))return;const o=this.anchor;this._ranges.length&&this._popRange(),"before"==i.compareWith(o)?(this._pushRange(new di(i,o)),this._lastRangeBackward=!0):(this._pushRange(new di(o,i)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const i=_i(t.start,e);ki(i,t)&&(yield i);for(const i of t.getWalker()){const n=i.item;"elementEnd"==i.type&&vi(n,e,t)&&(yield n)}const n=_i(t.end,e);Ci(n,t)&&(yield n)}}containsEntireContent(e=this.anchor.root){const t=oi._createAt(e,0),i=oi._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new di(e.start,e.end))}_checkRange(e){for(let t=0;t0;)this._popRange()}_popRange(){this._ranges.pop()}}function wi(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&!!e.parent)}function vi(e,t,i){return wi(e,t)&&yi(e,i)}function _i(e,t){const i=e.parent.root.document.model.schema,n=e.parent.getAncestors({parentFirst:!0,includeSelf:!0});let o=!1;const s=n.find((e=>!o&&(o=i.isLimit(e),!o&&wi(e,t))));return n.forEach((e=>t.add(e))),s}function yi(e,t){const i=function(e){const t=e.root.document.model.schema;let i=e.parent;for(;i;){if(t.isBlock(i))return i;i=i.parent}}(e);return!i||!t.containsRange(di._createOn(i),!0)}function ki(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.start.isTouching(oi._createAt(e,e.maxOffset))&&yi(e,t))}function Ci(e,t){return!!e&&(!(!t.isCollapsed&&!e.isEmpty)||!t.end.isTouching(oi._createAt(e,0))&&yi(e,t))}bi.prototype.is=function(e){return"selection"===e||"model:selection"===e};class Ai extends((0,n.EmitterMixin)(di)){constructor(e,t){super(e,t),Ei.call(this)}detach(){this.stopListening()}toRange(){return new di(this.start,this.end)}static fromRange(e){return new Ai(e.start,e.end)}}function Ei(){this.listenTo(this.root.document.model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&xi.call(this,i)}),{priority:"low"})}function xi(e){const t=this.getTransformedByOperation(e),i=di._createFromRanges(t),n=!i.isEqual(this),o=function(e,t){switch(t.type){case"insert":return e.containsPosition(t.position);case"move":case"remove":case"reinsert":case"merge":return e.containsPosition(t.sourcePosition)||e.start.isEqual(t.sourcePosition)||e.containsPosition(t.targetPosition);case"split":return e.containsPosition(t.splitPosition)||e.containsPosition(t.insertionPosition)}return!1}(this,e);let s=null;if(n){"$graveyard"==i.root.rootName&&(s="remove"==e.type?e.sourcePosition:e.deletionPosition);const t=this.toRange();this.start=i.start,this.end=i.end,this.fire("change:range",t,{deletionPosition:s})}else o&&this.fire("change:content",this.toRange(),{deletionPosition:s})}Ai.prototype.is=function(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e};const Ti="selection:";class Si extends((0,n.EmitterMixin)(Jt)){constructor(e){super(),this._selection=new Pi(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 Ti+e}static _isStoreAttributeKey(e){return e.startsWith(Ti)}}Si.prototype.is=function(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e};class Pi extends bi{constructor(e){super(),this.markers=new n.Collection({idProperty:"name"}),this._attributePriority=new Map,this._selectionRestorePosition=null,this._hasChangedRange=!1,this._overriddenGravityRegister=new Set,this._observedMarkers=new Set,this._model=e.model,this._document=e,this.listenTo(this._model,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&"marker"!=i.type&&"rename"!=i.type&&"noop"!=i.type&&(0==this._ranges.length&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))}),{priority:"lowest"}),this.on("change:range",(()=>{this._validateSelectionRanges(this.getRanges())})),this.listenTo(this._model.markers,"update",((e,t,i,n)=>{this._updateMarker(t,n)})),this.listenTo(this._document,"change",((e,t)=>{!function(e,t){const i=e.document.differ;for(const n of i.getChanges()){if("insert"!=n.type)continue;const i=n.position.parent;n.length===i.maxOffset&&e.enqueueChange(t,(e=>{const t=Array.from(i.getAttributeKeys()).filter((e=>e.startsWith(Ti)));for(const n of t)e.removeAttribute(n,i)}))}}(this._model,t)}))}get isCollapsed(){return 0===this._ranges.length?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let e=0;e{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=n.deletionPosition;const e=this._ranges.indexOf(t);this._ranges.splice(e,1),t.detach()}})),t}updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const t of this._model.markers){const i=t.name.split(":",1)[0];if(!this._observedMarkers.has(i))continue;const n=t.getRange();for(const i of this.getRanges())n.containsRange(i,!i.isCollapsed)&&e.push(t)}const i=Array.from(this.markers);for(const i of e)this.markers.has(i)||(this.markers.add(i),t=!0);for(const i of Array.from(this.markers))e.includes(i)||(this.markers.remove(i),t=!0);t&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateMarker(e,t){const i=e.name.split(":",1)[0];if(!this._observedMarkers.has(i))return;let n=!1;const o=Array.from(this.markers),s=this.markers.has(e);if(t){let i=!1;for(const e of this.getRanges())if(t.containsRange(e,!e.isCollapsed)){i=!0;break}i&&!s?(this.markers.add(e),n=!0):!i&&s&&(this.markers.remove(e),n=!0)}else s&&(this.markers.remove(e),n=!0);n&&this.fire("change:marker",{oldMarkers:o,directChange:!1})}_updateAttributes(e){const t=(0,n.toMap)(this._getSurroundingAttributes()),i=(0,n.toMap)(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 o=[];for(const[e,t]of this.getAttributes())i.has(e)&&i.get(e)===t||o.push(e);for(const[e]of i)this.hasAttribute(e)||o.push(e);o.length>0&&this.fire("change:attribute",{attributeKeys:o,directChange:!1})}_setAttribute(e,t,i=!0){const n=i?"normal":"low";return("low"!=n||"normal"!=this._attributePriority.get(e))&&(super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,n),!0))}_removeAttribute(e,t=!0){const i=t?"normal":"low";return!("low"==i&&"normal"==this._attributePriority.get(e)||(this._attributePriority.set(e,i),!super.hasAttribute(e)||(this._attrs.delete(e),0)))}_setAttributesTo(e){const t=new Set;for(const[t,i]of this.getAttributes())e.get(t)!==i&&this._removeAttribute(t,!1);for(const[i,n]of e)this._setAttribute(i,n,!1)&&t.add(i);return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())if(t.startsWith(Ti)){const i=t.substr(10);yield[i,e.getAttribute(t)]}}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;if("$graveyard"==e.root.rootName)return null;let i=null;if(this.isCollapsed){const n=e.textNode?e.textNode:e.nodeBefore,o=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(i=Ii(n,t)),i||(i=Ii(o,t)),!this.isGravityOverridden&&!i){let e=n;for(;e&&!i;)e=e.previousSibling,i=Ii(e,t)}if(!i){let e=o;for(;e&&!i;)e=e.nextSibling,i=Ii(e,t)}i||(i=this.getStoredAttributes())}else{const e=this.getFirstRange();for(const n of e){if(n.item.is("element")&&t.isObject(n.item)){i=Ii(n.item,t);break}if("text"==n.type){i=n.item.getAttributes();break}}}return i}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function Ii(e,t){if(!e)return null;if(e instanceof ei||e instanceof Xt)return e.getAttributes();if(!t.isInline(e))return null;if(!t.isObject(e))return[];const i=[];for(const[n,o]of e.getAttributes())t.checkAttribute("$text",n)&&!1!==t.getAttributeProperties(n).copyFromObject&&i.push([n,o]);return i}class Vi{constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}class Ri extends Vi{elementToElement(e){return this.add(function(e){const t=Mi(e.model),i=Ni(e.view,"container");return t.attributes.length&&(t.children=!0),n=>{n.on(`insert:${t.name}`,function(e,t=ji){return(i,n,o)=>{if(!t(n.item,o.consumable,{preflight:!0}))return;const s=e(n.item,o,n);if(!s)return;t(n.item,o.consumable);const r=o.mapper.toViewPosition(n.range.start);o.mapper.bindElements(n.item,s),o.writer.insert(r,s),o.convertAttributes(n.item),Wi(s,n.item.getChildren(),o,{reconversion:n.reconversion})}}(i,Hi(t)),{priority:e.converterPriority||"normal"}),(t.children||t.attributes.length)&&n.on("reduceChanges",zi(t),{priority:"low"})}}(e))}elementToStructure(e){return this.add(function(e){const t=Mi(e.model),i=Ni(e.view,"container");return t.children=!0,o=>{if(o._conversionApi.schema.checkChild(t.name,"$text"))throw new n.CKEditorError("conversion-element-to-structure-disallowed-text",o,{elementName:t.name});var s,r;o.on(`insert:${t.name}`,(s=i,r=Hi(t),(e,t,i)=>{if(!r(t.item,i.consumable,{preflight:!0}))return;const o=new Map;i.writer._registerSlotFactory(function(e,t,i){return(o,s)=>{const r=o.createContainerElement("$slot");let a=null;if("children"===s)a=Array.from(e.getChildren());else{if("function"!=typeof s)throw new n.CKEditorError("conversion-slot-mode-unknown",i.dispatcher,{modeOrFilter:s});a=Array.from(e.getChildren()).filter((e=>s(e)))}return t.set(r,a),r}}(t.item,o,i));const a=s(t.item,i,t);if(i.writer._clearSlotFactory(),!a)return;!function(e,t,i){const o=Array.from(t.values()).flat(),s=new Set(o);if(s.size!=o.length)throw new n.CKEditorError("conversion-slot-filter-overlap",i.dispatcher,{element:e});if(s.size!=e.childCount)throw new n.CKEditorError("conversion-slot-filter-incomplete",i.dispatcher,{element:e})}(t.item,o,i),r(t.item,i.consumable);const l=i.mapper.toViewPosition(t.range.start);i.mapper.bindElements(t.item,a),i.writer.insert(l,a),i.convertAttributes(t.item),function(e,t,i,n){i.mapper.on("modelToViewPosition",r,{priority:"highest"});let o=null,s=null;for([o,s]of t)Wi(e,s,i,n),i.writer.move(i.writer.createRangeIn(o),i.writer.createPositionBefore(o)),i.writer.remove(o);function r(e,t){const i=t.modelPosition.nodeAfter,n=s.indexOf(i);n<0||(t.viewPosition=t.mapper.findPositionIn(o,n))}i.mapper.off("modelToViewPosition",r)}(a,o,i,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),o.on("reduceChanges",zi(t),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){let t=(e=Zt(e)).model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;if(t.name&&(i+=":"+t.name),t.values)for(const i of t.values)e.view[i]=Ni(e.view[i],"attribute");else e.view=Ni(e.view,"attribute");const n=Di(e);return t=>{t.on(i,function(e){return(t,i,n)=>{if(!n.consumable.test(i.item,t.name))return;const o=e(i.attributeOldValue,n,i),s=e(i.attributeNewValue,n,i);if(!o&&!s)return;n.consumable.consume(i.item,t.name);const r=n.writer,a=r.document.selection;if(i.item instanceof bi||i.item instanceof Si)r.wrap(a.getFirstRange(),s);else{let e=n.mapper.toViewRange(i.range);null!==i.attributeOldValue&&o&&(e=r.unwrap(e,o)),null!==i.attributeNewValue&&s&&r.wrap(e,s)}}}(n),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){let t=(e=Zt(e)).model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;if(t.name&&(i+=":"+t.name),t.values)for(const i of t.values)e.view[i]=Li(e.view[i]);else e.view=Li(e.view);const o=Di(e);return t=>{var s;t.on(i,(s=o,(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const o=s(t.attributeOldValue,i,t),r=s(t.attributeNewValue,i,t);if(!o&&!r)return;i.consumable.consume(t.item,e.name);const a=i.mapper.toViewElement(t.item),l=i.writer;if(!a)throw new n.CKEditorError("conversion-attribute-to-attribute-on-text",i.dispatcher,t);if(null!==t.attributeOldValue&&o)if("class"==o.key){const e=(0,n.toArray)(o.value);for(const t of e)l.removeClass(t,a)}else if("style"==o.key){const e=Object.keys(o.value);for(const t of e)l.removeStyle(t,a)}else l.removeAttribute(o.key,a);if(null!==t.attributeNewValue&&r)if("class"==r.key){const e=(0,n.toArray)(r.value);for(const t of e)l.addClass(t,a)}else if("style"==r.key){const e=Object.keys(r.value);for(const t of e)l.setStyle(t,r.value[t],a)}else l.setAttribute(r.key,r.value,a)}),{priority:e.converterPriority||"normal"})}}(e))}markerToElement(e){return this.add(function(e){const t=Ni(e.view,"ui");return i=>{var n;i.on(`addMarker:${e.model}`,(n=t,(e,t,i)=>{t.isOpening=!0;const o=n(t,i);t.isOpening=!1;const s=n(t,i);if(!o||!s)return;const r=t.markerRange;if(r.isCollapsed&&!i.consumable.consume(r,e.name))return;for(const t of r)if(!i.consumable.consume(t.item,e.name))return;const a=i.mapper,l=i.writer;l.insert(a.toViewPosition(r.start),o),i.mapper.bindElementToMarker(o,t.markerName),r.isCollapsed||(l.insert(a.toViewPosition(r.end),s),i.mapper.bindElementToMarker(s,t.markerName)),e.stop()}),{priority:e.converterPriority||"normal"}),i.on(`removeMarker:${e.model}`,((e,t,i)=>{const n=i.mapper.markerNameToElements(t.markerName);if(n){for(const e of n)i.mapper.unbindElementFromMarkerName(e,t.markerName),i.writer.clear(i.writer.createRangeOn(e),e);i.writer.clearClonedElementsGroup(t.markerName),e.stop()}}),{priority:e.converterPriority||"normal"})}}(e))}markerToHighlight(e){return this.add(function(e){return t=>{var i;t.on(`addMarker:${e.model}`,(i=e.view,(e,t,n)=>{if(!t.item)return;if(!(t.item instanceof bi||t.item instanceof Si||t.item.is("$textProxy")))return;const o=Fi(i,t,n);if(!o)return;if(!n.consumable.consume(t.item,e.name))return;const s=n.writer,r=Oi(s,o),a=s.document.selection;if(t.item instanceof bi||t.item instanceof Si)s.wrap(a.getFirstRange(),r);else{const e=n.mapper.toViewRange(t.range),i=s.wrap(e,r);for(const e of i.getItems())if(e.is("attributeElement")&&e.isSimilar(r)){n.mapper.bindElementToMarker(e,t.markerName);break}}}),{priority:e.converterPriority||"normal"}),t.on(`addMarker:${e.model}`,function(e){return(t,i,n)=>{if(!i.item)return;if(!(i.item instanceof ti))return;const o=Fi(e,i,n);if(!o)return;if(!n.consumable.test(i.item,t.name))return;const s=n.mapper.toViewElement(i.item);if(s&&s.getCustomProperty("addHighlight")){n.consumable.consume(i.item,t.name);for(const e of di._createIn(i.item))n.consumable.consume(e.item,t.name);s.getCustomProperty("addHighlight")(s,o,n.writer),n.mapper.bindElementToMarker(s,i.markerName)}}}(e.view),{priority:e.converterPriority||"normal"}),t.on(`removeMarker:${e.model}`,function(e){return(t,i,n)=>{if(i.markerRange.isCollapsed)return;const o=Fi(e,i,n);if(!o)return;const s=Oi(n.writer,o),r=n.mapper.markerNameToElements(i.markerName);if(r){for(const e of r)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("attributeElement")?n.writer.unwrap(n.writer.createRangeOn(e),s):e.getCustomProperty("removeHighlight")(e,o.id,n.writer);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}markerToData(e){return this.add(function(e){const t=(e=Zt(e)).model;let i=e.view;return i||(i=i=>({group:t,name:i.substr(e.model.length+1)})),n=>{var o;n.on(`addMarker:${t}`,(o=i,(e,t,i)=>{const n=o(t.markerName,i);if(!n)return;const s=t.markerRange;i.consumable.consume(s,e.name)&&(Bi(s,!1,i,t,n),Bi(s,!0,i,t,n),e.stop())}),{priority:e.converterPriority||"normal"}),n.on(`removeMarker:${t}`,function(e){return(t,i,n)=>{const o=e(i.markerName,n);if(!o)return;const s=n.mapper.markerNameToElements(i.markerName);if(s){for(const e of s)n.mapper.unbindElementFromMarkerName(e,i.markerName),e.is("containerElement")?(r(`data-${o.group}-start-before`,e),r(`data-${o.group}-start-after`,e),r(`data-${o.group}-end-before`,e),r(`data-${o.group}-end-after`,e)):n.writer.clear(n.writer.createRangeOn(e),e);n.writer.clearClonedElementsGroup(i.markerName),t.stop()}function r(e,t){if(t.hasAttribute(e)){const i=new Set(t.getAttribute(e).split(","));i.delete(o.name),0==i.size?n.writer.removeAttribute(e,t):n.writer.setAttribute(e,Array.from(i).join(","),t)}}}}(i),{priority:e.converterPriority||"normal"})}}(e))}}function Oi(e,t){const i=e.createAttributeElement("span",t.attributes);return t.classes&&i._addClass(t.classes),"number"==typeof t.priority&&(i._priority=t.priority),i._id=t.id,i}function Bi(e,t,i,n,o){const s=t?e.start:e.end,r=s.nodeAfter&&s.nodeAfter.is("element")?s.nodeAfter:null,a=s.nodeBefore&&s.nodeBefore.is("element")?s.nodeBefore:null;if(r||a){let e,s;t&&r||!t&&!a?(e=r,s=!0):(e=a,s=!1);const l=i.mapper.toViewElement(e);if(l)return void function(e,t,i,n,o,s){const r=`data-${s.group}-${t?"start":"end"}-${i?"before":"after"}`,a=e.hasAttribute(r)?e.getAttribute(r).split(","):[];a.unshift(s.name),n.writer.setAttribute(r,a.join(","),e),n.mapper.bindElementToMarker(e,o.markerName)}(l,t,s,i,n,o)}!function(e,t,i,n,o){const s=`${o.group}-${t?"start":"end"}`,r=o.name?{name:o.name}:null,a=i.writer.createUIElement(s,r);i.writer.insert(e,a),i.mapper.bindElementToMarker(a,n.markerName)}(i.mapper.toViewPosition(s),t,i,n,o)}function Mi(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 Ni(e,t){return"function"==typeof e?e:(i,n)=>function(e,t,i){let n;"string"==typeof e&&(e={name:e});const o=t.writer,s=Object.assign({},e.attributes);if("container"==i)n=o.createContainerElement(e.name,s);else if("attribute"==i){const t={priority:e.priority||Le.DEFAULT_PRIORITY};n=o.createAttributeElement(e.name,s,t)}else n=o.createUIElement(e.name,s);if(e.styles){const t=Object.keys(e.styles);for(const i of t)o.setStyle(i,e.styles[i],n)}if(e.classes){const t=e.classes;if("string"==typeof t)o.addClass(t,n);else for(const e of t)o.addClass(e,n)}return n}(e,n,t)}function Di(e){return e.model.values?(t,i,n)=>{const o=e.view[t];return o?o(t,i,n):null}:e.view}function Li(e){return"string"==typeof e?t=>({key:e,value:t}):"object"==typeof e?e.value?()=>e:t=>({key:e.key,value:t}):e}function Fi(e,t,i){const n="function"==typeof e?e(t,i):e;return n?(n.priority||(n.priority=10),n.id||(n.id=t.markerName),n):null}function zi(e){const t=function(e){return(t,i)=>{if(!t.is("element",e.name))return!1;if("attribute"==i.type){if(e.attributes.includes(i.attributeKey))return!0}else if(e.children)return!0;return!1}}(e);return(e,i)=>{const n=[];i.reconvertedElements||(i.reconvertedElements=new Set);for(const e of i.changes){const o="attribute"==e.type?e.range.start.nodeAfter:e.position.parent;if(o&&t(o,e)){if(!i.reconvertedElements.has(o)){i.reconvertedElements.add(o);const e=oi._createBefore(o);let t=n.length;for(let i=n.length-1;i>=0;i--){const o=n[i],s=("attribute"==o.type?o.range.start:o.position).compareWith(e);if("before"==s||"remove"==o.type&&"same"==s)break;t=i}n.splice(t,0,{type:"remove",name:o.name,position:e,length:1},{type:"reinsert",name:o.name,position:e,length:1})}}else n.push(e)}i.changes=n}}function Hi(e){return(t,i,n={})=>{const o=["insert"];for(const i of e.attributes)t.hasAttribute(i)&&o.push(`attribute:${i}`);return!!o.every((e=>i.test(t,e)))&&(n.preflight||o.forEach((e=>i.consume(t,e))),!0)}}function Wi(e,t,i,n){for(const o of t)Ui(e.root,o,i,n)||i.convertItem(o)}function Ui(e,t,i,n){const{writer:o,mapper:s}=i;if(!n.reconversion)return!1;const r=s.toViewElement(t);return!(!r||r.root==e||!i.canReuseView(r)||(o.move(o.createRangeOn(r),s.toViewPosition(oi._createBefore(t))),0))}function ji(e,t,{preflight:i}={}){return i?t.test(e,"insert"):t.consume(e,"insert")}function $i(e){const{schema:t,document:i}=e.model;for(const n of i.getRoots())if(n.isEmpty&&!t.checkChild(n,"$text")&&t.checkChild(n,"paragraph"))return e.insertElement("paragraph",n),!0;return!1}function qi(e,t,i){const n=i.createContext(e);return!!i.checkChild(n,"paragraph")&&!!i.checkChild(n.push("paragraph"),t)}function Ki(e,t){const i=t.createElement("paragraph");return t.insert(i,e),t.createPositionAt(i,0)}class Zi extends Vi{elementToElement(e){return this.add(Gi(e))}elementToAttribute(e){return this.add(function(e){Qi(e=Zt(e));const t=Xi(e,!1),i=Ji(e.view),n=i?`element:${i}`:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){let t=null;("string"==typeof(e=Zt(e)).view||e.view.key)&&(t=function(e){"string"==typeof e.view&&(e.view={key:e.view});const t=e.view.key;let i;return i="class"==t||"style"==t?{["class"==t?"classes":"styles"]:e.view.value}:{attributes:{[t]:void 0===e.view.value?/[\s\S]*/:e.view.value}},e.view.name&&(i.name=e.view.name),e.view=i,t}(e)),Qi(e,t);const i=Xi(e,!0);return t=>{t.on("element",i,{priority:e.converterPriority||"low"})}}(e))}elementToMarker(e){return this.add(function(e){const t=function(e){return(t,i)=>{const n="string"==typeof e?e:e(t,i);return i.writer.createElement("$marker",{"data-name":n})}}(e.model);return Gi({...e,model:t})}(e))}dataToMarker(e){return this.add(function(e){(e=Zt(e)).model||(e.model=t=>t?e.view+":"+t:e.view);const t={view:e.view,model:e.model},i=Yi(en(t,"start")),o=Yi(en(t,"end"));return s=>{s.on(`element:${e.view}-start`,i,{priority:e.converterPriority||"normal"}),s.on(`element:${e.view}-end`,o,{priority:e.converterPriority||"normal"});const r=n.priorities.low,a=n.priorities.highest,l=n.priorities.get(e.converterPriority)/a;s.on("element",function(e){return(t,i,n)=>{const o=`data-${e.view}`;function s(t,o){for(const s of o){const o=e.model(s,n),r=n.writer.createElement("$marker",{"data-name":o});n.writer.insert(r,t),i.modelCursor.isEqual(t)?i.modelCursor=i.modelCursor.getShiftedBy(1):i.modelCursor=i.modelCursor._getTransformedByInsertion(t,1),i.modelRange=i.modelRange._getTransformedByInsertion(t,1)[0]}}(n.consumable.test(i.viewItem,{attributes:o+"-end-after"})||n.consumable.test(i.viewItem,{attributes:o+"-start-after"})||n.consumable.test(i.viewItem,{attributes:o+"-end-before"})||n.consumable.test(i.viewItem,{attributes:o+"-start-before"}))&&(i.modelRange||Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor)),n.consumable.consume(i.viewItem,{attributes:o+"-end-after"})&&s(i.modelRange.end,i.viewItem.getAttribute(o+"-end-after").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-start-after"})&&s(i.modelRange.end,i.viewItem.getAttribute(o+"-start-after").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-end-before"})&&s(i.modelRange.start,i.viewItem.getAttribute(o+"-end-before").split(",")),n.consumable.consume(i.viewItem,{attributes:o+"-start-before"})&&s(i.modelRange.start,i.viewItem.getAttribute(o+"-start-before").split(",")))}}(t),{priority:r+l})}}(e))}}function Gi(e){const t=Yi(e=Zt(e)),i=Ji(e.view),n=i?`element:${i}`:"element";return i=>{i.on(n,t,{priority:e.converterPriority||"normal"})}}function Ji(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}function Yi(e){const t=new y(e.view);return(i,n,o)=>{const s=t.match(n.viewItem);if(!s)return;const r=s.match;if(r.name=!0,!o.consumable.test(n.viewItem,r))return;const a=function(e,t,i){return e instanceof Function?e(t,i):i.writer.createElement(e)}(e.model,n.viewItem,o);a&&o.safeInsert(a,n.modelCursor)&&(o.consumable.consume(n.viewItem,r),o.convertChildren(n.viewItem,a),o.updateConversionResult(a,n))}}function Qi(e,t=null){const i=null===t||(e=>e.getAttribute(t)),n="object"!=typeof e.model?e.model:e.model.key,o="object"!=typeof e.model||void 0===e.model.value?i:e.model.value;e.model={key:n,value:o}}function Xi(e,t){const i=new y(e.view);return(n,o,s)=>{if(!o.modelRange&&t)return;const r=i.match(o.viewItem);if(!r)return;if(function(e,t){const i="function"==typeof e?e(t):e;return!("object"==typeof i&&!Ji(i))&&(!i.classes&&!i.attributes&&!i.styles)}(e.view,o.viewItem)?r.match.name=!0:delete r.match.name,!s.consumable.test(o.viewItem,r.match))return;const a=e.model.key,l="function"==typeof e.model.value?e.model.value(o.viewItem,s):e.model.value;if(null===l)return;o.modelRange||Object.assign(o,s.convertChildren(o.viewItem,o.modelCursor));const c=function(e,t,i,n){let o=!1;for(const s of Array.from(e.getItems({shallow:i})))n.schema.checkAttribute(s,t.key)&&(o=!0,s.hasAttribute(t.key)||n.writer.setAttribute(t.key,t.value,s));return o}(o.modelRange,{key:a,value:l},t,s);c&&(s.consumable.test(o.viewItem,{name:!0})&&(r.match.name=!0),s.consumable.consume(o.viewItem,r.match))}}function en(e,t){return{view:`${e.view}-${t}`,model:(t,i)=>{const n=t.getAttribute("name"),o=e.model(n,i);return i.writer.createElement("$marker",{"data-name":o})}}}function tn(e,t){return e.isCollapsed?function(e,t){const i=e.start,n=t.getNearestSelectionRange(i);if(!n){const e=i.getAncestors().reverse().find((e=>t.isObject(e)));return e?di._createOn(e):null}if(!n.isCollapsed)return n;const o=n.start;return i.isEqual(o)?null:new di(o)}(e,t):function(e,t){const{start:i,end:n}=e,o=t.checkChild(i,"$text"),s=t.checkChild(n,"$text"),r=t.getLimitElement(i),a=t.getLimitElement(n);if(r===a){if(o&&s)return null;if(function(e,t,i){const n=e.nodeAfter&&!i.isLimit(e.nodeAfter)||i.checkChild(e,"$text"),o=t.nodeBefore&&!i.isLimit(t.nodeBefore)||i.checkChild(t,"$text");return n||o}(i,n,t)){const e=i.nodeAfter&&t.isSelectable(i.nodeAfter)?null:t.getNearestSelectionRange(i,"forward"),o=n.nodeBefore&&t.isSelectable(n.nodeBefore)?null:t.getNearestSelectionRange(n,"backward"),s=e?e.start:i,r=o?o.end:n;return new di(s,r)}}const l=r&&!r.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const e=i.nodeAfter&&n.nodeBefore&&i.nodeAfter.parent===n.nodeBefore.parent,o=l&&(!e||!on(i.nodeAfter,t)),s=c&&(!e||!on(n.nodeBefore,t));let d=i,u=n;return o&&(d=oi._createBefore(nn(r,t))),s&&(u=oi._createAfter(nn(a,t))),new di(d,u)}return null}(e,t)}function nn(e,t){let i=e,n=i;for(;t.isLimit(n)&&n.parent;)i=n,n=n.parent;return i}function on(e,t){return e&&t.isSelectable(e)}class sn extends((0,n.ObservableMixin)()){constructor(e,t){super(),this.model=e,this.view=new Gt(t),this.mapper=new ui,this.downcastDispatcher=new gi({mapper:this.mapper,schema:e.schema});const i=this.model.document,o=i.selection,s=this.model.markers;var r,a,l;this.listenTo(this.model,"_beforeChanges",(()=>{this.view._disableRendering(!0)}),{priority:"highest"}),this.listenTo(this.model,"_afterChanges",(()=>{this.view._disableRendering(!1)}),{priority:"lowest"}),this.listenTo(i,"change",(()=>{this.view.change((e=>{this.downcastDispatcher.convertChanges(i.differ,s,e),this.downcastDispatcher.convertSelection(o,s,e)}))}),{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(i,n)=>{const o=n.newSelection,s=[];for(const e of o.getRanges())s.push(t.toModelRange(e));const r=e.createSelection(s,{backward:o.isBackward});r.isEqual(e.document.selection)||e.change((e=>{e.setSelection(r)}))}}(this.model,this.mapper)),this.listenTo(this.view.document,"beforeinput",(r=this.mapper,a=this.model.schema,l=this.view,(e,t)=>{if(!l.document.isComposing||n.env.isAndroid)for(let e=0;e{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewPosition(t.range.start),s=n.createText(t.item.data);n.insert(o,s)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)}),{priority:"lowest"}),this.downcastDispatcher.on("remove",((e,t,i)=>{const n=i.mapper.toViewPosition(t.position),o=t.position.getShiftedBy(t.length),s=i.mapper.toViewPosition(o,{isPhantom:!0}),r=i.writer.createRange(n,s),a=i.writer.remove(r.getTrimmed());for(const e of i.writer.createRangeIn(a).getItems())i.mapper.unbindViewElement(e,{defer:!0})}),{priority:"low"}),this.downcastDispatcher.on("cleanSelection",((e,t,i)=>{const n=i.writer,o=n.document.selection;for(const e of o.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&i.writer.mergeAttributes(e.start);n.setSelection(null)})),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=t.selection;if(n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const o=[];for(const e of n.getRanges())o.push(i.mapper.toViewRange(e));i.writer.setSelection(o,{backward:n.isBackward})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,i)=>{const n=t.selection;if(!n.isCollapsed)return;if(!i.consumable.consume(n,"selection"))return;const o=i.writer,s=n.getFirstPosition(),r=i.mapper.toViewPosition(s),a=o.breakAttributes(r);o.setSelection(a)}),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using((e=>{if("$graveyard"==e.rootName)return null;const t=new Ce(this.view.document,e.name);return t.rootName=e.rootName,this.mapper.bindElements(e,t),t}))}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const t="string"==typeof e?e:e.name,i=this.model.markers.get(t);if(!i)throw new n.CKEditorError("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change((()=>{this.model.markers._refresh(i)}))}reconvertItem(e){this.model.change((()=>{this.model.document.differ._refreshItem(e)}))}}class rn{constructor(){this._consumables=new Map}add(e,t){let i;e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):(this._consumables.has(e)?i=this._consumables.get(e):(i=new ln(e),this._consumables.set(e,i)),i.add(t))}test(e,t){const i=this._consumables.get(e);return void 0===i?null:e.is("$text")||e.is("documentFragment")?i:i.test(t)}consume(e,t){return!!this.test(e,t)&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!1):this._consumables.get(e).consume(t),!0)}revert(e,t){const i=this._consumables.get(e);void 0!==i&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):i.revert(t))}static consumablesFromElement(e){const t={element:e,name:!0,attributes:[],classes:[],styles:[]},i=e.getAttributeKeys();for(const e of i)"style"!=e&&"class"!=e&&t.attributes.push(e);const n=e.getClassNames();for(const e of n)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 rn),e.is("$text"))return t.add(e),t;e.is("element")&&t.add(e,rn.consumablesFromElement(e)),e.is("documentFragment")&&t.add(e);for(const i of e.getChildren())t=rn.createFrom(i,t);return t}}const an=["attributes","classes","styles"];class ln{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 an)t in e&&this._add(t,e[t])}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const t of an)if(t in e){const i=this._test(t,e[t]);if(!0!==i)return i}return!0}consume(e){e.name&&(this._canConsumeName=!1);for(const t of an)t in e&&this._consume(t,e[t])}revert(e){e.name&&(this._canConsumeName=!0);for(const t of an)t in e&&this._revert(t,e[t])}_add(e,t){const i=(0,E.Z)(t)?t:[t],o=this._consumables[e];for(const t of i){if("attributes"===e&&("class"===t||"style"===t))throw new n.CKEditorError("viewconsumable-invalid-attribute",this);if(o.set(t,!0),"styles"===e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))o.set(e,!0)}}_test(e,t){const i=(0,E.Z)(t)?t:[t],n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){const e=n.get(t);if(void 0===e)return null;if(!e)return!1}else{const e="class"==t?"classes":"styles",i=this._test(e,[...this._consumables[e].keys()]);if(!0!==i)return i}return!0}_consume(e,t){const i=(0,E.Z)(t)?t:[t],n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t){if(n.set(t,!1),"styles"==e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))n.set(e,!1)}else{const e="class"==t?"classes":"styles";this._consume(e,[...this._consumables[e].keys()])}}_revert(e,t){const i=(0,E.Z)(t)?t:[t],n=this._consumables[e];for(const t of i)if("attributes"!==e||"class"!==t&&"style"!==t)!1===n.get(t)&&n.set(t,!0);else{const e="class"==t?"classes":"styles";this._revert(e,[...this._consumables[e].keys()])}}}class cn extends((0,n.ObservableMixin)()){constructor(){super(),this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",((e,t)=>{t[0]=new dn(t[0])}),{priority:"highest"}),this.on("checkChild",((e,t)=>{t[0]=new dn(t[0]),t[1]=this.getDefinition(t[1])}),{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new n.CKEditorError("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 n.CKEditorError("schema-cannot-extend-missing-item",this,{itemName:e});this._sourceDefinitions[e].push(Object.assign({},t)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(e){let t;return t="string"==typeof e?e:"is"in e&&(e.is("$text")||e.is("$textProxy"))?"$text":e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const t=this.getDefinition(e);return!(!t||!t.isBlock)}isLimit(e){const t=this.getDefinition(e);return!(!t||!t.isLimit&&!t.isObject)}isObject(e){const t=this.getDefinition(e);return!!t&&!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent)}isInline(e){const t=this.getDefinition(e);return!(!t||!t.isInline)}isSelectable(e){const t=this.getDefinition(e);return!(!t||!t.isSelectable&&!t.isObject)}isContent(e){const t=this.getDefinition(e);return!(!t||!t.isContent&&!t.isObject)}checkChild(e,t){return!!t&&this._checkContextMatch(t,e)}checkAttribute(e,t){const i=this.getDefinition(e.last);return!!i&&i.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof oi){const t=e.nodeBefore,i=e.nodeAfter;if(!(t instanceof ti))throw new n.CKEditorError("schema-check-merge-no-element-before",this);if(!(i instanceof ti))throw new n.CKEditorError("schema-check-merge-no-element-after",this);return this.checkMerge(t,i)}for(const i of t.getChildren())if(!this.checkChild(e,i))return!1;return!0}addChildCheck(e){this.on("checkChild",((t,[i,n])=>{if(!n)return;const o=e(i,n);"boolean"==typeof o&&(t.stop(),t.return=o)}),{priority:"high"})}addAttributeCheck(e){this.on("checkAttribute",((t,[i,n])=>{const o=e(i,n);"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;for(t=e instanceof oi?e.parent:(e instanceof di?[e]:Array.from(e.getRanges())).reduce(((e,t)=>{const i=t.getCommonAncestor();return e?e.getCommonAncestor(i,{includeSelf:!0}):i}),null);!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const i=[...e.getFirstPosition().getAncestors(),new Xt("",e.getAttributes())];return this.checkAttribute(i,t)}{const i=e.getRanges();for(const e of i)for(const i of e)if(this.checkAttribute(i.item,t))return!0}return!1}*getValidRanges(e,t){e=function*(e){for(const t of e)yield*t.getMinimalFlatRanges()}(e);for(const i of e)yield*this._getValidRangesForRange(i,t)}getNearestSelectionRange(e,t="both"){if("$graveyard"==e.root.rootName)return null;if(this.checkChild(e,"$text"))return new di(e);let i,n;const o=e.getAncestors().reverse().find((e=>this.isLimit(e)))||e.root;"both"!=t&&"backward"!=t||(i=new ii({boundaries:di._createIn(o),startPosition:e,direction:"backward"})),"both"!=t&&"forward"!=t||(n=new ii({boundaries:di._createIn(o),startPosition:e}));for(const e of function*(e,t){let i=!1;for(;!i;){if(i=!0,e){const t=e.next();t.done||(i=!1,yield{walker:e,value:t.value})}if(t){const e=t.next();e.done||(i=!1,yield{walker:t,value:e.value})}}}(i,n)){const t=e.walker==i?"elementEnd":"elementStart",n=e.value;if(n.type==t&&this.isObject(n.item))return di._createOn(n.item);if(this.checkChild(n.nextPosition,"$text"))return new di(n.nextPosition)}return null}findAllowedParent(e,t){let i=e.parent;for(;i;){if(this.checkChild(i,t))return i;if(this.isLimit(i))return null;i=i.parent}return null}setAllowedAttributes(e,t,i){const n=i.model;for(const[o,s]of Object.entries(t))n.schema.checkAttribute(e,o)&&i.setAttribute(o,s,e)}removeDisallowedAttributes(e,t){for(const i of e)if(i.is("$text"))Cn(this,i,t);else{const e=di._createIn(i).getPositions();for(const i of e)Cn(this,i.nodeBefore||i.parent,t)}}getAttributesWithProperty(e,t,i){const n={};for(const[o,s]of e.getAttributes()){const e=this.getAttributeProperties(o);void 0!==e[t]&&(void 0!==i&&i!==e[t]||(n[o]=s))}return n}createContext(e){return new dn(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,i=Object.keys(t);for(const n of i)e[n]=un(t[n],n);for(const t of i)hn(e,t);for(const t of i)mn(e,t);for(const t of i)gn(e,t);for(const t of i)fn(e,t),pn(e,t);for(const t of i)bn(e,t),wn(e,t),vn(e,t);this._compiledDefinitions=e}_checkContextMatch(e,t,i=t.length-1){const n=t.getItem(i);if(e.allowIn.includes(n.name)){if(0==i)return!0;{const e=this.getDefinition(n);return this._checkContextMatch(e,t,i-1)}}return!1}*_getValidRangesForRange(e,t){let i=e.start,n=e.start;for(const o of e.getItems({shallow:!0}))o.is("element")&&(yield*this._getValidRangesForRange(di._createIn(o),t)),this.checkAttribute(o,t)||(i.isEqual(n)||(yield new di(i,n)),i=oi._createAfter(o)),n=oi._createAfter(o);i.isEqual(n)||(yield new di(i,n))}}class dn{constructor(e){if(e instanceof dn)return e;let t;t="string"==typeof e?[e]:Array.isArray(e)?e:e.getAncestors({includeSelf:!0}),this._items=t.map(kn)}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 dn([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 un(e,t){const i={name:t,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],allowChildren:[],inheritTypesFrom:[]};return function(e,t){for(const i of e){const e=Object.keys(i).filter((e=>e.startsWith("is")));for(const n of e)t[n]=!!i[n]}}(e,i),_n(e,i,"allowIn"),_n(e,i,"allowContentOf"),_n(e,i,"allowWhere"),_n(e,i,"allowAttributes"),_n(e,i,"allowAttributesOf"),_n(e,i,"allowChildren"),_n(e,i,"inheritTypesFrom"),function(e,t){for(const i of e){const e=i.inheritAllFrom;e&&(t.allowContentOf.push(e),t.allowWhere.push(e),t.allowAttributesOf.push(e),t.inheritTypesFrom.push(e))}}(e,i),i}function hn(e,t){const i=e[t];for(const n of i.allowChildren){const i=e[n];i&&i.allowIn.push(t)}i.allowChildren.length=0}function mn(e,t){for(const i of e[t].allowContentOf)e[i]&&yn(e,i).forEach((e=>{e.allowIn.push(t)}));delete e[t].allowContentOf}function gn(e,t){for(const i of e[t].allowWhere){const n=e[i];if(n){const i=n.allowIn;e[t].allowIn.push(...i)}}delete e[t].allowWhere}function fn(e,t){for(const i of e[t].allowAttributesOf){const n=e[i];if(n){const i=n.allowAttributes;e[t].allowAttributes.push(...i)}}delete e[t].allowAttributesOf}function pn(e,t){const i=e[t];for(const t of i.inheritTypesFrom){const n=e[t];if(n){const e=Object.keys(n).filter((e=>e.startsWith("is")));for(const t of e)t in i||(i[t]=n[t])}}delete i.inheritTypesFrom}function bn(e,t){const i=e[t],n=i.allowIn.filter((t=>e[t]));i.allowIn=Array.from(new Set(n))}function wn(e,t){const i=e[t];for(const n of i.allowIn)e[n].allowChildren.push(t)}function vn(e,t){const i=e[t];i.allowAttributes=Array.from(new Set(i.allowAttributes))}function _n(e,t,i){for(const n of e){const e=n[i];"string"==typeof e?t[i].push(e):Array.isArray(e)&&t[i].push(...e)}}function yn(e,t){const i=e[t];return(n=e,Object.keys(n).map((e=>n[e]))).filter((e=>e.allowIn.includes(i.name)));var n}function kn(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 Cn(e,t,i){for(const n of t.getAttributeKeys())e.checkAttribute(t,n)||i.removeAttribute(n,t)}class An extends((0,n.EmitterMixin)()){constructor(e){super(),this._splitParts=new Map,this._cursorParents=new Map,this._modelCursor=null,this._emptyElementsToKeep=new Set,this.conversionApi={...e,consumable:null,writer:null,store:null,convertItem:(e,t)=>this._convertItem(e,t),convertChildren:(e,t)=>this._convertChildren(e,t),safeInsert:(e,t)=>this._safeInsert(e,t),updateConversionResult:(e,t)=>this._updateConversionResult(e,t),splitToAllowedParent:(e,t)=>this._splitToAllowedParent(e,t),getSplitParts:e=>this._getSplitParts(e),keepEmptyElement:e=>this._keepEmptyElement(e)}}convert(e,t,i=["$root"]){this.fire("viewCleanup",e),this._modelCursor=function(e,t){let i;for(const n of new dn(e)){const e={};for(const t of n.getAttributeKeys())e[t]=n.getAttribute(t);const o=t.createElement(n.name,e);i&&t.insert(o,i),i=oi._createAt(o,0)}return i}(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=rn.createFrom(e),this.conversionApi.store={};const{modelRange:n}=this._convertItem(e,this._modelCursor),o=t.createDocumentFragment();if(n){this._removeEmptyElements();for(const e of Array.from(this._modelCursor.parent.getChildren()))t.append(e,o);o.markers=function(e,t){const i=new Set,n=new Map,o=di._createIn(e).getItems();for(const e of o)e.is("element","$marker")&&i.add(e);for(const e of i){const i=e.getAttribute("data-name"),o=t.createPositionBefore(e);n.has(i)?n.get(i).end=o.clone():n.set(i,new di(o.clone())),t.remove(e)}return n}(o,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,o}_convertItem(e,t){const i={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,i,this.conversionApi):e.is("$text")?this.fire("text",i,this.conversionApi):this.fire("documentFragment",i,this.conversionApi),i.modelRange&&!(i.modelRange instanceof di))throw new n.CKEditorError("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:oi._createAt(t,0);const n=new di(i);for(const t of Array.from(e.getChildren())){const e=this._convertItem(t,i);e.modelRange instanceof di&&(n.end=e.modelRange.end,i=e.modelCursor)}return{modelRange:n,modelCursor:i}}_safeInsert(e,t){const i=this._splitToAllowedParent(e,t);return!!i&&(this.conversionApi.writer.insert(e,i.position),!0)}_updateConversionResult(e,t){const i=this._getSplitParts(e),n=this.conversionApi.writer;t.modelRange||(t.modelRange=n.createRange(n.createPositionBefore(e),n.createPositionAfter(i[i.length-1])));const o=this._cursorParents.get(e);t.modelCursor=o?n.createPositionAt(o,0):t.modelRange.end}_splitToAllowedParent(e,t){const{schema:i,writer:n}=this.conversionApi;let o=i.findAllowedParent(t,e);if(o){if(o===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(o)&&(o=null)}if(!o)return qi(t,e,i)?{position:Ki(t,n)}:null;const s=this.conversionApi.writer.split(t,o),r=[];for(const e of s.range.getWalker())if("elementEnd"==e.type)r.push(e.item);else{const t=r.pop(),i=e.item;this._registerSplitPair(t,i)}const a=s.range.end.parent;return this._cursorParents.set(e,a),{position:s.position,cursorParent:a}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);const i=this._splitParts.get(e);this._splitParts.set(t,i),i.push(t)}_getSplitParts(e){let t;return t=this._splitParts.has(e)?this._splitParts.get(e):[e],t}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){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 En{getHtml(e){const t=document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class xn{constructor(e){this.skipComments=!0,this.domParser=new DOMParser,this.domConverter=new At(e,{renderingMode:"data"}),this.htmlWriter=new En}toData(e){const t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this.domConverter.domToView(t,{skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode="marked"==e?"markedNbsp":"nbsp"}_toDom(e){e.match(/<(?:html|body|head|meta)(?:\s[^>]*)?>/i)||(e=`${e}`);const t=this.domParser.parseFromString(e,"text/html"),i=t.createDocumentFragment(),n=t.body.childNodes;for(;n.length>0;)i.appendChild(n[0]);return i}}class Tn extends((0,n.EmitterMixin)()){constructor(e,t){super(),this.model=e,this.mapper=new ui,this.downcastDispatcher=new gi({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewPosition(t.range.start),s=n.createText(t.item.data);n.insert(o,s)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,i)=>{i.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||i.convertChildren(t.item)}),{priority:"lowest"}),this.upcastDispatcher=new An({schema:e.schema}),this.viewDocument=new De(t),this.stylesProcessor=t,this.htmlProcessor=new xn(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new Ze(this.viewDocument),this.upcastDispatcher.on("text",((e,t,{schema:i,consumable:n,writer:o})=>{let s=t.modelCursor;if(!n.test(t.viewItem))return;if(!i.checkChild(s,"$text")){if(!qi(s,"$text",i))return;if(0==t.viewItem.data.trim().length)return;const e=s.nodeBefore;s=Ki(s,o),e&&e.is("element","$marker")&&(o.move(o.createRangeOn(e),s),s=o.createPositionAfter(e))}n.consume(t.viewItem);const r=o.createText(t.viewItem.data);o.insert(r,s),t.modelRange=o.createRange(s,s.getShiftedBy(r.offsetSize)),t.modelCursor=t.modelRange.end}),{priority:"lowest"}),this.upcastDispatcher.on("element",((e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}}),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",((e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:n}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=n}}),{priority:"lowest"}),(0,n.ObservableMixin)().prototype.decorate.call(this,"init"),(0,n.ObservableMixin)().prototype.decorate.call(this,"set"),(0,n.ObservableMixin)().prototype.decorate.call(this,"get"),(0,n.ObservableMixin)().prototype.decorate.call(this,"toView"),(0,n.ObservableMixin)().prototype.decorate.call(this,"toModel"),this.on("init",(()=>{this.fire("ready")}),{priority:"lowest"}),this.on("ready",(()=>{this.model.enqueueChange({isUndoable:!1},$i)}),{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new n.CKEditorError("datacontroller-get-non-existent-root",this);const o=this.model.document.getRoot(t);return o.isAttached()||(0,n.logWarning)("datacontroller-get-detached-root",this),"empty"!==i||this.model.hasContent(o,{ignoreWhitespaces:!0})?this.stringify(o,e):""}stringify(e,t={}){const i=this.toView(e,t);return this.processor.toData(i)}toView(e,t={}){const i=this.viewDocument,n=this._viewWriter;this.mapper.clearBindings();const o=di._createIn(e),s=new Ke(i);this.mapper.bindElements(e,s);const r=e.is("documentFragment")?e.markers:function(e){const t=[],i=e.root.document;if(!i)return new Map;const n=di._createIn(e);for(const e of i.model.markers){const i=e.getRange(),o=i.isCollapsed,s=i.start.isEqual(n.start)||i.end.isEqual(n.end);if(o&&s)t.push([e.name,i]);else{const o=n.getIntersection(i);o&&t.push([e.name,o])}}return t.sort((([e,t],[i,n])=>{if("after"!==t.end.compareWith(n.start))return 1;if("before"!==t.start.compareWith(n.end))return-1;switch(t.start.compareWith(n.start)){case"before":return 1;case"after":return-1;default:switch(t.end.compareWith(n.end)){case"before":return 1;case"after":return-1;default:return i.localeCompare(e)}}})),new Map(t)}(e);return this.downcastDispatcher.convert(o,r,n,t),s}init(e){if(this.model.document.version)throw new n.CKEditorError("datacontroller-init-document-not-empty",this);let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new n.CKEditorError("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},(e=>{for(const i of Object.keys(t)){const n=this.model.document.getRoot(i);e.insert(this.parse(t[i],n),n,0)}})),Promise.resolve()}set(e,t={}){let i={};if("string"==typeof e?i.main=e:i=e,!this._checkIfRootsExists(Object.keys(i)))throw new n.CKEditorError("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},(e=>{e.setSelection(null),e.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const t of Object.keys(i)){const n=this.model.document.getRoot(t);e.remove(e.createRangeIn(n)),e.insert(this.parse(i[t],n),n,0)}}))}parse(e,t="$root"){const i=this.processor.toView(e);return this.toModel(i,t)}toModel(e,t="$root"){return this.model.change((i=>this.upcastDispatcher.convert(e,i,t)))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const t of e)if(!this.model.document.getRoot(t))return!1;return!0}}class Sn{constructor(e,t){this._helpers=new Map,this._downcast=(0,n.toArray)(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=(0,n.toArray)(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const i=this._downcast.includes(t);if(!this._upcast.includes(t)&&!i)throw new n.CKEditorError("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new n.CKEditorError("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:i}of Pn(e))this.for("upcast").elementToElement({model:t,view:i,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:i}of Pn(e))this.for("upcast").elementToAttribute({view:i,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:i}of Pn(e))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:i}){if(this._helpers.has(e))throw new n.CKEditorError("conversion-group-exists",this);const o=i?new Ri(t):new Zi(t);this._helpers.set(e,o)}}function*Pn(e){if(e.model.values)for(const t of e.model.values){const i={key:e.model.key,value:t},n=e.view[t],o=e.upcastAlso?e.upcastAlso[t]:void 0;yield*In(i,n,o)}else yield*In(e.model,e.view,e.upcastAlso)}function*In(e,t,i){if(yield{model:e,view:t},i)for(const t of(0,n.toArray)(i))yield{model:e,view:t}}class Vn{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 Rn(e,t){const i=Mn(t),n=i.reduce(((e,t)=>e+t.offsetSize),0),o=e.parent;Dn(e);const s=e.index;return o._insertChild(s,i),Nn(o,s+i.length),Nn(o,s),new di(e,e.getShiftedBy(n))}function On(e){if(!e.isFlat)throw new n.CKEditorError("operation-utils-remove-range-not-flat",this);const t=e.start.parent;Dn(e.start),Dn(e.end);const i=t._removeChildren(e.start.index,e.end.index-e.start.index);return Nn(t,e.start.index),i}function Bn(e,t){if(!e.isFlat)throw new n.CKEditorError("operation-utils-move-range-not-flat",this);const i=On(e);return Rn(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),i)}function Mn(e){const t=[];!function e(i){if("string"==typeof i)t.push(new Xt(i));else if(i instanceof ei)t.push(new Xt(i.data,i.getAttributes()));else if(i instanceof Yt)t.push(i);else if((0,n.isIterable)(i))for(const t of i)e(t)}(e);for(let e=1;ee.maxOffset)throw new n.CKEditorError("move-operation-nodes-do-not-exist",this);if(e===t&&i=i&&this.targetPosition.path[e]e._clone(!0)))),t=new zn(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new oi(e,[0]);return new Fn(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffsete._clone(!0)))),Rn(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){const i=[];for(const t of e.nodes)t.name?i.push(ti.fromJSON(t)):i.push(Xt.fromJSON(t));const n=new zn(oi.fromJSON(e.position,t),i,e.baseVersion);return n.shouldReceiveAttributes=e.shouldReceiveAttributes,n}}class Hn extends Vn{constructor(e,t,i,n,o){super(o),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=i,this.graveyardPosition=n?n.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new oi(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new di(this.splitPosition,e)}get affectedSelectable(){const e=[di._createFromPositionAndShift(this.splitPosition,0),di._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(di._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new Hn(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new oi(e,[0]);return new Wn(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 n=e.range.getDifference(t.range).map((t=>new $n(t,e.key,e.oldValue,e.newValue,0))),o=e.range.getIntersection(t.range);return o&&i.aIsStrong&&n.push(new $n(o,t.key,t.newValue,e.newValue,0)),0==n.length?[new qn(0)]:n}return[e]})),Xn($n,zn,((e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){const i=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map((t=>new $n(t,e.key,e.oldValue,e.newValue,e.baseVersion)));if(t.shouldReceiveAttributes){const n=ro(t,e.key,e.oldValue);n&&i.unshift(n)}return i}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]})),Xn($n,Wn,((e,t)=>{const i=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&i.push(di._createFromPositionAndShift(t.graveyardPosition,1));const n=e.range._getTransformedByMergeOperation(t);return n.isCollapsed||i.push(n),i.map((t=>new $n(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),Xn($n,Fn,((e,t)=>function(e,t){const i=di._createFromPositionAndShift(t.sourcePosition,t.howMany);let n=null,o=[];i.containsRange(e,!0)?n=e:e.start.hasSameParentAs(i.start)?(o=e.getDifference(i),n=e.getIntersection(i)):o=[e];const s=[];for(let e of o){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const i=t.getMovedRangeStart(),n=e.start.hasSameParentAs(i),o=e._getTransformedByInsertion(i,t.howMany,n);s.push(...o)}return n&&s.push(n._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]),s}(e.range,t).map((t=>new $n(t,e.key,e.oldValue,e.newValue,e.baseVersion))))),Xn($n,Hn,((e,t)=>{if(e.range.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.range.end.offset++,[e];if(e.range.start.hasSameParentAs(t.splitPosition)&&e.range.containsPosition(t.splitPosition)){const i=e.clone();return i.range=new di(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness="toPrevious",[e,i]}return e.range=e.range._getTransformedBySplitOperation(t),[e]})),Xn(zn,$n,((e,t)=>{const i=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const n=ro(e,t.key,t.newValue);n&&i.push(n)}return i})),Xn(zn,zn,((e,t,i)=>(e.position.isEqual(t.position)&&i.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e]))),Xn(zn,Fn,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Xn(zn,Hn,((e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e]))),Xn(zn,Wn,((e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e]))),Xn(Un,zn,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e]))),Xn(Un,Un,((e,t,i)=>{if(e.name==t.name){if(!i.aIsStrong)return[new qn(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]})),Xn(Un,Wn,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e]))),Xn(Un,Fn,((e,t,i)=>{if(e.oldRange&&(e.oldRange=di._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){if(i.abRelation){const n=di._createFromRanges(e.newRange._getTransformedByMoveOperation(t));if("left"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.start))return e.newRange.end=n.end,e.newRange.start.path=i.abRelation.path,[e];if("right"==i.abRelation.side&&t.targetPosition.isEqual(e.newRange.end))return e.newRange.start=n.start,e.newRange.end.path=i.abRelation.path,[e]}e.newRange=di._createFromRanges(e.newRange._getTransformedByMoveOperation(t))}return[e]})),Xn(Un,Hn,((e,t,i)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(i.abRelation){const n=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)&&i.abRelation.wasStartBeforeMergedElement?e.newRange.start=oi._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!i.abRelation.wasInLeftElement&&(e.newRange.start=oi._createAt(t.moveTargetPosition)),e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasInRightElement?e.newRange.end=oi._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?e.newRange.end=oi._createAt(t.insertionPosition):e.newRange.end=n.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]})),Xn(Wn,zn,((e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e]))),Xn(Wn,Wn,((e,t,i)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition)){if(i.bWasUndone){const i=t.graveyardPosition.path.slice();return i.push(0),e.sourcePosition=new oi(t.graveyardPosition.root,i),e.howMany=0,[e]}return[new qn(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!i.bWasUndone&&"splitAtSource"!=i.abRelation){const n="$graveyard"==e.targetPosition.root.rootName,o="$graveyard"==t.targetPosition.root.rootName;if(o&&!n||(!n||o)&&i.aIsStrong){const i=t.targetPosition._getTransformedByMergeOperation(t),n=e.targetPosition._getTransformedByMergeOperation(t);return[new Fn(i,e.howMany,n,0)]}return[new qn(0)]}return e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMergeOperation(t),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),e.graveyardPosition.isEqual(t.graveyardPosition)&&i.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),Xn(Wn,Fn,((e,t,i)=>{const n=di._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!i.bWasUndone&&!i.forceWeakRemove&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.sourcePosition)?[new qn(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])})),Xn(Wn,Hn,((e,t,i)=>{if(t.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByDeletion(t.graveyardPosition,1),e.deletionPosition.isEqual(t.graveyardPosition)&&(e.howMany=t.howMany)),e.targetPosition.isEqual(t.splitPosition)){const n=0!=t.howMany,o=t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition);if(n||o||"mergeTargetNotMoved"==i.abRelation)return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e]}if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==i.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==i.abRelation||e.sourcePosition.offset>0)return e.sourcePosition=t.moveTargetPosition.clone(),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}return e.sourcePosition.hasSameParentAs(t.splitPosition)&&(e.howMany=t.splitPosition.offset),e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]})),Xn(Fn,zn,((e,t)=>{const i=di._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=i.start,e.howMany=i.end.offset-i.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]})),Xn(Fn,Fn,((e,t,i)=>{const o=di._createFromPositionAndShift(e.sourcePosition,e.howMany),s=di._createFromPositionAndShift(t.sourcePosition,t.howMany);let r,a=i.aIsStrong,l=!i.aIsStrong;if("insertBefore"==i.abRelation||"insertAfter"==i.baRelation?l=!0:"insertAfter"!=i.abRelation&&"insertBefore"!=i.baRelation||(l=!1),r=e.targetPosition.isEqual(t.targetPosition)&&l?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),ao(e,t)&&ao(t,e))return[t.getReversed()];if(o.containsPosition(t.targetPosition)&&o.containsRange(s,!0))return o.start=o.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),o.end=o.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),lo([o],r);if(s.containsPosition(e.targetPosition)&&s.containsRange(o,!0))return o.start=o.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),o.end=o.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),lo([o],r);const c=(0,n.compareArrays)(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==c||"extension"==c)return o.start=o.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),o.end=o.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),lo([o],r);"remove"!=e.type||"remove"==t.type||i.aWasUndone||i.forceWeakRemove?"remove"==e.type||"remove"!=t.type||i.bWasUndone||i.forceWeakRemove||(a=!1):a=!0;const d=[],u=o.getDifference(s);for(const e of u){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const i="same"==(0,n.compareArrays)(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),o=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,i);d.push(...o)}const h=o.getIntersection(s);return null!==h&&a&&(h.start=h.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),h.end=h.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===d.length?d.push(h):1==d.length?s.start.isBefore(o.start)||s.start.isEqual(o.start)?d.unshift(h):d.push(h):d.splice(1,0,h)),0===d.length?[new qn(e.baseVersion)]:lo(d,r)})),Xn(Fn,Hn,((e,t,i)=>{let n=e.targetPosition.clone();e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=i.abRelation||(n=e.targetPosition._getTransformedBySplitOperation(t));const o=di._createFromPositionAndShift(e.sourcePosition,e.howMany);if(o.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.howMany++,e.targetPosition=n,[e];if(o.start.hasSameParentAs(t.splitPosition)&&o.containsPosition(t.splitPosition)){let e=new di(t.splitPosition,o.end);return e=e._getTransformedBySplitOperation(t),lo([new di(o.start,t.splitPosition),e],n)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==i.abRelation&&(n=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==i.abRelation&&(n=e.targetPosition);const s=[o._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const n=o.start.isEqual(t.graveyardPosition)||o.containsPosition(t.graveyardPosition);e.howMany>1&&n&&!i.aWasUndone&&s.push(di._createFromPositionAndShift(t.insertionPosition,1))}return lo(s,n)})),Xn(Fn,Wn,((e,t,i)=>{const n=di._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(t.sourcePosition))if("remove"!=e.type||i.forceWeakRemove){if(1==e.howMany)return i.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new qn(0)]}else if(!i.aWasUndone){const i=[];let n=t.graveyardPosition.clone(),o=t.targetPosition._getTransformedByMergeOperation(t);e.howMany>1&&(i.push(new Fn(e.sourcePosition,e.howMany-1,e.targetPosition,0)),n=n._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1),o=o._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1));const s=t.deletionPosition._getCombined(e.sourcePosition,e.targetPosition),r=new Fn(n,1,s,0),a=r.getMovedRangeStart().path.slice();a.push(0);const l=new oi(r.targetPosition.root,a);o=o._getTransformedByMove(n,s,1);const c=new Fn(o,t.howMany,l,0);return i.push(r),i.push(c),i}const o=di._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]})),Xn(Kn,zn,((e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e]))),Xn(Kn,Wn,((e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e]))),Xn(Kn,Fn,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),Xn(Kn,Kn,((e,t,i)=>{if(e.position.isEqual(t.position)){if(!i.aIsStrong)return[new qn(0)];e.oldName=t.newName}return[e]})),Xn(Kn,Hn,((e,t)=>{const i=e.position.path,o=t.splitPosition.getParentPath();if("same"==(0,n.compareArrays)(i,o)&&!t.graveyardPosition){const t=new Kn(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]})),Xn(Zn,Zn,((e,t,i)=>{if(e.root===t.root&&e.key===t.key){if(!i.aIsStrong||e.newValue===t.newValue)return[new qn(0)];e.oldValue=t.newValue}return[e]})),Xn(Gn,Gn,((e,t)=>e.rootName===t.rootName&&e.isAdd===t.isAdd?[new qn(0)]:[e])),Xn(Hn,zn,((e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset{if(!e.graveyardPosition&&!i.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const i=t.graveyardPosition.path.slice();i.push(0);const n=new oi(t.graveyardPosition.root,i),o=Hn.getInsertionPosition(new oi(t.graveyardPosition.root,i)),s=new Hn(n,0,o,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Hn.getInsertionPosition(e.splitPosition),e.graveyardPosition=s.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[s,e]}return e.splitPosition.hasSameParentAs(t.deletionPosition)&&!e.splitPosition.isAfter(t.deletionPosition)&&e.howMany--,e.splitPosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Hn.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),Xn(Hn,Fn,((e,t,i)=>{const n=di._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const o=n.start.isEqual(e.graveyardPosition)||n.containsPosition(e.graveyardPosition);if(!i.bWasUndone&&o){const i=e.splitPosition._getTransformedByMoveOperation(t),n=e.graveyardPosition._getTransformedByMoveOperation(t),o=n.path.slice();o.push(0);const s=new oi(n.root,o);return[new Fn(i,e.howMany,s,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const o=e.splitPosition.isEqual(t.targetPosition);if(o&&("insertAtSource"==i.baRelation||"splitBefore"==i.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=Hn.getInsertionPosition(e.splitPosition),[e];if(o&&i.abRelation&&i.abRelation.howMany){const{howMany:t,offset:n}=i.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(n),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.splitPosition)){const i=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=i,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new qn(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new qn(0)];if("splitBefore"==i.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){const n="$graveyard"==e.splitPosition.root.rootName,o="$graveyard"==t.splitPosition.root.rootName;if(o&&!n||(!n||o)&&i.aIsStrong){const i=[];return t.howMany&&i.push(new Fn(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&i.push(new Fn(e.splitPosition,e.howMany,e.moveTargetPosition,0)),i}return[new qn(0)]}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==i.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==i.baRelation){const i=t.insertionPosition.path.slice();i.push(0);const n=new oi(t.insertionPosition.root,i);return[e,new Fn(e.insertionPosition,1,n,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset{const i=t[0];i.isDocumentOperation&&ho.call(this,i)}),{priority:"low"})}function ho(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)}}co.prototype.is=function(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e};class mo{constructor(e={}){"string"==typeof e&&(e="transparent"===e?{isUndoable:!1}:{},(0,n.logWarning)("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:i=!0,isUndo:o=!1,isTyping:s=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=i,this.isUndo=o,this.isTyping=s}get type(){return(0,n.logWarning)("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 go{constructor(e){this._changesInElement=new Map,this._elementSnapshots=new Map,this._changedMarkers=new Map,this._changedRoots=new Map,this._changeCount=0,this._cachedChanges=null,this._cachedChangesWithGraveyard=null,this._refreshedItems=new Set,this._markerCollection=e}get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.size&&0==this._changedRoots.size}bufferOperation(e){const t=e;switch(t.type){case"insert":if(this._isInInsertedElement(t.position.parent))return;this._markInsert(t.position.parent,t.position.offset,t.nodes.maxOffset);break;case"addAttribute":case"removeAttribute":case"changeAttribute":for(const e of t.range.getItems({shallow:!0}))this._isInInsertedElement(e.parent)||this._markAttribute(e);break;case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const e=this._isInInsertedElement(t.sourcePosition.parent),i=this._isInInsertedElement(t.targetPosition.parent);e||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),i||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const e=di._createFromPositionAndShift(t.position,1);for(const t of this._markerCollection.getMarkersIntersectingRange(e)){const e=t.getData();this.bufferMarkerChange(t.name,e,e)}break}case"split":{const e=t.splitPosition.parent;this._isInInsertedElement(e)||this._markRemove(e,t.splitPosition.offset,t.howMany),this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1);break}case"merge":{const e=t.sourcePosition.parent;this._isInInsertedElement(e.parent)||this._markRemove(e.parent,e.startOffset,1);const i=t.graveyardPosition.parent;this._markInsert(i,t.graveyardPosition.offset,1);const n=t.targetPosition.parent;this._isInInsertedElement(n)||this._markInsert(n,t.targetPosition.offset,e.maxOffset);break}case"detachRoot":case"addRoot":{const e=t.affectedSelectable;if(!e._isLoaded)return;if(e.isAttached()==t.isAdd)return;this._bufferRootStateChange(t.rootName,t.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!t.root._isLoaded)return;const e=t.root.rootName;this._bufferRootAttributeChange(e,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,i){t.range&&t.range.root.is("rootElement")&&!t.range.root._isLoaded&&(t.range=null),i.range&&i.range.root.is("rootElement")&&!i.range.root._isLoaded&&(i.range=null);let n=this._changedMarkers.get(e);n?n.newMarkerData=i:(n={newMarkerData:i,oldMarkerData:t},this._changedMarkers.set(e,n)),null==n.oldMarkerData.range&&null==i.range&&this._changedMarkers.delete(e)}getMarkersToRemove(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.oldMarkerData.range&&e.push({name:t,range:i.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,i]of this._changedMarkers)null!=i.newMarkerData.range&&e.push({name:t,range:i.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map((([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}})))}hasDataChanges(){if(this._changesInElement.size>0)return!0;if(this._changedRoots.size>0)return!0;for(const{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){const i=e.range&&!t.range,n=!e.range&&t.range,o=e.range&&t.range&&!e.range.isEqual(t.range);if(i||n||o)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const e of this._changesInElement.keys()){const i=this._changesInElement.get(e).sort(((e,t)=>e.offset===t.offset?e.type!=t.type?"remove"==e.type?-1:1:0:e.offsete.position.root!=t.position.root?e.position.root.rootNamee));for(const e of t)delete e.changeCount,"attribute"==e.type&&(delete e.position,delete e.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(bo),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getChangedRoots(){return Array.from(this._changedRoots.values()).map((e=>{const t={...e};return void 0!==t.state&&delete t.attributes,t}))}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementSnapshots.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems=new Set,this._cachedChanges=null}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e))return void this._changedRoots.set(e,{name:e,state:t?"attached":"detached"});const i=this._changedRoots.get(e);void 0!==i.state?(delete i.state,void 0===i.attributes&&this._changedRoots.delete(e)):i.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,i,n){const o=this._changedRoots.get(e)||{name:e},s=o.attributes||{};if(s[t]){const e=s[t];n===e.oldValue?delete s[t]:e.newValue=n}else s[t]={oldValue:i,newValue:n};0===Object.entries(s).length?(delete o.attributes,void 0===o.state&&this._changedRoots.delete(e)):(o.attributes=s,this._changedRoots.set(e,o))}_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=di._createOn(e);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getData();this.bufferMarkerChange(e.name,t,t)}this._cachedChanges=null}_bufferRootLoad(e){if(e.isAttached()){this._bufferRootStateChange(e.rootName,!0),this._markInsert(e,0,e.maxOffset);for(const t of e.getAttributeKeys())this._bufferRootAttributeChange(e.rootName,t,null,e.getAttribute(t));for(const t of this._markerCollection)if(t.getRange().root==e){const e=t.getData();this.bufferMarkerChange(t.name,{...e,range:null},e)}}}_markInsert(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n)}_markRemove(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const n={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,n),this._removeAllNestedChanges(e,t,i)}_markAttribute(e){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshot(e);const i=this._getChangesForElement(e);this._handleChange(t,i),i.push(t);for(let e=0;ei.offset){if(n>o){const e={type:"attribute",offset:o,howMany:n-o,count:this._changeCount++};this._handleChange(e,t),t.push(e)}e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=i.offset&&e.offseto?(e.nodesToHandle=n-o,e.offset=o):e.nodesToHandle=0);if("remove"==i.type&&e.offseti.offset){const o={type:"attribute",offset:i.offset,howMany:n-i.offset,count:this._changeCount++};this._handleChange(o,t),t.push(o),e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==i.type&&(e.offset>=i.offset&&n<=o?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=i.offset&&n>=o&&(i.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,i){return{type:"insert",position:oi._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++}}_getRemoveDiff(e,t,i){return{type:"remove",position:oi._createAt(e,t),name:i.name,attributes:new Map(i.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,i){const n=[];i=new Map(i);for(const[o,s]of t){const t=i.has(o)?i.get(o):null;t!==s&&n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:o,attributeOldValue:s,attributeNewValue:t,changeCount:this._changeCount++}),i.delete(o)}for(const[t,o]of i)n.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:o,changeCount:this._changeCount++});return n}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const i=this._changesInElement.get(t),n=e.startOffset;if(i)for(const e of i)if("insert"==e.type&&n>=e.offset&&nn){for(let t=0;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 n.CKEditorError("model-document-history-addoperation-incorrect-version",this,{operation:e,historyVersion:this.version});this._operations.push(e),this._version++,this._baseVersionToOperationIndex.set(e.baseVersion,this._operations.length-1)}getOperations(e,t=this.version){if(!this._operations.length)return[];const i=this._operations[0];void 0===e&&(e=i.baseVersion);let n=t-1;for(const[t,i]of this._gaps)e>t&&et&&nthis.lastOperation.baseVersion)return[];let o=this._baseVersionToOperationIndex.get(e);void 0===o&&(o=0);let s=this._baseVersionToOperationIndex.get(n);return void 0===s&&(s=this._operations.length-1),this._operations.slice(o,s+1)}getOperation(e){const t=this._baseVersionToOperationIndex.get(e);if(void 0!==t)return this._operations[t]}setOperationAsUndone(e,t){this._undoPairs.set(t,e),this._undoneOperations.add(e)}isUndoingOperation(e){return this._undoPairs.has(e)}isUndoneOperation(e){return this._undoneOperations.has(e)}getUndoneOperation(e){return this._undoPairs.get(e)}reset(){this._version=0,this._undoPairs=new Map,this._operations=[],this._undoneOperations=new Set,this._gaps=new Map,this._baseVersionToOperationIndex=new Map}}class vo extends ti{constructor(e,t,i="main"){super(t),this._isAttached=!0,this._isLoaded=!0,this._document=e,this.rootName=i}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}vo.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 _o="$graveyard";class yo extends((0,n.EmitterMixin)()){constructor(e){super(),this.model=e,this.history=new wo,this.selection=new Si(this),this.roots=new n.Collection({idProperty:"rootName"}),this.differ=new go(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",_o),this.listenTo(e,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&this.differ.bufferOperation(i)}),{priority:"high"}),this.listenTo(e,"applyOperation",((e,t)=>{const i=t[0];i.isDocumentOperation&&this.history.addOperation(i)}),{priority:"low"}),this.listenTo(this.selection,"change",(()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0})),this.listenTo(e.markers,"update",((e,t,i,n,o)=>{const s={...t.getData(),range:n};this.differ.bufferMarkerChange(t.name,o,s),null===i&&t.on("change",((e,i)=>{const n=t.getData();this.differ.bufferMarkerChange(t.name,{...n,range:i},n)}))})),this.registerPostFixer((e=>{let t=!1;for(const i of this.roots)i.isAttached()||i.isEmpty||(e.remove(e.createRangeIn(i)),t=!0);for(const i of this.model.markers)i.getRange().root.isAttached()||(e.removeMarker(i),t=!0);return t}))}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(_o)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new n.CKEditorError("model-document-createroot-name-exists",this,{name:t});const i=new vo(this,e,t);return this.roots.add(i),i}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map((e=>e.rootName))}getRoots(e=!1){return Array.from(this.roots).filter((t=>t!=this.graveyard&&(e||t.isAttached())&&t._isLoaded))}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=p(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){const e=this.getRoots();return e.length?e[0]:this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,i=t.schema,n=t.createPositionFromPath(e,[0]);return i.getNearestSelectionRange(n)||t.createRange(n)}_validateSelectionRange(e){return ko(e.start)&&ko(e.end)}_callPostFixers(e){let t=!1;do{for(const i of this._postFixers)if(this.selection.refresh(),t=i(e),t)break}while(t)}}function ko(e){const t=e.textNode;if(t){const i=t.data,o=e.offset-t.startOffset;return!(0,n.isInsideSurrogatePair)(i,o)&&!(0,n.isInsideCombinedSymbol)(i,o)}return!0}class Co extends((0,n.EmitterMixin)()){constructor(){super(...arguments),this._markers=new Map}[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof Ao?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,i=!1,o=!1){const s=e instanceof Ao?e.name:e;if(s.includes(","))throw new n.CKEditorError("markercollection-incorrect-marker-name",this);const r=this._markers.get(s);if(r){const e=r.getData(),n=r.getRange();let a=!1;return n.isEqual(t)||(r._attachLiveRange(Ai.fromRange(t)),a=!0),i!=r.managedUsingOperations&&(r._managedUsingOperations=i,a=!0),"boolean"==typeof o&&o!=r.affectsData&&(r._affectsData=o,a=!0),a&&this.fire(`update:${s}`,r,n,t,e),r}const a=Ai.fromRange(t),l=new Ao(s,a,i,o);return this._markers.set(s,l),this.fire(`update:${s}`,l,null,t,{...l.getData(),range:null}),l}_remove(e){const t=e instanceof Ao?e.name:e,i=this._markers.get(t);return!!i&&(this._markers.delete(t),this.fire(`update:${t}`,i,i.getRange(),null,i.getData()),this._destroyMarker(i),!0)}_refresh(e){const t=e instanceof Ao?e.name:e,i=this._markers.get(t);if(!i)throw new n.CKEditorError("markercollection-refresh-marker-not-exists",this);const o=i.getRange();this.fire(`update:${t}`,i,o,o,i.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)null!==t.getRange().getIntersection(e)&&(yield t)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}class Ao extends((0,n.EmitterMixin)(Jt)){constructor(e,t,i,n){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=i,this._affectsData=n}get managedUsingOperations(){if(!this._liveRange)throw new n.CKEditorError("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new n.CKEditorError("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new n.CKEditorError("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new n.CKEditorError("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new n.CKEditorError("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}}Ao.prototype.is=function(e){return"marker"===e||"model:marker"===e};class Eo extends Vn{constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}get type(){return"detach"}get affectedSelectable(){return null}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new n.CKEditorError("detach-operation-on-document-node",this)}_execute(){On(di._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class xo extends Jt{constructor(e){super(),this.markers=new Map,this._children=new Qt,e&&this._insertChild(0,e)}[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}get nextSibling(){return null}get previousSibling(){return null}get root(){return this}get parent(){return null}get document(){return null}isAttached(){return!1}getAncestors(){return[]}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(const i of e)t=t.getChild(t.offsetToIndex(i));return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const i of e)i.name?t.push(ti.fromJSON(i)):t.push(Xt.fromJSON(i));return new xo(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const i=function(e){return"string"==typeof e?[new Xt(e)]:((0,n.isIterable)(e)||(e=[e]),Array.from(e).map((e=>"string"==typeof e?new Xt(e):e instanceof ei?new Xt(e.data,e.getAttributes()):e)))}(t);for(const e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){const i=this._children._removeNodes(e,t);for(const e of i)e.parent=null;return i}}xo.prototype.is=function(e){return"documentFragment"===e||"model:documentFragment"===e};class To{constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new Xt(e,t)}createElement(e,t){return new ti(e,t)}createDocumentFragment(){return new xo}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,i=0){if(this._assertWriterUsedCorrectly(),e instanceof Xt&&""==e.data)return;const o=oi._createAt(t,i);if(e.parent){if(Ro(e.root,o.root))return void this.move(di._createOn(e),o);if(e.root.document)throw new n.CKEditorError("model-writer-insert-forbidden-move",this);this.remove(e)}const s=o.root.document?o.root.document.version:null,r=new zn(o,e,s);if(e instanceof Xt&&(r.shouldReceiveAttributes=!0),this.batch.addOperation(r),this.model.applyOperation(r),e instanceof xo)for(const[t,i]of e.markers){const e=oi._createAt(i.root,0),n={range:new di(i.start._getCombined(e,o),i.end._getCombined(e,o)),usingOperation:!0,affectsData:!0};this.model.markers.has(t)?this.updateMarker(t,n):this.addMarker(t,n)}}insertText(e,t,i,n){t instanceof xo||t instanceof ti||t instanceof oi?this.insert(this.createText(e),t,i):this.insert(this.createText(e,t),i,n)}insertElement(e,t,i,n){t instanceof xo||t instanceof ti||t instanceof oi?this.insert(this.createElement(e),t,i):this.insert(this.createElement(e,t),i,n)}append(e,t){this.insert(e,t,"end")}appendText(e,t,i){t instanceof xo||t instanceof ti?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),i,"end")}appendElement(e,t,i){t instanceof xo||t instanceof ti?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),i,"end")}setAttribute(e,t,i){if(this._assertWriterUsedCorrectly(),i instanceof di){const n=i.getMinimalFlatRanges();for(const i of n)So(this,e,t,i)}else Po(this,e,t,i)}setAttributes(e,t){for(const[i,o]of(0,n.toMap)(e))this.setAttribute(i,o,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof di){const i=t.getMinimalFlatRanges();for(const t of i)So(this,e,null,t)}else Po(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=e=>{for(const t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof di)for(const i of e.getItems())t(i);else t(e)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof di))throw new n.CKEditorError("writer-move-invalid-range",this);if(!e.isFlat)throw new n.CKEditorError("writer-move-range-not-flat",this);const o=oi._createAt(t,i);if(o.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!Ro(e.root,o.root))throw new n.CKEditorError("writer-move-different-document",this);const s=e.root.document?e.root.document.version:null,r=new Fn(e.start,e.end.offset-e.start.offset,o,s);this.batch.addOperation(r),this.model.applyOperation(r)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof di?e:di._createOn(e)).getMinimalFlatRanges().reverse();for(const e of t)this._addOperationForAffectedMarkers("move",e),Vo(e.start,e.end.offset-e.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,i=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof ti))throw new n.CKEditorError("writer-merge-no-element-before",this);if(!(i instanceof ti))throw new n.CKEditorError("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,i){return this.model.createPositionFromPath(e,t,i)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(...e){return this.model.createSelection(...e)}_mergeDetached(e){const t=e.nodeBefore,i=e.nodeAfter;this.move(di._createIn(i),oi._createAt(t,"end")),this.remove(i)}_merge(e){const t=oi._createAt(e.nodeBefore,"end"),i=oi._createAt(e.nodeAfter,0),n=e.root.document.graveyard,o=new oi(n,[0]),s=e.root.document.version,r=new Wn(i,e.nodeAfter.maxOffset,t,o,s);this.batch.addOperation(r),this.model.applyOperation(r)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof ti))throw new n.CKEditorError("writer-rename-not-element-instance",this);const i=e.root.document?e.root.document.version:null,o=new Kn(oi._createBefore(e),e.name,t,i);this.batch.addOperation(o),this.model.applyOperation(o)}split(e,t){this._assertWriterUsedCorrectly();let i,o,s=e.parent;if(!s.parent)throw new n.CKEditorError("writer-split-element-no-parent",this);if(t||(t=s.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new n.CKEditorError("writer-split-invalid-limit-element",this);do{const t=s.root.document?s.root.document.version:null,n=s.maxOffset-e.offset,r=Hn.getInsertionPosition(e),a=new Hn(e,n,r,null,t);this.batch.addOperation(a),this.model.applyOperation(a),i||o||(i=s,o=e.parent.nextSibling),s=(e=this.createPositionAfter(e.parent)).parent}while(s!==t);return{position:e,range:new di(oi._createAt(i,"end"),oi._createAt(o,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new n.CKEditorError("writer-wrap-range-not-flat",this);const i=t instanceof ti?t:new ti(t);if(i.childCount>0)throw new n.CKEditorError("writer-wrap-element-not-empty",this);if(null!==i.parent)throw new n.CKEditorError("writer-wrap-element-attached",this);this.insert(i,e.start);const o=new di(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(o,oi._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new n.CKEditorError("writer-unwrap-element-no-parent",this);this.move(di._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new n.CKEditorError("writer-addmarker-no-usingoperation",this);const i=t.usingOperation,o=t.range,s=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new n.CKEditorError("writer-addmarker-marker-exists",this);if(!o)throw new n.CKEditorError("writer-addmarker-no-range",this);return i?(Io(this,e,null,o,s),this.model.markers.get(e)):this.model.markers._set(e,o,i,s)}updateMarker(e,t){this._assertWriterUsedCorrectly();const i="string"==typeof e?e:e.name,o=this.model.markers.get(i);if(!o)throw new n.CKEditorError("writer-updatemarker-marker-not-exists",this);if(!t)return(0,n.logWarning)("writer-updatemarker-reconvert-using-editingcontroller",{markerName:i}),void this.model.markers._refresh(o);const s="boolean"==typeof t.usingOperation,r="boolean"==typeof t.affectsData,a=r?t.affectsData:o.affectsData;if(!s&&!t.range&&!r)throw new n.CKEditorError("writer-updatemarker-wrong-options",this);const l=o.getRange(),c=t.range?t.range:l;s&&t.usingOperation!==o.managedUsingOperations?t.usingOperation?Io(this,i,null,c,a):(Io(this,i,l,null,a),this.model.markers._set(i,c,void 0,a)):o.managedUsingOperations?Io(this,i,l,c,a):this.model.markers._set(i,c,void 0,a)}removeMarker(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new n.CKEditorError("writer-removemarker-no-marker",this);const i=this.model.markers.get(t);i.managedUsingOperations?Io(this,t,i.getRange(),null,i.affectsData):this.model.markers._remove(t)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const i=this.model.document.getRoot(e);if(i&&i.isAttached())throw new n.CKEditorError("writer-addroot-root-exists",this);const o=this.model.document,s=new Gn(e,t,!0,o,o.version);return this.batch.addOperation(s),this.model.applyOperation(s),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new n.CKEditorError("writer-detachroot-no-root",this);for(const e of this.model.markers)e.getRange().root===t&&this.removeMarker(e);for(const e of t.getAttributeKeys())this.removeAttribute(e,t);this.remove(this.createRangeIn(t));const i=this.model.document,o=new Gn(t.rootName,t.name,!1,i,i.version);this.batch.addOperation(o),this.model.applyOperation(o)}setSelection(...e){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...e)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._setSelectionAttribute(e,t);else for(const[t,i]of(0,n.toMap)(e))this._setSelectionAttribute(t,i)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._removeSelectionAttribute(e);else for(const t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){const i=this.model.document.selection;if(i.isCollapsed&&i.anchor.parent.isEmpty){const n=Si._getStoreAttributeKey(e);this.setAttribute(n,t,i.anchor.parent)}i._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const i=Si._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new n.CKEditorError("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const i of this.model.markers){if(!i.managedUsingOperations)continue;const n=i.getRange();let o=!1;if("move"===e){const e=t;o=e.containsPosition(n.start)||e.start.isEqual(n.start)||e.containsPosition(n.end)||e.end.isEqual(n.end)}else{const e=t,i=e.nodeBefore,s=e.nodeAfter,r=n.start.parent==i&&n.start.isAtEnd,a=n.end.parent==s&&0==n.end.offset,l=n.end.nodeAfter==s,c=n.start.nodeAfter==s;o=r||a||l||c}o&&this.updateMarker(i.name,{range:n})}}}function So(e,t,i,n){const o=e.model,s=o.document;let r,a,l,c=n.start;for(const e of n.getWalker({shallow:!0}))l=e.item.getAttribute(t),r&&a!=l&&(a!=i&&d(),c=r),r=e.nextPosition,a=l;function d(){const n=new di(c,r),l=n.root.document?s.version:null,d=new $n(n,t,a,i,l);e.batch.addOperation(d),o.applyOperation(d)}r instanceof oi&&r!=c&&a!=i&&d()}function Po(e,t,i,n){const o=e.model,s=o.document,r=n.getAttribute(t);let a,l;if(r!=i){if(n.root===n){const e=n.document?s.version:null;l=new Zn(n,t,r,i,e)}else{a=new di(oi._createBefore(n),e.createPositionAfter(n));const o=a.root.document?s.version:null;l=new $n(a,t,r,i,o)}e.batch.addOperation(l),o.applyOperation(l)}}function Io(e,t,i,n,o){const s=e.model,r=s.document,a=new Un(t,i,n,s.markers,!!o,r.version);e.batch.addOperation(a),s.applyOperation(a)}function Vo(e,t,i,n){let o;if(e.root.document){const i=n.document,s=new oi(i.graveyard,[0]);o=new Fn(e,t,s,i.version)}else o=new Eo(e,t);i.addOperation(o),n.applyOperation(o)}function Ro(e,t){return e===t||e instanceof vo&&t instanceof vo}function Oo(e,t,i={}){if(t.isCollapsed)return;const n=t.getFirstRange();if("$graveyard"==n.root.rootName)return;const o=e.schema;e.change((e=>{if(!i.doNotResetEntireContent&&function(e,t){const i=e.getLimitElement(t);if(!t.containsEntireContent(i))return!1;const n=t.getFirstRange();return n.start.parent!=n.end.parent&&e.checkChild(i,"paragraph")}(o,t))return void function(e,t){const i=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(i)),Do(e,e.createPositionAt(i,0),t)}(e,t);const s={};if(!i.doNotAutoparagraph){const e=t.getSelectedElement();e&&Object.assign(s,o.getAttributesWithProperty(e,"copyOnReplace",!0))}const[r,a]=function(e){const t=e.root.document.model,i=e.start;let n=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){const i=function(e){const t=e.parent,i=t.root.document.model.schema,n=t.getAncestors({parentFirst:!0,includeSelf:!0});for(const e of n){if(i.isLimit(e))return null;if(i.isBlock(e))return e}}(n);if(i&&n.isTouching(t.createPositionAt(i,0))){const i=t.createSelection(e);t.modifySelection(i,{direction:"backward"});const o=i.getLastPosition(),s=t.createRange(o,n);t.hasContent(s,{ignoreMarkers:!0})||(n=o)}}return[co.fromPosition(i,"toPrevious"),co.fromPosition(n,"toNext")]}(n);r.isTouching(a)||e.remove(e.createRange(r,a)),i.leaveUnmerged||(function(e,t,i){const n=e.model;if(!No(e.model.schema,t,i))return;const[o,s]=function(e,t){const i=e.getAncestors(),n=t.getAncestors();let o=0;for(;i[o]&&i[o]==n[o];)o++;return[i[o],n[o]]}(t,i);o&&s&&(!n.hasContent(o,{ignoreMarkers:!0})&&n.hasContent(s,{ignoreMarkers:!0})?Mo(e,t,i,o.parent):Bo(e,t,i,o.parent))}(e,r,a),o.removeDisallowedAttributes(r.parent.getChildren(),e)),Lo(e,t,r),!i.doNotAutoparagraph&&function(e,t){const i=e.checkChild(t,"$text"),n=e.checkChild(t,"paragraph");return!i&&n}(o,r)&&Do(e,r,t,s),r.detach(),a.detach()}))}function Bo(e,t,i,n){const o=t.parent,s=i.parent;if(o!=n&&s!=n){for(t=e.createPositionAfter(o),(i=e.createPositionBefore(s)).isEqual(t)||e.insert(s,t),e.merge(t);i.parent.isEmpty;){const t=i.parent;i=e.createPositionBefore(t),e.remove(t)}No(e.model.schema,t,i)&&Bo(e,t,i,n)}}function Mo(e,t,i,n){const o=t.parent,s=i.parent;if(o!=n&&s!=n){for(t=e.createPositionAfter(o),(i=e.createPositionBefore(s)).isEqual(t)||e.insert(o,i);t.parent.isEmpty;){const i=t.parent;t=e.createPositionBefore(i),e.remove(i)}i=e.createPositionBefore(s),function(e,t){const i=t.nodeBefore,n=t.nodeAfter;i.name!=n.name&&e.rename(i,n.name),e.clearAttributes(i),e.setAttributes(Object.fromEntries(n.getAttributes()),i),e.merge(t)}(e,i),No(e.model.schema,t,i)&&Mo(e,t,i,n)}}function No(e,t,i){const n=t.parent,o=i.parent;return n!=o&&!e.isLimit(n)&&!e.isLimit(o)&&function(e,t,i){const n=new di(e,t);for(const e of n.getWalker())if(i.isLimit(e.item))return!1;return!0}(t,i,e)}function Do(e,t,i,n={}){const o=e.createElement("paragraph");e.model.schema.setAllowedAttributes(o,n,e),e.insert(o,t),Lo(e,i,e.createPositionAt(o,0))}function Lo(e,t,i){t instanceof Si?e.setSelection(i):t.setTo(i)}function Fo(e,t){const i=[];Array.from(e.getItems({direction:"backward"})).map((e=>t.createRangeOn(e))).filter((t=>(t.start.isAfter(e.start)||t.start.isEqual(e.start))&&(t.end.isBefore(e.end)||t.end.isEqual(e.end)))).forEach((e=>{i.push(e.start.parent),t.remove(e)})),i.forEach((e=>{let i=e;for(;i.parent&&i.isEmpty;){const e=t.createRangeOn(i);i=i.parent,t.remove(e)}}))}class zo{constructor(e,t,i){this._firstNode=null,this._lastNode=null,this._lastAutoParagraph=null,this._filterAttributesOf=[],this._affectedStart=null,this._affectedEnd=null,this._nodeToSelect=null,this.model=e,this.writer=t,this.position=i,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0)}handleNodes(e){for(const t of Array.from(e))this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),i=this.writer.createPositionAfter(e);if(i.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new n.CKEditorError("insertcontent-invalid-insertion-position",this);this.position=i,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?di._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new di(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=co.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 n.CKEditorError("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=co.fromPosition(e,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(e)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=co.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof ti))return;if(!this._canMergeLeft(e))return;const t=co._createBefore(e);t.stickiness="toNext";const i=co.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=co._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=co._createAt(t.nodeBefore,"end","toNext")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof ti))return;if(!this._canMergeRight(e))return;const t=co._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new n.CKEditorError("insertcontent-invalid-insertion-position",this);this.position=oi._createAt(t.nodeBefore,"end");const i=co.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=co._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=co._createAt(t.nodeBefore,0,"toPrevious")),this.position=i.toPosition(),i.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof ti&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof ti&&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 Ho(e,t,i="auto"){const o=e.getSelectedElement();if(o&&t.schema.isObject(o)&&!t.schema.isInline(o))return"before"==i||"after"==i?t.createRange(t.createPositionAt(o,i)):t.createRangeOn(o);const s=(0,n.first)(e.getSelectedBlocks());if(!s)return t.createRange(e.focus);if(s.isEmpty)return t.createRange(t.createPositionAt(s,0));const r=t.createPositionAfter(s);return e.focus.isTouching(r)?t.createRange(r):t.createRange(t.createPositionBefore(s))}const Wo=' ,.?!:;"-()';function Uo(e,t){const{isForward:i,walker:o,unit:s,schema:r,treatEmojiAsSingleUnit:a}=e,{type:l,item:c,nextPosition:d}=t;if("text"==l)return"word"===e.unit?function(e,t){let i=e.position.textNode;for(i||(i=t?e.position.nodeAfter:e.position.nodeBefore);i&&i.is("$text");){const n=e.position.offset-i.startOffset;if(qo(i,n,t))i=t?e.position.nodeAfter:e.position.nodeBefore;else{if($o(i.data,n,t))break;e.next()}}return e.position}(o,i):function(e,t,i){const o=e.position.textNode;if(o){const s=o.data;let r=e.position.offset-o.startOffset;for(;(0,n.isInsideSurrogatePair)(s,r)||"character"==t&&(0,n.isInsideCombinedSymbol)(s,r)||i&&(0,n.isInsideEmojiSequence)(s,r);)e.next(),r=e.position.offset-o.startOffset}return e.position}(o,s,a);if(l==(i?"elementStart":"elementEnd")){if(r.isSelectable(c))return oi._createAt(c,i?"after":"before");if(r.checkChild(d,"$text"))return d}else{if(r.isLimit(c))return void o.skip((()=>!0));if(r.checkChild(d,"$text"))return d}}function jo(e,t){const i=e.root,n=oi._createAt(i,t?"end":0);return t?new di(e,n):new di(n,e)}function $o(e,t,i){const n=t+(i?0:-1);return Wo.includes(e.charAt(n))}function qo(e,t,i){return t===(i?e.offsetSize:0)}class Ko extends((0,n.ObservableMixin)()){constructor(){var e;super(),this.markers=new Co,this.document=new yo(this),this.schema=new cn,this._pendingChanges=[],this._currentWriter=null,["deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach((e=>this.decorate(e))),this.on("applyOperation",((e,t)=>{t[0]._validate()}),{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck(((e,t)=>{if("$marker"===t.name)return!0})),(e=this).document.registerPostFixer((t=>function(e,t){const i=t.document.selection,n=t.schema,o=[];let s=!1;for(const e of i.getRanges()){const t=tn(e,n);t&&!t.isEqual(e)?(o.push(t),s=!0):o.push(e)}return s&&e.setSelection(function(e){const t=[...e],i=new Set;let n=1;for(;n!i.has(t)))}(o),{backward:i.isBackward}),!1}(t,e))),this.document.registerPostFixer($i),this.on("insertContent",((e,[t,i])=>{e.return=function(e,t,i){return e.change((n=>{const o=i||e.document.selection;o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0});const s=new zo(e,n,o.anchor),r=[];let a;if(t.is("documentFragment")){if(t.markers.size){const e=[];for(const[i,n]of t.markers){const{start:t,end:o}=n,s=t.isEqual(o);e.push({position:t,name:i,isCollapsed:s},{position:o,name:i,isCollapsed:s})}e.sort((({position:e},{position:t})=>e.isBefore(t)?1:-1));for(const{position:i,name:o,isCollapsed:s}of e){let e=null,a=null;const l=i.parent===t&&i.isAtStart,c=i.parent===t&&i.isAtEnd;l||c?s&&(a=l?"start":"end"):(e=n.createElement("$marker"),n.insert(e,i)),r.push({name:o,element:e,collapsed:a})}}a=t.getChildren()}else a=[t];s.handleNodes(a);let l=s.getSelectionRange();if(t.is("documentFragment")&&r.length){const e=l?Ai.fromRange(l):null,t={};for(let e=r.length-1;e>=0;e--){const{name:i,element:o,collapsed:a}=r[e],l=!t[i];if(l&&(t[i]=[]),o){const e=n.createPositionAt(o,"before");t[i].push(e),n.remove(o)}else{const e=s.getAffectedRange();if(!e){a&&t[i].push(s.position);continue}a?t[i].push(e[a]):t[i].push(l?e.start:e.end)}}for(const[e,[i,o]]of Object.entries(t))i&&o&&i.root===o.root&&n.addMarker(e,{usingOperation:!0,affectsData:!0,range:new di(i,o)});e&&(l=e.toRange(),e.detach())}l&&(o instanceof Si?n.setSelection(l):o.setTo(l));const c=s.getAffectedRange()||e.createRange(o.anchor);return s.destroy(),c}))}(this,t,i)})),this.on("insertObject",((e,[t,i,o])=>{e.return=function(e,t,i,o={}){if(!e.schema.isObject(t))throw new n.CKEditorError("insertobject-element-not-an-object",e,{object:t});const s=i||e.document.selection;let r=s;o.findOptimalPosition&&e.schema.isBlock(t)&&(r=e.createSelection(Ho(s,e,o.findOptimalPosition)));const a=(0,n.first)(s.getSelectedBlocks()),l={};return a&&Object.assign(l,e.schema.getAttributesWithProperty(a,"copyOnReplace",!0)),e.change((i=>{r.isCollapsed||e.deleteContent(r,{doNotAutoparagraph:!0});let s=t;const a=r.anchor.parent;!e.schema.checkChild(a,t)&&e.schema.checkChild(a,"paragraph")&&e.schema.checkChild("paragraph",t)&&(s=i.createElement("paragraph"),i.insert(t,s)),e.schema.setAllowedAttributes(s,l,i);const c=e.insertContent(s,r);return c.isCollapsed||o.setSelection&&function(e,t,i,o){const s=e.model;if("on"==i)return void e.setSelection(t,"on");if("after"!=i)throw new n.CKEditorError("insertobject-invalid-place-parameter-value",s);let r=t.nextSibling;s.schema.isInline(t)?e.setSelection(t,"after"):(!(r&&s.schema.checkChild(r,"$text"))&&s.schema.checkChild(t.parent,"paragraph")&&(r=e.createElement("paragraph"),s.schema.setAllowedAttributes(r,o,e),s.insertContent(r,e.createPositionAfter(t))),r&&e.setSelection(r,0))}(i,t,o.setSelection,l),c}))}(this,t,i,o)})),this.on("canEditAt",(e=>{const t=!this.document.isReadOnly;e.return=t,t||e.stop()}))}change(e){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new mo,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(e){n.CKEditorError.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{e?"function"==typeof e?(t=e,e=new mo):e instanceof mo||(e=new mo(e)):e=new mo,this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(e){n.CKEditorError.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,i,...n){const o=Zo(t,i);return this.fire("insertContent",[e,o,i,...n])}insertObject(e,t,i,n,...o){const s=Zo(t,i);return this.fire("insertObject",[e,s,n,n,...o])}deleteContent(e,t){Oo(this,e,t)}modifySelection(e,t){!function(e,t,i={}){const n=e.schema,o="backward"!=i.direction,s=i.unit?i.unit:"character",r=!!i.treatEmojiAsSingleUnit,a=t.focus,l=new ii({boundaries:jo(a,o),singleCharacters:!0,direction:o?"forward":"backward"}),c={walker:l,schema:n,isForward:o,unit:s,treatEmojiAsSingleUnit:r};let d;for(;d=l.next();){if(d.done)return;const i=Uo(c,d.value);if(i)return void(t instanceof Si?e.change((e=>{e.setSelectionFocus(i)})):t.setFocus(i))}}(this,e,t)}getSelectedContent(e){return function(e,t){return e.change((e=>{const i=e.createDocumentFragment(),n=t.getFirstRange();if(!n||n.isCollapsed)return i;const o=n.start.root,s=n.start.getCommonPath(n.end),r=o.getNodeByPath(s);let a;a=n.start.parent==n.end.parent?n:e.createRange(e.createPositionAt(r,n.start.path[s.length]),e.createPositionAt(r,n.end.path[s.length]+1));const l=a.end.offset-a.start.offset;for(const t of a.getItems({shallow:!0}))t.is("$textProxy")?e.appendText(t.data,t.getAttributes(),i):e.append(e.cloneElement(t,!0),i);if(a!=n){const t=n._getTransformedByMove(a.start,e.createPositionAt(i,0),l)[0],o=e.createRange(e.createPositionAt(i,0),t.start);Fo(e.createRange(t.end,e.createPositionAt(i,"end")),e),Fo(o,e)}return i}))}(this,e)}hasContent(e,t={}){const i=e instanceof di?e:di._createIn(e);if(i.isCollapsed)return!1;const{ignoreWhitespaces:n=!1,ignoreMarkers:o=!1}=t;if(!o)for(const e of this.markers.getMarkersIntersectingRange(i))if(e.affectsData)return!0;for(const e of i.getItems())if(this.schema.isContent(e)){if(!e.is("$textProxy"))return!0;if(!n)return!0;if(-1!==e.data.search(/\S/))return!0}return!1}canEditAt(e){const t=Zo(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,i){return new oi(e,t,i)}createPositionAt(e,t){return oi._createAt(e,t)}createPositionAfter(e){return oi._createAfter(e)}createPositionBefore(e){return oi._createBefore(e)}createRange(e,t){return new di(e,t)}createRangeIn(e){return di._createIn(e)}createRangeOn(e){return di._createOn(e)}createSelection(...e){return new bi(...e)}createBatch(e){return new mo(e)}createOperationFromJSON(e){return Yn.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 To(this,t);const i=this._pendingChanges[0].callback(this._currentWriter);e.push(i),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}return e}}function Zo(e,t){if(e)return e instanceof bi||e instanceof Si?e:e instanceof Yt?t||0===t?new bi(e,t):e.is("rootElement")?new bi(e,"in"):new bi(e,"on"):new bi(e)}class Go extends Rt{constructor(){super(...arguments),this.domEventType="click"}onDomEvent(e){this.fire(e.type,e)}}class Jo extends Rt{constructor(){super(...arguments),this.domEventType=["mousedown","mouseup","mouseover","mouseout"]}onDomEvent(e){this.fire(e.type,e)}}class Yo{constructor(e){this.document=e}createDocumentFragment(e){return new Ke(this.document,e)}createElement(e,t,i){return new be(this.document,e,t,i)}createText(e){return new w(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,i){return i._insertChild(e,t)}removeChildren(e,t,i){return i._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const i=e.parent;if(i){const n=i.getChildIndex(e);return this.removeChildren(n,1,i),this.insertChild(n,t,i),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const i=t.getChildIndex(e);this.remove(e),this.insertChild(i,e.getChildren(),t)}}rename(e,t){const i=new be(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,i)?i:null}setAttribute(e,t,i){i._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){(0,_.Z)(e)&&void 0===i?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return Ee._createAt(e,t)}createPositionAfter(e){return Ee._createAfter(e)}createPositionBefore(e){return Ee._createBefore(e)}createRange(e,t){return new xe(e,t)}createRangeOn(e){return xe._createOn(e)}createRangeIn(e){return xe._createIn(e)}createSelection(...e){return new Se(...e)}}const Qo=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Xo=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,es=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,ts=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,is=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,ns=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,os=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 ss(e){return e.startsWith("#")?Qo.test(e):e.startsWith("rgb")?Xo.test(e)||es.test(e):e.startsWith("hsl")?ts.test(e)||is.test(e):os.has(e.toLowerCase())}const rs=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];function as(e){return rs.includes(e)}const ls=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function cs(e){return ls.test(e)}const ds=/^[+-]?[0-9]*([.][0-9]+)?%$/;function us(e){return ds.test(e)}const hs=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function ms(e){return hs.includes(e)}const gs=["center","top","bottom","left","right"];function fs(e){return gs.includes(e)}const ps=["fixed","scroll","local"];function bs(e){return ps.includes(e)}const ws=/^url\(/;function vs(e){return ws.test(e)}function _s(e=""){if(""===e)return{top:void 0,right:void 0,bottom:void 0,left:void 0};const t=As(e),i=t[0],n=t[2]||i,o=t[1]||i;return{top:i,bottom:n,right:o,left:t[3]||o}}function ys(e){return t=>{const{top:i,right:n,bottom:o,left:s}=t,r=[];return[i,n,s,o].every((e=>!!e))?r.push([e,ks(t)]):(i&&r.push([e+"-top",i]),n&&r.push([e+"-right",n]),o&&r.push([e+"-bottom",o]),s&&r.push([e+"-left",s])),r}}function ks({top:e,right:t,bottom:i,left:n}){const o=[];return n!==t?o.push(e,t,i,n):i!==e?o.push(e,t,i):t!==e?o.push(e,t):o.push(e),o.join(" ")}function Cs(e){return t=>({path:e,value:_s(t)})}function As(e){const t=e.matchAll(ns);return Array.from(t).map((e=>e[0]))}function Es(e){e.setNormalizer("background",(e=>{const t={},i=As(e);for(const e of i)ms(e)?(t.repeat=t.repeat||[],t.repeat.push(e)):fs(e)?(t.position=t.position||[],t.position.push(e)):bs(e)?t.attachment=e:ss(e)?t.color=e:vs(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 xs(e){e.setNormalizer("border",(e=>{const{color:t,style:i,width:n}=Os(e);return{path:"border",value:{color:_s(t),style:_s(i),width:_s(n)}}})),e.setNormalizer("border-top",Ts("top")),e.setNormalizer("border-right",Ts("right")),e.setNormalizer("border-bottom",Ts("bottom")),e.setNormalizer("border-left",Ts("left")),e.setNormalizer("border-color",Ss("color")),e.setNormalizer("border-width",Ss("width")),e.setNormalizer("border-style",Ss("style")),e.setNormalizer("border-top-color",Is("color","top")),e.setNormalizer("border-top-style",Is("style","top")),e.setNormalizer("border-top-width",Is("width","top")),e.setNormalizer("border-right-color",Is("color","right")),e.setNormalizer("border-right-style",Is("style","right")),e.setNormalizer("border-right-width",Is("width","right")),e.setNormalizer("border-bottom-color",Is("color","bottom")),e.setNormalizer("border-bottom-style",Is("style","bottom")),e.setNormalizer("border-bottom-width",Is("width","bottom")),e.setNormalizer("border-left-color",Is("color","left")),e.setNormalizer("border-left-style",Is("style","left")),e.setNormalizer("border-left-width",Is("width","left")),e.setExtractor("border-top",Vs("top")),e.setExtractor("border-right",Vs("right")),e.setExtractor("border-bottom",Vs("bottom")),e.setExtractor("border-left",Vs("left")),e.setExtractor("border-top-color","border.color.top"),e.setExtractor("border-right-color","border.color.right"),e.setExtractor("border-bottom-color","border.color.bottom"),e.setExtractor("border-left-color","border.color.left"),e.setExtractor("border-top-width","border.width.top"),e.setExtractor("border-right-width","border.width.right"),e.setExtractor("border-bottom-width","border.width.bottom"),e.setExtractor("border-left-width","border.width.left"),e.setExtractor("border-top-style","border.style.top"),e.setExtractor("border-right-style","border.style.right"),e.setExtractor("border-bottom-style","border.style.bottom"),e.setExtractor("border-left-style","border.style.left"),e.setReducer("border-color",ys("border-color")),e.setReducer("border-style",ys("border-style")),e.setReducer("border-width",ys("border-width")),e.setReducer("border-top",Bs("top")),e.setReducer("border-right",Bs("right")),e.setReducer("border-bottom",Bs("bottom")),e.setReducer("border-left",Bs("left")),e.setReducer("border",function(){return t=>{const i=Rs(t,"top"),n=Rs(t,"right"),o=Rs(t,"bottom"),s=Rs(t,"left"),r=[i,n,o,s],a={width:e(r,"width"),style:e(r,"style"),color:e(r,"color")},l=Ms(a,"all");if(l.length)return l;const c=Object.entries(a).reduce(((e,[t,i])=>(i&&(e.push([`border-${t}`,i]),r.forEach((e=>delete e[t]))),e)),[]);return[...c,...Ms(i,"top"),...Ms(n,"right"),...Ms(o,"bottom"),...Ms(s,"left")]};function e(e,t){return e.map((e=>e[t])).reduce(((e,t)=>e==t?e:null))}}()),e.setStyleRelation("border",["border-color","border-style","border-width","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),e.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),e.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),e.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),e.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),e.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function Ts(e){return t=>{const{color:i,style:n,width:o}=Os(t),s={};return void 0!==i&&(s.color={[e]:i}),void 0!==n&&(s.style={[e]:n}),void 0!==o&&(s.width={[e]:o}),{path:"border",value:s}}}function Ss(e){return t=>({path:"border",value:Ps(t,e)})}function Ps(e,t){return{[t]:_s(e)}}function Is(e,t){return i=>({path:"border",value:{[e]:{[t]:i}}})}function Vs(e){return(t,i)=>{if(i.border)return Rs(i.border,e)}}function Rs(e,t){const i={};return e.width&&e.width[t]&&(i.width=e.width[t]),e.style&&e.style[t]&&(i.style=e.style[t]),e.color&&e.color[t]&&(i.color=e.color[t]),i}function Os(e){const t={},i=As(e);for(const e of i)cs(e)||/thin|medium|thick/.test(e)?t.width=e:as(e)?t.style=e:t.color=e;return t}function Bs(e){return t=>Ms(t,e)}function Ms(e,t){const i=[];if(e&&e.width&&i.push("width"),e&&e.style&&i.push("style"),e&&e.color&&i.push("color"),3==i.length){const n=i.map((t=>e[t])).join(" ");return["all"==t?["border",n]:[`border-${t}`,n]]}return"all"==t?[]:i.map((i=>[`border-${t}-${i}`,e[i]]))}function Ns(e){e.setNormalizer("margin",Cs("margin")),e.setNormalizer("margin-top",(e=>({path:"margin.top",value:e}))),e.setNormalizer("margin-right",(e=>({path:"margin.right",value:e}))),e.setNormalizer("margin-bottom",(e=>({path:"margin.bottom",value:e}))),e.setNormalizer("margin-left",(e=>({path:"margin.left",value:e}))),e.setReducer("margin",ys("margin")),e.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}function Ds(e){e.setNormalizer("padding",Cs("padding")),e.setNormalizer("padding-top",(e=>({path:"padding.top",value:e}))),e.setNormalizer("padding-right",(e=>({path:"padding.right",value:e}))),e.setNormalizer("padding-bottom",(e=>({path:"padding.bottom",value:e}))),e.setNormalizer("padding-left",(e=>({path:"padding.left",value:e}))),e.setReducer("padding",ys("padding")),e.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}},5725:(e,t,i)=>{"use strict";i.d(t,{C:()=>u,G:()=>f});var n=i(7833);function*o(e,t){for(const i of t)i&&e.getAttributeProperties(i[0]).copyOnEnter&&(yield i)}class s extends n.Command{execute(){this.editor.model.change((e=>{this.enterBlock(e),this.fire("afterExecute",{writer:e})}))}enterBlock(e){const t=this.editor.model,i=t.document.selection,n=t.schema,s=i.isCollapsed,a=i.getFirstRange(),l=a.start.parent,c=a.end.parent;if(n.isLimit(l)||n.isLimit(c))return s||l!=c||t.deleteContent(i),!1;if(s){const t=o(e.model.schema,i.getAttributes());return r(e,a.start),e.setSelectionAttribute(t),!0}{const n=!(a.start.isAtStart&&a.end.isAtEnd),o=l==c;if(t.deleteContent(i,{leaveUnmerged:n}),n){if(o)return r(e,i.focus),!0;e.setSelection(c,0)}}return!1}}function r(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}var a=i(6243),l=i(5044);const c={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class d extends a.Observer{constructor(e){super(e);const t=this.document;let i=!1;t.on("keydown",((e,t)=>{i=t.shiftKey})),t.on("beforeinput",((n,o)=>{if(!this.isEnabled)return;let s=o.inputType;l.env.isSafari&&i&&"insertParagraph"==s&&(s="insertLineBreak");const r=o.domEvent,d=c[s];if(!d)return;const u=new a.BubblingEventInfo(t,"enter",o.targetRanges[0]);t.fire(u,new a.DomEventData(e,r,{isSoft:d.isSoft})),u.stop.called&&n.stop()}))}observe(){}stopObserving(){}}class u extends n.Plugin{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,i=t.document;t.addObserver(d),e.commands.add("enter",new s(e)),this.listenTo(i,"enter",((n,o)=>{i.isComposing||o.preventDefault(),o.isSoft||(e.execute("enter"),t.scrollToTheSelection())}),{priority:"low"})}}class h extends n.Command{execute(){const e=this.editor.model,t=e.document;e.change((i=>{!function(e,t,i){const n=i.isCollapsed,s=i.getFirstRange(),r=s.start.parent,a=s.end.parent,l=r==a;if(n){const n=o(e.schema,i.getAttributes());m(e,t,s.end),t.removeSelectionAttribute(i.getAttributeKeys()),t.setSelectionAttribute(n)}else{const n=!(s.start.isAtStart&&s.end.isAtEnd);e.deleteContent(i,{leaveUnmerged:n}),l?m(e,t,i.focus):n&&t.setSelection(a,0)}}(e,i,t.selection),this.fire("afterExecute",{writer:i})}))}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=function(e,t){if(t.rangeCount>1)return!1;const i=t.anchor;if(!i||!e.checkChild(i,"softBreak"))return!1;const n=t.getFirstRange(),o=n.start.parent,s=n.end.parent;return!g(o,e)&&!g(s,e)||o===s}(e.schema,t.selection)}}function m(e,t,i){const n=t.createElement("softBreak");e.insertContent(n,i),t.setSelection(n,"after")}function g(e,t){return!e.is("rootElement")&&(t.isLimit(e)||g(e.parent,t))}class f extends n.Plugin{static get pluginName(){return"ShiftEnter"}init(){const e=this.editor,t=e.model.schema,i=e.conversion,n=e.editing.view,o=n.document;t.register("softBreak",{allowWhere:"$text",isInline:!0}),i.for("upcast").elementToElement({model:"softBreak",view:"br"}),i.for("downcast").elementToElement({model:"softBreak",view:(e,{writer:t})=>t.createEmptyElement("br")}),n.addObserver(d),e.commands.add("shiftEnter",new h(e)),this.listenTo(o,"enter",((t,i)=>{o.isComposing||i.preventDefault(),i.isSoft&&(e.execute("shiftEnter"),n.scrollToTheSelection())}),{priority:"low"})}}},1638:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Essentials:()=>b});var n=i(6854),o=i(4079),s=i(1863),r=i(7833),a=i(5044);class l extends r.Command{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let i=e.schema.getLimitElement(t);if(t.containsEntireContent(i)||!c(e.schema,i))do{if(i=i.parent,!i)return}while(!c(e.schema,i));e.change((e=>{e.setSelection(i,"in")}))}}function c(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const d=(0,a.parseKeystroke)("Ctrl+A");class u extends r.Plugin{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new l(e)),this.listenTo(t,"keydown",((t,i)=>{(0,a.getCode)(i)===d&&(e.execute("selectAll"),i.preventDefault())}))}}var h=i(2692);class m extends r.Plugin{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(t=>{const i=e.commands.get("selectAll"),n=new h.ButtonView(t),o=t.t;return n.set({label:o("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),n.bind("isEnabled").to(i,"isEnabled"),this.listenTo(n,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),n}))}}class g extends r.Plugin{static get requires(){return[u,m]}static get pluginName(){return"SelectAll"}}var f=i(5187),p=i(1903);class b extends n.Sy{static get requires(){return[o.TU,s.C,g,s.G,f.Mq,p.WP]}static get pluginName(){return"Essentials"}}},3457:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Font:()=>F,FontBackgroundColor:()=>L,FontBackgroundColorEditing:()=>N,FontBackgroundColorUI:()=>D,FontColor:()=>B,FontColorEditing:()=>V,FontColorUI:()=>O,FontFamily:()=>_,FontFamilyEditing:()=>b,FontFamilyUI:()=>v,FontSize:()=>P,FontSizeEditing:()=>T,FontSizeUI:()=>S});var n=i(6854);class o extends n.mY{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute(this.attributeKey),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value,o=e.batch,s=e=>{if(i.isCollapsed)n?e.setSelectionAttribute(this.attributeKey,n):e.removeSelectionAttribute(this.attributeKey);else{const o=t.schema.getValidRanges(i.getRanges(),this.attributeKey);for(const t of o)n?e.setAttribute(this.attributeKey,n,t):e.removeAttribute(this.attributeKey,t)}};o?t.enqueueChange(o,(e=>{s(e)})):t.change((e=>{s(e)}))}}var s=i(7095);const r="fontSize",a="fontFamily",l="fontColor",c="fontBackgroundColor";function d(e,t){const i={model:{key:e,values:[]},view:{},upcastAlso:{}};for(const e of t)i.model.values.push(e.model),i.view[e.model]=e.view,e.upcastAlso&&(i.upcastAlso[e.model]=e.upcastAlso);return i}function u(e){return t=>t.getStyle(e).replace(/\s/g,"")}function h(e){return(t,{writer:i})=>i.createAttributeElement("span",{style:`${e}:${t}`},{priority:7})}class m extends o{constructor(e){super(e,a)}}function g(e){return e.map(f).filter((e=>void 0!==e))}function f(e){return"object"==typeof e?e:"default"===e?{title:"Default",model:void 0}:"string"==typeof e?function(e){const t=e.replace(/"|'/g,"").split(","),i=t[0],n=t.map(p).join(", ");return{title:i,model:n,view:{name:"span",styles:{"font-family":n},priority:7}}}(e):void 0}function p(e){return(e=e.trim()).indexOf(" ")>0&&(e=`'${e}'`),e}class b extends n.Sy{static get pluginName(){return"FontFamilyEditing"}constructor(e){super(e),e.config.define(a,{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:a}),e.model.schema.setAttributeProperties(a,{isFormatting:!0,copyOnEnter:!0});const t=g(e.config.get("fontFamily.options")).filter((e=>e.model)),i=d(a,t);e.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(i),e.commands.add(a,new m(e))}_prepareAnyValueConverters(){const e=this.editor;e.conversion.for("downcast").attributeToElement({model:a,view:(e,{writer:t})=>t.createAttributeElement("span",{style:"font-family:"+e},{priority:7})}),e.conversion.for("upcast").elementToAttribute({model:{key:a,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:a,value:e=>e.getAttribute("face")}})}}var w=i(6553);class v extends n.Sy{static get pluginName(){return"FontFamilyUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(a),o=t("Font Family");e.ui.componentFactory.add(a,(t=>{const r=(0,s.t9)(t);return(0,s.Pm)(r,(()=>function(e,t){const i=new w.FE;for(const n of e){const e={type:"button",model:new s.Hn({commandName:a,commandParam:n.model,label:n.title,role:"menuitemradio",withText:!0})};e.model.bind("isOn").to(t,"value",(e=>e===n.model||!(!e||!n.model)&&e.split(",")[0].replace(/'/g,"").toLowerCase()===n.model.toLowerCase())),n.view&&"string"!=typeof n.view&&n.view.styles&&e.model.set("labelStyle",`font-family: ${n.view.styles["font-family"]}`),i.add(e)}return i}(i,n)),{role:"menu",ariaLabel:o}),r.buttonView.set({label:o,icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),r.bind("isEnabled").to(n),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 g(e.config.get(a).options).map((e=>("Default"===e.title&&(e.title=t("Default")),e)))}}class _ extends n.Sy{static get requires(){return[b,v]}static get pluginName(){return"FontFamily"}}var y=i(3291);class k extends o{constructor(e){super(e,r)}}function C(e){return e.map((e=>function(e){if("number"==typeof e&&(e=String(e)),"object"==typeof e&&((t=e).title&&t.model&&t.view))return E(e);var t;const i=function(e){return"string"==typeof e?A[e]:A[e.model]}(e);return i?E(i):"default"===e?{model:void 0,title:"Default"}:function(e){let t;if("object"==typeof e){if(!e.model)throw new w.Bb("font-size-invalid-definition",null,e);t=parseFloat(e.model)}else t=parseFloat(e);return isNaN(t)}(e)?void 0:function(e){return"string"==typeof e&&(e={title:e,model:`${parseFloat(e)}px`}),e.view={name:"span",styles:{"font-size":e.model}},E(e)}(e)}(e))).filter((e=>void 0!==e))}const A={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 E(e){return e.view&&"string"!=typeof e.view&&!e.view.priority&&(e.view.priority=7),e}const x=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class T extends n.Sy{static get pluginName(){return"FontSizeEditing"}constructor(e){super(e),e.config.define(r,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:r}),e.model.schema.setAttributeProperties(r,{isFormatting:!0,copyOnEnter:!0});const t=e.config.get("fontSize.supportAllValues"),i=C(this.editor.config.get("fontSize.options")).filter((e=>e.model)),n=d(r,i);t?(this._prepareAnyValueConverters(n),this._prepareCompatibilityConverter()):e.conversion.attributeToElement(n),e.commands.add(r,new k(e))}_prepareAnyValueConverters(e){const t=this.editor,i=e.model.values.filter((e=>!(0,y.G9)(String(e))&&!(0,y.zz)(String(e))));if(i.length)throw new w.Bb("font-size-invalid-use-of-named-presets",null,{presets:i});t.conversion.for("downcast").attributeToElement({model:r,view:(e,{writer:t})=>{if(e)return t.createAttributeElement("span",{style:"font-size:"+e},{priority:7})}}),t.conversion.for("upcast").elementToAttribute({model:{key:r,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:r,value:e=>{const t=e.getAttribute("size"),i="-"===t[0]||"+"===t[0];let n=parseInt(t,10);i&&(n=3+n);const o=x.length-1,s=Math.min(Math.max(n,0),o);return x[s]}}})}}class S extends n.Sy{static get pluginName(){return"FontSizeUI"}init(){const e=this.editor,t=e.t,i=this._getLocalizedOptions(),n=e.commands.get(r),o=t("Font Size");e.ui.componentFactory.add(r,(t=>{const a=(0,s.t9)(t);return(0,s.Pm)(a,(()=>function(e,t){const i=new w.FE;for(const n of e){const e={type:"button",model:new s.Hn({commandName:r,commandParam:n.model,label:n.title,class:"ck-fontsize-option",role:"menuitemradio",withText:!0})};n.view&&"string"!=typeof n.view&&(n.view.styles&&e.model.set("labelStyle",`font-size:${n.view.styles["font-size"]}`),n.view.classes&&e.model.set("class",`${e.model.class} ${n.view.classes}`)),e.model.bind("isOn").to(t,"value",(e=>e===n.model)),i.add(e)}return i}(i,n)),{role:"menu",ariaLabel:o}),a.buttonView.set({label:o,icon:'',tooltip:!0}),a.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),a.bind("isEnabled").to(n),this.listenTo(a,"execute",(t=>{e.execute(t.source.commandName,{value:t.source.commandParam}),e.editing.view.focus()})),a}))}_getLocalizedOptions(){const e=this.editor,t=e.t,i={Default:t("Default"),Tiny:t("Tiny"),Small:t("Small"),Big:t("Big"),Huge:t("Huge")};return C(e.config.get(r).options).map((e=>{const t=i[e.title];return t&&t!=e.title&&(e=Object.assign({},e,{title:t})),e}))}}class P extends n.Sy{static get requires(){return[T,S]}static get pluginName(){return"FontSize"}normalizeSizeOptions(e){return C(e)}}class I extends o{constructor(e){super(e,l)}}class V extends n.Sy{static get pluginName(){return"FontColorEditing"}constructor(e){super(e),e.config.define(l,{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:l,value:u("color")}}),e.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:l,value:e=>e.getAttribute("color")}}),e.conversion.for("downcast").attributeToElement({model:l,view:h("color")}),e.commands.add(l,new I(e)),e.model.schema.extend("$text",{allowAttributes:l}),e.model.schema.setAttributeProperties(l,{isFormatting:!0,copyOnEnter:!0})}}class R extends n.Sy{constructor(e,{commandName:t,componentName:i,icon:n,dropdownLabel:o}){super(e),this.commandName=t,this.componentName=i,this.icon=n,this.dropdownLabel=o,this.columns=e.config.get(`${this.componentName}.columns`),this.colorSelectorView=void 0}init(){const e=this.editor,t=e.locale,i=t.t,n=e.commands.get(this.commandName),o=e.config.get(this.componentName),r=(0,s.S1)(o.colors),a=(0,s.k6)(t,r),l=o.documentColors,c=!1!==o.colorPicker;e.ui.componentFactory.add(this.componentName,(t=>{const r=(0,s.t9)(t);let d=!1;return this.colorSelectorView=function({dropdownView:e,colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:r,documentColorsCount:a,colorPickerViewConfig:l}){const c=e.locale,d=new s.MI(c,{colors:t,columns:i,removeButtonLabel:n,colorPickerLabel:o,documentColorsLabel:r,documentColorsCount:a,colorPickerViewConfig:l});return e.colorSelectorView=d,e.panelView.children.add(d),d}({dropdownView:r,colors:a.map((e=>({label:e.label,color:e.model,options:{hasBorder:e.hasBorder}}))),columns:this.columns,removeButtonLabel:i("Remove color"),colorPickerLabel:i("Color picker"),documentColorsLabel:0!==l?i("Document colors"):"",documentColorsCount:void 0===l?this.columns:l,colorPickerViewConfig:!!c&&(o.colorPicker||{})}),this.colorSelectorView.bind("selectedColor").to(n,"value"),r.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),r.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),r.bind("isEnabled").to(n),this.colorSelectorView.on("execute",((t,i)=>{r.isOpen&&e.execute(this.commandName,{value:i.value,batch:this._undoStepBatch}),"colorPicker"!==i.source&&e.editing.view.focus(),"colorPickerSaveButton"===i.source&&(r.isOpen=!1)})),this.colorSelectorView.on("colorPicker:show",(()=>{this._undoStepBatch=e.model.createBatch()})),this.colorSelectorView.on("colorPicker:cancel",(()=>{this._undoStepBatch.operations.length&&(r.isOpen=!1,e.execute("undo",this._undoStepBatch)),e.editing.view.focus()})),r.on("change:isOpen",((t,i,n)=>{d||(d=!0,r.colorSelectorView.appendUI()),n&&(0!==l&&this.colorSelectorView.updateDocumentColors(e.model,this.componentName),this.colorSelectorView.updateSelectedColors(),this.colorSelectorView.showColorGridsFragment())})),(0,s.Mh)(r,(()=>r.colorSelectorView.colorGridsFragmentView.staticColorsGrid.items.find((e=>e.isOn)))),r}))}}class O extends R{constructor(e){const t=e.locale.t;super(e,{commandName:l,componentName:l,icon:'',dropdownLabel:t("Font Color")})}static get pluginName(){return"FontColorUI"}}class B extends n.Sy{static get requires(){return[V,O]}static get pluginName(){return"FontColor"}}class M extends o{constructor(e){super(e,c)}}class N extends n.Sy{static get pluginName(){return"FontBackgroundColorEditing"}constructor(e){super(e),e.config.define(c,{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(y.QR),e.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{"background-color":/[\s\S]+/}},model:{key:c,value:u("background-color")}}),e.conversion.for("downcast").attributeToElement({model:c,view:h("background-color")}),e.commands.add(c,new M(e)),e.model.schema.extend("$text",{allowAttributes:c}),e.model.schema.setAttributeProperties(c,{isFormatting:!0,copyOnEnter:!0})}}class D extends R{constructor(e){const t=e.locale.t;super(e,{commandName:c,componentName:c,icon:'',dropdownLabel:t("Font Background Color")})}static get pluginName(){return"FontBackgroundColorUI"}}class L extends n.Sy{static get requires(){return[N,D]}static get pluginName(){return"FontBackgroundColor"}}class F extends n.Sy{static get requires(){return[_,P,B,L]}static get pluginName(){return"Font"}}},8107:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Heading:()=>m,HeadingButtonsUI:()=>f,HeadingEditing:()=>c,HeadingUI:()=>h,Title:()=>w});var n=i(6854),o=i(4690),s=i(6553);class r extends n.mY{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=(0,s.Ps)(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>a(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,i=t.document,n=e.value;t.change((e=>{const o=Array.from(i.selection.getSelectedBlocks()).filter((e=>a(e,n,t.schema)));for(const t of o)t.is("element",n)||e.rename(t,n)}))}}function a(e,t,i){return i.checkChild(e.parent,t)&&!i.isObject(e)}const l="paragraph";class c extends n.Sy{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[o.Paragraph]}init(){const e=this.editor,t=e.config.get("heading.options"),i=[];for(const n of t)"paragraph"!==n.model&&(e.model.schema.register(n.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(n),i.push(n.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new r(e,i))}afterInit(){const e=this.editor,t=e.commands.get("enter"),i=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,n)=>{const o=e.model.document.selection.getFirstPosition().parent;i.some((e=>o.is("element",e.model)))&&!o.is("element",l)&&0===o.childCount&&n.writer.rename(o,l)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:s.tA.low+1})}}var d=i(7095);function u(e){const t=e.t,i={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map((e=>{const t=i[e.title];return t&&t!=e.title&&(e.title=t),e}))}class h extends n.Sy{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,i=u(e),n=t("Choose heading"),o=t("Heading");e.ui.componentFactory.add("heading",(t=>{const r={},a=new s.FE,l=e.commands.get("heading"),c=e.commands.get("paragraph"),u=[l];for(const e of i){const t={type:"button",model:new d.Hn({label:e.title,class:e.class,role:"menuitemradio",withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(c,"value"),t.model.set("commandName","paragraph"),u.push(c)):(t.model.bind("isOn").to(l,"value",(t=>t===e.model)),t.model.set({commandName:"heading",commandValue:e.model})),a.add(t),r[e.model]=e.title}const h=(0,d.t9)(t);return(0,d.Pm)(h,a,{ariaLabel:o,role:"menu"}),h.buttonView.set({ariaLabel:o,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:o}),h.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),h.bind("isEnabled").toMany(u,"isEnabled",((...e)=>e.some((e=>e)))),h.buttonView.bind("label").to(l,"value",c,"value",((e,t)=>{const i=e||t&&"paragraph";return"boolean"==typeof i?n:r[i]?r[i]:n})),this.listenTo(h,"execute",(t=>{const{commandName:i,commandValue:n}=t.source;e.execute(i,n?{value:n}:void 0),e.editing.view.focus()})),h}))}}class m extends n.Sy{static get requires(){return[c,h]}static get pluginName(){return"Heading"}}const g={heading1:'',heading2:'',heading3:'',heading4:'',heading5:'',heading6:''};class f extends n.Sy{init(){u(this.editor).filter((e=>"paragraph"!==e.model)).map((e=>this._createButton(e)))}_createButton(e){const t=this.editor;t.ui.componentFactory.add(e.model,(i=>{const n=new d.r5(i),o=t.commands.get("heading");return n.label=e.title,n.icon=e.icon||g[e.model],n.tooltip=!0,n.isToggleable=!0,n.bind("isEnabled").to(o),n.bind("isOn").to(o,"value",(t=>t==e.model)),n.on("execute",(()=>{t.execute("heading",{value:e.model}),t.editing.view.focus()})),n}))}}var p=i(3291);const b=new Set(["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"]);class w extends n.Sy{constructor(){super(...arguments),this._bodyPlaceholder=new Map}static get pluginName(){return"Title"}static get requires(){return["Paragraph"]}init(){const e=this.editor,t=e.model;t.schema.register("title",{isBlock:!0,allowIn:"$root"}),t.schema.register("title-content",{isBlock:!0,allowIn:"title",allowAttributes:["alignment"]}),t.schema.extend("$text",{allowIn:"title-content"}),t.schema.addAttributeCheck((e=>{if(e.endsWith("title-content $text"))return!1})),e.editing.mapper.on("modelToViewPosition",_(e.editing.view)),e.data.mapper.on("modelToViewPosition",_(e.editing.view)),e.conversion.for("downcast").elementToElement({model:"title-content",view:"h1"}),e.conversion.for("downcast").add((e=>e.on("insert:title",((e,t,i)=>{i.consumable.consume(t.item,e.name)})))),e.data.upcastDispatcher.on("element:h1",v,{priority:"high"}),e.data.upcastDispatcher.on("element:h2",v,{priority:"high"}),e.data.upcastDispatcher.on("element:h3",v,{priority:"high"}),t.document.registerPostFixer((e=>this._fixTitleContent(e))),t.document.registerPostFixer((e=>this._fixTitleElement(e))),t.document.registerPostFixer((e=>this._fixBodyElement(e))),t.document.registerPostFixer((e=>this._fixExtraParagraph(e))),this._attachPlaceholders(),this._attachTabPressHandling()}getTitle(e={}){const t=e.rootName?e.rootName:void 0,i=this._getTitleElement(t).getChild(0);return this.editor.data.stringify(i,e)}getBody(e={}){const t=this.editor,i=t.data,n=t.model,o=e.rootName?e.rootName:void 0,s=t.model.document.getRoot(o),r=t.editing.view,a=new p.qD(r.document),l=n.createRangeIn(s),c=a.createDocumentFragment(),d=n.createPositionAfter(s.getChild(0)),u=n.createRange(d,n.createPositionAt(s,"end")),h=new Map;for(const e of n.markers){const t=u.getIntersection(e.getRange());t&&h.set(e.name,t)}return i.mapper.clearBindings(),i.mapper.bindElements(s,c),i.downcastDispatcher.convert(l,h,a,e),a.remove(a.createRangeOn(c.getChild(0))),t.data.processor.toData(c)}_getTitleElement(e){const t=this.editor.model.document.getRoot(e);for(const e of t.getChildren())if(y(e))return e}_fixTitleContent(e){let t=!1;for(const i of this.editor.model.document.getRootNames()){const n=this._getTitleElement(i);if(!n||1===n.maxOffset)continue;const o=Array.from(n.getChildren());o.shift();for(const t of o)e.move(e.createRangeOn(t),n,"after"),e.rename(t,"paragraph");t=!0}return t}_fixTitleElement(e){let t=!1;const i=this.editor.model;for(const n of this.editor.model.document.getRoots()){const o=Array.from(n.getChildren()).filter(y),s=o[0],r=n.getChild(0);if(r.is("element","title"))o.length>1&&(C(o,e,i),t=!0);else if(s||b.has(r.name))b.has(r.name)?k(r,e,i):e.move(e.createRangeOn(s),n,0),C(o,e,i),t=!0;else{const i=e.createElement("title");e.insert(i,n),e.insertElement("title-content",i),t=!0}}return t}_fixBodyElement(e){let t=!1;for(const i of this.editor.model.document.getRootNames()){const n=this.editor.model.document.getRoot(i);if(n.childCount<2){const o=e.createElement("paragraph");e.insert(o,n,1),this._bodyPlaceholder.set(i,o),t=!0}}return t}_fixExtraParagraph(e){let t=!1;for(const i of this.editor.model.document.getRootNames()){const n=this.editor.model.document.getRoot(i),o=this._bodyPlaceholder.get(i);E(o,n)&&(this._bodyPlaceholder.delete(i),e.remove(o),t=!0)}return t}_attachPlaceholders(){const e=this.editor,t=e.t,i=e.editing.view,n=e.sourceElement,o=e.config.get("title.placeholder")||t("Type your title"),s=e.config.get("placeholder")||n&&"textarea"===n.tagName.toLowerCase()&&n.getAttribute("placeholder")||t("Type or paste your content here.");e.editing.downcastDispatcher.on("insert:title-content",((e,t,n)=>{const s=n.mapper.toViewElement(t.item);s.placeholder=o,(0,p.ID)({view:i,element:s,keepOnFocus:!0})}));const r=new Map;i.document.registerPostFixer((e=>{let t=!1;for(const n of i.document.roots){if(n.isEmpty)continue;const i=n.getChild(1),o=r.get(n.rootName);i!==o&&(o&&((0,p.$_)(e,o),e.removeAttribute("data-placeholder",o)),e.setAttribute("data-placeholder",s,i),r.set(n.rootName,i),t=!0),t=(0,p.Q7)(i,!0)&&2===n.childCount&&"p"===i.name?!!(0,p.NJ)(e,i)||t:!!(0,p.$_)(e,i)||t}return t}))}_attachTabPressHandling(){const e=this.editor,t=e.model;e.keystrokes.set("TAB",((e,i)=>{t.change((e=>{const n=t.document.selection,o=Array.from(n.getSelectedBlocks());if(1===o.length&&o[0].is("element","title-content")){const t=n.getFirstPosition().root.getChild(1);e.setSelection(t,0),i()}}))})),e.keystrokes.set("SHIFT + TAB",((i,n)=>{t.change((i=>{const o=t.document.selection;if(!o.isCollapsed)return;const r=(0,s.Ps)(o.getSelectedBlocks()),a=o.getFirstPosition(),l=e.model.document.getRoot(a.root.rootName),c=l.getChild(0);r===l.getChild(1)&&a.isAtStart&&(i.setSelection(c.getChild(0),0),n())}))}))}}function v(e,t,i){const n=t.modelCursor,o=t.viewItem;if(!n.isAtStart||!n.parent.is("element","$root"))return;if(!i.consumable.consume(o,{name:!0}))return;const s=i.writer,r=s.createElement("title"),a=s.createElement("title-content");s.append(a,r),s.insert(r,n),i.convertChildren(o,a),i.updateConversionResult(r,t)}function _(e){return(t,i)=>{const n=i.modelPosition.parent;if(!n.is("element","title"))return;const o=n.parent,s=i.mapper.toViewElement(o);i.viewPosition=e.createPositionAt(s,0),t.stop()}}function y(e){return e.is("element","title")}function k(e,t,i){const n=t.createElement("title");t.insert(n,e,"before"),t.insert(e,n,0),t.rename(e,"title-content"),i.schema.removeDisallowedAttributes([e],t)}function C(e,t,i){let n=!1;for(const o of e)0!==o.index&&(A(o,t,i),n=!0);return n}function A(e,t,i){const n=e.getChild(0);n.isEmpty?t.remove(e):(t.move(t.createRangeOn(n),e,"before"),t.rename(n,"paragraph"),t.remove(e),i.schema.removeDisallowedAttributes([n],t))}function E(e,t){return!(!e||!e.is("element","paragraph")||e.childCount||t.childCount<=2||t.getChild(t.childCount-1)!==e)}},5242:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Highlight:()=>c,HighlightEditing:()=>s,HighlightUI:()=>a});var n=i(6854);class o extends n.mY{refresh(){const e=this.editor.model,t=e.document;this.value=t.selection.getAttribute("highlight"),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"highlight")}execute(e={}){const t=this.editor.model,i=t.document.selection,n=e.value;t.change((e=>{if(i.isCollapsed){const t=i.getFirstPosition();if(i.hasAttribute("highlight")){const i=e=>e.item.hasAttribute("highlight")&&e.item.getAttribute("highlight")===this.value,o=t.getLastMatchingPosition(i,{direction:"backward"}),s=t.getLastMatchingPosition(i),r=e.createRange(o,s);n&&this.value!==n?(t.isEqual(s)||e.setAttribute("highlight",n,r),e.setSelectionAttribute("highlight",n)):(t.isEqual(s)||e.removeAttribute("highlight",r),e.removeSelectionAttribute("highlight"))}else n&&e.setSelectionAttribute("highlight",n)}else{const o=t.schema.getValidRanges(i.getRanges(),"highlight");for(const t of o)n?e.setAttribute("highlight",n,t):e.removeAttribute("highlight",t)}}))}}class s extends n.Sy{static get pluginName(){return"HighlightEditing"}constructor(e){super(e),e.config.define("highlight",{options:[{model:"yellowMarker",class:"marker-yellow",title:"Yellow marker",color:"var(--ck-highlight-marker-yellow)",type:"marker"},{model:"greenMarker",class:"marker-green",title:"Green marker",color:"var(--ck-highlight-marker-green)",type:"marker"},{model:"pinkMarker",class:"marker-pink",title:"Pink marker",color:"var(--ck-highlight-marker-pink)",type:"marker"},{model:"blueMarker",class:"marker-blue",title:"Blue marker",color:"var(--ck-highlight-marker-blue)",type:"marker"},{model:"redPen",class:"pen-red",title:"Red pen",color:"var(--ck-highlight-pen-red)",type:"pen"},{model:"greenPen",class:"pen-green",title:"Green pen",color:"var(--ck-highlight-pen-green)",type:"pen"}]})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"highlight"});const t=e.config.get("highlight.options");e.conversion.attributeToElement(function(e){const t={model:{key:"highlight",values:[]},view:{}};for(const i of e)t.model.values.push(i.model),t.view[i.model]={name:"mark",classes:i.class};return t}(t)),e.commands.add("highlight",new o(e))}}var r=i(7095);class a extends n.Sy{get localizedOptionTitles(){const e=this.editor.t;return{"Yellow marker":e("Yellow marker"),"Green marker":e("Green marker"),"Pink marker":e("Pink marker"),"Blue marker":e("Blue marker"),"Red pen":e("Red pen"),"Green pen":e("Green pen")}}static get pluginName(){return"HighlightUI"}init(){const e=this.editor.config.get("highlight.options");for(const t of e)this._addHighlighterButton(t);this._addRemoveHighlightButton(),this._addDropdown(e)}_addRemoveHighlightButton(){const e=this.editor.t,t=this.editor.commands.get("highlight");this._addButton("removeHighlight",e("Remove highlight"),n.icons.eraser,null,(e=>{e.bind("isEnabled").to(t,"isEnabled")}))}_addHighlighterButton(e){const t=this.editor.commands.get("highlight");this._addButton("highlight:"+e.model,e.title,l(e.type),e.model,(function(i){i.bind("isEnabled").to(t,"isEnabled"),i.bind("isOn").to(t,"value",(t=>t===e.model)),i.iconView.fillColor=e.color,i.isToggleable=!0}))}_addButton(e,t,i,n,o){const s=this.editor;s.ui.componentFactory.add(e,(e=>{const a=new r.r5(e),l=this.localizedOptionTitles[t]?this.localizedOptionTitles[t]:t;return a.set({label:l,icon:i,tooltip:!0}),a.on("execute",(()=>{s.execute("highlight",{value:n}),s.editing.view.focus()})),o(a),a}))}_addDropdown(e){const t=this.editor,i=t.t,n=t.ui.componentFactory,o=e[0],s=e.reduce(((e,t)=>(e[t.model]=t,e)),{});n.add("highlight",(a=>{const c=t.commands.get("highlight"),d=(0,r.t9)(a,r.Rm),u=d.buttonView;function h(e,t){const i=e&&e!==u.lastExecuted?e:u.lastExecuted;return s[i][t]}return u.set({label:i("Highlight"),tooltip:!0,lastExecuted:o.model,commandValue:o.model,isToggleable:!0}),u.bind("icon").to(c,"value",(e=>l(h(e,"type")))),u.bind("color").to(c,"value",(e=>h(e,"color"))),u.bind("commandValue").to(c,"value",(e=>h(e,"model"))),u.bind("isOn").to(c,"value",(e=>!!e)),u.delegate("execute").to(d),d.bind("isEnabled").to(c,"isEnabled"),(0,r.up)(d,(()=>{const t=e.map((e=>{const t=n.create("highlight:"+e.model);return this.listenTo(t,"execute",(()=>{d.buttonView.set({lastExecuted:e.model})})),t}));return t.push(new r.$y),t.push(n.create("removeHighlight")),t}),{enableActiveItemFocusOnDropdownOpen:!0,ariaLabel:i("Text highlight toolbar")}),function(e){e.buttonView.actionView.iconView.bind("fillColor").to(e.buttonView,"color")}(d),u.on("execute",(()=>{t.execute("highlight",{value:u.commandValue})})),this.listenTo(d,"execute",(()=>{t.editing.view.focus()})),d}))}}function l(e){return"marker"===e?'':''}class c extends n.Sy{static get requires(){return[s,a]}static get pluginName(){return"Highlight"}}},2337:(e,t,i)=>{"use strict";i.r(t),i.d(t,{HorizontalLine:()=>c,HorizontalLineEditing:()=>r,HorizontalLineUI:()=>l});var n=i(6854),o=i(5549);class s extends n.mY{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection;this.isEnabled=function(e,t,i){const n=function(e,t){const i=(0,o.KT)(e,t).start.parent;return i.isEmpty&&!i.is("element","$root")?i.parent:i}(e,i);return t.checkChild(n,"horizontalLine")}(i,t,e)}execute(){const e=this.editor.model;e.change((t=>{const i=t.createElement("horizontalLine");e.insertObject(i,null,null,{setSelection:"after"})}))}}class r extends n.Sy{static get pluginName(){return"HorizontalLineEditing"}init(){const e=this.editor,t=e.model.schema,i=e.t,n=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),n.for("dataDowncast").elementToElement({model:"horizontalLine",view:(e,{writer:t})=>t.createEmptyElement("hr")}),n.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(e,{writer:t})=>{const n=i("Horizontal line"),s=t.createContainerElement("div",null,t.createEmptyElement("hr"));return t.addClass("ck-horizontal-line",s),t.setCustomProperty("hr",!0,s),function(e,t,i){return t.setCustomProperty("horizontalLine",!0,e),(0,o.XC)(e,t,{label:i})}(s,t,n)}}),n.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new s(e))}}var a=i(7095);class l extends n.Sy{static get pluginName(){return"HorizontalLineUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("horizontalLine",(i=>{const n=e.commands.get("horizontalLine"),o=new a.r5(i);return o.set({label:t("Horizontal line"),icon:'',tooltip:!0}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("horizontalLine"),e.editing.view.focus()})),o}))}}class c extends n.Sy{static get requires(){return[r,l,o.$L]}static get pluginName(){return"HorizontalLine"}}},8691:(e,t,i)=>{"use strict";i.r(t),i.d(t,{HtmlEmbed:()=>h,HtmlEmbedEditing:()=>c,HtmlEmbedUI:()=>u});var n=i(6854),o=i(5549),s=i(7095),r=i(6553);class a extends n.mY{refresh(){const e=this.editor.model,t=e.schema,i=e.document.selection,n=l(i);this.isEnabled=function(e,t,i){const n=function(e,t){const i=(0,o.KT)(e,t).start.parent;return i.isEmpty&&!i.is("rootElement")?i.parent:i}(e,i);return t.checkChild(n,"rawHtml")}(i,t,e),this.value=n?n.getAttribute("value")||"":null}execute(e){const t=this.editor.model,i=t.document.selection;t.change((n=>{let o;null!==this.value?o=l(i):(o=n.createElement("rawHtml"),t.insertObject(o,null,null,{setSelection:"on"})),n.setAttribute("value",e,o)}))}}function l(e){const t=e.getSelectedElement();return t&&t.is("element","rawHtml")?t:null}class c extends n.Sy{static get pluginName(){return"HtmlEmbedEditing"}constructor(e){super(e),this._widgetButtonViewReferences=new Set,e.config.define("htmlEmbed",{showPreviews:!1,sanitizeHtml:e=>((0,r.KE)("html-embed-provide-sanitize-function"),{html:e,hasChanged:!1})})}init(){const e=this.editor;e.model.schema.register("rawHtml",{inheritAllFrom:"$blockObject",allowAttributes:["value"]}),e.commands.add("htmlEmbed",new a(e)),this._setupConversion()}_setupConversion(){const e=this.editor,t=e.t,i=e.editing.view,n=this._widgetButtonViewReferences,s=e.config.get("htmlEmbed");function a({editor:e,domElement:i,state:o,props:s}){i.textContent="";const a=i.ownerDocument;let c;if(o.isEditable){const e={isDisabled:!1,placeholder:s.textareaPlaceholder};c=l({domDocument:a,state:o,props:e}),i.append(c)}else if(o.showPreviews){const n={sanitizeHtml:s.sanitizeHtml};i.append(function({editor:e,domDocument:i,state:n,props:o}){const s=o.sanitizeHtml(n.getRawHtmlValue()),a=n.getRawHtmlValue().length>0?t("No preview available"):t("Empty snippet content"),l=(0,r.az)(i,"div",{class:"ck ck-reset_all raw-html-embed__preview-placeholder"},a),c=(0,r.az)(i,"div",{class:"raw-html-embed__preview-content",dir:e.locale.contentLanguageDirection}),d=i.createRange().createContextualFragment(s.html);c.appendChild(d);return(0,r.az)(i,"div",{class:"raw-html-embed__preview"},[l,c])}({domDocument:a,state:o,props:n,editor:e}))}else{const e={isDisabled:!0,placeholder:s.textareaPlaceholder};i.append(l({domDocument:a,state:o,props:e}))}const u={onEditClick:s.onEditClick,onSaveClick:()=>{s.onSaveClick(c.value)},onCancelClick:s.onCancelClick};i.prepend(function({editor:e,domDocument:t,state:i,props:o}){const s=(0,r.az)(t,"div",{class:"raw-html-embed__buttons-wrapper"});if(i.isEditable){const t=d(e,"save",o.onSaveClick),i=d(e,"cancel",o.onCancelClick);s.append(t.element,i.element),n.add(t).add(i)}else{const t=d(e,"edit",o.onEditClick);s.append(t.element),n.add(t)}return s}({editor:e,domDocument:a,state:o,props:u}))}function l({domDocument:e,state:t,props:i}){const n=(0,r.az)(e,"textarea",{placeholder:i.placeholder,class:"ck ck-reset ck-input ck-input-text raw-html-embed__source"});return n.disabled=i.isDisabled,n.value=t.getRawHtmlValue(),n}this.editor.editing.view.on("render",(()=>{for(const e of n){if(e.element&&e.element.isConnected)return;e.destroy(),n.delete(e)}}),{priority:"lowest"}),e.data.registerRawContentMatcher({name:"div",classes:"raw-html-embed"}),e.conversion.for("upcast").elementToElement({view:{name:"div",classes:"raw-html-embed"},model:(e,{writer:t})=>t.createElement("rawHtml",{value:e.getCustomProperty("$rawContent")})}),e.conversion.for("dataDowncast").elementToElement({model:"rawHtml",view:(e,{writer:t})=>t.createRawElement("div",{class:"raw-html-embed"},(function(t){t.innerHTML=e.getAttribute("value")||""}))}),e.conversion.for("editingDowncast").elementToStructure({model:{name:"rawHtml",attributes:["value"]},view:(n,{writer:r})=>{let l,c,d;const u=r.createRawElement("div",{class:"raw-html-embed__content-wrapper"},(function(t){l=t,a({editor:e,domElement:t,state:c,props:d}),l.addEventListener("mousedown",(()=>{if(c.isEditable){const t=e.model;t.document.selection.getSelectedElement()!==n&&t.change((e=>e.setSelection(n,"on")))}}),!0)})),h={makeEditable(){c=Object.assign({},c,{isEditable:!0}),a({domElement:l,editor:e,state:c,props:d}),i.change((e=>{e.setAttribute("data-cke-ignore-events","true",u)})),l.querySelector("textarea").focus()},save(t){t!==c.getRawHtmlValue()?(e.execute("htmlEmbed",t),e.editing.view.focus()):this.cancel()},cancel(){c=Object.assign({},c,{isEditable:!1}),a({domElement:l,editor:e,state:c,props:d}),e.editing.view.focus(),i.change((e=>{e.removeAttribute("data-cke-ignore-events",u)}))}};c={showPreviews:s.showPreviews,isEditable:!1,getRawHtmlValue:()=>n.getAttribute("value")||""},d={sanitizeHtml:s.sanitizeHtml,textareaPlaceholder:t("Paste raw HTML here..."),onEditClick(){h.makeEditable()},onSaveClick(e){h.save(e)},onCancelClick(){h.cancel()}};const m=r.createContainerElement("div",{class:"raw-html-embed","data-html-embed-label":t("HTML snippet"),dir:e.locale.uiLanguageDirection},u);return r.setCustomProperty("rawHtmlApi",h,m),r.setCustomProperty("rawHtml",!0,m),(0,o.XC)(m,r,{label:t("HTML snippet"),hasSelectionHandle:!0})}})}}function d(e,t,i){const{t:o}=e.locale,r=new s.r5(e.locale),a=e.commands.get("htmlEmbed");return r.set({class:`raw-html-embed__${t}-button`,icon:n.icons.pencil,tooltip:!0,tooltipPosition:"rtl"===e.locale.uiLanguageDirection?"e":"w"}),r.render(),"edit"===t?(r.set({icon:n.icons.pencil,label:o("Edit source")}),r.bind("isEnabled").to(a)):"save"===t?(r.set({icon:n.icons.check,label:o("Save changes")}),r.bind("isEnabled").to(a)):r.set({icon:n.icons.cancel,label:o("Cancel")}),r.on("execute",i),r}class u extends n.Sy{static get pluginName(){return"HtmlEmbedUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("htmlEmbed",(i=>{const n=e.commands.get("htmlEmbed"),o=new s.r5(i);return o.set({label:t("Insert HTML"),icon:'',tooltip:!0}),o.bind("isEnabled").to(n,"isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("htmlEmbed"),e.editing.view.focus(),e.editing.view.document.selection.getSelectedElement().getCustomProperty("rawHtmlApi").makeEditable()})),o}))}}class h extends n.Sy{static get requires(){return[c,u,o.$L]}static get pluginName(){return"HtmlEmbed"}}},7261:(e,t,i)=>{"use strict";i.r(t),i.d(t,{AutoImage:()=>p,Image:()=>M,ImageBlock:()=>R,ImageBlockEditing:()=>V,ImageCaption:()=>z,ImageCaptionEditing:()=>L,ImageCaptionUI:()=>F,ImageCaptionUtils:()=>N,ImageEditing:()=>P,ImageInline:()=>B,ImageInsert:()=>re,ImageInsertUI:()=>oe,ImageInsertViaUrl:()=>se,ImageResize:()=>fe,ImageResizeButtons:()=>de,ImageResizeEditing:()=>le,ImageResizeHandles:()=>ge,ImageStyle:()=>De,ImageStyleEditing:()=>Ie,ImageStyleUI:()=>Oe,ImageTextAlternative:()=>C,ImageTextAlternativeEditing:()=>w,ImageTextAlternativeUI:()=>k,ImageToolbar:()=>Le,ImageUpload:()=>ee,ImageUploadEditing:()=>Q,ImageUploadProgress:()=>$,ImageUploadUI:()=>j,ImageUtils:()=>m,PictureEditing:()=>Fe});var n=i(6854),o=i(4079),s=i(3291),r=i(1903),a=i(5187),l=i(6553),c=i(5549);function d(e){return e.createContainerElement("figure",{class:"image"},[e.createEmptyElement("img"),e.createSlot("children")])}function u(e,t){const i=e.plugins.get("ImageUtils"),n=e.plugins.has("ImageInlineEditing")&&e.plugins.has("ImageBlockEditing");return e=>i.isInlineImageView(e)?n&&("block"==e.getStyle("display")||e.findAncestor(i.isBlockImageView)?"imageBlock":"imageInline")!==t?null:o(e):null;function o(e){const t={name:!0};return e.hasAttribute("src")&&(t.attributes=["src"]),t}}function h(e,t){const i=(0,l.Ps)(t.getSelectedBlocks());return!i||e.isObject(i)||i.isEmpty&&"listItem"!=i.name?"imageBlock":"imageInline"}class m extends n.Sy{static get pluginName(){return"ImageUtils"}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(e={},t=null,i=null){const n=this.editor,o=n.model,s=o.document.selection;i=g(n,t||s,i),e={...Object.fromEntries(s.getAttributes()),...e};for(const t in e)o.schema.checkAttribute(i,t)||delete e[t];return o.change((n=>{const s=n.createElement(i,e);return o.insertObject(s,t,null,{setSelection:"on",findOptimalPosition:t||"imageInline"==i?void 0:"auto"}),s.parent?s:null}))}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const i=e.getSelectedElement();if(i&&this.isImageWidget(i))return i;let n=t.parent;for(;n;){if(n.is("element")&&this.isImageWidget(n))return n;n=n.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}isImageAllowed(){const e=this.editor.model.document.selection;return function(e,t){if("imageBlock"==g(e,t,null)){const i=function(e,t){const i=(0,c.KT)(e,t).start.parent;return i.isEmpty&&!i.is("element","$root")?i.parent:i}(t,e.model);if(e.model.schema.checkChild(i,"imageBlock"))return!0}else if(e.model.schema.checkChild(t.focus,"imageInline"))return!0;return!1}(this.editor,e)&&function(e){return[...e.focus.getAncestors()].every((e=>!e.is("element","imageBlock")))}(e)}toImageWidget(e,t,i){return t.setCustomProperty("image",!0,e),(0,c.XC)(e,t,{label:()=>{const t=this.findViewImgElement(e).getAttribute("alt");return t?`${t} ${i}`:i}})}isImageWidget(e){return!!e.getCustomProperty("image")&&(0,c.Qd)(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:i}of t.createRangeIn(e))if(this.isInlineImageView(i))return i}}function g(e,t,i){const n=e.model.schema,o=e.config.get("image.insert.type");return e.plugins.has("ImageBlockEditing")?e.plugins.has("ImageInlineEditing")?i||("inline"===o?"imageInline":"block"===o?"imageBlock":t.is("selection")?h(n,t):n.checkChild(t,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}const f=new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@!$&'()*+,;=%-]+/.source+/\.(jpg|jpeg|png|gif|ico|webp|JPG|JPEG|PNG|GIF|ICO|WEBP)/.source+/(\?[\w.~:/[\]@!$&'()*+,;=%-]*)?/.source+/(#[\w.~:/[\]@!$&'()*+,;=%-]*)?$/.source));class p extends n.Sy{static get requires(){return[o.TU,m,r.WP,a.HG]}static get pluginName(){return"AutoImage"}constructor(e){super(e),this._timeoutId=null,this._positionToInsert=null}init(){const e=this.editor,t=e.model.document,i=e.plugins.get("ClipboardPipeline");this.listenTo(i,"inputTransformation",(()=>{const e=t.selection.getFirstRange(),i=s.jP.fromPosition(e.start);i.stickiness="toPrevious";const n=s.jP.fromPosition(e.end);n.stickiness="toNext",t.once("change:data",(()=>{this._embedImageBetweenPositions(i,n),i.detach(),n.detach()}),{priority:"high"})})),e.commands.get("undo").on("execute",(()=>{this._timeoutId&&(l.CO.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)}),{priority:"high"})}_embedImageBetweenPositions(e,t){const i=this.editor,n=new s.iE(e,t),o=n.getWalker({ignoreElementEnd:!0}),r=Object.fromEntries(i.model.document.selection.getAttributes()),a=this.editor.plugins.get("ImageUtils");let l="";for(const e of o)e.item.is("$textProxy")&&(l+=e.item.data);l=l.trim(),l.match(f)?(this._positionToInsert=s.jP.fromPosition(e),this._timeoutId=setTimeout((()=>{i.commands.get("insertImage").isEnabled?(i.model.change((e=>{let t;this._timeoutId=null,e.remove(n),n.detach(),"$graveyard"!==this._positionToInsert.root.rootName&&(t=this._positionToInsert.toPosition()),a.insertImage({...r,src:l},t),this._positionToInsert.detach(),this._positionToInsert=null})),i.plugins.get("Delete").requestUndoOnBackspace()):n.detach()}),100)):n.detach()}}class b extends n.mY{refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,i=t.plugins.get("ImageUtils"),n=t.model,o=i.getClosestSelectedImageElement(n.document.selection);n.change((t=>{t.setAttribute("alt",e.newValue,o)}))}}class w extends n.Sy{static get requires(){return[m]}static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new b(this.editor))}}var v=i(7095);class _ extends v.G7{constructor(e){super(e);const t=this.locale.t;this.focusTracker=new l.Rh,this.keystrokes=new l.VD,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),n.icons.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),n.icons.cancel,"ck-button-cancel","cancel"),this._focusables=new v.vX,this._focusCycler=new v.I0({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),(0,v.GI)({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(e,t,i,n){const o=new v.r5(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:i}}),n&&o.delegate("execute").to(this,n),o}_createLabeledInputView(){const e=this.locale.t,t=new v.KP(this.locale,v.R);return t.label=e("Text alternative"),t}}function y(e){const t=e.editing.view,i=v.no.defaultPositions,n=e.plugins.get("ImageUtils");return{target:t.domConverter.mapViewToDom(n.getClosestSelectedImageWidget(t.document.selection)),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}class k extends n.Sy{static get requires(){return[v.WB]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",(i=>{const o=e.commands.get("imageTextAlternative"),s=new v.r5(i);return s.set({label:t("Change image text alternative"),icon:n.icons.lowVision,tooltip:!0}),s.bind("isEnabled").to(o,"isEnabled"),s.bind("isOn").to(o,"value",(e=>!!e)),this.listenTo(s,"execute",(()=>{this._showForm()})),s}))}_createForm(){const e=this.editor,t=e.editing.view.document,i=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new((0,v.RX)(_))(e.locale),this._form.render(),this.listenTo(this._form,"submit",(()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((e,t)=>{this._hideForm(!0),t()})),this.listenTo(e.ui,"update",(()=>{i.getClosestSelectedImageWidget(t.selection)?this._isVisible&&function(e){const t=e.plugins.get("ContextualBalloon");if(e.plugins.get("ImageUtils").getClosestSelectedImageWidget(e.editing.view.document.selection)){const i=y(e);t.updatePosition(i)}}(e):this._hideForm(!0)})),(0,v.eC)({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const e=this.editor,t=e.commands.get("imageTextAlternative"),i=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:y(e)}),i.fieldView.value=i.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class C extends n.Sy{static get requires(){return[w,k]}static get pluginName(){return"ImageTextAlternative"}}function A(e,t){const i=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const o=n.writer,s=n.mapper.toViewElement(i.item),r=e.findViewImgElement(s);if(null===i.attributeNewValue){const e=i.attributeOldValue;e&&e.data&&(o.removeAttribute("srcset",r),o.removeAttribute("sizes",r),e.width&&o.removeAttribute("width",r))}else{const e=i.attributeNewValue;e&&e.data&&(o.setAttribute("srcset",e.data,r),o.setAttribute("sizes","100vw",r),e.width&&o.setAttribute("width",e.width,r))}};return e=>{e.on(`attribute:srcset:${t}`,i)}}function E(e,t,i){const n=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const o=n.writer,s=n.mapper.toViewElement(i.item),r=e.findViewImgElement(s);o.setAttribute(i.attributeKey,i.attributeNewValue||"",r)};return e=>{e.on(`attribute:${i}:${t}`,n)}}class x extends s.Qj{observe(e){this.listenTo(e,"load",((e,t)=>{const i=t.target;this.checkShouldIgnoreEventFromTarget(i)||"IMG"==i.tagName&&this._fireEvents(t)}),{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}class T extends n.mY{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||"block"===t&&(0,l.KE)("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||"inline"===t&&(0,l.KE)("image-inline-plugin-required")}refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=(0,l.qo)(e.source),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(i.getAttributes());t.forEach(((e,t)=>{const s=i.getSelectedElement();if("string"==typeof e&&(e={src:e}),t&&s&&n.isImage(s)){const t=this.editor.model.createPositionAfter(s);n.insertImage({...e,...o},t)}else n.insertImage({...e,...o})}))}}class S extends n.mY{refresh(){const e=this.editor.plugins.get("ImageUtils"),t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=e.isImage(t),this.value=this.isEnabled?t.getAttribute("src"):null}execute(e){const t=this.editor.model.document.selection.getSelectedElement();this.editor.model.change((i=>{i.setAttribute("src",e.source,t),i.removeAttribute("srcset",t),i.removeAttribute("sizes",t)}))}}class P extends n.Sy{static get requires(){return[m]}static get pluginName(){return"ImageEditing"}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(x),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:e=>{const t={data:e.getAttribute("srcset")};return e.hasAttribute("width")&&(t.width=e.getAttribute("width")),t}}});const i=new T(e),n=new S(e);e.commands.add("insertImage",i),e.commands.add("replaceImageSource",n),e.commands.add("imageInsert",i)}}class I extends n.mY{constructor(e,t){super(e),this._modelElementName=t}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=e.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=e.isInlineImage(t):this.isEnabled=e.isBlockImage(t)}execute(){const e=this.editor,t=this.editor.model,i=e.plugins.get("ImageUtils"),n=i.getClosestSelectedImageElement(t.document.selection),o=Object.fromEntries(n.getAttributes());return o.src||o.uploadId?t.change((e=>{const s=Array.from(t.markers).filter((e=>e.getRange().containsItem(n))),r=i.insertImage(o,t.createSelection(n,"on"),this._modelElementName);if(!r)return null;const a=e.createRangeOn(r);for(const t of s){const i=t.getRange(),n="$graveyard"!=i.root.rootName?i.getJoined(a,!0):a;e.updateMarker(t,{range:n})}return{oldElement:n,newElement:r}})):null}}class V extends n.Sy{static get requires(){return[P,m,o._l]}static get pluginName(){return"ImageBlockEditing"}init(){const e=this.editor;e.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),e.plugins.has("ImageInlineEditing")&&(e.commands.add("imageTypeBlock",new I(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:t})=>d(t)}),i.for("editingDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:i})=>n.toImageWidget(d(i),i,t("image widget"))}),i.for("downcast").add(E(n,"imageBlock","src")).add(E(n,"imageBlock","alt")).add(A(n,"imageBlock")),i.for("upcast").elementToElement({view:u(e,"imageBlock"),model:(e,{writer:t})=>t.createElement("imageBlock",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)}).add(function(e){const t=(t,i,n)=>{if(!n.consumable.test(i.viewItem,{name:!0,classes:"image"}))return;const o=e.findViewImgElement(i.viewItem);if(!o||!n.consumable.test(o,{name:!0}))return;n.consumable.consume(i.viewItem,{name:!0,classes:"image"});const s=n.convertItem(o,i.modelCursor),r=(0,l.Ps)(s.modelRange.getItems());r?(n.convertChildren(i.viewItem,r),n.updateConversionResult(r,i)):n.consumable.revert(i.viewItem,{name:!0,classes:"image"})};return e=>{e.on("element:figure",t)}}(n))}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",((o,r)=>{const a=Array.from(r.content.getChildren());let l;if(!a.every(n.isInlineImageView))return;l=r.targetRanges?e.editing.mapper.toModelRange(r.targetRanges[0]):t.document.selection.getFirstRange();const c=t.createSelection(l);if("imageBlock"===h(t.schema,c)){const e=new s.yj(i.document),t=a.map((t=>e.createElement("figure",{class:"image"},t)));r.content=e.createDocumentFragment(t)}}))}}class R extends n.Sy{static get requires(){return[V,c.$L,C]}static get pluginName(){return"ImageBlock"}}class O extends n.Sy{static get requires(){return[P,m,o._l]}static get pluginName(){return"ImageInlineEditing"}init(){const e=this.editor,t=e.model.schema;t.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"]}),t.addChildCheck(((e,t)=>{if(e.endsWith("caption")&&"imageInline"===t.name)return!1})),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new I(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,i=e.conversion,n=e.plugins.get("ImageUtils");i.for("dataDowncast").elementToElement({model:"imageInline",view:(e,{writer:t})=>t.createEmptyElement("img")}),i.for("editingDowncast").elementToStructure({model:"imageInline",view:(e,{writer:i})=>n.toImageWidget(function(e){return e.createContainerElement("span",{class:"image-inline"},e.createEmptyElement("img"))}(i),i,t("image widget"))}),i.for("downcast").add(E(n,"imageInline","src")).add(E(n,"imageInline","alt")).add(A(n,"imageInline")),i.for("upcast").elementToElement({view:u(e,"imageInline"),model:(e,{writer:t})=>t.createElement("imageInline",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,i=e.editing.view,n=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline");this.listenTo(o,"inputTransformation",((o,r)=>{const a=Array.from(r.content.getChildren());let l;if(!a.every(n.isBlockImageView))return;l=r.targetRanges?e.editing.mapper.toModelRange(r.targetRanges[0]):t.document.selection.getFirstRange();const c=t.createSelection(l);if("imageInline"===h(t.schema,c)){const e=new s.yj(i.document),t=a.map((t=>1===t.childCount?(Array.from(t.getAttributes()).forEach((i=>e.setAttribute(...i,n.findViewImgElement(t)))),t.getChild(0)):t));r.content=e.createDocumentFragment(t)}}))}}class B extends n.Sy{static get requires(){return[O,c.$L,C]}static get pluginName(){return"ImageInline"}}class M extends n.Sy{static get requires(){return[R,B]}static get pluginName(){return"Image"}}class N extends n.Sy{static get pluginName(){return"ImageCaptionUtils"}static get requires(){return[m]}getCaptionFromImageModelElement(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}getCaptionFromModelSelection(e){const t=this.editor.plugins.get("ImageUtils"),i=e.getFirstPosition().findAncestor("caption");return i&&t.isBlockImage(i.parent)?i:null}matchImageCaptionViewElement(e){const t=this.editor.plugins.get("ImageUtils");return"figcaption"==e.name&&t.isBlockImageView(e.parent)?{name:!0}:null}}class D extends n.mY{refresh(){const e=this.editor,t=e.plugins.get("ImageCaptionUtils"),i=e.plugins.get("ImageUtils");if(!e.plugins.has(V))return this.isEnabled=!1,void(this.value=!1);const n=e.model.document.selection,o=n.getSelectedElement();if(!o){const e=t.getCaptionFromModelSelection(n);return this.isEnabled=!!e,void(this.value=!!e)}this.isEnabled=i.isImage(o),this.isEnabled?this.value=!!t.getCaptionFromImageModelElement(o):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change((e=>{this.value?this._hideImageCaption(e):this._showImageCaption(e,t)}))}_showImageCaption(e,t){const i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageCaptionEditing"),o=this.editor.plugins.get("ImageUtils");let s=i.getSelectedElement();const r=n._getSavedCaption(s);o.isInlineImage(s)&&(this.editor.execute("imageTypeBlock"),s=i.getSelectedElement());const a=r||e.createElement("caption");e.append(a,s),t&&e.setSelection(a,"in")}_hideImageCaption(e){const t=this.editor,i=t.model.document.selection,n=t.plugins.get("ImageCaptionEditing"),o=t.plugins.get("ImageCaptionUtils");let s,r=i.getSelectedElement();r?s=o.getCaptionFromImageModelElement(r):(s=o.getCaptionFromModelSelection(i),r=s.parent),n._saveCaption(r,s),e.setSelection(r,"on"),e.remove(s)}}class L extends n.Sy{static get requires(){return[m,N]}static get pluginName(){return"ImageCaptionEditing"}constructor(e){super(e),this._savedCaptionsMap=new WeakMap}init(){const e=this.editor,t=e.model.schema;t.isRegistered("caption")?t.extend("caption",{allowIn:"imageBlock"}):t.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleImageCaption",new D(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils"),o=e.t;e.conversion.for("upcast").elementToElement({view:e=>n.matchImageCaptionViewElement(e),model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>i.isBlockImage(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:n})=>{if(!i.isBlockImage(e.parent))return null;const r=n.createEditableElement("figcaption");n.setCustomProperty("imageCaption",!0,r),r.placeholder=o("Enter image caption"),(0,s.ID)({view:t,element:r,keepOnFocus:!0});const a=e.parent.getAttribute("alt"),l=a?o("Caption for image: %0",[a]):o("Caption for the image");return(0,c.sC)(r,n,{label:l})}})}_setupImageTypeCommandsIntegration(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.plugins.get("ImageCaptionUtils"),n=e.commands.get("imageTypeInline"),o=e.commands.get("imageTypeBlock"),s=e=>{if(!e.return)return;const{oldElement:n,newElement:o}=e.return;if(!n)return;if(t.isBlockImage(n)){const e=i.getCaptionFromImageModelElement(n);if(e)return void this._saveCaption(o,e)}const s=this._getSavedCaption(n);s&&this._saveCaption(o,s)};n&&this.listenTo(n,"execute",s,{priority:"low"}),o&&this.listenTo(o,"execute",s,{priority:"low"})}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?s.W_.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}_registerCaptionReconversion(){const e=this.editor,t=e.model,i=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils");t.document.on("change:data",(()=>{const o=t.document.differ.getChanges();for(const t of o){if("alt"!==t.attributeKey)continue;const o=t.range.start.nodeAfter;if(i.isBlockImage(o)){const t=n.getCaptionFromImageModelElement(o);if(!t)return;e.editing.reconvertItem(t)}}}))}}class F extends n.Sy{static get requires(){return[N]}static get pluginName(){return"ImageCaptionUI"}init(){const e=this.editor,t=e.editing.view,i=e.plugins.get("ImageCaptionUtils"),o=e.t;e.ui.componentFactory.add("toggleImageCaption",(s=>{const r=e.commands.get("toggleImageCaption"),a=new v.r5(s);return a.set({icon:n.icons.caption,tooltip:!0,isToggleable:!0}),a.bind("isOn","isEnabled").to(r,"value","isEnabled"),a.bind("label").to(r,"value",(e=>o(e?"Toggle caption off":"Toggle caption on"))),this.listenTo(a,"execute",(()=>{e.execute("toggleImageCaption",{focusCaptionOnShow:!0});const n=i.getCaptionFromModelSelection(e.model.document.selection);if(n){const i=e.editing.mapper.toViewElement(n);t.scrollToTheSelection(),t.change((e=>{e.addClass("image__caption_highlighted",i)}))}e.editing.view.focus()})),a}))}}class z extends n.Sy{static get requires(){return[L,F]}static get pluginName(){return"ImageCaption"}}var H=i(1070);function W(e){const t=e.map((e=>e.replace("+","\\+")));return new RegExp(`^image\\/(${t.join("|")})$`)}function U(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class j extends n.Sy{static get pluginName(){return"ImageUploadUI"}init(){const e=this.editor,t=e.t,i=i=>{const o=new H.FileDialogButtonView(i),s=e.commands.get("uploadImage"),r=e.config.get("image.upload.types"),a=W(r);return o.set({acceptedType:r.map((e=>`image/${e}`)).join(","),allowMultipleFiles:!0}),o.buttonView.set({label:t("Insert image"),icon:n.icons.image,tooltip:!0}),o.buttonView.bind("isEnabled").to(s),o.on("done",((t,i)=>{const n=Array.from(i).filter((e=>a.test(e.type)));n.length&&(e.execute("uploadImage",{file:n}),e.editing.view.focus())})),o};e.ui.componentFactory.add("uploadImage",i),e.ui.componentFactory.add("imageUpload",i)}}class $ extends n.Sy{static get pluginName(){return"ImageUploadProgress"}constructor(e){super(e),this.uploadStatusChange=(e,t,i)=>{const n=this.editor,o=t.item,s=o.getAttribute("uploadId");if(!i.consumable.consume(t.item,e.name))return;const r=n.plugins.get("ImageUtils"),a=n.plugins.get(H.FileRepository),l=s?t.attributeNewValue:null,c=this.placeholder,d=n.editing.mapper.toViewElement(o),u=i.writer;if("reading"==l)return q(d,u),void K(r,c,d,u);if("uploading"==l){const e=a.loaders.get(s);return q(d,u),void(e?(Z(d,u),function(e,t,i,n){const o=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),o),i.on("change:uploadedPercent",((e,t,i)=>{n.change((e=>{e.setStyle("width",i+"%",o)}))}))}(d,u,e,n.editing.view),function(e,t,i,n){if(n.data){const o=e.findViewImgElement(t);i.setAttribute("src",n.data,o)}}(r,d,u,e)):K(r,c,d,u))}"complete"==l&&a.loaders.get(s)&&function(e,t,i){const n=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),n),setTimeout((()=>{i.change((e=>e.remove(e.createRangeOn(n))))}),3e3)}(d,u,n.editing.view),function(e,t){J(e,t,"progressBar")}(d,u),Z(d,u),function(e,t){t.removeClass("ck-appear",e)}(d,u)},this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",this.uploadStatusChange),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}}function q(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function K(e,t,i,n){i.hasClass("ck-image-upload-placeholder")||n.addClass("ck-image-upload-placeholder",i);const o=e.findViewImgElement(i);o.getAttribute("src")!==t&&n.setAttribute("src",t,o),G(i,"placeholder")||n.insert(n.createPositionAfter(o),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(n))}function Z(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),J(e,t,"placeholder")}function G(e,t){for(const i of e.getChildren())if(i.getCustomProperty(t))return i}function J(e,t,i){const n=G(e,i);n&&t.remove(t.createRangeOn(n))}class Y extends n.mY{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),i=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(i)}execute(e){const t=(0,l.qo)(e.file),i=this.editor.model.document.selection,n=this.editor.plugins.get("ImageUtils"),o=Object.fromEntries(i.getAttributes());t.forEach(((e,t)=>{const s=i.getSelectedElement();if(t&&s&&n.isImage(s)){const t=this.editor.model.createPositionAfter(s);this._uploadImage(e,o,t)}else this._uploadImage(e,o)}))}_uploadImage(e,t,i){const n=this.editor,o=n.plugins.get(H.FileRepository).createLoader(e),s=n.plugins.get("ImageUtils");o&&s.insertImage({...t,uploadId:o.id},i)}}class Q extends n.Sy{static get requires(){return[H.FileRepository,v.P_,o._l,m]}static get pluginName(){return"ImageUploadEditing"}constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const e=this.editor,t=e.model.document,i=e.conversion,n=e.plugins.get(H.FileRepository),o=e.plugins.get("ImageUtils"),r=e.plugins.get("ClipboardPipeline"),a=W(e.config.get("image.upload.types")),c=new Y(e);e.commands.add("uploadImage",c),e.commands.add("imageUpload",c),i.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,i)=>{if(n=i.dataTransfer,Array.from(n.types).includes("text/html")&&""!==n.getData("text/html"))return;var n;const o=Array.from(i.dataTransfer.files).filter((e=>!!e&&a.test(e.type)));o.length&&(t.stop(),e.model.change((t=>{i.targetRanges&&t.setSelection(i.targetRanges.map((t=>e.editing.mapper.toModelRange(t)))),e.model.enqueueChange((()=>{e.execute("uploadImage",{file:o})}))})))})),this.listenTo(r,"inputTransformation",((t,i)=>{const r=Array.from(e.editing.view.createRangeIn(i.content)).map((e=>e.item)).filter((e=>function(e,t){return!(!e.isInlineImageView(t)||!t.getAttribute("src")||!t.getAttribute("src").match(/^data:image\/\w+;base64,/g)&&!t.getAttribute("src").match(/^blob:/g))}(o,e)&&!e.getAttribute("uploadProcessed"))).map((e=>{return{promise:(t=e,new Promise(((e,i)=>{const n=t.getAttribute("src");fetch(n).then((e=>e.blob())).then((t=>{const i=U(t,n),o=i.replace("image/",""),s=new File([t],`image.${o}`,{type:i});e(s)})).catch((t=>t&&"TypeError"===t.name?function(e){return function(e){return new Promise(((t,i)=>{const n=l.CO.document.createElement("img");n.addEventListener("load",(()=>{const e=l.CO.document.createElement("canvas");e.width=n.width,e.height=n.height,e.getContext("2d").drawImage(n,0,0),e.toBlob((e=>e?t(e):i()))})),n.addEventListener("error",(()=>i())),n.src=e}))}(e).then((t=>{const i=U(t,e),n=i.replace("image/","");return new File([t],`image.${n}`,{type:i})}))}(n).then(e).catch(i):i(t)))}))),imageElement:e};var t}));if(!r.length)return;const a=new s.yj(e.editing.view.document);for(const e of r){a.setAttribute("uploadProcessed",!0,e.imageElement);const t=n.createLoader(e.promise);t&&(a.setAttribute("src","",e.imageElement),a.setAttribute("uploadId",t.id,e.imageElement))}})),e.editing.view.document.on("dragover",((e,t)=>{t.preventDefault()})),t.on("change",(()=>{const i=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),o=new Set;for(const t of i)if("insert"==t.type&&"$text"!=t.name){const i=t.position.nodeAfter,s="$graveyard"==t.position.root.rootName;for(const t of X(e,i)){const e=t.getAttribute("uploadId");if(!e)continue;const i=n.loaders.get(e);i&&(s?o.has(e)||i.abort():(o.add(e),this._uploadImageElements.set(e,t),"idle"==i.status&&this._readAndUpload(i)))}}})),this.on("uploadComplete",((e,{imageElement:t,data:i})=>{const n=i.urls?i.urls:i;this.editor.model.change((e=>{e.setAttribute("src",n.default,t),this._parseAndSetSrcsetAttributeOnImage(n,t,e)}))}),{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this.editor.plugins.has("ImageInlineEditing")&&e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]})}_readAndUpload(e){const t=this.editor,i=t.model,n=t.locale.t,o=t.plugins.get(H.FileRepository),s=t.plugins.get(v.P_),r=t.plugins.get("ImageUtils"),a=this._uploadImageElements;return i.enqueueChange({isUndoable:!1},(t=>{t.setAttribute("uploadStatus","reading",a.get(e.id))})),e.read().then((()=>{const n=e.upload(),o=a.get(e.id);if(l.OB.isSafari){const e=t.editing.mapper.toViewElement(o),i=r.findViewImgElement(e);t.editing.view.once("render",(()=>{if(!i.parent)return;const e=t.editing.view.domConverter.mapViewToDom(i.parent);if(!e)return;const n=e.style.display;e.style.display="none",e._ckHack=e.offsetHeight,e.style.display=n}))}return i.enqueueChange({isUndoable:!1},(e=>{e.setAttribute("uploadStatus","uploading",o)})),n})).then((t=>{i.enqueueChange({isUndoable:!1},(i=>{const n=a.get(e.id);i.setAttribute("uploadStatus","complete",n),this.fire("uploadComplete",{data:t,imageElement:n})})),c()})).catch((t=>{if("error"!==e.status&&"aborted"!==e.status)throw t;"error"==e.status&&t&&s.showWarning(t,{title:n("Upload failed"),namespace:"upload"}),i.enqueueChange({isUndoable:!1},(t=>{t.remove(a.get(e.id))})),c()}));function c(){i.enqueueChange({isUndoable:!1},(t=>{const i=a.get(e.id);t.removeAttribute("uploadId",i),t.removeAttribute("uploadStatus",i),a.delete(e.id)})),o.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,i){let n=0;const o=Object.keys(e).filter((e=>{const t=parseInt(e,10);if(!isNaN(t))return n=Math.max(n,t),!0})).map((t=>`${e[t]} ${t}w`)).join(", ");""!=o&&i.setAttribute("srcset",{data:o,width:n},t)}}function X(e,t){const i=e.plugins.get("ImageUtils");return Array.from(e.model.createRangeOn(t)).filter((e=>i.isImage(e.item))).map((e=>e.item))}class ee extends n.Sy{static get pluginName(){return"ImageUpload"}static get requires(){return[Q,j,$]}}class te extends v.G7{constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("class",t.class||null),this.children=this.createCollection(),t.children&&t.children.forEach((e=>this.children.add(e))),this.set("_role",null),this.set("_ariaLabelledBy",null),t.labelView&&this.set({_role:"group",_ariaLabelledBy:t.labelView.id}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",i.to("class")],role:i.to("_role"),"aria-labelledby":i.to("_ariaLabelledBy")},children:this.children})}}class ie extends v.G7{constructor(e,t={}){super(e);const{insertButtonView:i,cancelButtonView:n}=this._createActionButtons(e);this.insertButtonView=i,this.cancelButtonView=n,this.set("imageURLInputValue",""),this.focusTracker=new l.Rh,this.keystrokes=new l.VD,this._focusables=new v.vX,this._focusCycler=new v.I0({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.set("_integrations",new l.FE);for(const[e,i]of Object.entries(t))"insertImageViaUrl"===e&&(i.fieldView.bind("value").to(this,"imageURLInputValue",(e=>e||"")),i.fieldView.on("input",(()=>{this.imageURLInputValue=i.fieldView.element.value.trim()}))),i.name=e,this._integrations.add(i);this.setTemplate({tag:"form",attributes:{class:["ck","ck-image-insert-form"],tabindex:"-1"},children:[...this._integrations,new te(e,{children:[this.insertButtonView,this.cancelButtonView],class:"ck-image-insert-form__action-row"})]})}render(){super.render(),(0,v.GI)({view:this}),[...this._integrations,this.insertButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}getIntegration(e){return this._integrations.find((t=>t.name===e))}_createActionButtons(e){const t=e.t,i=new v.r5(e),o=new v.r5(e);return i.set({label:t("Insert"),icon:n.icons.check,class:"ck-button-save",type:"submit",withText:!0,isEnabled:this.imageURLInputValue}),o.set({label:t("Cancel"),icon:n.icons.cancel,class:"ck-button-cancel",withText:!0}),i.bind("isEnabled").to(this,"imageURLInputValue",(e=>!!e)),i.delegate("execute").to(this,"submit"),o.delegate("execute").to(this,"cancel"),{insertButtonView:i,cancelButtonView:o}}focus(){this._focusCycler.focusFirst()}}function ne(e){const t=e.t,i=new v.KP(e,v.R);return i.set({label:t("Insert image via URL")}),i.fieldView.placeholder="https://example.com/image.png",i}class oe extends n.Sy{static get pluginName(){return"ImageInsertUI"}init(){const e=this.editor,t=e=>this._createDropdownView(e);e.ui.componentFactory.add("insertImage",t),e.ui.componentFactory.add("imageInsert",t)}_createDropdownView(e){const t=this.editor,i=e.t,o=t.commands.get("uploadImage"),s=t.commands.get("insertImage");this.dropdownView=(0,v.t9)(e,o?v.Rm:void 0);const r=this.dropdownView.buttonView,a=this.dropdownView.panelView;if(r.set({label:i("Insert image"),icon:n.icons.image,tooltip:!0}),a.extendTemplate({attributes:{class:"ck-image-insert__panel"}}),o){const e=this.dropdownView.buttonView;e.actionView=t.ui.componentFactory.create("uploadImage"),e.actionView.extendTemplate({attributes:{class:"ck ck-button ck-splitbutton__action"}})}return this._setUpDropdown(o||s)}_setUpDropdown(e){const t=this.editor,i=t.t,n=this.dropdownView,o=n.panelView,s=this.editor.plugins.get("ImageUtils"),r=t.commands.get("replaceImageSource");let a;function l(){t.editing.view.focus(),n.isOpen=!1}return n.bind("isEnabled").to(e),n.once("change:isOpen",(()=>{a=new ie(t.locale,function(e){const t=e.config.get("image.insert.integrations"),i=e.plugins.get("ImageInsertUI"),n={insertImageViaUrl:ne(e.locale)};if(!t)return n;if(t.find((e=>"openCKFinder"===e))&&e.ui.componentFactory.has("ckfinder")){const t=e.ui.componentFactory.create("ckfinder");t.set({withText:!0,class:"ck-image-insert__ck-finder-button"}),t.delegate("execute").to(i,"cancel"),n.openCKFinder=t}return t.reduce(((t,i)=>(n[i]?t[i]=n[i]:e.ui.componentFactory.has(i)&&(t[i]=e.ui.componentFactory.create(i)),t)),{})}(t)),a.delegate("submit","cancel").to(n),o.children.add(a)})),n.on("change:isOpen",(()=>{const e=t.model.document.selection.getSelectedElement(),o=a.insertButtonView,l=a.getIntegration("insertImageViaUrl");n.isOpen&&(s.isImage(e)?(a.imageURLInputValue=r.value,o.label=i("Update"),l.label=i("Update image URL")):(a.imageURLInputValue="",o.label=i("Insert"),l.label=i("Insert image via URL")))}),{priority:"low"}),this.delegate("cancel").to(n),n.on("submit",(()=>{l(),function(){const e=t.model.document.selection.getSelectedElement();s.isImage(e)?t.execute("replaceImageSource",{source:a.imageURLInputValue}):t.execute("insertImage",{source:a.imageURLInputValue})}()})),n.on("cancel",(()=>{l()})),n}}class se extends n.Sy{static get pluginName(){return"ImageInsertViaUrl"}static get requires(){return[oe]}}class re extends n.Sy{static get pluginName(){return"ImageInsert"}static get requires(){return[ee,se,oe]}}class ae extends n.mY{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils").getClosestSelectedImageElement(e.model.document.selection);this.isEnabled=!!t,t&&t.hasAttribute("width")?this.value={width:t.getAttribute("width"),height:null}:this.value=null}execute(e){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils").getClosestSelectedImageElement(i.document.selection);this.value={width:e.width,height:null},n&&i.change((t=>{t.setAttribute("width",e.width,n)}))}}class le extends n.Sy{static get requires(){return[m]}static get pluginName(){return"ImageResizeEditing"}constructor(e){super(e),e.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}init(){const e=this.editor,t=new ae(e);this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline"),e.commands.add("resizeImage",t),e.commands.add("imageResize",t)}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:"width"}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:"width"})}_registerConverters(e){const t=this.editor;t.conversion.for("downcast").add((t=>t.on(`attribute:width:${e}`,((e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.writer,o=i.mapper.toViewElement(t.item);null!==t.attributeNewValue?(n.setStyle("width",t.attributeNewValue,o),n.addClass("image_resized",o)):(n.removeStyle("width",o),n.removeClass("image_resized",o))})))),t.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===e?"figure":"img",styles:{width:/.+/}},model:{key:"width",value:e=>e.getStyle("width")}})}}const ce={small:n.icons.objectSizeSmall,medium:n.icons.objectSizeMedium,large:n.icons.objectSizeLarge,original:n.icons.objectSizeFull};class de extends n.Sy{static get requires(){return[le]}static get pluginName(){return"ImageResizeButtons"}constructor(e){super(e),this._resizeUnit=e.config.get("image.resizeUnit")}init(){const e=this.editor,t=e.config.get("image.resizeOptions"),i=e.commands.get("resizeImage");this.bind("isEnabled").to(i);for(const e of t)this._registerImageResizeButton(e);this._registerImageResizeDropdown(t)}_registerImageResizeButton(e){const t=this.editor,{name:i,value:n,icon:o}=e,s=n?n+this._resizeUnit:null;t.ui.componentFactory.add(i,(i=>{const n=new v.r5(i),r=t.commands.get("resizeImage"),a=this._getOptionLabelValue(e,!0);if(!ce[o])throw new l.Bb("imageresizebuttons-missing-icon",t,e);return n.set({label:a,icon:ce[o],tooltip:a,isToggleable:!0}),n.bind("isEnabled").to(this),n.bind("isOn").to(r,"value",ue(s)),this.listenTo(n,"execute",(()=>{t.execute("resizeImage",{width:s})})),n}))}_registerImageResizeDropdown(e){const t=this.editor,i=t.t,n=e.find((e=>!e.value)),o=o=>{const s=t.commands.get("resizeImage"),r=(0,v.t9)(o,v.J0),a=r.buttonView,l=i("Resize image");return a.set({tooltip:l,commandValue:n.value,icon:ce.medium,isToggleable:!0,label:this._getOptionLabelValue(n),withText:!0,class:"ck-resize-image-button",ariaLabel:l,ariaLabelledBy:void 0}),a.bind("label").to(s,"value",(e=>e&&e.width?e.width:this._getOptionLabelValue(n))),r.bind("isEnabled").to(this),(0,v.Pm)(r,(()=>this._getResizeDropdownListItemDefinitions(e,s)),{ariaLabel:i("Image resize list"),role:"menu"}),this.listenTo(r,"execute",(e=>{t.execute(e.source.commandName,{width:e.source.commandValue}),t.editing.view.focus()})),r};t.ui.componentFactory.add("resizeImage",o),t.ui.componentFactory.add("imageResize",o)}_getOptionLabelValue(e,t=!1){const i=this.editor.t;return e.label?e.label:t?e.value?i("Resize image to %0",e.value+this._resizeUnit):i("Resize image to the original size"):e.value?e.value+this._resizeUnit:i("Original")}_getResizeDropdownListItemDefinitions(e,t){const i=new l.FE;return e.map((e=>{const n=e.value?e.value+this._resizeUnit:null,o={type:"button",model:new v.Hn({commandName:"resizeImage",commandValue:n,label:this._getOptionLabelValue(e),role:"menuitemradio",withText:!0,icon:null})};o.model.bind("isOn").to(t,"value",ue(n)),i.add(o)})),i}}function ue(e){return t=>null===e&&t===e||null!==t&&t.width===e}const he=/(image|image-inline)/,me="image_resized";class ge extends n.Sy{static get requires(){return[c.WR]}static get pluginName(){return"ImageResizeHandles"}init(){const e=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(e),this._setupResizerCreator()}_setupResizerCreator(){const e=this.editor,t=e.editing.view;t.addObserver(x),this.listenTo(t.document,"imageLoaded",((i,n)=>{if(!n.target.matches("figure.image.ck-widget > img,figure.image.ck-widget > picture > img,figure.image.ck-widget > a > img,figure.image.ck-widget > a > picture > img,span.image-inline.ck-widget > img,span.image-inline.ck-widget > picture > img"))return;const o=e.editing.view.domConverter,s=o.domToView(n.target).findAncestor({classes:he});let r=this.editor.plugins.get(c.WR).getResizerByViewElement(s);if(r)return void r.redraw();const a=e.editing.mapper,l=a.toModelElement(s);r=e.plugins.get(c.WR).attachTo({unit:e.config.get("image.resizeUnit"),modelElement:l,viewElement:s,editor:e,getHandleHost:e=>e.querySelector("img"),getResizeHost:()=>o.mapViewToDom(a.toViewElement(l.parent)),isCentered(){const e=l.getAttribute("imageStyle");return!e||"block"==e||"alignCenter"==e},onCommit(i){t.change((e=>{e.removeClass(me,s)})),e.execute("resizeImage",{width:i})}}),r.on("updateSize",(()=>{s.hasClass(me)||t.change((e=>{e.addClass(me,s)}))})),r.bind("isEnabled").to(this)}))}}class fe extends n.Sy{static get requires(){return[le,ge,de]}static get pluginName(){return"ImageResize"}}class pe extends n.mY{constructor(e,t){super(e),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map((e=>{if(e.isDefault)for(const t of e.modelElements)this._defaultStyles[t]=e.name;return[e.name,e]})))}refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?e.hasAttribute("imageStyle")?this.value=e.getAttribute("imageStyle"):this.value=this._defaultStyles[e.name]:this.value=!1}execute(e={}){const t=this.editor,i=t.model,n=t.plugins.get("ImageUtils");i.change((t=>{const o=e.value;let s=n.getClosestSelectedImageElement(i.document.selection);o&&this.shouldConvertImageType(o,s)&&(this.editor.execute(n.isBlockImage(s)?"imageTypeInline":"imageTypeBlock"),s=n.getClosestSelectedImageElement(i.document.selection)),!o||this._styles.get(o).isDefault?t.removeAttribute("imageStyle",s):t.setAttribute("imageStyle",o,s)}))}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}}const{objectFullWidth:be,objectInline:we,objectLeft:ve,objectRight:_e,objectCenter:ye,objectBlockLeft:ke,objectBlockRight:Ce}=n.icons,Ae={get inline(){return{name:"inline",title:"In line",icon:we,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:ve,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:ke,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:ye,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:_e,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:Ce,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:ye,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:_e,modelElements:["imageBlock"],className:"image-style-side"}}},Ee={full:be,left:ke,right:Ce,center:ye,inlineLeft:ve,inlineRight:_e,inline:we},xe=[{name:"imageStyle:wrapText",title:"Wrap text",defaultItem:"imageStyle:alignLeft",items:["imageStyle:alignLeft","imageStyle:alignRight"]},{name:"imageStyle:breakText",title:"Break text",defaultItem:"imageStyle:block",items:["imageStyle:alignBlockLeft","imageStyle:block","imageStyle:alignBlockRight"]}];function Te(e){(0,l.KE)("image-style-configuration-definition-invalid",e)}const Se={normalizeStyles:function(e){return(e.configuredStyles.options||[]).map((e=>{return"string"==typeof(t="string"==typeof(t=e)?Ae[t]?{...Ae[t]}:{name:t}:function(e,t){const i={...t};for(const n in e)Object.prototype.hasOwnProperty.call(t,n)||(i[n]=e[n]);return i}(Ae[t.name],t)).icon&&(t.icon=Ee[t.icon]||t.icon),t;var t})).filter((t=>function(e,{isBlockPluginLoaded:t,isInlinePluginLoaded:i}){const{modelElements:n,name:o}=e;if(!(n&&n.length&&o))return Te({style:e}),!1;{const o=[t?"imageBlock":null,i?"imageInline":null];if(!n.some((e=>o.includes(e))))return(0,l.KE)("image-style-missing-dependency",{style:e,missingPlugins:n.map((e=>"imageBlock"===e?"ImageBlockEditing":"ImageInlineEditing"))}),!1}return!0}(t,e)))},getDefaultStylesConfiguration:function(e,t){return e&&t?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:e?{options:["block","side"]}:t?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(e){return e.has("ImageBlockEditing")&&e.has("ImageInlineEditing")?[...xe]:[]},warnInvalidStyle:Te,DEFAULT_OPTIONS:Ae,DEFAULT_ICONS:Ee,DEFAULT_DROPDOWN_DEFINITIONS:xe};function Pe(e,t){for(const i of t)if(i.name===e)return i}class Ie extends n.Sy{static get pluginName(){return"ImageStyleEditing"}static get requires(){return[m]}init(){const{normalizeStyles:e,getDefaultStylesConfiguration:t}=Se,i=this.editor,n=i.plugins.has("ImageBlockEditing"),o=i.plugins.has("ImageInlineEditing");i.config.define("image.styles",t(n,o)),this.normalizedStyles=e({configuredStyles:i.config.get("image.styles"),isBlockPluginLoaded:n,isInlinePluginLoaded:o}),this._setupConversion(n,o),this._setupPostFixer(),i.commands.add("imageStyle",new pe(i,this.normalizedStyles))}_setupConversion(e,t){const i=this.editor,n=i.model.schema,o=(s=this.normalizedStyles,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=Pe(t.attributeNewValue,s),o=Pe(t.attributeOldValue,s),r=i.mapper.toViewElement(t.item),a=i.writer;o&&a.removeClass(o.className,r),n&&a.addClass(n.className,r)});var s;const r=function(e){const t={imageInline:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageInline"))),imageBlock:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageBlock")))};return(e,i,n)=>{if(!i.modelRange)return;const o=i.viewItem,s=(0,l.Ps)(i.modelRange.getItems());if(s&&n.schema.checkAttribute(s,"imageStyle"))for(const e of t[s.name])n.consumable.consume(o,{classes:e.className})&&n.writer.setAttribute("imageStyle",e.name,s)}}(this.normalizedStyles);i.editing.downcastDispatcher.on("attribute:imageStyle",o),i.data.downcastDispatcher.on("attribute:imageStyle",o),e&&(n.extend("imageBlock",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:figure",r,{priority:"low"})),t&&(n.extend("imageInline",{allowAttributes:"imageStyle"}),i.data.upcastDispatcher.on("element:img",r,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,i=e.plugins.get(m),n=new Map(this.normalizedStyles.map((e=>[e.name,e])));t.registerPostFixer((e=>{let o=!1;for(const s of t.differ.getChanges())if("insert"==s.type||"attribute"==s.type&&"imageStyle"==s.attributeKey){let t="insert"==s.type?s.position.nodeAfter:s.range.start.nodeAfter;if(t&&t.is("element","paragraph")&&t.childCount>0&&(t=t.getChild(0)),!i.isImage(t))continue;const r=t.getAttribute("imageStyle");if(!r)continue;const a=n.get(r);a&&a.modelElements.includes(t.name)||(e.removeAttribute("imageStyle",t),o=!0)}return o}))}}var Ve=i(7226),Re=i(9203);class Oe extends n.Sy{static get requires(){return[Ie]}static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Wrap text":e("Wrap text"),"Break text":e("Break text"),"In line":e("In line"),"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=this.editor.plugins,t=this.editor.config.get("image.toolbar")||[],i=Be(e.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const e of i)this._createButton(e);const n=Be([...t.filter(Ve.Z),...Se.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const e of n)this._createDropdown(e,i)}_createDropdown(e,t){const i=this.editor.ui.componentFactory;i.add(e.name,(n=>{let o;const{defaultItem:s,items:r,title:a}=e,l=r.filter((e=>t.find((({name:t})=>Me(t)===e)))).map((e=>{const t=i.create(e);return e===s&&(o=t),t}));r.length!==l.length&&Se.warnInvalidStyle({dropdown:e});const c=(0,v.t9)(n,v.Rm),d=c.buttonView,u=d.arrowView;return(0,v.up)(c,l,{enableActiveItemFocusOnDropdownOpen:!0}),d.set({label:Ne(a,o.label),class:null,tooltip:!0}),u.unbind("label"),u.set({label:a}),d.bind("icon").toMany(l,"isOn",((...e)=>{const t=e.findIndex(Re.Z);return t<0?o.icon:l[t].icon})),d.bind("label").toMany(l,"isOn",((...e)=>{const t=e.findIndex(Re.Z);return Ne(a,t<0?o.label:l[t].label)})),d.bind("isOn").toMany(l,"isOn",((...e)=>e.some(Re.Z))),d.bind("class").toMany(l,"isOn",((...e)=>e.some(Re.Z)?"ck-splitbutton_flatten":void 0)),d.on("execute",(()=>{l.some((({isOn:e})=>e))?c.isOpen=!c.isOpen:o.fire("execute")})),c.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some(Re.Z))),this.listenTo(c,"execute",(()=>{this.editor.editing.view.focus()})),c}))}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(Me(t),(i=>{const n=this.editor.commands.get("imageStyle"),o=new v.r5(i);return o.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(n,"isEnabled"),o.bind("isOn").to(n,"value",(e=>e===t)),o.on("execute",this._executeCommand.bind(this,t)),o}))}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function Be(e,t){for(const i of e)t[i.title]&&(i.title=t[i.title]);return e}function Me(e){return`imageStyle:${e}`}function Ne(e,t){return(e?e+": ":"")+t}class De extends n.Sy{static get requires(){return[Ie,Oe]}static get pluginName(){return"ImageStyle"}}class Le extends n.Sy{static get requires(){return[c.e8,m]}static get pluginName(){return"ImageToolbar"}afterInit(){const e=this.editor,t=e.t,i=e.plugins.get(c.e8),n=e.plugins.get("ImageUtils");var o;i.register("image",{ariaLabel:t("Image toolbar"),items:(o=e.config.get("image.toolbar")||[],o.map((e=>(0,Ve.Z)(e)?e.name:e))),getRelatedElement:e=>n.getClosestSelectedImageWidget(e)})}}class Fe extends n.Sy{static get requires(){return[P,m]}static get pluginName(){return"PictureEditing"}afterInit(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:["sources"]}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:["sources"]}),this._setupConversion(),this._setupImageUploadEditingIntegration()}_setupConversion(){const e=this.editor,t=e.conversion,i=e.plugins.get("ImageUtils");t.for("upcast").add(function(e){const t=["srcset","media","type","sizes"],i=(i,n,o)=>{const s=n.viewItem;if(!o.consumable.test(s,{name:!0}))return;const r=new Map;for(const e of s.getChildren())if(e.is("element","source")){const i={};for(const n of t)e.hasAttribute(n)&&o.consumable.test(e,{attributes:n})&&(i[n]=e.getAttribute(n));Object.keys(i).length&&r.set(e,i)}const a=e.findViewImgElement(s);if(!a)return;let c=n.modelCursor.parent;if(!c.is("element","imageBlock")){const e=o.convertItem(a,n.modelCursor);n.modelRange=e.modelRange,n.modelCursor=e.modelCursor,c=(0,l.Ps)(e.modelRange.getItems())}o.consumable.consume(s,{name:!0});for(const[e,t]of r)o.consumable.consume(e,{attributes:Object.keys(t)});r.size&&o.writer.setAttribute("sources",Array.from(r.values()),c),o.convertChildren(s,c)};return e=>{e.on("element:picture",i)}}(i)),t.for("downcast").add(function(e){const t=(t,i,n)=>{if(!n.consumable.consume(i.item,t.name))return;const o=n.writer,s=n.mapper.toViewElement(i.item),r=e.findViewImgElement(s),a=i.attributeNewValue;if(a&&a.length){const e=o.createContainerElement("picture",null,a.map((e=>o.createEmptyElement("source",e)))),t=[];let i=r.parent;for(;i&&i.is("attributeElement");){const e=i.parent;o.unwrap(o.createRangeOn(r),i),t.unshift(i),i=e}o.insert(o.createPositionBefore(r),e),o.move(o.createRangeOn(r),o.createPositionAt(e,"end"));for(const i of t)o.wrap(o.createRangeOn(e),i)}else if(r.parent.is("element","picture")){const e=r.parent;o.move(o.createRangeOn(r),o.createPositionBefore(e)),o.remove(e)}};return e=>{e.on("attribute:sources:imageBlock",t),e.on("attribute:sources:imageInline",t)}}(i))}_setupImageUploadEditingIntegration(){const e=this.editor;if(!e.plugins.has("ImageUploadEditing"))return;const t=e.plugins.get("ImageUploadEditing");this.listenTo(t,"uploadComplete",((t,{imageElement:i,data:n})=>{const o=n.sources;o&&e.model.change((e=>{e.setAttributes({sources:o},i)}))}))}}},3531:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Indent:()=>c,IndentBlock:()=>p,IndentEditing:()=>o,IndentUI:()=>l});var n=i(6854);class o extends n.Sy{static get pluginName(){return"IndentEditing"}init(){const e=this.editor;e.commands.add("indent",new n.AJ(e)),e.commands.add("outdent",new n.AJ(e))}}var s=i(7095);const r='',a='';class l extends n.Sy{static get pluginName(){return"IndentUI"}init(){const e=this.editor,t=e.locale,i=e.t,n="ltr"==t.uiLanguageDirection?r:a,o="ltr"==t.uiLanguageDirection?a:r;this._defineButton("indent",i("Increase indent"),n),this._defineButton("outdent",i("Decrease indent"),o)}_defineButton(e,t,i){const n=this.editor;n.ui.componentFactory.add(e,(o=>{const r=n.commands.get(e),a=new s.r5(o);return a.set({label:t,icon:i,tooltip:!0}),a.bind("isEnabled").to(r,"isEnabled"),this.listenTo(a,"execute",(()=>{n.execute(e),n.editing.view.focus()})),a}))}}class c extends n.Sy{static get pluginName(){return"Indent"}static get requires(){return[o,l]}}var d=i(3291),u=i(6553);class h extends n.mY{constructor(e,t){super(e),this._indentBehavior=t}refresh(){const e=this.editor.model,t=(0,u.Ps)(e.document.selection.getSelectedBlocks());t&&e.schema.checkAttribute(t,"blockIndent")?this.isEnabled=this._indentBehavior.checkEnabled(t.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const e=this.editor.model,t=function(e){const t=e.document.selection,i=e.schema;return Array.from(t.getSelectedBlocks()).filter((e=>i.checkAttribute(e,"blockIndent")))}(e);e.change((e=>{for(const i of t){const t=i.getAttribute("blockIndent"),n=this._indentBehavior.getNextIndent(t);n?e.setAttribute("blockIndent",n,i):e.removeAttribute("blockIndent",i)}}))}}class m{constructor(e){this.isForward="forward"===e.direction,this.offset=e.offset,this.unit=e.unit}checkEnabled(e){const t=parseFloat(e||"0");return this.isForward||t>0}getNextIndent(e){const t=parseFloat(e||"0");if(e&&!e.endsWith(this.unit))return this.isForward?this.offset+this.unit:void 0;const i=t+(this.isForward?this.offset:-this.offset);return i>0?i+this.unit:void 0}}class g{constructor(e){this.isForward="forward"===e.direction,this.classes=e.classes}checkEnabled(e){const t=this.classes.indexOf(e);return this.isForward?t=0}getNextIndent(e){const t=this.classes.indexOf(e),i=this.isForward?1:-1;return this.classes[t+i]}}const f=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];class p extends n.Sy{constructor(e){super(e),e.config.define("indentBlock",{offset:40,unit:"px"})}static get pluginName(){return"IndentBlock"}init(){const e=this.editor,t=e.config.get("indentBlock");t.classes&&t.classes.length?(this._setupConversionUsingClasses(t.classes),e.commands.add("indentBlock",new h(e,new g({direction:"forward",classes:t.classes}))),e.commands.add("outdentBlock",new h(e,new g({direction:"backward",classes:t.classes})))):(e.data.addStyleProcessorRules(d.vt),this._setupConversionUsingOffset(),e.commands.add("indentBlock",new h(e,new m({direction:"forward",offset:t.offset,unit:t.unit}))),e.commands.add("outdentBlock",new h(e,new m({direction:"backward",offset:t.offset,unit:t.unit}))))}afterInit(){const e=this.editor,t=e.model.schema,i=e.commands.get("indent"),n=e.commands.get("outdent"),o=e.config.get("heading.options");(o&&o.map((e=>e.model))||f).forEach((e=>{t.isRegistered(e)&&t.extend(e,{allowAttributes:"blockIndent"})})),t.setAttributeProperties("blockIndent",{isFormatting:!0}),i.registerChildCommand(e.commands.get("indentBlock")),n.registerChildCommand(e.commands.get("outdentBlock"))}_setupConversionUsingOffset(){const e=this.editor.conversion,t="rtl"===this.editor.locale.contentLanguageDirection?"margin-right":"margin-left";e.for("upcast").attributeToAttribute({view:{styles:{[t]:/[\s\S]+/}},model:{key:"blockIndent",value:e=>e.getStyle(t)}}),e.for("downcast").attributeToAttribute({model:"blockIndent",view:e=>({key:"style",value:{[t]:e}})})}_setupConversionUsingClasses(e){const t={model:{key:"blockIndent",values:[]},view:{}};for(const i of e)t.model.values.push(i),t.view[i]={key:"class",value:[i]};this.editor.conversion.attributeToAttribute(t)}}},5127:(e,t,i)=>{"use strict";i.r(t),i.d(t,{AutoLink:()=>ne,Link:()=>se,LinkCommand:()=>L,LinkEditing:()=>j,LinkImage:()=>de,LinkImageEditing:()=>re,LinkImageUI:()=>ce,LinkUI:()=>ee,UnlinkCommand:()=>z});var n=i(6854),o=i(3291),s=i(5187),r=i(4079),a=i(6553);class l{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach((e=>this._definitions.add(e))):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",((e,t,i)=>{if(!i.consumable.test(t.item,"attribute:linkHref"))return;if(!t.item.is("selection")&&!i.schema.isInline(t.item))return;const n=i.writer,o=n.document.selection;for(const e of this._definitions){const s=n.createAttributeElement("a",e.attributes,{priority:5});e.classes&&n.addClass(e.classes,s);for(const t in e.styles)n.setStyle(t,e.styles[t],s);n.setCustomProperty("link",!0,s),e.callback(t.attributeNewValue)?t.item.is("selection")?n.wrap(o.getFirstRange(),s):n.wrap(i.mapper.toViewRange(t.range),s):n.unwrap(i.mapper.toViewRange(t.range),s)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",((e,t,{writer:i,mapper:n})=>{const o=n.toViewElement(t.item),s=Array.from(o.getChildren()).find((e=>e.is("element","a")));for(const e of this._definitions){const n=(0,a.qL)(e.attributes);if(e.callback(t.attributeNewValue)){for(const[e,t]of n)"class"===e?i.addClass(t,s):i.setAttribute(e,t,s);e.classes&&i.addClass(e.classes,s);for(const t in e.styles)i.setStyle(t,e.styles[t],s)}else{for(const[e,t]of n)"class"===e?i.removeClass(t,s):i.removeAttribute(e,s);e.classes&&i.removeClass(e.classes,s);for(const t in e.styles)i.removeStyle(t,s)}}}))}}}var c=i(7855);var d=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const u=function(e){return d.test(e)};var h="\\ud800-\\udfff",m="["+h+"]",g="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",f="\\ud83c[\\udffb-\\udfff]",p="[^"+h+"]",b="(?:\\ud83c[\\udde6-\\uddff]){2}",w="[\\ud800-\\udbff][\\udc00-\\udfff]",v="(?:"+g+"|"+f+")?",_="[\\ufe0e\\ufe0f]?",y=_+v+"(?:\\u200d(?:"+[p,b,w].join("|")+")"+_+v+")*",k="(?:"+[p+g+"?",g,b,w,m].join("|")+")",C=RegExp(f+"(?="+f+")|"+k+y,"g");const A=function(e){return u(e)?function(e){return e.match(C)||[]}(e):function(e){return e.split("")}(e)};var E=i(9939);const x=function(e){e=(0,E.Z)(e);var t,i,n,o,s=u(e)?A(e):void 0,r=s?s[0]:e.charAt(0),a=s?(t=s,i=1,o=t.length,n=void 0===n?o:n,!i&&n>=o?t:(0,c.Z)(t,i,n)).join(""):e.slice(1);return r.toUpperCase()+a},T=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,S=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,P=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,I=/^((\w+:(\/{2,})?)|(\W))/i,V="Ctrl+K";function R(e,{writer:t}){const i=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,i),i}function O(e){const t=String(e);return function(e){return!!e.replace(T,"").match(S)}(t)?t:"#"}function B(e,t){return!!e&&t.checkAttribute(e.name,"linkHref")}function M(e,t){const i=(n=e,P.test(n)?"mailto:":t);var n;const o=!!i&&!N(e);return e&&o?i+e:e}function N(e){return I.test(e)}function D(e){window.open(e,"_blank","noopener")}class L extends n.mY{constructor(){super(...arguments),this.manualDecorators=new a.FE,this.automaticDecorators=new l}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement()||(0,a.Ps)(t.getSelectedBlocks());B(i,e.schema)?(this.value=i.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(i,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={}){const i=this.editor.model,n=i.document.selection,o=[],r=[];for(const e in t)t[e]?o.push(e):r.push(e);i.change((t=>{if(n.isCollapsed){const l=n.getFirstPosition();if(n.hasAttribute("linkHref")){const a=F(n);let c=(0,s.VD)(l,"linkHref",n.getAttribute("linkHref"),i);n.getAttribute("linkHref")===a&&(c=this._updateLinkContent(i,t,c,e)),t.setAttribute("linkHref",e,c),o.forEach((e=>{t.setAttribute(e,!0,c)})),r.forEach((e=>{t.removeAttribute(e,c)})),t.setSelection(t.createPositionAfter(c.end.nodeBefore))}else if(""!==e){const s=(0,a.qL)(n.getAttributes());s.set("linkHref",e),o.forEach((e=>{s.set(e,!0)}));const{end:r}=i.insertContent(t.createText(e,s),l);t.setSelection(r)}["linkHref",...o,...r].forEach((e=>{t.removeSelectionAttribute(e)}))}else{const s=i.schema.getValidRanges(n.getRanges(),"linkHref"),a=[];for(const e of n.getSelectedBlocks())i.schema.checkAttribute(e,"linkHref")&&a.push(t.createRangeOn(e));const l=a.slice();for(const e of s)this._isRangeToUpdate(e,a)&&l.push(e);for(const s of l){let a=s;if(1===l.length){const o=F(n);n.getAttribute("linkHref")===o&&(a=this._updateLinkContent(i,t,s,e),t.setSelection(t.createSelection(a)))}t.setAttribute("linkHref",e,a),o.forEach((e=>{t.setAttribute(e,!0,a)})),r.forEach((e=>{t.removeAttribute(e,a)}))}}}))}_getDecoratorStateFromModel(e){const t=this.editor.model,i=t.document.selection,n=i.getSelectedElement();return B(n,t.schema)?n.getAttribute(e):i.getAttribute(e)}_isRangeToUpdate(e,t){for(const i of t)if(i.containsRange(e))return!1;return!0}_updateLinkContent(e,t,i,n){const o=t.createText(n,{linkHref:n});return e.insertContent(o,i)}}function F(e){if(e.isCollapsed){const t=e.getFirstPosition();return t.textNode&&t.textNode.data}{const t=Array.from(e.getFirstRange().getItems());if(t.length>1)return null;const i=t[0];return i.is("$text")||i.is("$textProxy")?i.data:null}}class z extends n.mY{refresh(){const e=this.editor.model,t=e.document.selection,i=t.getSelectedElement();B(i,e.schema)?this.isEnabled=e.schema.checkAttribute(i,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,i=t.document.selection,n=e.commands.get("link");t.change((e=>{const o=i.isCollapsed?[(0,s.VD)(i.getFirstPosition(),"linkHref",i.getAttribute("linkHref"),t)]:t.schema.getValidRanges(i.getRanges(),"linkHref");for(const t of o)if(e.removeAttribute("linkHref",t),n)for(const i of n.manualDecorators)e.removeAttribute(i.id,t)}))}}class H extends((0,a.Re)()){constructor({id:e,label:t,attributes:i,classes:n,styles:o,defaultValue:s}){super(),this.id=e,this.set("value",void 0),this.defaultValue=s,this.label=t,this.attributes=i,this.classes=n,this.styles=o}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}const W="automatic",U=/^(https?:)?\/\//;class j extends n.Sy{static get pluginName(){return"LinkEditing"}static get requires(){return[s.mh,s.II,r._l]}constructor(e){super(e),e.config.define("link",{addTargetToExternalLinks:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:R}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,t)=>R(O(e),t)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new L(e)),e.commands.add("unlink",new z(e));const t=function(e,t){const i={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach((e=>("label"in e&&i[e.label]&&(e.label=i[e.label]),e))),t}(e.t,function(e){const t=[];if(e)for(const[i,n]of Object.entries(e)){const e=Object.assign({},n,{id:`link${x(i)}`});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(t.filter((e=>e.mode===W))),this._enableManualDecorators(t.filter((e=>"manual"===e.mode))),e.plugins.get(s.mh).registerAttribute("linkHref"),(0,s.Im)(e,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterLink(),this._enableTypingOverLink(),this._handleDeleteContentAfterLink(),this._enableClipboardIntegration()}_enableAutomaticDecorators(e){const t=this.editor,i=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&i.add({id:"linkIsExternal",mode:W,callback:e=>!!e&&U.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),i.add(e),i.length&&t.conversion.for("downcast").add(i.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,i=t.commands.get("link").manualDecorators;e.forEach((e=>{t.model.schema.extend("$text",{allowAttributes:e.id});const n=new H(e);i.add(n),t.conversion.for("downcast").attributeToElement({model:n.id,view:(e,{writer:t,schema:i},{item:o})=>{if((o.is("selection")||i.isInline(o))&&e){const e=t.createAttributeElement("a",n.attributes,{priority:5});n.classes&&t.addClass(n.classes,e);for(const i in n.styles)t.setStyle(i,n.styles[i],e);return t.setCustomProperty("link",!0,e),e}}}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",...n._createPattern()},model:{key:n.id}})}))}_enableLinkOpen(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",((e,t)=>{if(!(a.OB.isMac?t.domEvent.metaKey:t.domEvent.ctrlKey))return;let i=t.domTarget;if("a"!=i.tagName.toLowerCase()&&(i=i.closest("a")),!i)return;const n=i.getAttribute("href");n&&(e.stop(),t.preventDefault(),D(n))}),{context:"$capture"}),this.listenTo(t,"keydown",((t,i)=>{const n=e.commands.get("link").value;n&&i.keyCode===a.Do.enter&&i.altKey&&(t.stop(),D(n))}))}_enableInsertContentSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;this.listenTo(e,"insertContent",(()=>{const i=t.anchor.nodeBefore,n=t.anchor.nodeAfter;t.hasAttribute("linkHref")&&i&&i.hasAttribute("linkHref")&&(n&&n.hasAttribute("linkHref")||e.change((t=>{$(t,K(e.schema))})))}),{priority:"low"})}_enableClickingAfterLink(){const e=this.editor,t=e.model;e.editing.view.addObserver(o.dM);let i=!1;this.listenTo(e.editing.view.document,"mousedown",(()=>{i=!0})),this.listenTo(e.editing.view.document,"selectionChange",(()=>{if(!i)return;i=!1;const e=t.document.selection;if(!e.isCollapsed)return;if(!e.hasAttribute("linkHref"))return;const n=e.getFirstPosition(),o=(0,s.VD)(n,"linkHref",e.getAttribute("linkHref"),t);(n.isTouching(o.start)||n.isTouching(o.end))&&t.change((e=>{$(e,K(t.schema))}))}))}_enableTypingOverLink(){const e=this.editor,t=e.editing.view;let i=null,n=!1;this.listenTo(t.document,"delete",(()=>{n=!0}),{priority:"high"}),this.listenTo(e.model,"deleteContent",(()=>{const t=e.model.document.selection;t.isCollapsed||(n?n=!1:q(e)&&function(e){const t=e.document.selection,i=t.getFirstPosition(),n=t.getLastPosition(),o=i.nodeAfter;if(!o)return!1;if(!o.is("$text"))return!1;if(!o.hasAttribute("linkHref"))return!1;return o===(n.textNode||n.nodeBefore)||(0,s.VD)(i,"linkHref",o.getAttribute("linkHref"),e).containsRange(e.createRange(i,n),!0)}(e.model)&&(i=t.getAttributes()))}),{priority:"high"}),this.listenTo(e.model,"insertContent",((t,[o])=>{n=!1,q(e)&&i&&(e.model.change((e=>{for(const[t,n]of i)e.setAttribute(t,n,o)})),i=null)}),{priority:"high"})}_handleDeleteContentAfterLink(){const e=this.editor,t=e.model,i=t.document.selection,n=e.editing.view;let o=!1,r=!1;this.listenTo(n.document,"delete",((e,t)=>{r="backward"===t.direction}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{o=!1;const e=i.getFirstPosition(),n=i.getAttribute("linkHref");if(!n)return;const r=(0,s.VD)(e,"linkHref",n,t);o=r.containsPosition(e)||r.end.isEqual(e)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{r&&(r=!1,o||e.model.enqueueChange((e=>{$(e,K(t.schema))})))}),{priority:"low"})}_enableClipboardIntegration(){const e=this.editor,t=e.model,i=this.editor.config.get("link.defaultProtocol");i&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",((e,n)=>{t.change((e=>{const t=e.createRangeIn(n.content);for(const n of t.getItems())if(n.hasAttribute("linkHref")){const t=M(n.getAttribute("linkHref"),i);e.setAttribute("linkHref",t,n)}}))}))}}function $(e,t){e.removeSelectionAttribute("linkHref");for(const i of t)e.removeSelectionAttribute(i)}function q(e){return e.model.change((e=>e.batch)).isTyping}function K(e){return e.getDefinition("$text").allowAttributes.filter((e=>e.startsWith("link")))}var Z=i(7095),G=i(5549);class J extends Z.G7{constructor(e,t){super(e),this.focusTracker=new a.Rh,this.keystrokes=new a.VD,this._focusables=new Z.vX;const i=e.t;this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(i("Save"),n.icons.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(i("Cancel"),n.icons.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusCycler=new Z.I0({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const o=["ck","ck-link-form","ck-responsive-form"];t.manualDecorators.length&&o.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:o,tabindex:"-1"},children:this.children})}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((e,t)=>(e[t.name]=t.isOn,e)),{})}render(){super.render(),(0,Z.GI)({view:this}),[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const e=this.locale.t,t=new Z.KP(this.locale,Z.R);return t.label=e("Link URL"),t}_createButton(e,t,i,n){const o=new Z.r5(this.locale);return o.set({label:e,icon:t,tooltip:!0}),o.extendTemplate({attributes:{class:i}}),n&&o.delegate("execute").to(this,n),o}_createManualDecoratorSwitches(e){const t=this.createCollection();for(const i of e.manualDecorators){const n=new Z.BM(this.locale);n.set({name:i.id,label:i.label,withText:!0}),n.bind("isOn").toMany([i,e],"value",((e,t)=>void 0===t&&void 0===e?!!i.defaultValue:!!e)),n.on("execute",(()=>{i.set("value",!n.isOn)})),t.add(n)}return t}_createFormChildren(e){const t=this.createCollection();if(t.add(this.urlInputView),e.length){const e=new Z.G7;e.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((e=>({tag:"li",children:[e],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),t.add(e)}return t.add(this.saveButtonView),t.add(this.cancelButtonView),t}}class Y extends Z.G7{constructor(e){super(e),this.focusTracker=new a.Rh,this.keystrokes=new a.VD,this._focusables=new Z.vX;const t=e.t;this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(t("Unlink"),'',"unlink"),this.editButtonView=this._createButton(t("Edit link"),n.icons.pencil,"edit"),this.set("href",void 0),this._focusCycler=new Z.I0({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-actions","ck-responsive-form"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}render(){super.render(),[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(e,t,i){const n=new Z.r5(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n.delegate("execute").to(this,i),n}_createPreviewButton(){const e=new Z.r5(this.locale),t=this.bindTemplate,i=this.t;return e.set({withText:!0,tooltip:i("Open link in new tab")}),e.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:t.to("href",(e=>e&&O(e))),target:"_blank",rel:"noopener noreferrer"}}),e.bind("label").to(this,"href",(e=>e||i("This link has no URL"))),e.bind("isEnabled").to(this,"href",(e=>!!e)),e.template.tag="a",e.template.eventListeners={},e}}const Q='',X="link-ui";class ee extends n.Sy{constructor(){super(...arguments),this.actionsView=null,this.formView=null}static get requires(){return[Z.WB]}static get pluginName(){return"LinkUI"}init(){const e=this.editor;e.editing.view.addObserver(o.KU),this._balloon=e.plugins.get(Z.WB),this._createToolbarLinkButton(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:X,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:X,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy(),this.formView&&this.formView.destroy(),this.actionsView&&this.actionsView.destroy()}_createViews(){this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createActionsView(){const e=this.editor,t=new Y(e.locale),i=e.commands.get("link"),n=e.commands.get("unlink");return t.bind("href").to(i,"value"),t.editButtonView.bind("isEnabled").to(i),t.unlinkButtonView.bind("isEnabled").to(n),this.listenTo(t,"edit",(()=>{this._addFormView()})),this.listenTo(t,"unlink",(()=>{e.execute("unlink"),this._hideUI()})),t.keystrokes.set("Esc",((e,t)=>{this._hideUI(),t()})),t.keystrokes.set(V,((e,t)=>{this._addFormView(),t()})),t}_createFormView(){const e=this.editor,t=e.commands.get("link"),i=e.config.get("link.defaultProtocol"),n=new((0,Z.RX)(J))(e.locale,t);return n.urlInputView.fieldView.bind("value").to(t,"value"),n.urlInputView.bind("isEnabled").to(t,"isEnabled"),n.saveButtonView.bind("isEnabled").to(t),this.listenTo(n,"submit",(()=>{const{value:t}=n.urlInputView.fieldView.element,o=M(t,i);e.execute("link",o,n.getDecoratorSwitchesState()),this._closeFormView()})),this.listenTo(n,"cancel",(()=>{this._closeFormView()})),n.keystrokes.set("Esc",((e,t)=>{this._closeFormView(),t()})),n}_createToolbarLinkButton(){const e=this.editor,t=e.commands.get("link"),i=e.t;e.ui.componentFactory.add("link",(e=>{const n=new Z.r5(e);return n.isEnabled=!0,n.label=i("Link"),n.icon=Q,n.keystroke=V,n.tooltip=!0,n.isToggleable=!0,n.bind("isEnabled").to(t,"isEnabled"),n.bind("isOn").to(t,"value",(e=>!!e)),this.listenTo(n,"execute",(()=>this._showUI(!0))),n}))}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),e.keystrokes.set(V,((t,i)=>{i(),e.commands.get("link").isEnabled&&this._showUI(!0)}))}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",((e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((e,t)=>{this._isUIVisible&&(this._hideUI(),t())})),(0,Z.eC)({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this.actionsView||this._createViews(),this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions(),this.formView.urlInputView.fieldView.element.value=e.value||""}_closeFormView(){const e=this.editor.commands.get("link");e.restoreManualDecoratorStates(),void 0!==e.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let i=this._getSelectedLinkElement(),n=s();const o=()=>{const e=this._getSelectedLinkElement(),t=s();i&&!e||!i&&t!==n?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),i=e,n=t};function s(){return t.selection.focus.getAncestors().reverse().find((e=>e.is("element")))}this.listenTo(e.ui,"update",o),this.listenTo(this._balloon,"change:visibleView",o)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _areActionsInPanel(){return!!this.actionsView&&this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return!!this.actionsView&&this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){const e=this._balloon.visibleView;return!!this.formView&&e==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model,i=e.document;let n;if(t.markers.has(X)){const t=Array.from(this.editor.editing.mapper.markerNameToElements(X)),i=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));n=e.domConverter.viewRangeToDom(i)}else n=()=>{const t=this._getSelectedLinkElement();return t?e.domConverter.mapViewToDom(t):e.domConverter.viewRangeToDom(i.selection.getFirstRange())};return{target:n}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,i=t.getSelectedElement();if(t.isCollapsed||i&&(0,G.Qd)(i))return te(t.getFirstPosition());{const i=t.getFirstRange().getTrimmed(),n=te(i.start),o=te(i.end);return n&&n==o&&e.createRangeIn(n).getTrimmed().isEqual(i)?n:null}}_showFakeVisualSelection(){const e=this.editor.model;e.change((t=>{const i=e.document.selection.getFirstRange();if(e.markers.has(X))t.updateMarker(X,{range:i});else if(i.start.isAtEnd){const n=i.start.getLastMatchingPosition((({item:t})=>!e.schema.isContent(t)),{boundaries:i});t.addMarker(X,{usingOperation:!1,affectsData:!1,range:t.createRange(n,i.end)})}else t.addMarker(X,{usingOperation:!1,affectsData:!1,range:i})}))}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(X)&&e.change((e=>{e.removeMarker(X)}))}}function te(e){return e.getAncestors().find((e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t}))||null}const ie=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63})))(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i");class ne extends n.Sy{static get requires(){return[s.HG]}static get pluginName(){return"AutoLink"}init(){const e=this.editor.model.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling()}_enableTypingHandling(){const e=this.editor,t=new s.uL(e.model,(e=>{if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(e))return;const t=oe(e.substr(0,e.length-1));return t?{url:t}:void 0}));t.on("matched:data",((t,i)=>{const{batch:n,range:o,url:s}=i;if(!n.isTyping)return;const r=o.end.getShiftedBy(-1),a=r.getShiftedBy(-s.length),l=e.model.createRange(a,r);this._applyAutoLink(s,l)})),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("enter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition();if(!e.parent.previousSibling)return;const i=t.createRangeIn(e.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(i)}))}_enableShiftEnterHandling(){const e=this.editor,t=e.model,i=e.commands.get("shiftEnter");i&&i.on("execute",(()=>{const e=t.document.selection.getFirstPosition(),i=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(i)}))}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:i,range:n}=(0,s.Up)(e,t),o=oe(i);if(o){const e=t.createRange(n.end.getShiftedBy(-o.length),n.end);this._applyAutoLink(o,e)}}_applyAutoLink(e,t){const i=this.editor.model,n=M(e,this.editor.config.get("link.defaultProtocol"));this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}(t,i)&&N(n)&&!function(e){const t=e.start.nodeAfter;return!!t&&t.hasAttribute("linkHref")}(t)&&this._persistAutoLink(n,t)}_persistAutoLink(e,t){const i=this.editor.model,n=this.editor.plugins.get("Delete");i.enqueueChange((o=>{o.setAttribute("linkHref",e,t),i.enqueueChange((()=>{n.requestUndoOnBackspace()}))}))}}function oe(e){const t=ie.exec(e);return t?t[2]:null}class se extends n.Sy{static get requires(){return[j,ee,ne]}static get pluginName(){return"Link"}}class re extends n.Sy{static get requires(){return["ImageEditing","ImageUtils",j]}static get pluginName(){return"LinkImageEditing"}init(){const e=this.editor,t=e.model.schema;e.plugins.has("ImageBlockEditing")&&t.extend("imageBlock",{allowAttributes:["linkHref"]}),e.conversion.for("upcast").add(function(e){const t=e.plugins.has("ImageInlineEditing"),i=e.plugins.get("ImageUtils");return e=>{e.on("element:a",((e,n,o)=>{const s=n.viewItem,r=i.findViewImgElement(s);if(!r)return;const a=r.findAncestor((e=>i.isBlockImageView(e)));if(t&&!a)return;if(!o.consumable.consume(s,{attributes:["href"]}))return;const l=s.getAttribute("href");if(!l)return;let c=n.modelCursor.parent;if(!c.is("element","imageBlock")){const e=o.convertItem(r,n.modelCursor);n.modelRange=e.modelRange,n.modelCursor=e.modelCursor,c=n.modelCursor.nodeBefore}c&&c.is("element","imageBlock")&&o.writer.setAttribute("linkHref",l,c)}),{priority:"high"})}}(e)),e.conversion.for("downcast").add(function(e){const t=e.plugins.get("ImageUtils");return e=>{e.on("attribute:linkHref:imageBlock",((e,i,n)=>{if(!n.consumable.consume(i.item,e.name))return;const o=n.mapper.toViewElement(i.item),s=n.writer,r=Array.from(o.getChildren()).find((e=>e.is("element","a"))),a=t.findViewImgElement(o),l=a.parent.is("element","picture")?a.parent:a;if(r)i.attributeNewValue?s.setAttribute("href",i.attributeNewValue,r):(s.move(s.createRangeOn(l),s.createPositionAt(o,0)),s.remove(r));else{const e=s.createContainerElement("a",{href:i.attributeNewValue});s.insert(s.createPositionAt(o,0),e),s.move(s.createRangeOn(l),s.createPositionAt(e,0))}}),{priority:"high"})}}(e)),this._enableAutomaticDecorators(),this._enableManualDecorators()}_enableAutomaticDecorators(){const e=this.editor,t=e.commands.get("link").automaticDecorators;t.length&&e.conversion.for("downcast").add(t.getDispatcherForLinkedImage())}_enableManualDecorators(){const e=this.editor,t=e.commands.get("link");for(const i of t.manualDecorators)e.plugins.has("ImageBlockEditing")&&e.model.schema.extend("imageBlock",{allowAttributes:i.id}),e.plugins.has("ImageInlineEditing")&&e.model.schema.extend("imageInline",{allowAttributes:i.id}),e.conversion.for("downcast").add(ae(i)),e.conversion.for("upcast").add(le(e,i))}}function ae(e){return t=>{t.on(`attribute:${e.id}:imageBlock`,((t,i,n)=>{const o=n.mapper.toViewElement(i.item),s=Array.from(o.getChildren()).find((e=>e.is("element","a")));if(s){for(const[t,i]of(0,a.qL)(e.attributes))n.writer.setAttribute(t,i,s);e.classes&&n.writer.addClass(e.classes,s);for(const t in e.styles)n.writer.setStyle(t,e.styles[t],s)}}))}}function le(e,t){const i=e.plugins.has("ImageInlineEditing"),n=e.plugins.get("ImageUtils");return e=>{e.on("element:a",((e,s,r)=>{const a=s.viewItem,l=n.findViewImgElement(a);if(!l)return;const c=l.findAncestor((e=>n.isBlockImageView(e)));if(i&&!c)return;const d=new o.xO(t._createPattern()).match(a);if(!d)return;if(!r.consumable.consume(a,d.match))return;const u=s.modelCursor.nodeBefore||s.modelCursor.parent;r.writer.setAttribute(t.id,!0,u)}),{priority:"high"})}}class ce extends n.Sy{static get requires(){return[j,ee,"ImageBlockEditing"]}static get pluginName(){return"LinkImageUI"}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",((t,i)=>{this._isSelectedLinkedImage(e.model.document.selection)&&(i.preventDefault(),t.stop())}),{priority:"high"}),this._createToolbarLinkImageButton()}_createToolbarLinkImageButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("linkImage",(i=>{const n=new Z.r5(i),o=e.plugins.get("LinkUI"),s=e.commands.get("link");return n.set({isEnabled:!0,label:t("Link image"),icon:Q,keystroke:V,tooltip:!0,isToggleable:!0}),n.bind("isEnabled").to(s,"isEnabled"),n.bind("isOn").to(s,"value",(e=>!!e)),this.listenTo(n,"execute",(()=>{this._isSelectedLinkedImage(e.model.document.selection)?o._addActionsView():o._showUI(!0)})),n}))}_isSelectedLinkedImage(e){const t=e.getSelectedElement();return this.editor.plugins.get("ImageUtils").isImage(t)&&t.hasAttribute("linkHref")}}class de extends n.Sy{static get requires(){return[re,ce]}static get pluginName(){return"LinkImage"}}},6144:(e,t,i)=>{"use strict";i.r(t),i.d(t,{AdjacentListsSupport:()=>he,DocumentList:()=>ue,DocumentListEditing:()=>q,DocumentListIndentCommand:()=>T,DocumentListProperties:()=>Be,DocumentListPropertiesEditing:()=>Se,DocumentListPropertiesUtils:()=>xe,DocumentListUtils:()=>R,IndentCommand:()=>Me,List:()=>tt,ListEditing:()=>Xe,ListProperties:()=>ht,ListPropertiesEditing:()=>rt,ListPropertiesUI:()=>Re,ListUI:()=>de,ListUtils:()=>Fe,TodoList:()=>kt,TodoListEditing:()=>_t,TodoListUI:()=>yt});var n=i(6854),o=i(5187),s=i(1863),r=i(6553);class a{constructor(e,t){this._startElement=e,this._referenceIndent=e.getAttribute("listIndent"),this._isForward="forward"==t.direction,this._includeSelf=!!t.includeSelf,this._sameAttributes=(0,r.qo)(t.sameAttributes||[]),this._sameIndent=!!t.sameIndent,this._lowerIndent=!!t.lowerIndent,this._higherIndent=!!t.higherIndent}static first(e,t){const i=new this(e,t)[Symbol.iterator]();return(0,r.Ps)(i)}*[Symbol.iterator](){const e=[];for(const{node:t}of l(this._getStartNode(),this._isForward?"forward":"backward")){const i=t.getAttribute("listIndent");if(ithis._referenceIndent){if(!this._higherIndent)continue;if(!this._isForward){e.push(t);continue}}else{if(!this._sameIndent){if(this._higherIndent){e.length&&(yield*e,e.length=0);break}continue}if(this._sameAttributes.some((e=>t.getAttribute(e)!==this._startElement.getAttribute(e))))break}e.length&&(yield*e,e.length=0),yield t}}_getStartNode(){return this._includeSelf?this._startElement:this._isForward?this._startElement.nextSibling:this._startElement.previousSibling}}function*l(e,t="forward"){const i="forward"==t;let n=null;for(;u(e);)yield{node:e,previous:n},n=e,e=i?e.nextSibling:e.previousSibling}class c{constructor(e){this._listHead=e}[Symbol.iterator](){return l(this._listHead,"forward")}}class d{static next(){return(0,r.hQ)()}}function u(e){return!!e&&e.is("element")&&e.hasAttribute("listItemId")}function h(e,t={}){return[...m(e,{...t,direction:"backward"}),...m(e,{...t,direction:"forward"})]}function m(e,t={}){const i="forward"==t.direction,n=Array.from(new a(e,{...t,includeSelf:i,sameIndent:!0,sameAttributes:"listItemId"}));return i?n:n.reverse()}function g(e){const t=new a(e,{sameIndent:!0,sameAttributes:"listType"}),i=new a(e,{sameIndent:!0,sameAttributes:"listType",includeSelf:!0,direction:"forward"});return[...Array.from(t).reverse(),...i]}function f(e){return!a.first(e,{sameIndent:!0,sameAttributes:"listItemId"})}function p(e){return!a.first(e,{direction:"forward",sameIndent:!0,sameAttributes:"listItemId"})}function b(e,t={}){e=(0,r.qo)(e);const i=!1!==t.withNested,n=new Set;for(const t of e)for(const e of h(t,{higherIndent:i}))n.add(e);return A(n)}function w(e){e=(0,r.qo)(e);const t=new Set;for(const i of e)for(const e of g(i))t.add(e);return A(t)}function v(e,t){const i=m(e,{direction:"forward"}),n=d.next();for(const e of i)t.setAttribute("listItemId",n,e);return i}function _(e,t,i){const n={};for(const[e,i]of t.getAttributes())e.startsWith("list")&&(n[e]=i);const o=m(e,{direction:"forward"});for(const e of o)i.setAttributes(n,e);return o}function y(e,t,{expand:i,indentBy:n=1}={}){e=(0,r.qo)(e);const o=i?b(e):e;for(const e of o){const i=e.getAttribute("listIndent")+n;i<0?k(e,t):t.setAttribute("listIndent",i,e)}return o}function k(e,t){e=(0,r.qo)(e);for(const i of e)for(const e of i.getAttributeKeys())e.startsWith("list")&&t.removeAttribute(e,i);return e}function C(e){if(!e.length)return!1;const t=e[0].getAttribute("listItemId");return!!t&&!e.some((e=>e.getAttribute("listItemId")!=t))}function A(e){return Array.from(e).filter((e=>"$graveyard"!==e.root.rootName)).sort(((e,t)=>e.index-t.index))}function E(e){const t=e.document.selection.getSelectedElement();return t&&e.schema.isObject(t)&&e.schema.isBlock(t)?t:null}function x(e,t,i){return m(t,{direction:"forward"}).pop().index>e.index?_(e,t,i):[]}class T extends n.mY{constructor(e,t){super(e),this._direction=t}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=S(e.document.selection);e.change((e=>{const i=[];C(t)&&!f(t[0])?("forward"==this._direction&&i.push(...y(t,e)),i.push(...v(t[0],e))):"forward"==this._direction?i.push(...y(t,e,{expand:!0})):i.push(...function(e,t){const i=b(e=(0,r.qo)(e)),n=new Set,o=Math.min(...i.map((e=>e.getAttribute("listIndent")))),s=new Map;for(const e of i)s.set(e,a.first(e,{lowerIndent:!0}));for(const e of i){if(n.has(e))continue;n.add(e);const i=e.getAttribute("listIndent")-1;if(i<0)k(e,t);else{if(e.getAttribute("listIndent")==o){const i=x(e,s.get(e),t);for(const e of i)n.add(e);if(i.length)continue}t.setAttribute("listIndent",i,e)}}return A(n)}(t,e));for(const t of i){if(!t.hasAttribute("listType"))continue;const i=a.first(t,{sameIndent:!0});i&&e.setAttribute("listType",i.getAttribute("listType"),t)}this._fireAfterExecute(i)}))}_fireAfterExecute(e){this.fire("afterExecute",A(new Set(e)))}_checkEnabled(){let e=S(this.editor.model.document.selection),t=e[0];if(!t)return!1;if("backward"==this._direction)return!0;if(C(e)&&!f(e[0]))return!0;e=b(e),t=e[0];const i=a.first(t,{sameIndent:!0});return!!i&&i.getAttribute("listType")==t.getAttribute("listType")}}function S(e){const t=Array.from(e.getSelectedBlocks()),i=t.findIndex((e=>!u(e)));return-1!=i&&(t.length=i),t}class P extends n.mY{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,n=E(t),o=Array.from(i.selection.getSelectedBlocks()).filter((e=>t.schema.checkAttribute(e,"listType"))),s=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(s){const t=o[o.length-1],i=m(t,{direction:"forward"}),n=[];i.length>1&&n.push(...v(i[1],e)),n.push(...k(o,e)),n.push(...function(e,t){const i=[];let n=Number.POSITIVE_INFINITY;for(const{node:o}of l(e.nextSibling,"forward")){const e=o.getAttribute("listIndent");if(0==e)break;e{const{firstElement:s,lastElement:r}=this._getMergeSubjectElements(i,e),l=s.getAttribute("listIndent")||0,c=r.getAttribute("listIndent"),d=r.getAttribute("listItemId");if(l!=c){const e=(u=r,Array.from(new a(u,{direction:"forward",higherIndent:!0})));n.push(...y([r,...e],o,{indentBy:l-c,expand:l{const t=v(this._getStartBlock(),e);this._fireAfterExecute(t)}))}_fireAfterExecute(e){this.fire("afterExecute",A(new Set(e)))}_checkEnabled(){const e=this.editor.model.document.selection,t=this._getStartBlock();return e.isCollapsed&&u(t)&&!f(t)}_getStartBlock(){const e=this.editor.model.document.selection.getFirstPosition().parent;return"before"==this._direction?e:e.nextSibling}}class R extends n.Sy{static get pluginName(){return"DocumentListUtils"}expandListBlocksToCompleteList(e){return w(e)}isFirstBlockOfListItem(e){return f(e)}isListItemBlock(e){return u(e)}expandListBlocksToCompleteItems(e,t={}){return b(e,t)}}var O=i(3291);function B(e){return e.is("element","ol")||e.is("element","ul")}function M(e){return e.is("element","li")}function N(e){let t=0,i=e.parent;for(;i;){if(M(i))t++;else{const e=i.previousSibling;e&&M(e)&&t++}i=i.parent}return t}function D(e,t,i,n=z(i,t)){return e.createAttributeElement(F(i),null,{priority:2*t/100-100,id:n})}function L(e,t,i){return e.createAttributeElement("li",null,{priority:(2*t+1)/100-100,id:i})}function F(e){return"numbered"==e?"ol":"ul"}function z(e,t){return`list-${e}-${t}`}function H(e,t){const i=e.nodeBefore;if(u(i)){let e=i;for(const{node:i}of l(e,"backward"))if(e=i,t.has(e))return;t.set(i,e)}else{const i=e.nodeAfter;u(i)&&t.set(i,i)}}function W(){return(e,t,i)=>{if(!i.consumable.test(t.viewItem,{name:!0}))return;const n=new O.yj(t.viewItem.document);for(const e of Array.from(t.viewItem.getChildren()))M(e)||B(e)||n.remove(e)}}function U(e,{dataPipeline:t}={}){return(i,{writer:n})=>{if(!j(i,e))return null;if(!t)return n.createContainerElement("span",{class:"ck-list-bogus-paragraph"});const o=n.createContainerElement("p");return n.setCustomProperty("dataPipeline:transparentRendering",!0,o),o}}function j(e,t,i=h(e)){if(!u(e))return!1;for(const i of e.getAttributeKeys())if(!i.startsWith("selection:")&&!t.includes(i))return!1;return i.length<2}const $=["listType","listIndent","listItemId"];class q extends n.Sy{constructor(){super(...arguments),this._downcastStrategies=[]}static get pluginName(){return"DocumentListEditing"}static get requires(){return[s.C,o.HG,R]}init(){const e=this.editor,t=e.model;if(e.plugins.has("ListEditing"))throw new r.Bb("document-list-feature-conflict",this,{conflictPlugin:"ListEditing"});t.schema.extend("$container",{allowAttributes:$}),t.schema.extend("$block",{allowAttributes:$}),t.schema.extend("$blockObject",{allowAttributes:$});for(const e of $)t.schema.setAttributeProperties(e,{copyOnReplace:!0});e.commands.add("numberedList",new P(e,"numbered")),e.commands.add("bulletedList",new P(e,"bulleted")),e.commands.add("indentList",new T(e,"forward")),e.commands.add("outdentList",new T(e,"backward")),e.commands.add("mergeListItemBackward",new I(e,"backward")),e.commands.add("mergeListItemForward",new I(e,"forward")),e.commands.add("splitListItemBefore",new V(e,"before")),e.commands.add("splitListItemAfter",new V(e,"after")),this._setupDeleteIntegration(),this._setupEnterIntegration(),this._setupTabIntegration(),this._setupClipboardIntegration()}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList"),{priority:"high"}),i&&i.registerChildCommand(e.get("outdentList"),{priority:"lowest"}),this._setupModelPostFixing(),this._setupConversion()}registerDowncastStrategy(e){this._downcastStrategies.push(e)}_getListAttributeNames(){return[...$,...this._downcastStrategies.map((e=>e.attributeName))]}_setupDeleteIntegration(){const e=this.editor,t=e.commands.get("mergeListItemBackward"),i=e.commands.get("mergeListItemForward");this.listenTo(e.editing.view.document,"delete",((n,o)=>{const s=e.model.document.selection;E(e.model)||e.model.change((()=>{const r=s.getFirstPosition();if(s.isCollapsed&&"backward"==o.direction){if(!r.isAtStart)return;const i=r.parent;if(!u(i))return;if(a.first(i,{sameAttributes:"listType",sameIndent:!0})||0!==i.getAttribute("listIndent")){if(!t.isEnabled)return;t.execute({shouldMergeOnBlocksContentLevel:K(e.model,"backward")})}else p(i)||e.execute("splitListItemAfter"),e.execute("outdentList");o.preventDefault(),n.stop()}else{if(s.isCollapsed&&!s.getLastPosition().isAtEnd)return;if(!i.isEnabled)return;i.execute({shouldMergeOnBlocksContentLevel:K(e.model,"forward")}),o.preventDefault(),n.stop()}}))}),{context:"li"})}_setupEnterIntegration(){const e=this.editor,t=e.model,i=e.commands,n=i.get("enter");this.listenTo(e.editing.view.document,"enter",((i,n)=>{const o=t.document,s=o.selection.getFirstPosition().parent;if(o.selection.isCollapsed&&u(s)&&s.isEmpty&&!n.isSoft){const t=f(s),o=p(s);t&&o?(e.execute("outdentList"),n.preventDefault(),i.stop()):t&&!o?(e.execute("splitListItemAfter"),n.preventDefault(),i.stop()):o&&(e.execute("splitListItemBefore"),n.preventDefault(),i.stop())}}),{context:"li"}),this.listenTo(n,"afterExecute",(()=>{const t=i.get("splitListItemBefore");t.refresh(),t.isEnabled&&2===h(e.model.document.selection.getLastPosition().parent).length&&t.execute()}))}_setupTabIntegration(){const e=this.editor;this.listenTo(e.editing.view.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"li"})}_setupConversion(){const e=this.editor,t=e.model,i=this._getListAttributeNames();e.conversion.for("upcast").elementToElement({view:"li",model:"paragraph"}).add((e=>{e.on("element:li",((e,t,i)=>{const{writer:n,schema:o}=i;if(!t.modelRange)return;const s=Array.from(t.modelRange.getItems({shallow:!0})).filter((e=>o.checkAttribute(e,"listItemId")));if(!s.length)return;const r={listItemId:d.next(),listIndent:N(t.viewItem),listType:t.viewItem.parent&&t.viewItem.parent.is("element","ol")?"numbered":"bulleted"};for(const e of s)u(e)||n.setAttributes(r,e);s.length>1&&s[1].getAttribute("listItemId")!=r.listItemId&&i.keepEmptyElement(s[0])})),e.on("element:ul",W(),{priority:"high"}),e.on("element:ol",W(),{priority:"high"})})),e.conversion.for("editingDowncast").elementToElement({model:"paragraph",view:U(i),converterPriority:"high"}),e.conversion.for("dataDowncast").elementToElement({model:"paragraph",view:U(i,{dataPipeline:!0}),converterPriority:"high"}),e.conversion.for("downcast").add((e=>{e.on("attribute",function(e,t,i){const n=function(e){return(t,i)=>{const n=[];for(const i of e)t.hasAttribute(i)&&n.push(`attribute:${i}`);return!!n.every((e=>!1!==i.test(t,e)))&&(n.forEach((e=>i.consume(t,e))),!0)}}(e);return(o,s,r)=>{const{writer:l,mapper:c,consumable:d}=r,u=s.item;if(!e.includes(s.attributeKey))return;if(!n(u,d))return;const h=function(e,t,i){const n=i.createRangeOn(e);return t.toViewRange(n).getTrimmed().getContainedElement()}(u,c,i);!function(e,t){let i=e.parent;for(;i.is("attributeElement")&&["ul","ol","li"].includes(i.name);){const n=i.parent;t.unwrap(t.createRangeOn(e),i),i=n}}(h,l),function(e,t,i,n){if(!e.hasAttribute("listIndent"))return;const o=e.getAttribute("listIndent");let s=e;for(let e=o;e>=0;e--){const o=L(n,e,s.getAttribute("listItemId")),r=D(n,e,s.getAttribute("listType"));for(const e of i)s.hasAttribute(e.attributeName)&&e.setAttributeOnDowncast(n,s.getAttribute(e.attributeName),"list"==e.scope?r:o);if(t=n.wrap(t,o),t=n.wrap(t,r),0==e)break;if(s=a.first(s,{lowerIndent:!0}),!s)break}}(u,l.createRangeOn(h),t,l)}}(i,this._downcastStrategies,t))})),this.listenTo(t.document,"change:data",function(e,t,i,n){return()=>{const n=e.document.differ.getChanges(),r=[],a=new Map,l=new Set;for(const e of n)if("insert"==e.type&&"$text"!=e.name)H(e.position,a),e.attributes.has("listItemId")?l.add(e.position.nodeAfter):H(e.position.getShiftedBy(e.length),a);else if("remove"==e.type&&e.attributes.has("listItemId"))H(e.position,a);else if("attribute"==e.type){const t=e.range.start.nodeAfter;i.includes(e.attributeKey)?(H(e.range.start,a),null===e.attributeNewValue?(H(e.range.start.getShiftedBy(1),a),s(t)&&r.push(t)):l.add(t)):u(t)&&s(t)&&r.push(t)}for(const e of a.values())r.push(...o(e,l));for(const e of new Set(r))t.reconvertItem(e)};function o(e,t){const n=[],o=new Set,a=[];for(const{node:c,previous:d}of l(e,"forward")){if(o.has(c))continue;const e=c.getAttribute("listIndent");d&&ei.includes(e))));const l=m(c,{direction:"forward"});for(const e of l)o.add(e),(s(e,l)||r(e,a,t))&&n.push(e)}return n}function s(e,n){if(!e.is("element","paragraph"))return!1;const o=t.mapper.toViewElement(e);if(!o)return!1;const s=j(e,i,n);return!(!s||!o.is("element","p"))||!(s||!o.is("element","span"))}function r(e,i,o){if(o.has(e))return!1;const s=t.mapper.toViewElement(e);let r=i.length-1;for(let e=s.parent;!e.is("editableElement");e=e.parent){const t=M(e),o=B(e);if(!o&&!t)continue;const s="checkAttributes:"+(t?"item":"list");if(n.fire(s,{viewElement:e,modelAttributes:i[r]}))break;if(o&&(r--,r<0))return!1}return!0}}(t,e.editing,i,this),{priority:"high"}),this.on("checkAttributes:item",((e,{viewElement:t,modelAttributes:i})=>{t.id!=i.listItemId&&(e.return=!0,e.stop())})),this.on("checkAttributes:list",((e,{viewElement:t,modelAttributes:i})=>{t.name==F(i.listType)&&t.id==z(i.listType,i.listIndent)||(e.return=!0,e.stop())}))}_setupModelPostFixing(){const e=this.editor.model,t=this._getListAttributeNames();e.document.registerPostFixer((i=>function(e,t,i,n){const o=e.document.differ.getChanges(),s=new Map;let r=!1;for(const n of o)if("insert"==n.type&&"$text"!=n.name){const o=n.position.nodeAfter;if(!e.schema.checkAttribute(o,"listItemId"))for(const e of Array.from(o.getAttributeKeys()))i.includes(e)&&(t.removeAttribute(e,o),r=!0);H(n.position,s),n.attributes.has("listItemId")||H(n.position.getShiftedBy(n.length),s);for(const{item:t,previousPosition:i}of e.createRangeIn(o))u(t)&&H(i,s)}else"remove"==n.type?H(n.position,s):"attribute"==n.type&&i.includes(n.attributeKey)&&(H(n.range.start,s),null===n.attributeNewValue&&H(n.range.start.getShiftedBy(1),s));const a=new Set;for(const e of s.values())r=n.fire("postFixer",{listNodes:new c(e),listHead:e,writer:t,seenIds:a})||r;return r}(e,i,t,this))),this.on("postFixer",((e,{listNodes:t,writer:i})=>{e.return=function(e,t){let i=0,n=-1,o=null,s=!1;for(const{node:r}of e){const e=r.getAttribute("listIndent");if(e>i){let a;null===o?(o=e-i,a=i):(o>e&&(o=e),a=e-o),a>n+1&&(a=n+1),t.setAttribute("listIndent",a,r),s=!0,n=a}else o=null,i=e+1,n=e}return s}(t,i)||e.return}),{priority:"high"}),this.on("postFixer",((e,{listNodes:t,writer:i,seenIds:n})=>{e.return=function(e,t,i){const n=new Set;let o=!1;for(const{node:s}of e){if(n.has(s))continue;let e=s.getAttribute("listType"),r=s.getAttribute("listItemId");t.has(r)&&(r=d.next()),t.add(r);for(const t of m(s,{direction:"forward"}))n.add(t),t.getAttribute("listType")!=e&&(r=d.next(),e=t.getAttribute("listType")),t.getAttribute("listItemId")!=r&&(i.setAttribute("listItemId",r,t),o=!0)}return o}(t,n,i)||e.return}),{priority:"high"})}_setupClipboardIntegration(){const e=this.editor.model;this.listenTo(e,"insertContent",function(e){return(t,[i,n])=>{const o=i.is("documentFragment")?i.getChild(0):i;if(!u(o))return;let s;s=n?e.createSelection(n):e.document.selection;const r=s.getFirstPosition();let a=null;if(u(r.parent)?a=r.parent:u(r.nodeBefore)&&(a=r.nodeBefore),!a)return;const c=a.getAttribute("listIndent")-o.getAttribute("listIndent");c<=0||e.change((e=>{for(const{node:t}of l(o,"forward"))e.setAttribute("listIndent",t.getAttribute("listIndent")+c,t)}))}}(e),{priority:"high"}),this.listenTo(e,"getSelectedContent",((t,[i])=>{C(Array.from(i.getSelectedBlocks()))&&e.change((e=>k(Array.from(t.return.getChildren()),e)))}))}}function K(e,t){const i=e.document.selection;if(!i.isCollapsed)return!E(e);if("forward"===t)return!0;const n=i.getFirstPosition().parent,o=n.previousSibling;return!e.schema.isObject(o)&&(!!o.isEmpty||C([n,o]))}var Z=i(7095);function G(e,t){const i=t.mapper,n=t.writer,o="numbered"==e.getAttribute("listType")?"ol":"ul",s=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=ae,t}(n),r=n.createContainerElement(o,null);return n.insert(n.createPositionAt(r,0),s),i.bindElements(e,s),s}function J(e,t,i,n){const o=t.parent,s=i.mapper,r=i.writer;let a=s.toViewPosition(n.createPositionBefore(e));const l=X(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),c=e.previousSibling;if(l&&l.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=s.toViewElement(l);a=r.breakContainer(r.createPositionAfter(e))}else if(c&&"listItem"==c.name){a=s.toViewPosition(n.createPositionAt(c,"end"));const e=s.findMappedViewAncestor(a),t=te(e);a=t?r.createPositionBefore(t):r.createPositionAt(e,"end")}else a=s.toViewPosition(n.createPositionBefore(e));if(a=Q(a),r.insert(a,o),c&&"listItem"==c.name){const e=s.toViewElement(c),i=r.createRange(r.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of i)if(e.item.is("element","li")){const n=r.breakContainer(r.createPositionBefore(e.item)),o=e.item.parent,s=r.createPositionAt(t,"end");Y(r,s.nodeBefore,s.nodeAfter),r.move(r.createRangeOn(o),s),i._position=n}}else{const i=o.nextSibling;if(i&&(i.is("element","ul")||i.is("element","ol"))){let n=null;for(const t of i.getChildren()){const i=s.toModelElement(t);if(!(i&&i.getAttribute("listIndent")>e.getAttribute("listIndent")))break;n=t}n&&(r.breakContainer(r.createPositionAfter(n)),r.move(r.createRangeOn(n.parent),r.createPositionAt(t,"end")))}}Y(r,o,o.nextSibling),Y(r,o.previousSibling,o)}function Y(e,t,i){return!t||!i||"ul"!=t.name&&"ol"!=t.name||t.name!=i.name||t.getAttribute("class")!==i.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function Q(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function X(e,t){const i=!!t.sameIndent,n=!!t.smallerIndent,o=t.listIndent;let s=e;for(;s&&"listItem"==s.name;){const e=s.getAttribute("listIndent");if(i&&o==e||n&&o>e)return s;s="forward"===t.direction?s.nextSibling:s.previousSibling}return null}function ee(e,t,i,n){e.ui.componentFactory.add(t,(o=>{const s=e.commands.get(t),r=new Z.r5(o);return r.set({label:i,icon:n,tooltip:!0,isToggleable:!0}),r.bind("isOn","isEnabled").to(s,"value","isEnabled"),r.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),r}))}function te(e){for(const t of e.getChildren())if("ul"==t.name||"ol"==t.name)return t;return null}function ie(e,t){const i=[],n=e.parent,o={ignoreElementEnd:!1,startPosition:e,shallow:!0,direction:t},s=n.getAttribute("listIndent"),r=[...new O.Po(o)].filter((e=>e.item.is("element"))).map((e=>e.item));for(const e of r){if(!e.is("element","listItem"))break;if(e.getAttribute("listIndent")s)){if(e.getAttribute("listType")!==n.getAttribute("listType"))break;if(e.getAttribute("listStyle")!==n.getAttribute("listStyle"))break;if(e.getAttribute("listReversed")!==n.getAttribute("listReversed"))break;if(e.getAttribute("listStart")!==n.getAttribute("listStart"))break;"backward"===t?i.unshift(e):i.push(e)}}return i}function ne(e){let t=[...e.document.selection.getSelectedBlocks()].filter((e=>e.is("element","listItem"))).map((t=>{const i=e.change((e=>e.createPositionAt(t,0)));return[...ie(i,"backward"),...ie(i,"forward")]})).flat();return t=[...new Set(t)],t}const oe=["disc","circle","square"],se=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function re(e){return oe.includes(e)?"bulleted":se.includes(e)?"numbered":null}function ae(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:O.YG.call(this)}const le='',ce='';class de extends n.Sy{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;ee(this.editor,"numberedList",e("Numbered List"),le),ee(this.editor,"bulletedList",e("Bulleted List"),ce)}}class ue extends n.Sy{static get requires(){return[q,de]}static get pluginName(){return"DocumentList"}}class he extends n.Sy{static get pluginName(){return"AdjacentListsSupport"}init(){const e=this.editor;e.model.schema.register("listSeparator",{allowWhere:"$block",isBlock:!0}),e.conversion.for("upcast").add((e=>{e.on("element:ol",me()),e.on("element:ul",me())})).elementToElement({model:"listSeparator",view:"ck-list-separator"}),e.conversion.for("editingDowncast").elementToElement({model:"listSeparator",view:{name:"div",classes:["ck-list-separator","ck-hidden"]}}),e.conversion.for("dataDowncast").elementToElement({model:"listSeparator",view:(e,t)=>{const i=t.writer.createContainerElement("ck-list-separator");return t.writer.setCustomProperty("dataPipeline:transparentRendering",!0,i),i.getFillerOffset=()=>null,i}})}}function me(){return(e,t,i)=>{const n=t.viewItem,o=n.nextSibling;if(!o)return;if(n.name!==o.name)return;t.modelRange||Object.assign(t,i.convertChildren(t.viewItem,t.modelCursor));const s=i.writer,r=s.createElement("listSeparator");if(!i.safeInsert(r,t.modelCursor))return;const a=i.getSplitParts(r);t.modelRange=s.createRange(t.modelRange.start,s.createPositionAfter(a[a.length-1])),i.updateConversionResult(r,t)}}class ge extends n.mY{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute({startIndex:e=1}={}){const t=this.editor.model,i=t.document;let n=Array.from(i.selection.getSelectedBlocks()).filter((e=>u(e)&&"numbered"==e.getAttribute("listType")));n=w(n),t.change((t=>{for(const i of n)t.setAttribute("listStart",e>=0?e:1,i)}))}_getValue(){const e=this.editor.model.document,t=(0,r.Ps)(e.selection.getSelectedBlocks());return t&&u(t)&&"numbered"==t.getAttribute("listType")?t.getAttribute("listStart"):null}}const fe={},pe={},be={},we=[{listStyle:"disc",typeAttribute:"disc",listType:"bulleted"},{listStyle:"circle",typeAttribute:"circle",listType:"bulleted"},{listStyle:"square",typeAttribute:"square",listType:"bulleted"},{listStyle:"decimal",typeAttribute:"1",listType:"numbered"},{listStyle:"decimal-leading-zero",typeAttribute:null,listType:"numbered"},{listStyle:"lower-roman",typeAttribute:"i",listType:"numbered"},{listStyle:"upper-roman",typeAttribute:"I",listType:"numbered"},{listStyle:"lower-alpha",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-alpha",typeAttribute:"A",listType:"numbered"},{listStyle:"lower-latin",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-latin",typeAttribute:"A",listType:"numbered"}];for(const{listStyle:e,typeAttribute:t,listType:i}of we)fe[e]=i,pe[e]=t,t&&(be[t]=e);function ve(){return we.map((e=>e.listStyle))}function _e(e){return fe[e]||null}function ye(e){return be[e]||null}function ke(e){return pe[e]||null}class Ce extends n.mY{constructor(e,t,i){super(e),this.defaultType=t,this._supportedTypes=i}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document;t.change((t=>{this._tryToConvertItemsToList(e);let n=Array.from(i.selection.getSelectedBlocks()).filter((e=>e.hasAttribute("listType")));if(n.length){n=w(n);for(const i of n)t.setAttribute("listStyle",e.type||this.defaultType,i)}}))}isStyleTypeSupported(e){return!this._supportedTypes||this._supportedTypes.includes(e)}_getValue(){const e=(0,r.Ps)(this.editor.model.document.selection.getSelectedBlocks());return u(e)?e.getAttribute("listStyle"):null}_checkEnabled(){const e=this.editor,t=e.commands.get("numberedList"),i=e.commands.get("bulletedList");return t.isEnabled||i.isEnabled}_tryToConvertItemsToList(e){if(!e.type)return;const t=_e(e.type);if(!t)return;const i=this.editor,n=`${t}List`;i.commands.get(n).value||i.execute(n)}}class Ae extends n.mY{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute(e={}){const t=this.editor.model,i=t.document;let n=Array.from(i.selection.getSelectedBlocks()).filter((e=>u(e)&&"numbered"==e.getAttribute("listType")));n=w(n),t.change((t=>{for(const i of n)t.setAttribute("listReversed",!!e.reversed,i)}))}_getValue(){const e=this.editor.model.document,t=(0,r.Ps)(e.selection.getSelectedBlocks());return u(t)&&"numbered"==t.getAttribute("listType")?t.getAttribute("listReversed"):null}}function Ee(e){return(t,i,n)=>{const{writer:o,schema:s,consumable:r}=n;if(!1===r.test(i.viewItem,e.viewConsumables))return;i.modelRange||Object.assign(i,n.convertChildren(i.viewItem,i.modelCursor));let a=!1;for(const t of i.modelRange.getItems({shallow:!0}))s.checkAttribute(t,e.attributeName)&&e.appliesToListItem(t)&&(t.hasAttribute(e.attributeName)||(o.setAttribute(e.attributeName,e.getAttributeOnUpcast(i.viewItem),t),a=!0));a&&r.consume(i.viewItem,e.viewConsumables)}}class xe extends n.Sy{static get pluginName(){return"DocumentListPropertiesUtils"}getAllSupportedStyleTypes(){return ve()}getListTypeFromListStyleType(e){return _e(e)}getListStyleTypeFromTypeAttribute(e){return ye(e)}getTypeAttributeFromListStyleType(e){return ke(e)}}const Te="default";class Se extends n.Sy{static get requires(){return[q,xe]}static get pluginName(){return"DocumentListPropertiesEditing"}constructor(e){super(e),e.config.define("list",{properties:{styles:!0,startIndex:!1,reversed:!1}})}init(){const e=this.editor,t=e.model,i=e.plugins.get(q),n=function(e){const t=[];if(e.styles){const i="object"==typeof e.styles&&e.styles.useAttribute;t.push({attributeName:"listStyle",defaultValue:Te,viewConsumables:{styles:"list-style-type"},addCommand(e){let t=ve();i&&(t=t.filter((e=>!!ke(e)))),e.commands.add("listStyle",new Ce(e,Te,t))},appliesToListItem:()=>!0,hasValidAttribute(e){if(!e.hasAttribute("listStyle"))return!1;const t=e.getAttribute("listStyle");return t==Te||_e(t)==e.getAttribute("listType")},setAttributeOnDowncast(e,t,n){if(t&&t!==Te){if(!i)return void e.setStyle("list-style-type",t,n);{const i=ke(t);if(i)return void e.setAttribute("type",i,n)}}e.removeStyle("list-style-type",n),e.removeAttribute("type",n)},getAttributeOnUpcast(e){const t=e.getStyle("list-style-type");if(t)return t;const i=e.getAttribute("type");return i?ye(i):Te}})}return e.reversed&&t.push({attributeName:"listReversed",defaultValue:!1,viewConsumables:{attributes:"reversed"},addCommand(e){e.commands.add("listReversed",new Ae(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),hasValidAttribute(e){return this.appliesToListItem(e)==e.hasAttribute("listReversed")},setAttributeOnDowncast(e,t,i){t?e.setAttribute("reversed","reversed",i):e.removeAttribute("reversed",i)},getAttributeOnUpcast:e=>e.hasAttribute("reversed")}),e.startIndex&&t.push({attributeName:"listStart",defaultValue:1,viewConsumables:{attributes:"start"},addCommand(e){e.commands.add("listStart",new ge(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),hasValidAttribute(e){return this.appliesToListItem(e)==e.hasAttribute("listStart")},setAttributeOnDowncast(e,t,i){0==t||t>1?e.setAttribute("start",t,i):e.removeAttribute("start",i)},getAttributeOnUpcast(e){const t=e.getAttribute("start");return t>=0?t:1}}),t}(e.config.get("list.properties"));for(const o of n)o.addCommand(e),t.schema.extend("$container",{allowAttributes:o.attributeName}),t.schema.extend("$block",{allowAttributes:o.attributeName}),t.schema.extend("$blockObject",{allowAttributes:o.attributeName}),i.registerDowncastStrategy({scope:"list",attributeName:o.attributeName,setAttributeOnDowncast(e,t,i){o.setAttributeOnDowncast(e,t,i)}});e.conversion.for("upcast").add((e=>{for(const t of n)e.on("element:ol",Ee(t)),e.on("element:ul",Ee(t))})),i.on("checkAttributes:list",((e,{viewElement:t,modelAttributes:i})=>{for(const o of n)o.getAttributeOnUpcast(t)!=i[o.attributeName]&&(e.return=!0,e.stop())})),this.listenTo(e.commands.get("indentList"),"afterExecute",((e,i)=>{t.change((e=>{for(const t of i)for(const i of n)i.appliesToListItem(t)&&e.setAttribute(i.attributeName,i.defaultValue,t)}))})),i.on("postFixer",((e,{listNodes:t,writer:i})=>{for(const{node:o}of t)for(const t of n)t.hasValidAttribute(o)||(t.appliesToListItem(o)?i.setAttribute(t.attributeName,t.defaultValue,o):i.removeAttribute(t.attributeName,o),e.return=!0)})),i.on("postFixer",((e,{listNodes:t,writer:i})=>{const o=[];for(const{node:s,previous:r}of t){if(!r)continue;const t=s.getAttribute("listIndent"),a=r.getAttribute("listIndent");let l=null;if(t>a?o[a]=r:tString(e)))}}),e.bind("label").to(this),e.bind("isOn").to(this,"isCollapsed",(e=>!e)),e.on("execute",(()=>{this.isCollapsed=!this.isCollapsed})),e}}class Ve extends Z.G7{constructor(e,{enabledProperties:t,styleButtonViews:i,styleGridAriaLabel:n}){super(e),this.stylesView=null,this.additionalPropertiesCollapsibleView=null,this.startIndexFieldView=null,this.reversedSwitchButtonView=null,this.focusTracker=new r.Rh,this.keystrokes=new r.VD,this.focusables=new Z.vX;const o=["ck","ck-list-properties"];this.children=this.createCollection(),this.focusCycler=new Z.I0({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),t.styles?(this.stylesView=this._createStylesView(i,n),this.children.add(this.stylesView)):o.push("ck-list-properties_without-styles"),(t.startIndex||t.reversed)&&(this._addNumberedListPropertyViews(t),o.push("ck-list-properties_with-numbered-properties")),this.setTemplate({tag:"div",attributes:{class:o},children:this.children})}render(){if(super.render(),this.stylesView){this.focusables.add(this.stylesView),this.focusTracker.add(this.stylesView.element),(this.startIndexFieldView||this.reversedSwitchButtonView)&&(this.focusables.add(this.children.last.buttonView),this.focusTracker.add(this.children.last.buttonView.element));for(const e of this.stylesView.children)this.stylesView.focusTracker.add(e.element);(0,Z.IJ)({keystrokeHandler:this.stylesView.keystrokes,focusTracker:this.stylesView.focusTracker,gridItems:this.stylesView.children,numberOfColumns:()=>r.CO.window.getComputedStyle(this.stylesView.element).getPropertyValue("grid-template-columns").split(" ").length,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection})}if(this.startIndexFieldView){this.focusables.add(this.startIndexFieldView),this.focusTracker.add(this.startIndexFieldView.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}this.reversedSwitchButtonView&&(this.focusables.add(this.reversedSwitchButtonView),this.focusTracker.add(this.reversedSwitchButtonView.element)),this.keystrokes.listenTo(this.element)}focus(){this.focusCycler.focusFirst()}focusLast(){this.focusCycler.focusLast()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createStylesView(e,t){const i=new Z.G7(this.locale);return i.children=i.createCollection(),i.children.addMany(e),i.setTemplate({tag:"div",attributes:{"aria-label":t,class:["ck","ck-list-styles-list"]},children:i.children}),i.children.delegate("execute").to(this),i.focus=function(){this.children.first.focus()},i.focusTracker=new r.Rh,i.keystrokes=new r.VD,i.render(),i.keystrokes.listenTo(i.element),i}_addNumberedListPropertyViews(e){const t=this.locale.t,i=[];e.startIndex&&(this.startIndexFieldView=this._createStartIndexField(),i.push(this.startIndexFieldView)),e.reversed&&(this.reversedSwitchButtonView=this._createReversedSwitchButton(),i.push(this.reversedSwitchButtonView)),e.styles?(this.additionalPropertiesCollapsibleView=new Ie(this.locale,i),this.additionalPropertiesCollapsibleView.set({label:t("List properties"),isCollapsed:!0}),this.additionalPropertiesCollapsibleView.buttonView.bind("isEnabled").toMany(i,"isEnabled",((...e)=>e.some((e=>e)))),this.additionalPropertiesCollapsibleView.buttonView.on("change:isEnabled",((e,t,i)=>{i||(this.additionalPropertiesCollapsibleView.isCollapsed=!0)})),this.children.add(this.additionalPropertiesCollapsibleView)):this.children.addMany(i)}_createStartIndexField(){const e=this.locale.t,t=new Z.KP(this.locale,Z.sh);return t.set({label:e("Start at"),class:"ck-numbered-list-properties__start-index"}),t.fieldView.set({min:0,step:1,value:1,inputMode:"numeric"}),t.fieldView.on("input",(()=>{const i=t.fieldView.element,n=i.valueAsNumber;Number.isNaN(n)||(i.checkValidity()?this.fire("listStart",{startIndex:n}):t.errorText=e("Start index must be greater than 0."))})),t}_createReversedSwitchButton(){const e=this.locale.t,t=new Z.BM(this.locale);return t.set({withText:!0,label:e("Reversed order"),class:"ck-numbered-list-properties__reversed-order"}),t.delegate("execute").to(this,"listReversed"),t}}class Re extends n.Sy{static get pluginName(){return"ListPropertiesUI"}init(){const e=this.editor,t=e.locale.t,i=e.config.get("list.properties");i.styles&&e.ui.componentFactory.add("bulletedList",Oe({editor:e,parentCommandName:"bulletedList",buttonLabel:t("Bulleted List"),buttonIcon:ce,styleGridAriaLabel:t("Bulleted list styles toolbar"),styleDefinitions:[{label:t("Toggle the disc list style"),tooltip:t("Disc"),type:"disc",icon:''},{label:t("Toggle the circle list style"),tooltip:t("Circle"),type:"circle",icon:''},{label:t("Toggle the square list style"),tooltip:t("Square"),type:"square",icon:''}]})),(i.styles||i.startIndex||i.reversed)&&e.ui.componentFactory.add("numberedList",Oe({editor:e,parentCommandName:"numberedList",buttonLabel:t("Numbered List"),buttonIcon:le,styleGridAriaLabel:t("Numbered list styles toolbar"),styleDefinitions:[{label:t("Toggle the decimal list style"),tooltip:t("Decimal"),type:"decimal",icon:''},{label:t("Toggle the decimal with leading zero list style"),tooltip:t("Decimal with leading zero"),type:"decimal-leading-zero",icon:''},{label:t("Toggle the lower–roman list style"),tooltip:t("Lower–roman"),type:"lower-roman",icon:''},{label:t("Toggle the upper–roman list style"),tooltip:t("Upper-roman"),type:"upper-roman",icon:''},{label:t("Toggle the lower–latin list style"),tooltip:t("Lower-latin"),type:"lower-latin",icon:''},{label:t("Toggle the upper–latin list style"),tooltip:t("Upper-latin"),type:"upper-latin",icon:''}]}))}}function Oe({editor:e,parentCommandName:t,buttonLabel:i,buttonIcon:n,styleGridAriaLabel:o,styleDefinitions:s}){const r=e.commands.get(t);return a=>{const l=(0,Z.t9)(a,Z.Rm),c=l.buttonView;return l.bind("isEnabled").to(r),l.class="ck-list-styles-dropdown",c.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),c.set({label:i,icon:n,tooltip:!0,isToggleable:!0}),c.bind("isOn").to(r,"value",(e=>!!e)),l.once("change:isOpen",(()=>{const i=function({editor:e,dropdownView:t,parentCommandName:i,styleDefinitions:n,styleGridAriaLabel:o}){const s=e.locale,r=e.config.get("list.properties");let a=null;if("numberedList"!=i&&(r.startIndex=!1,r.reversed=!1),r.styles){const t=e.commands.get("listStyle"),o=function({editor:e,listStyleCommand:t,parentCommandName:i}){const n=e.locale,o=e.commands.get(i);return({label:i,type:s,icon:r,tooltip:a})=>{const l=new Z.r5(n);return l.set({label:i,icon:r,tooltip:a}),t.on("change:value",(()=>{l.isOn=t.value===s})),l.on("execute",(()=>{o.value?t.value!==s?e.execute("listStyle",{type:s}):e.execute("listStyle",{type:t.defaultType}):e.model.change((()=>{e.execute("listStyle",{type:s})}))})),l}}({editor:e,parentCommandName:i,listStyleCommand:t}),s="function"==typeof t.isStyleTypeSupported?e=>t.isStyleTypeSupported(e.type):()=>!0;a=n.filter(s).map(o)}const l=new Ve(s,{styleGridAriaLabel:o,enabledProperties:r,styleButtonViews:a});if(r.styles&&(0,Z.Mh)(t,(()=>l.stylesView.children.find((e=>e.isOn)))),r.startIndex){const t=e.commands.get("listStart");l.startIndexFieldView.bind("isEnabled").to(t),l.startIndexFieldView.fieldView.bind("value").to(t),l.on("listStart",((t,i)=>e.execute("listStart",i)))}if(r.reversed){const t=e.commands.get("listReversed");l.reversedSwitchButtonView.bind("isEnabled").to(t),l.reversedSwitchButtonView.bind("isOn").to(t,"value",(e=>!!e)),l.on("listReversed",(()=>{const i=t.value;e.execute("listReversed",{reversed:!i})}))}return l.delegate("execute").to(t),l}({editor:e,dropdownView:l,parentCommandName:t,styleGridAriaLabel:o,styleDefinitions:s});l.panelView.children.add(i)})),l.on("execute",(()=>{e.editing.view.focus()})),l}}class Be extends n.Sy{static get requires(){return[Se,Re]}static get pluginName(){return"DocumentListProperties"}}class Me extends n.mY{constructor(e,t){super(e),this._indentBy="forward"==t?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document;let i=Array.from(t.selection.getSelectedBlocks());e.change((e=>{const t=i[i.length-1];let n=t.nextSibling;for(;n&&"listItem"==n.name&&n.getAttribute("listIndent")>t.getAttribute("listIndent");)i.push(n),n=n.nextSibling;this._indentBy<0&&(i=i.reverse());for(const t of i){const i=t.getAttribute("listIndent")+this._indentBy;i<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",i,t)}this.fire("_executeCleanup",i)}))}_checkEnabled(){const e=(0,r.Ps)(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("element","listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),i=e.getAttribute("listType");let n=e.previousSibling;for(;n&&n.is("element","listItem")&&n.getAttribute("listIndent")>=t;){if(n.getAttribute("listIndent")==t)return n.getAttribute("listType")==i;n=n.previousSibling}return!1}return!0}}class Ne extends n.mY{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,i=t.document,n=Array.from(i.selection.getSelectedBlocks()).filter((e=>Le(e,t.schema))),o=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(o){let t=n[n.length-1].nextSibling,i=Number.POSITIVE_INFINITY,o=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=i;)s>o.getAttribute("listIndent")&&(s=o.getAttribute("listIndent")),o.getAttribute("listIndent")==s&&e[t?"unshift":"push"](o),o=o[t?"previousSibling":"nextSibling"]}}function Le(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class Fe extends n.Sy{static get pluginName(){return"ListUtils"}getListTypeFromListStyleType(e){return re(e)}getSelectedListItems(e){return ne(e)}getSiblingNodes(e,t){return ie(e,t)}}function ze(e){return(t,i,n)=>{const o=n.consumable;if(!o.test(i.item,"insert")||!o.test(i.item,"attribute:listType")||!o.test(i.item,"attribute:listIndent"))return;o.consume(i.item,"insert"),o.consume(i.item,"attribute:listType"),o.consume(i.item,"attribute:listIndent");const s=i.item;J(s,G(s,n),n,e)}}const He=(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;const n=i.mapper.toViewElement(t.item),o=i.writer;o.breakContainer(o.createPositionBefore(n)),o.breakContainer(o.createPositionAfter(n));const s=n.parent,r="numbered"==t.attributeNewValue?"ol":"ul";o.rename(r,s)},We=(e,t,i)=>{i.consumable.consume(t.item,e.name);const n=i.mapper.toViewElement(t.item).parent,o=i.writer;Y(o,n,n.nextSibling),Y(o,n.previousSibling,n)},Ue=(e,t,i)=>{if(i.consumable.test(t.item,e.name)&&"listItem"!=t.item.name){let e=i.mapper.toViewPosition(t.range.start);const n=i.writer,o=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=n.breakContainer(e),"li"==e.parent.name);){const t=e,i=n.createPositionAt(e.parent,"end");if(!t.isEqual(i)){const e=n.remove(n.createRange(t,i));o.push(e)}e=n.createPositionAfter(e.parent)}if(o.length>0){for(let t=0;t0){const t=Y(n,i,i.nextSibling);t&&t.parent==i&&e.offset--}}Y(n,e.nodeBefore,e.nodeAfter)}}},je=(e,t,i)=>{const n=i.mapper.toViewPosition(t.position),o=n.nodeBefore,s=n.nodeAfter;Y(i.writer,o,s)},$e=(e,t,i)=>{if(i.consumable.consume(t.viewItem,{name:!0})){const e=i.writer,n=e.createElement("listItem"),o=function(e){let t=0,i=e.parent;for(;i;){if(i.is("element","li"))t++;else{const e=i.previousSibling;e&&e.is("element","li")&&t++}i=i.parent}return t}(t.viewItem);e.setAttribute("listIndent",o,n);const s=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",s,n),!i.safeInsert(n,t.modelCursor))return;const r=function(e,t,i){const{writer:n,schema:o}=i;let s=n.createPositionAfter(e);for(const r of t)if("ul"==r.name||"ol"==r.name)s=i.convertItem(r,s).modelCursor;else{const t=i.convertItem(r,n.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:Je(t.modelCursor),s=n.createPositionAfter(e))}return s}(n,t.viewItem.getChildren(),i);t.modelRange=e.createRange(t.modelCursor,r),i.updateConversionResult(n,t)}},qe=(e,t,i)=>{if(i.consumable.test(t.viewItem,{name:!0})){const e=Array.from(t.viewItem.getChildren());for(const t of e)!t.is("element","li")&&!Qe(t)&&t._remove()}},Ke=(e,t,i)=>{if(i.consumable.test(t.viewItem,{name:!0})){if(0===t.viewItem.childCount)return;const e=[...t.viewItem.getChildren()];let i=!1;for(const t of e)i&&!Qe(t)&&t._remove(),Qe(t)&&(i=!0)}};function Ze(e){return(t,i)=>{if(i.isPhantom)return;const n=i.modelPosition.nodeBefore;if(n&&n.is("element","listItem")){const t=i.mapper.toViewElement(n),o=t.getAncestors().find(Qe),s=e.createPositionAt(t,0).getWalker();for(const e of s){if("elementStart"==e.type&&e.item.is("element","li")){i.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==o){i.viewPosition=e.nextPosition;break}}}}}const Ge=function(e,[t,i]){let n,o=t.is("documentFragment")?t.getChild(0):t;if(n=i?this.createSelection(i):this.document.selection,o&&o.is("element","listItem")){const e=n.getFirstPosition();let t=null;if(e.parent.is("element","listItem")?t=e.parent:e.nodeBefore&&e.nodeBefore.is("element","listItem")&&(t=e.nodeBefore),t){const e=t.getAttribute("listIndent");if(e>0)for(;o&&o.is("element","listItem");)o._setAttribute("listIndent",o.getAttribute("listIndent")+e),o=o.nextSibling}}};function Je(e){const t=new O.Po({startPosition:e});let i;do{i=t.next()}while(!i.value.item.is("element","listItem"));return i.value.item}function Ye(e,t,i,n,o,s){const r=X(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e}),a=o.mapper,l=o.writer,c=r?r.getAttribute("listIndent"):null;let d;if(r)if(c==e){const e=a.toViewElement(r).parent;d=l.createPositionAfter(e)}else{const e=s.createPositionAt(r,"end");d=a.toViewPosition(e)}else d=i;d=Q(d);for(const e of[...n.getChildren()])Qe(e)&&(d=l.move(l.createRangeOn(e),d).end,Y(l,e,e.nextSibling),Y(l,e.previousSibling,e))}function Qe(e){return e.is("element","ol")||e.is("element","ul")}class Xe extends n.Sy{static get pluginName(){return"ListEditing"}static get requires(){return[s.C,o.HG,Fe]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,i=e.editing;var n;e.model.document.registerPostFixer((t=>function(e,t){const i=e.document.differ.getChanges(),n=new Map;let o=!1;for(const n of i)if("insert"==n.type&&"listItem"==n.name)s(n.position);else if("insert"==n.type&&"listItem"!=n.name){if("$text"!=n.name){const i=n.position.nodeAfter;i.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",i),o=!0),i.hasAttribute("listType")&&(t.removeAttribute("listType",i),o=!0),i.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",i),o=!0),i.hasAttribute("listReversed")&&(t.removeAttribute("listReversed",i),o=!0),i.hasAttribute("listStart")&&(t.removeAttribute("listStart",i),o=!0);for(const t of Array.from(e.createRangeIn(i)).filter((e=>e.item.is("element","listItem"))))s(t.previousPosition)}s(n.position.getShiftedBy(n.length))}else"remove"==n.type&&"listItem"==n.name?s(n.position):("attribute"==n.type&&"listIndent"==n.attributeKey||"attribute"==n.type&&"listType"==n.attributeKey)&&s(n.range.start);for(const e of n.values())r(e),a(e);return o;function s(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(n.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,n.has(e))return;n.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&n.set(t,t)}}function r(e){let i=0,n=null;for(;e&&e.is("element","listItem");){const s=e.getAttribute("listIndent");if(s>i){let r;null===n?(n=s-i,r=i):(n>s&&(n=s),r=s-n),t.setAttribute("listIndent",r,e),o=!0}else n=null,i=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let i=[],n=null;for(;e&&e.is("element","listItem");){const s=e.getAttribute("listIndent");if(n&&n.getAttribute("listIndent")>s&&(i=i.slice(0,s+1)),0!=s)if(i[s]){const n=i[s];e.getAttribute("listType")!=n&&(t.setAttribute("listType",n,e),o=!0)}else i[s]=e.getAttribute("listType");n=e,e=e.nextSibling}}}(e.model,t))),i.mapper.registerViewToModelLength("li",et),t.mapper.registerViewToModelLength("li",et),i.mapper.on("modelToViewPosition",Ze(i.view)),i.mapper.on("viewToModelPosition",(n=e.model,(e,t)=>{const i=t.viewPosition,o=i.parent,s=t.mapper;if("ul"==o.name||"ol"==o.name){if(i.isAtEnd){const e=s.toModelElement(i.nodeBefore),o=s.getModelLength(i.nodeBefore);t.modelPosition=n.createPositionBefore(e).getShiftedBy(o)}else{const e=s.toModelElement(i.nodeAfter);t.modelPosition=n.createPositionBefore(e)}e.stop()}else if("li"==o.name&&i.nodeBefore&&("ul"==i.nodeBefore.name||"ol"==i.nodeBefore.name)){const r=s.toModelElement(o);let a=1,l=i.nodeBefore;for(;l&&Qe(l);)a+=s.getModelLength(l),l=l.previousSibling;t.modelPosition=n.createPositionBefore(r).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",Ze(i.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",Ue,{priority:"high"}),t.on("insert:listItem",ze(e.model)),t.on("attribute:listType:listItem",He,{priority:"high"}),t.on("attribute:listType:listItem",We,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,i,n)=>{if(!n.consumable.consume(i.item,"attribute:listIndent"))return;const o=n.mapper.toViewElement(i.item),s=n.writer;s.breakContainer(s.createPositionBefore(o)),s.breakContainer(s.createPositionAfter(o));const r=o.parent,a=r.previousSibling,l=s.createRangeOn(r);s.remove(l),a&&a.nextSibling&&Y(s,a,a.nextSibling),Ye(i.attributeOldValue+1,i.range.start,l.start,o,n,e),J(i.item,o,n,e);for(const e of i.item.getChildren())n.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,i,n)=>{const o=n.mapper.toViewPosition(i.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,s=n.writer;s.breakContainer(s.createPositionBefore(o)),s.breakContainer(s.createPositionAfter(o));const r=o.parent,a=r.previousSibling,l=s.createRangeOn(r),c=s.remove(l);a&&a.nextSibling&&Y(s,a,a.nextSibling),Ye(n.mapper.toModelElement(o).getAttribute("listIndent")+1,i.position,l.start,o,n,e);for(const e of s.createRangeIn(c).getItems())n.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",je,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",Ue,{priority:"high"}),t.on("insert:listItem",ze(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",qe,{priority:"high"}),e.on("element:ol",qe,{priority:"high"}),e.on("element:li",Ke,{priority:"high"}),e.on("element:li",$e)})),e.model.on("insertContent",Ge,{priority:"high"}),e.commands.add("numberedList",new Ne(e,"numbered")),e.commands.add("bulletedList",new Ne(e,"bulleted")),e.commands.add("indentList",new Me(e,"forward")),e.commands.add("outdentList",new Me(e,"backward"));const o=i.view.document;this.listenTo(o,"enter",((e,t)=>{const i=this.editor.model.document,n=i.selection.getLastPosition().parent;i.selection.isCollapsed&&"listItem"==n.name&&n.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(o,"delete",((e,t)=>{if("backward"!==t.direction)return;const i=this.editor.model.document.selection;if(!i.isCollapsed)return;const n=i.getFirstPosition();if(!n.isAtStart)return;const o=n.parent;"listItem"===o.name&&(o.previousSibling&&"listItem"===o.previousSibling.name||(this.editor.execute("outdentList"),t.preventDefault(),e.stop()))}),{context:"li"}),this.listenTo(e.editing.view.document,"tab",((t,i)=>{const n=i.shiftKey?"outdentList":"indentList";this.editor.commands.get(n).isEnabled&&(e.execute(n),i.stopPropagation(),i.preventDefault(),t.stop())}),{context:"li"})}afterInit(){const e=this.editor.commands,t=e.get("indent"),i=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),i&&i.registerChildCommand(e.get("outdentList"))}}function et(e){let t=1;for(const i of e.getChildren())if("ul"==i.name||"ol"==i.name)for(const e of i.getChildren())t+=et(e);return t}class tt extends n.Sy{static get requires(){return[Xe,de]}static get pluginName(){return"List"}}class it extends n.mY{constructor(e,t){super(e),this.defaultType=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){this._tryToConvertItemsToList(e);const t=this.editor.model,i=ne(t);i.length&&t.change((t=>{for(const n of i)t.setAttribute("listStyle",e.type||this.defaultType,n)}))}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")?e.getAttribute("listStyle"):null}_checkEnabled(){const e=this.editor,t=e.commands.get("numberedList"),i=e.commands.get("bulletedList");return t.isEnabled||i.isEnabled}_tryToConvertItemsToList(e){if(!e.type)return;const t=re(e.type);if(!t)return;const i=this.editor,n=`${t}List`;i.commands.get(n).value||i.execute(n)}}class nt extends n.mY{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute(e={}){const t=this.editor.model,i=ne(t).filter((e=>"numbered"==e.getAttribute("listType")));t.change((t=>{for(const n of i)t.setAttribute("listReversed",!!e.reversed,n)}))}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")&&"numbered"==e.getAttribute("listType")?e.getAttribute("listReversed"):null}}class ot extends n.mY{refresh(){const e=this._getValue();this.value=e,this.isEnabled=null!=e}execute({startIndex:e=1}={}){const t=this.editor.model,i=ne(t).filter((e=>"numbered"==e.getAttribute("listType")));t.change((t=>{for(const n of i)t.setAttribute("listStart",e>=0?e:1,n)}))}_getValue(){const e=this.editor.model.document.selection.getFirstPosition().parent;return e&&e.is("element","listItem")&&"numbered"==e.getAttribute("listType")?e.getAttribute("listStart"):null}}const st="default";class rt extends n.Sy{static get requires(){return[Xe]}static get pluginName(){return"ListPropertiesEditing"}constructor(e){super(e),e.config.define("list",{properties:{styles:!0,startIndex:!1,reversed:!1}})}init(){const e=this.editor,t=e.model,i=function(e){const t=[];return e.styles&&t.push({attributeName:"listStyle",defaultValue:st,addCommand(e){e.commands.add("listStyle",new it(e,st))},appliesToListItem:()=>!0,setAttributeOnDowncast(e,t,i){t&&t!==st?e.setStyle("list-style-type",t,i):e.removeStyle("list-style-type",i)},getAttributeOnUpcast:e=>e.getStyle("list-style-type")||st}),e.reversed&&t.push({attributeName:"listReversed",defaultValue:!1,addCommand(e){e.commands.add("listReversed",new nt(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),setAttributeOnDowncast(e,t,i){t?e.setAttribute("reversed","reversed",i):e.removeAttribute("reversed",i)},getAttributeOnUpcast:e=>e.hasAttribute("reversed")}),e.startIndex&&t.push({attributeName:"listStart",defaultValue:1,addCommand(e){e.commands.add("listStart",new ot(e))},appliesToListItem:e=>"numbered"==e.getAttribute("listType"),setAttributeOnDowncast(e,t,i){0==t||t>1?e.setAttribute("start",t,i):e.removeAttribute("start",i)},getAttributeOnUpcast(e){const t=e.getAttribute("start");return t>=0?t:1}}),t}(e.config.get("list.properties"));t.schema.extend("listItem",{allowAttributes:i.map((e=>e.attributeName))});for(const t of i)t.addCommand(e);var n;this.listenTo(e.commands.get("indentList"),"_executeCleanup",function(e,t){return(i,n)=>{const o=n[0],s=o.getAttribute("listIndent"),r=n.filter((e=>e.getAttribute("listIndent")===s));let a=null;o.previousSibling.getAttribute("listIndent")+1!==s&&(a=X(o.previousSibling,{sameIndent:!0,direction:"backward",listIndent:s})),e.model.change((e=>{for(const i of r)for(const n of t)if(n.appliesToListItem(i)){const t=null==a?n.defaultValue:a.getAttribute(n.attributeName);e.setAttribute(n.attributeName,t,i)}}))}}(e,i)),this.listenTo(e.commands.get("outdentList"),"_executeCleanup",function(e,t){return(i,n)=>{if(!(n=n.reverse().filter((e=>e.is("element","listItem")))).length)return;const o=n[0].getAttribute("listIndent"),s=n[0].getAttribute("listType");let r=n[0].previousSibling;if(r.is("element","listItem"))for(;r.getAttribute("listIndent")!==o;)r=r.previousSibling;else r=null;r||(r=n[n.length-1].nextSibling),r&&r.is("element","listItem")&&r.getAttribute("listType")===s&&e.model.change((e=>{const i=n.filter((e=>e.getAttribute("listIndent")===o));for(const n of i)for(const i of t)if(i.appliesToListItem(n)){const t=i.attributeName,o=r.getAttribute(t);e.setAttribute(t,o,n)}}))}}(e,i)),this.listenTo(e.commands.get("bulletedList"),"_executeCleanup",ct(e)),this.listenTo(e.commands.get("numberedList"),"_executeCleanup",ct(e)),t.document.registerPostFixer(function(e,t){return i=>{let n=!1;const o=dt(e.model.document.differ.getChanges()).filter((e=>"todo"!==e.getAttribute("listType")));if(!o.length)return n;let s=o[o.length-1].nextSibling;if((!s||!s.is("element","listItem"))&&(s=o[0].previousSibling,s)){const e=o[0].getAttribute("listIndent");for(;s.is("element","listItem")&&s.getAttribute("listIndent")!==e&&(s=s.previousSibling,s););}for(const e of t){const t=e.attributeName;for(const r of o)if(e.appliesToListItem(r))if(r.hasAttribute(t)){const o=r.previousSibling;lt(o,r,e.attributeName)&&(i.setAttribute(t,o.getAttribute(t),r),n=!0)}else at(s,r,e)?i.setAttribute(t,s.getAttribute(t),r):i.setAttribute(t,e.defaultValue,r),n=!0;else i.removeAttribute(t,r)}return n}}(e,i)),e.conversion.for("upcast").add((n=i,e=>{e.on("element:li",((e,t,i)=>{if(!t.modelRange)return;const o=t.viewItem.parent,s=t.modelRange.start.nodeAfter||t.modelRange.end.nodeBefore;for(const e of n)if(e.appliesToListItem(s)){const t=e.getAttributeOnUpcast(o);i.writer.setAttribute(e.attributeName,t,s)}}),{priority:"low"})})),e.conversion.for("downcast").add(function(e){return t=>{for(const i of e)t.on(`attribute:${i.attributeName}:listItem`,((e,t,n)=>{const o=n.writer,s=t.item,r=X(s.previousSibling,{sameIndent:!0,listIndent:s.getAttribute("listIndent"),direction:"backward"}),a=n.mapper.toViewElement(s);var l,c;l=s,(c=r)&&l.getAttribute("listType")===c.getAttribute("listType")&&l.getAttribute("listIndent")===c.getAttribute("listIndent")&&l.getAttribute("listStyle")===c.getAttribute("listStyle")&&l.getAttribute("listReversed")===c.getAttribute("listReversed")&&l.getAttribute("listStart")===c.getAttribute("listStart")||o.breakContainer(o.createPositionBefore(a)),i.setAttributeOnDowncast(o,t.attributeNewValue,a.parent)}),{priority:"low"})}}(i)),this._mergeListAttributesWhileMergingLists(i)}afterInit(){const e=this.editor;e.commands.get("todoList")&&e.model.document.registerPostFixer(function(e){return t=>{const i=dt(e.model.document.differ.getChanges()).filter((e=>"todo"===e.getAttribute("listType")&&(e.hasAttribute("listStyle")||e.hasAttribute("listReversed")||e.hasAttribute("listStart"))));if(!i.length)return!1;for(const e of i)t.removeAttribute("listStyle",e),t.removeAttribute("listReversed",e),t.removeAttribute("listStart",e);return!0}}(e))}_mergeListAttributesWhileMergingLists(e){const t=this.editor.model;let i;this.listenTo(t,"deleteContent",((e,[t])=>{const n=t.getFirstPosition(),o=t.getLastPosition();if(n.parent===o.parent)return;if(!n.parent.is("element","listItem"))return;const s=o.parent.nextSibling;if(!s||!s.is("element","listItem"))return;const r=X(n.parent,{sameIndent:!0,listIndent:s.getAttribute("listIndent")});r&&r.getAttribute("listType")===s.getAttribute("listType")&&(i=r)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{i&&(t.change((t=>{const n=X(i.nextSibling,{sameIndent:!0,listIndent:i.getAttribute("listIndent"),direction:"forward"});if(!n)return void(i=null);const o=[n,...ie(t.createPositionAt(n,0),"forward")];for(const n of o)for(const o of e)if(o.appliesToListItem(n)){const e=o.attributeName,s=i.getAttribute(e);t.setAttribute(e,s,n)}})),i=null)}),{priority:"low"})}}function at(e,t,i){if(!e)return!1;const n=e.getAttribute(i.attributeName);return!!n&&n!=i.defaultValue&&e.getAttribute("listType")===t.getAttribute("listType")}function lt(e,t,i){if(!e||!e.is("element","listItem"))return!1;if(t.getAttribute("listType")!==e.getAttribute("listType"))return!1;const n=e.getAttribute("listIndent");if(n<1||n!==t.getAttribute("listIndent"))return!1;const o=e.getAttribute(i);return!(!o||o===t.getAttribute(i))}function ct(e){return(t,i)=>{i=i.filter((e=>e.is("element","listItem"))),e.model.change((e=>{for(const t of i)e.removeAttribute("listStyle",t)}))}}function dt(e){const t=[];for(const i of e){const e=ut(i);e&&e.is("element","listItem")&&t.push(e)}return t}function ut(e){return"attribute"===e.type?e.range.start.nodeAfter:"insert"===e.type?e.position.nodeAfter:null}class ht extends n.Sy{static get requires(){return[rt,Re]}static get pluginName(){return"ListProperties"}}const mt="todoListChecked";class gt extends n.mY{constructor(e){super(e),this._selectedElements=[],this.on("execute",(()=>{this.refresh()}),{priority:"highest"})}refresh(){this._selectedElements=this._getSelectedItems(),this.value=this._selectedElements.every((e=>!!e.getAttribute(mt))),this.isEnabled=!!this._selectedElements.length}_getSelectedItems(){const e=this.editor.model,t=e.schema,i=e.document.selection.getFirstRange(),n=i.start.parent,o=[];t.checkAttribute(n,mt)&&o.push(n);for(const e of i.getItems())t.checkAttribute(e,mt)&&!o.includes(e)&&o.push(e);return o}execute(e={}){this.editor.model.change((t=>{for(const i of this._selectedElements)(void 0===e.forceValue?!this.value:e.forceValue)?t.setAttribute(mt,!0,i):t.removeAttribute(mt,i)}))}}const ft=(e,t,i)=>{const n=t.modelCursor,o=n.parent,s=t.viewItem;if("checkbox"!=s.getAttribute("type")||"listItem"!=o.name||!n.isAtStart)return;if(!i.consumable.consume(s,{name:!0}))return;const r=i.writer;r.setAttribute("listType","todo",o),t.viewItem.hasAttribute("checked")&&r.setAttribute("todoListChecked",!0,o),t.modelRange=r.createRange(n)};function pt(e){return(t,i)=>{const n=i.modelPosition,o=n.parent;if(!o.is("element","listItem")||"todo"!=o.getAttribute("listType"))return;const s=wt(i.mapper.toViewElement(o),e);s&&(i.viewPosition=i.mapper.findPositionIn(s,n.offset))}}function bt(e,t,i,n){return t.createUIElement("label",{class:"todo-list__label",contenteditable:!1},(function(t){const o=(0,r.az)(document,"input",{type:"checkbox",tabindex:"-1"});i&&o.setAttribute("checked","checked"),o.addEventListener("change",(()=>n(e)));const s=this.toDomElement(t);return s.appendChild(o),s}))}function wt(e,t){const i=t.createRangeIn(e);for(const e of i)if(e.item.is("containerElement","span")&&e.item.hasClass("todo-list__label__description"))return e.item}const vt=(0,r.Zz)("Ctrl+Enter");class _t extends n.Sy{static get pluginName(){return"TodoListEditing"}static get requires(){return[Xe]}init(){const e=this.editor,{editing:t,data:i,model:n}=e;n.schema.extend("listItem",{allowAttributes:["todoListChecked"]}),n.schema.addAttributeCheck(((e,t)=>{const i=e.last;if("todoListChecked"==t&&"listItem"==i.name&&"todo"!=i.getAttribute("listType"))return!1})),e.commands.add("todoList",new Ne(e,"todo"));const o=new gt(e);var s,a;e.commands.add("checkTodoList",o),e.commands.add("todoListCheck",o),i.downcastDispatcher.on("insert:listItem",function(e){return(t,i,n)=>{const o=n.consumable;if(!o.test(i.item,"insert")||!o.test(i.item,"attribute:listType")||!o.test(i.item,"attribute:listIndent"))return;if("todo"!=i.item.getAttribute("listType"))return;const s=i.item;o.consume(s,"insert"),o.consume(s,"attribute:listType"),o.consume(s,"attribute:listIndent"),o.consume(s,"attribute:todoListChecked");const r=n.writer,a=G(s,n);r.addClass("todo-list",a.parent);const l=r.createContainerElement("label",{class:"todo-list__label"}),c=r.createEmptyElement("input",{type:"checkbox",disabled:"disabled"}),d=r.createContainerElement("span",{class:"todo-list__label__description"});s.getAttribute("todoListChecked")&&r.setAttribute("checked","checked",c),r.insert(r.createPositionAt(a,0),l),r.insert(r.createPositionAt(l,0),c),r.insert(r.createPositionAfter(c),d),J(s,a,n,e)}}(n),{priority:"high"}),i.upcastDispatcher.on("element:input",ft,{priority:"high"}),t.downcastDispatcher.on("insert:listItem",function(e,t){return(i,n,o)=>{const s=o.consumable;if(!s.test(n.item,"insert")||!s.test(n.item,"attribute:listType")||!s.test(n.item,"attribute:listIndent"))return;if("todo"!=n.item.getAttribute("listType"))return;const r=n.item;s.consume(r,"insert"),s.consume(r,"attribute:listType"),s.consume(r,"attribute:listIndent"),s.consume(r,"attribute:todoListChecked");const a=o.writer,l=G(r,o),c=!!r.getAttribute("todoListChecked"),d=bt(r,a,c,t),u=a.createContainerElement("span",{class:"todo-list__label__description"});a.addClass("todo-list",l.parent),a.insert(a.createPositionAt(l,0),d),a.insert(a.createPositionAfter(d),u),J(r,l,o,e)}}(n,(e=>this._handleCheckmarkChange(e))),{priority:"high"}),t.downcastDispatcher.on("attribute:listType:listItem",(s=e=>this._handleCheckmarkChange(e),a=t.view,(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;const n=i.mapper.toViewElement(t.item),o=i.writer,r=function(e,t){const i=t.createRangeIn(e);for(const e of i)if(e.item.is("uiElement","label"))return e.item}(n,a);if("todo"==t.attributeNewValue){const e=!!t.item.getAttribute("todoListChecked"),i=bt(t.item,o,e,s),r=o.createContainerElement("span",{class:"todo-list__label__description"}),a=o.createRangeIn(n),l=te(n),c=Q(a.start),d=l?o.createPositionBefore(l):a.end,u=o.createRange(c,d);o.addClass("todo-list",n.parent),o.move(u,o.createPositionAt(r,0)),o.insert(o.createPositionAt(n,0),i),o.insert(o.createPositionAfter(i),r)}else if("todo"==t.attributeOldValue){const e=wt(n,a);o.removeClass("todo-list",n.parent),o.remove(r),o.move(o.createRangeIn(e),o.createPositionBefore(e)),o.remove(e)}})),t.downcastDispatcher.on("attribute:todoListChecked:listItem",function(e){return(t,i,n)=>{if("todo"!=i.item.getAttribute("listType"))return;if(!n.consumable.consume(i.item,"attribute:todoListChecked"))return;const{mapper:o,writer:s}=n,r=!!i.item.getAttribute("todoListChecked"),a=o.toViewElement(i.item).getChild(0),l=bt(i.item,s,r,e);s.insert(s.createPositionAfter(a),l),s.remove(a)}}((e=>this._handleCheckmarkChange(e)))),t.mapper.on("modelToViewPosition",pt(t.view)),i.mapper.on("modelToViewPosition",pt(t.view)),this.listenTo(t.view.document,"arrowKey",function(e,t){return(i,n)=>{if("left"!=(0,r.mA)(n.keyCode,t.contentLanguageDirection))return;const o=e.schema,s=e.document.selection;if(!s.isCollapsed)return;const a=s.getFirstPosition(),l=a.parent;if("listItem"===l.name&&"todo"==l.getAttribute("listType")&&a.isAtStart){const t=o.getNearestSelectionRange(e.createPositionBefore(l),"backward");t&&e.change((e=>e.setSelection(t))),n.preventDefault(),n.stopPropagation(),i.stop()}}}(n,e.locale),{context:"li"}),this.listenTo(t.view.document,"keydown",((t,i)=>{(0,r.Cq)(i)===vt&&(e.execute("checkTodoList"),t.stop())}),{priority:"high"});const l=new Set;this.listenTo(n,"applyOperation",((e,t)=>{const i=t[0];if("rename"==i.type&&"listItem"==i.oldName){const e=i.position.nodeAfter;e.hasAttribute("todoListChecked")&&l.add(e)}else if("changeAttribute"==i.type&&"listType"==i.key&&"todo"===i.oldValue)for(const e of i.range.getItems())e.hasAttribute("todoListChecked")&&"todo"!==e.getAttribute("listType")&&l.add(e)})),n.document.registerPostFixer((e=>{let t=!1;for(const i of l)e.removeAttribute("todoListChecked",i),t=!0;return l.clear(),t}))}_handleCheckmarkChange(e){const t=this.editor,i=t.model,n=Array.from(i.document.selection.getRanges());i.change((i=>{i.setSelection(e,"end"),t.execute("checkTodoList"),i.setSelection(n)}))}}class yt extends n.Sy{static get pluginName(){return"TodoListUI"}init(){const e=this.editor.t;ee(this.editor,"todoList",e("To-do List"),'')}}class kt extends n.Sy{static get requires(){return[_t,yt]}static get pluginName(){return"TodoList"}}},6335:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Mention:()=>S,MentionEditing:()=>r,MentionUI:()=>y});var n=i(6854),o=i(6553);class s extends n.mY{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=e.schema.checkAttributeInSelection(t.selection,"mention")}execute(e){const t=this.editor.model,i=t.document.selection,n="string"==typeof e.mention?{id:e.mention}:e.mention,s=n.id,r=e.range||i.getFirstRange();if(!t.canEditAt(r))return;const l=e.text||s,c=a({_text:l,id:s},n);if(1!=e.marker.length)throw new o.Bb("mentioncommand-incorrect-marker",this);if(s.charAt(0)!=e.marker)throw new o.Bb("mentioncommand-incorrect-id",this);t.change((e=>{const n=(0,o.qL)(i.getAttributes()),s=new Map(n.entries());s.set("mention",c),t.insertContent(e.createText(l,s),r),t.insertContent(e.createText(" ",n),r.start.getShiftedBy(l.length))}))}}class r extends n.Sy{static get pluginName(){return"MentionEditing"}init(){const e=this.editor,t=e.model,i=t.document;t.schema.extend("$text",{allowAttributes:"mention"}),e.conversion.for("upcast").elementToAttribute({view:{name:"span",key:"data-mention",classes:"mention"},model:{key:"mention",value:e=>l(e)}}),e.conversion.for("downcast").attributeToElement({model:"mention",view:d}),e.conversion.for("downcast").add(c),i.registerPostFixer((e=>function(e,t,i){const n=t.differ.getChanges();let o=!1;for(const t of n){if("attribute"==t.type)continue;const n=t.position;if("$text"==t.name){const t=n.textNode&&n.textNode.nextSibling;o=h(n.textNode,e)||o,o=h(t,e)||o,o=h(n.nodeBefore,e)||o,o=h(n.nodeAfter,e)||o}if("$text"!=t.name&&"insert"==t.type){const t=n.nodeAfter;for(const i of e.createRangeIn(t).getItems())o=h(i,e)||o}if("insert"==t.type&&i.isInline(t.name)){const t=n.nodeAfter&&n.nodeAfter.nextSibling;o=h(n.nodeBefore,e)||o,o=h(t,e)||o}}return o}(e,i,t.schema))),i.registerPostFixer((e=>function(e,t){const i=t.differ.getChanges();let n=!1;for(const t of i)if("attribute"===t.type&&"mention"!=t.attributeKey){const i=t.range.start.nodeBefore,o=t.range.end.nodeAfter;for(const s of[i,o])u(s)&&s.getAttribute(t.attributeKey)!=t.attributeNewValue&&(e.setAttribute(t.attributeKey,t.attributeNewValue,s),n=!0)}return n}(e,i))),i.registerPostFixer((e=>function(e,t){const i=t.selection,n=i.focus;return!!(i.isCollapsed&&i.hasAttribute("mention")&&function(e){const t=e.isAtStart;return e.nodeBefore&&e.nodeBefore.is("$text")||t}(n))&&(e.removeSelectionAttribute("mention"),!0)}(e,i))),e.commands.add("mention",new s(e))}}function a(e,t){return Object.assign({uid:(0,o.hQ)()},e,t||{})}function l(e,t){const i=e.getAttribute("data-mention"),n=e.getChild(0);if(n)return a({id:i,_text:n.data},t)}function c(e){e.on("attribute:mention",((e,t,i)=>{const n=t.attributeNewValue;if(!t.item.is("$textProxy")||!n)return;const o=t.range.start;(o.textNode||o.nodeAfter).data!=n._text&&i.consumable.consume(t.item,e.name)}),{priority:"highest"})}function d(e,{writer:t}){if(!e)return;const i={class:"mention","data-mention":e.id},n={id:e.uid,priority:20};return t.createAttributeElement("span",i,n)}function u(e){return!(!e||!e.is("$text")&&!e.is("$textProxy")||!e.hasAttribute("mention"))&&e.data!=e.getAttribute("mention")._text}function h(e,t){return!!u(e)&&(t.removeAttribute("mention",e),!0)}var m=i(7095),g=i(5187),f=i(6682);class p extends m.Bv{constructor(e){super(e),this.extendTemplate({attributes:{class:["ck-mentions"],tabindex:"-1"}})}selectFirst(){this.select(0)}selectNext(){const e=this.selected,t=this.items.getIndex(e);this.select(t+1)}selectPrevious(){const e=this.selected,t=this.items.getIndex(e);this.select(t-1)}select(e){let t=0;e>0&&e{i?(this.domElement.classList.add("ck-on"),this.domElement.classList.remove("ck-off")):(this.domElement.classList.add("ck-off"),this.domElement.classList.remove("ck-on"))})),this.listenTo(this.domElement,"click",(()=>{this.fire("execute")}))}render(){super.render(),this.element=this.domElement}}class w extends m.dn{highlight(){this.children.first.isOn=!0}removeHighlight(){this.children.first.isOn=!1}}const v=[o.Do.arrowup,o.Do.arrowdown,o.Do.esc],_=[o.Do.enter,o.Do.tab];class y extends n.Sy{static get pluginName(){return"MentionUI"}static get requires(){return[m.WB]}constructor(e){super(e),this._items=new o.FE,this._mentionsView=this._createMentionView(),this._mentionsConfigurations=new Map,this._requestFeedDebounced=(0,f.Z)(this._requestFeed,100),e.config.define("mention",{feeds:[]})}init(){const e=this.editor,t=e.config.get("mention.commitKeys")||_,i=v.concat(t);this._balloon=e.plugins.get(m.WB),e.editing.view.document.on("keydown",((e,n)=>{var s;s=n.keyCode,i.includes(s)&&this._isUIVisible&&(n.preventDefault(),e.stop(),n.keyCode==o.Do.arrowdown&&this._mentionsView.selectNext(),n.keyCode==o.Do.arrowup&&this._mentionsView.selectPrevious(),t.includes(n.keyCode)&&this._mentionsView.executeSelected(),n.keyCode==o.Do.esc&&this._hideUIAndRemoveMarker())}),{priority:"highest"}),(0,m.eC)({emitter:this._mentionsView,activator:()=>this._isUIVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUIAndRemoveMarker()});const n=e.config.get("mention.feeds");for(const e of n){const{feed:t,marker:i,dropdownLimit:n}=e;if(!x(i))throw new o.Bb("mentionconfig-incorrect-marker",null,{marker:i});const s={marker:i,feedCallback:"function"==typeof t?t.bind(this.editor):E(t),itemRenderer:e.itemRenderer,dropdownLimit:n};this._mentionsConfigurations.set(i,s)}this._setupTextWatcher(n),this.listenTo(e,"change:isReadOnly",(()=>{this._hideUIAndRemoveMarker()})),this.on("requestFeed:response",((e,t)=>this._handleFeedResponse(t))),this.on("requestFeed:error",(()=>this._hideUIAndRemoveMarker()))}destroy(){super.destroy(),this._mentionsView.destroy()}get _isUIVisible(){return this._balloon.visibleView===this._mentionsView}_createMentionView(){const e=this.editor.locale,t=new p(e);return t.items.bindTo(this._items).using((i=>{const{item:n,marker:o}=i,{dropdownLimit:s}=this._mentionsConfigurations.get(o),r=s||this.editor.config.get("mention.dropdownLimit")||10;if(t.items.length>=r)return null;const a=new w(e),l=this._renderItem(n,o);return l.delegate("execute").to(a),a.children.add(l),a.item=n,a.marker=o,a.on("execute",(()=>{t.fire("execute",{item:n,marker:o})})),a})),t.on("execute",((e,t)=>{const i=this.editor,n=i.model,o=t.item,s=t.marker,r=i.model.markers.get("mention"),a=n.createPositionAt(n.document.selection.focus),l=n.createPositionAt(r.getStart()),c=n.createRange(l,a);this._hideUIAndRemoveMarker(),i.execute("mention",{mention:o,text:o.text,marker:s,range:c}),i.editing.view.focus()})),t}_getItemRenderer(e){const{itemRenderer:t}=this._mentionsConfigurations.get(e);return t}_requestFeed(e,t){this._lastRequested=t;const{feedCallback:i}=this._mentionsConfigurations.get(e),n=i(t);n instanceof Promise?n.then((i=>{this._lastRequested==t?this.fire("requestFeed:response",{feed:i,marker:e,feedText:t}):this.fire("requestFeed:discarded",{feed:i,marker:e,feedText:t})})).catch((t=>{this.fire("requestFeed:error",{error:t}),(0,o.KE)("mention-feed-callback-error",{marker:e})})):this.fire("requestFeed:response",{feed:n,marker:e,feedText:t})}_setupTextWatcher(e){const t=this.editor,i=e.map((e=>({...e,pattern:A(e.marker,e.minimumCharacters||0)}))),n=new g.uL(t.model,function(e){return t=>{const i=C(e,t);if(!i)return!1;let n=0;0!==i.position&&(n=i.position-1);const o=t.substring(n);return i.pattern.test(o)}}(i));n.on("matched",((e,n)=>{const o=C(i,n.text),s=t.model.document.selection.focus,r=t.model.createPositionAt(s.parent,o.position);if(function(e){const t=e.textNode&&e.textNode.hasAttribute("mention"),i=e.nodeBefore;return t||i&&i.is("$text")&&i.hasAttribute("mention")}(s)||function(e){const t=e.nodeAfter;return t&&t.is("$text")&&t.hasAttribute("mention")}(r))return void this._hideUIAndRemoveMarker();const a=function(e,t){let i=0;0!==e.position&&(i=e.position-1);const n=A(e.marker,0);return t.substring(i).match(n)[2]}(o,n.text),l=o.marker.length+a.length,c=s.getShiftedBy(-l),d=s.getShiftedBy(-a.length),u=t.model.createRange(c,d);if(T(t)){const e=t.model.markers.get("mention");t.model.change((t=>{t.updateMarker(e,{range:u})}))}else t.model.change((e=>{e.addMarker("mention",{range:u,usingOperation:!1,affectsData:!1})}));this._requestFeedDebounced(o.marker,a)})),n.on("unmatched",(()=>{this._hideUIAndRemoveMarker()}));const o=t.commands.get("mention");return n.bind("isEnabled").to(o),n}_handleFeedResponse(e){const{feed:t,marker:i}=e;if(!T(this.editor))return;this._items.clear();for(const e of t){const t="object"!=typeof e?{id:e,text:e}:e;this._items.add({item:t,marker:i})}const n=this.editor.model.markers.get("mention");this._items.length?this._showOrUpdateUI(n):this._hideUIAndRemoveMarker()}_showOrUpdateUI(e){this._isUIVisible?this._balloon.updatePosition(this._getBalloonPanelPositionData(e,this._mentionsView.position)):this._balloon.add({view:this._mentionsView,position:this._getBalloonPanelPositionData(e,this._mentionsView.position),singleViewMode:!0}),this._mentionsView.position=this._balloon.view.position,this._mentionsView.selectFirst()}_hideUIAndRemoveMarker(){this._balloon.hasView(this._mentionsView)&&this._balloon.remove(this._mentionsView),T(this.editor)&&this.editor.model.change((e=>e.removeMarker("mention"))),this._mentionsView.position=void 0}_renderItem(e,t){const i=this.editor;let n,o=e.id;const s=this._getItemRenderer(t);if(s){const t=s(e);"string"!=typeof t?n=new b(i.locale,t):o=t}if(!n){const e=new m.r5(i.locale);e.label=o,e.withText=!0,n=e}return n}_getBalloonPanelPositionData(e,t){const i=this.editor,n=i.editing,s=n.view.domConverter,r=n.mapper;return{target:()=>{let t=e.getRange();"$graveyard"==t.start.root.rootName&&(t=i.model.document.selection.getFirstRange());const n=r.toViewRange(t);return o.UL.getDomRangeRects(s.viewRangeToDom(n)).pop()},limiter:()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},positions:k(t,i.locale.uiLanguageDirection)}}}function k(e,t){const i={caret_se:e=>({top:e.bottom+3,left:e.right,name:"caret_se",config:{withArrow:!1}}),caret_ne:(e,t)=>({top:e.top-t.height-3,left:e.right,name:"caret_ne",config:{withArrow:!1}}),caret_sw:(e,t)=>({top:e.bottom+3,left:e.right-t.width,name:"caret_sw",config:{withArrow:!1}}),caret_nw:(e,t)=>({top:e.top-t.height-3,left:e.right-t.width,name:"caret_nw",config:{withArrow:!1}})};return Object.prototype.hasOwnProperty.call(i,e)?[i[e]]:"rtl"!==t?[i.caret_se,i.caret_sw,i.caret_ne,i.caret_nw]:[i.caret_sw,i.caret_se,i.caret_nw,i.caret_ne]}function C(e,t){let i;for(const n of e){const e=t.lastIndexOf(n.marker);e>0&&!t.substring(e-1).match(n.pattern)||(!i||e>=i.position)&&(i={marker:n.marker,position:e,minimumCharacters:n.minimumCharacters,pattern:n.pattern})}return i}function A(e,t){const i=0==t?"*":`{${t},}`,n=o.OB.features.isRegExpUnicodePropertySupported?"\\p{Ps}\\p{Pi}\"'":"\\(\\[{\"'";return new RegExp(`(?:^|[ ${n}])([${e}])(.${i})$`,"u")}function E(e){return t=>e.filter((e=>("string"==typeof e?e:String(e.id)).toLowerCase().includes(t.toLowerCase())))}function x(e){return e&&1==e.length}function T(e){return e.model.markers.has("mention")}class S extends n.Sy{toMentionAttribute(e,t){return l(e,t)}static get pluginName(){return"Mention"}static get requires(){return[r,y]}}},4690:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Paragraph:()=>l,ParagraphButtonUI:()=>u});var n=i(7833),o=i(5044);class s extends n.Command{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=e.document,i=(0,o.first)(t.selection.getSelectedBlocks());this.value=!!i&&i.is("element","paragraph"),this.isEnabled=!!i&&r(i,e.schema)}execute(e={}){const t=this.editor.model,i=t.document,n=e.selection||i.selection;t.canEditAt(n)&&t.change((e=>{const i=n.getSelectedBlocks();for(const n of i)!n.is("element","paragraph")&&r(n,t.schema)&&e.rename(n,"paragraph")}))}}function r(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class a extends n.Command{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,i=e.attributes;let n=e.position;t.canEditAt(n)&&t.change((e=>{if(n=this._findPositionToInsertParagraph(n,e),!n)return;const o=e.createElement("paragraph");i&&t.schema.setAllowedAttributes(o,i,e),t.insertContent(o,n),e.setSelection(o,"in")}))}_findPositionToInsertParagraph(e,t){const i=this.editor.model;if(i.schema.checkChild(e,"paragraph"))return e;const n=i.schema.findAllowedParent(e,"paragraph");if(!n)return null;const o=e.parent,s=i.schema.checkChild(o,"$text");return o.isEmpty||s&&e.isAtEnd?i.createPositionAfter(o):!o.isEmpty&&s&&e.isAtStart?i.createPositionBefore(o):t.split(e,n).position}}class l extends n.Plugin{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new s(e)),e.commands.add("insertParagraph",new a(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>l.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}l.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);var c=i(2692);const d=n.icons.paragraph;class u extends n.Plugin{static get requires(){return[l]}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("paragraph",(i=>{const n=new c.ButtonView(i),o=e.commands.get("paragraph");return n.label=t("Paragraph"),n.icon=d,n.tooltip=!0,n.isToggleable=!0,n.bind("isEnabled").to(o),n.bind("isOn").to(o,"value"),n.on("execute",(()=>{e.execute("paragraph")})),n}))}}},7983:(e,t,i)=>{"use strict";i.r(t),i.d(t,{MSWordNormalizer:()=>u,PasteFromOffice:()=>_,parseHtml:()=>v});var n=i(6854),o=i(4079),s=i(3291);function r(e){if(e.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(e){case"alpha-upper":return"upper-alpha";case"alpha-lower":return"lower-alpha";case"roman-upper":return"upper-roman";case"roman-lower":return"lower-roman";case"circle":case"disc":case"square":return e;default:return null}}function a(e,t,i){const n=t.parent,o=i.createElement(e.type),s=n.getChildIndex(t)+1;return i.insertChild(s,o,n),e.style&&i.setStyle("list-style-type",e.style,o),e.startIndex&&e.startIndex>1&&i.setAttribute("start",e.startIndex,o),o}function l(e){const t={},i=e.getStyle("mso-list");if(i){const e=i.match(/(^|\s{1,100})l(\d+)/i),n=i.match(/\s{0,100}lfo(\d+)/i),o=i.match(/\s{0,100}level(\d+)/i);e&&n&&o&&(t.id=e[2],t.order=n[1],t.indent=parseInt(o[1]))}return t}const c=//i,d=/xmlns:o="urn:schemas-microsoft-com/i;class u{constructor(e){this.document=e}isActive(e){return c.test(e)||d.test(e)}execute(e){const{body:t,stylesString:i}=e._parsedData;(function(e,t){if(!e.childCount)return;const i=new s.yj(e.document),n=function(e,t){const i=t.createRangeIn(e),n=new s.xO({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),o=[];for(const e of i)if("elementStart"===e.type&&n.match(e.item)){const t=l(e.item);o.push({element:e.item,id:t.id,order:t.order,indent:t.indent})}return o}(e,i);if(!n.length)return;let o=null,c=1;n.forEach(((e,l)=>{const d=function(e,t){if(!e)return!0;if(e.id!==t.id)return t.indent-e.indent!=1;const i=t.element.previousSibling;return!i||!((n=i).is("element","ol")||n.is("element","ul"));var n}(n[l-1],e),u=(m=e,(h=d?null:n[l-1])?m.indent-h.indent:m.indent-1);var h,m;if(d&&(o=null,c=1),!o||0!==u){const n=function(e,t){const i=/mso-level-number-format:([^;]{0,100});/gi,n=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,o=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi").exec(t);let s="decimal",a="ol",l=null;if(o&&o[1]){const t=i.exec(o[1]);if(t&&t[1]&&(s=t[1].trim(),a="bullet"!==s&&"image"!==s?"ol":"ul"),"bullet"===s){const t=function(e){const t=function(e){if(e.getChild(0).is("$text"))return null;for(const t of e.getChildren()){if(!t.is("element","span"))continue;const e=t.getChild(0);if(e)return e.is("$text")?e:e.getChild(0)}return null}(e);if(!t)return null;const i=t._data;return"o"===i?"circle":"·"===i?"disc":"§"===i?"square":null}(e.element);t&&(s=t)}else{const e=n.exec(o[1]);e&&e[1]&&(l=parseInt(e[1]))}}return{type:a,startIndex:l,style:r(s)}}(e,t);if(o){if(e.indent>c){const e=o.getChild(o.childCount-1),t=e.getChild(e.childCount-1);o=a(n,t,i),c+=1}else if(e.indente.indexOf(t)>-1))?r.push(i):i.getAttribute("src")||r.push(i)}for(const e of r)i.remove(e)}(n,e,i),function(e,t,i){const n=i.createRangeIn(t),o=[];for(const t of n)if("elementStart"==t.type&&t.item.is("element","v:shape")){const i=t.item.getAttribute("id");if(e.includes(i))continue;s(t.item.parent.getChildren(),i)||o.push(t.item)}for(const e of o){const t={src:r(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const n=i.createElement("img",t);i.insertChild(e.index+1,n,e.parent)}function s(e,t){for(const i of e)if(i.is("element")){if("img"==i.name&&i.getAttribute("v:shapes")==t)return!0;if(s(i.getChildren(),t))return!0}return!1}function r(e){for(const t of e.getChildren())if(t.is("element")&&t.getAttribute("src"))return t.getAttribute("src")}}(n,e,i),function(e,t){const i=t.createRangeIn(e),n=new s.xO({name:/v:(.+)/}),o=[];for(const e of i)"elementStart"==e.type&&n.match(e.item)&&o.push(e.item);for(const e of o)t.remove(e)}(e,i);const o=function(e,t){const i=t.createRangeIn(e),n=new s.xO({name:"img"}),o=[];for(const e of i)e.item.is("element")&&n.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&o.push(e.item);return o}(e,i);o.length&&function(e,t,i){if(e.length===t.length)for(let o=0;oString.fromCharCode(parseInt(e,16)))).join(""))}`;i.setAttribute("src",s,e[o])}var n}(o,function(e){if(!e)return[];const t=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,i=new RegExp("(?:("+t.source+"))([\\da-fA-F\\s]+)\\}","g"),n=e.match(i),o=[];if(n)for(const e of n){let i=!1;e.includes("\\pngblip")?i="image/png":e.includes("\\jpegblip")&&(i="image/jpeg"),i&&o.push({hex:e.replace(t,"").replace(/[^\da-fA-F]/g,""),type:i})}return o}(t),i)}(t,e.dataTransfer.getData("text/rtf")),function(e){const t=new s.yj(e.document);for(const i of e.getChildren()){if(!i.is("element"))continue;if(i.is("element","table")){t.setAttribute("align","left",i);continue}const e=i.getAttribute("align"),n=i.getChild(0);"div"===i.name&&e&&n&&n.is("element","table")&&t.setAttribute("align","center"===e?"none":e,n)}}(t),e.content=t}}function h(e,t,i,{blockElements:n,inlineObjectElements:o}){let s=i.createPositionAt(e,"forward"==t?"after":"before");return s=s.getLastMatchingPosition((({item:e})=>e.is("element")&&!n.includes(e.name)&&!o.includes(e.name)),{direction:t}),"forward"==t?s.nodeAfter:s.nodeBefore}function m(e,t){return!!e&&e.is("element")&&t.includes(e.name)}const g=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class f{constructor(e){this.document=e}isActive(e){return g.test(e)}execute(e){const t=new s.yj(this.document),{body:i}=e._parsedData;!function(e,t){for(const i of e.getChildren())if(i.is("element","b")&&"normal"===i.getStyle("font-weight")){const n=e.getChildIndex(i);t.remove(i),t.insertChild(n,i.getChildren(),e)}}(i,t),function(e,t){for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","li")){const i=e.getChild(0);i&&i.is("element","p")&&t.unwrapElement(i)}}}(i,t),function(e,t){const i=new s.Ux(t.document.stylesProcessor),n=new s.pG(i,{renderingMode:"data"}),o=n.blockElements,r=n.inlineObjectElements,a=[];for(const i of t.createRangeIn(e)){const e=i.item;if(e.is("element","br")){const i=h(e,"forward",t,{blockElements:o,inlineObjectElements:r}),n=h(e,"backward",t,{blockElements:o,inlineObjectElements:r}),s=m(i,o);(m(n,o)||s)&&a.push(e)}}for(const e of a)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(i,t),e.content=i}}const p=/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join("  ").substr(0,t.length)))}function v(e,t){const i=new DOMParser,n=function(e){return w(w(e)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/()[\r\n]+(<\/span>)/g,"$1 $2").replace(/ <\//g," <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(e){const t="",i=e.indexOf(t);if(i<0)return e;const n=e.indexOf("",i+7);return e.substring(0,i+7)+(n>=0?e.substring(n):"")}(e=e.replace(//g,"")}(n.getData("text/html")):n.getData("text/plain")&&(((r=(r=n.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),s=this.editor.data.htmlProcessor.toView(e)}var r;const a=new o.EventInfo(this,"inputTransformation");this.fire(a,{content:s,dataTransfer:n,targetRanges:t.targetRanges,method:t.method}),a.stop.called&&e.stop(),i.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,i)=>{if(i.content.isEmpty)return;const n=this.editor.data.toModel(i.content,"$clipboardHolder");0!=n.childCount&&(e.stop(),t.change((()=>{this.fire("contentInsertion",{content:n,method:i.method,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,i)=>{i.resultRange=t.insertContent(i.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,i=e.editing.view.document,n=(n,o)=>{const s=o.dataTransfer;o.preventDefault();const r=e.data.toView(e.model.getSelectedContent(t.selection));i.fire("clipboardOutput",{dataTransfer:s,content:r,method:n.name})};this.listenTo(i,"copy",n,{priority:"low"}),this.listenTo(i,"cut",((t,i)=>{e.model.canEditAt(e.model.document.selection)?n(t,i):i.preventDefault()}),{priority:"low"}),this.listenTo(i,"clipboardOutput",((i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",l(n.content))),"cut"==n.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}var d=i(1460),u=i(111);class h extends n.Plugin{static get pluginName(){return"DragDrop"}static get requires(){return[c,d.Widget]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=(0,u.Z)((e=>this._updateDropMarker(e)),40),this._removeDropMarkerDelayed=(0,o.delay)((()=>this._removeDropMarker()),40),this._clearDraggableAttributesDelayed=(0,o.delay)((()=>this._clearDraggableAttributes()),40),e.plugins.has("DragDropExperimental")?this.forceDisabled("DragDropExperimental"):(t.addObserver(r),t.addObserver(s.MouseObserver),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",((e,t,i)=>{i?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((e,t,i)=>{i||this._finalizeDragging(!1)})),o.env.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,i=t.document,n=e.editing.view,r=n.document;this.listenTo(r,"dragstart",((n,a)=>{const l=i.selection;if(a.target&&a.target.is("editableElement"))return void a.preventDefault();const c=a.target?f(a.target):null;if(c){const i=e.editing.mapper.toModelElement(c);this._draggedRange=s.LiveRange.fromRange(t.createRangeOn(i)),e.plugins.has("WidgetToolbarRepository")&&e.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}else if(!r.selection.isCollapsed){const e=r.selection.getSelectedElement();e&&(0,d.isWidget)(e)||(this._draggedRange=s.LiveRange.fromRange(l.getFirstRange()))}if(!this._draggedRange)return void a.preventDefault();this._draggingUid=(0,o.uid)();const u=this.isEnabled&&e.model.canEditAt(this._draggedRange);a.dataTransfer.effectAllowed=u?"copyMove":"copy",a.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const h=t.createSelection(this._draggedRange.toRange()),m=e.data.toView(t.getSelectedContent(h));r.fire("clipboardOutput",{dataTransfer:a.dataTransfer,content:m,method:"dragstart"}),u||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(r,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this.listenTo(r,"dragenter",(()=>{this.isEnabled&&n.focus()})),this.listenTo(r,"dragleave",(()=>{this._removeDropMarkerDelayed()})),this.listenTo(r,"dragging",((t,i)=>{if(!this.isEnabled)return void(i.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const n=m(e,i.targetRanges,i.target);e.model.canEditAt(n)?(this._draggedRange||(i.dataTransfer.dropEffect="copy"),o.env.isGecko||("copy"==i.dataTransfer.effectAllowed?i.dataTransfer.dropEffect="copy":["all","copyMove"].includes(i.dataTransfer.effectAllowed)&&(i.dataTransfer.dropEffect="move")),n&&this._updateDropMarkerThrottled(n)):i.dataTransfer.dropEffect="none"}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"clipboardInput",((t,i)=>{if("drop"!=i.method)return;const n=m(e,i.targetRanges,i.target);return this._removeDropMarker(),n&&e.model.canEditAt(n)?(this._draggedRange&&this._draggingUid!=i.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid=""),"move"==g(i.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(n,!0)?(this._finalizeDragging(!1),void t.stop()):void(i.targetRanges=[e.editing.mapper.toViewRange(n)])):(this._finalizeDragging(!1),void t.stop())}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(c);e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i=t.targetRanges.map((e=>this.editor.editing.mapper.toModelRange(e)));this.editor.model.change((e=>e.setSelection(i)))}),{priority:"high"}),e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const i="move"==g(t.dataTransfer),n=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(n&&i)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,i=t.document;this.listenTo(i,"mousedown",((n,s)=>{if(o.env.isAndroid||!s)return;this._clearDraggableAttributesDelayed.cancel();let r=f(s.target);if(o.env.isBlink&&!r&&!i.selection.isCollapsed){const e=i.selection.getSelectedElement();if(!e||!(0,d.isWidget)(e)){const e=i.selection.editableElement;e&&!e.isReadOnly&&(r=e)}}r&&(t.change((e=>{e.setAttribute("draggable","true",r)})),this._draggableElement=e.editing.mapper.toModelElement(r))})),this.listenTo(i,"mouseup",(()=>{o.env.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:i})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return i.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,i=t.model.markers;t.model.change((t=>{i.has("drop-target")?i.get("drop-target").getRange().isEqual(e)||t.updateMarker("drop-target",{range:e}):t.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})}))}_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,i=t.model;this._removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._draggedRange&&(e&&this.isEnabled&&i.deleteContent(i.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function m(e,t,i){const n=e.model,s=e.editing.mapper;let r=null;const a=t?t[0].start:null;if(i.is("uiElement")&&(i=i.parent),r=function(e,t){const i=e.model,n=e.editing.mapper;if((0,d.isWidget)(t))return i.createRangeOn(n.toModelElement(t));if(!t.is("editableElement")){const e=t.findAncestor((e=>(0,d.isWidget)(e)||e.is("editableElement")));if((0,d.isWidget)(e))return i.createRangeOn(n.toModelElement(e))}return null}(e,i),r)return r;const l=function(e,t){const i=e.editing.mapper,n=e.editing.view,o=i.toModelElement(t);if(o)return o;const s=n.createPositionBefore(t),r=i.findMappedViewAncestor(s);return i.toModelElement(r)}(e,i),c=a?s.toModelPosition(a):null;return c?(r=function(e,t,i){const n=e.model;if(!n.schema.checkChild(i,"$block"))return null;const o=n.createPositionAt(i,0),s=t.path.slice(0,o.path.length),r=n.createPositionFromPath(t.root,s).nodeAfter;return r&&n.schema.isObject(r)?n.createRangeOn(r):null}(e,c,l),r||(r=n.schema.getNearestSelectionRange(c,o.env.isGecko?"forward":"backward"),r||function(e,t){const i=e.model;let n=t;for(;n;){if(i.schema.isObject(n))return i.createRangeOn(n);n=n.parent}return null}(e,c.parent))):function(e,t){const i=e.model,n=i.schema,o=i.createPositionAt(t,0);return n.getNearestSelectionRange(o,"forward")}(e,l)}function g(e){return o.env.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function f(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(d.isWidget);if((0,d.isWidget)(e))return e;const t=e.findAncestor((e=>(0,d.isWidget)(e)||e.is("editableElement")));return(0,d.isWidget)(t)?t:null}class p extends n.Plugin{static get pluginName(){return"PastePlainText"}static get requires(){return[c]}init(){const e=this.editor,t=e.model,i=e.editing.view,n=i.document,o=t.document.selection;let s=!1;i.addObserver(r),this.listenTo(n,"keydown",((e,t)=>{s=t.shiftKey})),e.plugins.get(c).on("contentInsertion",((e,i)=>{(s||function(e,t){if(e.childCount>1)return!1;const i=e.getChild(0);return!t.isObject(i)&&0==Array.from(i.getAttributeKeys()).length}(i.content,t.schema))&&t.change((e=>{const n=Array.from(o.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));o.isCollapsed||t.deleteContent(o,{doNotAutoparagraph:!0}),n.push(...o.getAttributes());const s=e.createRangeIn(i.content);for(const t of s.getItems())t.is("$textProxy")&&e.setAttributes(n,t)}))}))}}class b extends n.Plugin{static get pluginName(){return"Clipboard"}static get requires(){return[c,h,p]}}i(2692),(0,o.toUnit)("px")},6854:(e,t,i)=>{"use strict";i.d(t,{AJ:()=>n.MultiCommand,ML:()=>n.Editor,P$:()=>n.attachToForm,Sy:()=>n.Plugin,W9:()=>n.DataApiMixin,_y:()=>n.Context,icons:()=>n.icons,lR:()=>n.PendingActions,mY:()=>n.Command,xK:()=>n.ElementApiMixin});var n=i(7833)},3291:(e,t,i)=>{"use strict";i.d(t,{$_:()=>n.hidePlaceholder,D5:()=>n.isColor,G9:()=>n.isLength,ID:()=>n.enablePlaceholder,J8:()=>n.addPaddingRules,KU:()=>n.ClickObserver,NJ:()=>n.showPlaceholder,Po:()=>n.TreeWalker,Q7:()=>n.needsPlaceholder,QR:()=>n.addBackgroundRules,Qj:()=>n.Observer,Ux:()=>n.ViewDocument,W_:()=>n.Element,YG:()=>n.getFillerOffset,dM:()=>n.MouseObserver,iE:()=>n.LiveRange,jP:()=>n.LivePosition,pG:()=>n.DomConverter,qD:()=>n.DowncastWriter,qZ:()=>n.DomEventObserver,sI:()=>n.addBorderRules,vt:()=>n.addMarginRules,xO:()=>n.Matcher,yj:()=>n.UpcastWriter,zz:()=>n.isPercentage});var n=i(6243)},1863:(e,t,i)=>{"use strict";i.d(t,{C:()=>n.C,G:()=>n.G});var n=i(5725)},5187:(e,t,i)=>{"use strict";i.d(t,{HG:()=>n.HG,II:()=>n.II,Im:()=>n.Im,Mq:()=>n.Mq,Up:()=>n.Up,VD:()=>n.VD,mh:()=>n.mh,uL:()=>n.uL});var n=i(3701)},7095:(e,t,i)=>{"use strict";i.d(t,{$y:()=>n.ToolbarSeparatorView,BM:()=>n.SwitchButtonView,Bv:()=>n.ListView,Dn:()=>n.LabelView,FH:()=>n.createLabeledDropdown,G7:()=>n.View,GI:()=>n.submitHandler,Gp:()=>n.FormHeaderView,Hn:()=>n.Model,I0:()=>n.FocusCycler,IJ:()=>n.addKeyboardHandlingForGrid,J0:()=>n.DropdownButtonView,KP:()=>n.LabeledFieldView,MI:()=>n.ColorSelectorView,Mh:()=>n.focusChildOnDropdownOpen,P_:()=>n.Notification,Pm:()=>n.addListToDropdown,R:()=>n.createLabeledInputText,RX:()=>n.CssTransitionDisablerMixin,Rm:()=>n.SplitButtonView,S1:()=>n.normalizeColorOptions,S8:()=>n.EditorUI,WB:()=>n.ContextualBalloon,dn:()=>n.ListItemView,eC:()=>n.clickOutsideHandler,iw:()=>n.normalizeToolbarConfig,jB:()=>n.ToolbarView,k6:()=>n.getLocalizedColorOptions,lp:()=>n.StickyPanelView,no:()=>n.BalloonPanelView,pq:()=>n.InputTextView,py:()=>n.BoxedEditorUIView,r1:()=>n.InlineEditableUIView,r5:()=>n.ButtonView,sh:()=>n.createLabeledInputNumber,t9:()=>n.createDropdown,up:()=>n.addToolbarToDropdown,vX:()=>n.ViewCollection});var n=i(2692)},1903:(e,t,i)=>{"use strict";i.d(t,{WP:()=>n.Undo});var n=i(8779)},6553:(e,t,i)=>{"use strict";i.d(t,{Bb:()=>n.CKEditorError,CO:()=>n.global,Cq:()=>n.getCode,Do:()=>n.keyCodes,FE:()=>n.Collection,KE:()=>n.logWarning,OB:()=>n.env,Ps:()=>n.first,Re:()=>n.ObservableMixin,Rh:()=>n.FocusTracker,UL:()=>n.Rect,VD:()=>n.KeystrokeHandler,Xu:()=>n.DomEmitterMixin,Zz:()=>n.parseKeystroke,a6:()=>n.ElementReplacer,az:()=>n.createElement,hQ:()=>n.uid,mA:()=>n.getLocalizedArrowKeyCodeDirection,qL:()=>n.toMap,qo:()=>n.toArray,tA:()=>n.priorities,yy:()=>n.getDataFromElement});var n=i(5044)},5549:(e,t,i)=>{"use strict";i.d(t,{$L:()=>n.Widget,KT:()=>n.findOptimalInsertionRange,Qd:()=>n.isWidget,WR:()=>n.WidgetResize,XC:()=>n.toWidget,e8:()=>n.WidgetToolbarRepository,sC:()=>n.toWidgetEditable});var n=i(1460)},8168:(e,t,i)=>{const n=i(8874),o={};for(const e of Object.keys(n))o[n[e]]=e;const s={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};e.exports=s;for(const e of Object.keys(s)){if(!("channels"in s[e]))throw new Error("missing channels property: "+e);if(!("labels"in s[e]))throw new Error("missing channel labels property: "+e);if(s[e].labels.length!==s[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:i}=s[e];delete s[e].channels,delete s[e].labels,Object.defineProperty(s[e],"channels",{value:t}),Object.defineProperty(s[e],"labels",{value:i})}s.rgb.hsl=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,o=Math.min(t,i,n),s=Math.max(t,i,n),r=s-o;let a,l;s===o?a=0:t===s?a=(i-n)/r:i===s?a=2+(n-t)/r:n===s&&(a=4+(t-i)/r),a=Math.min(60*a,360),a<0&&(a+=360);const c=(o+s)/2;return l=s===o?0:c<=.5?r/(s+o):r/(2-s-o),[a,100*l,100*c]},s.rgb.hsv=function(e){let t,i,n,o,s;const r=e[0]/255,a=e[1]/255,l=e[2]/255,c=Math.max(r,a,l),d=c-Math.min(r,a,l),u=function(e){return(c-e)/6/d+.5};return 0===d?(o=0,s=0):(s=d/c,t=u(r),i=u(a),n=u(l),r===c?o=n-i:a===c?o=1/3+t-n:l===c&&(o=2/3+i-t),o<0?o+=1:o>1&&(o-=1)),[360*o,100*s,100*c]},s.rgb.hwb=function(e){const t=e[0],i=e[1];let n=e[2];const o=s.rgb.hsl(e)[0],r=1/255*Math.min(t,Math.min(i,n));return n=1-1/255*Math.max(t,Math.max(i,n)),[o,100*r,100*n]},s.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,o=Math.min(1-t,1-i,1-n);return[100*((1-t-o)/(1-o)||0),100*((1-i-o)/(1-o)||0),100*((1-n-o)/(1-o)||0),100*o]},s.rgb.keyword=function(e){const t=o[e];if(t)return t;let i,s=1/0;for(const t of Object.keys(n)){const o=(a=n[t],((r=e)[0]-a[0])**2+(r[1]-a[1])**2+(r[2]-a[2])**2);o.04045?((t+.055)/1.055)**2.4:t/12.92,i=i>.04045?((i+.055)/1.055)**2.4:i/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,[100*(.4124*t+.3576*i+.1805*n),100*(.2126*t+.7152*i+.0722*n),100*(.0193*t+.1192*i+.9505*n)]},s.rgb.lab=function(e){const t=s.rgb.xyz(e);let i=t[0],n=t[1],o=t[2];return i/=95.047,n/=100,o/=108.883,i=i>.008856?i**(1/3):7.787*i+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,o=o>.008856?o**(1/3):7.787*o+16/116,[116*n-16,500*(i-n),200*(n-o)]},s.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;let o,s,r;if(0===i)return r=255*n,[r,r,r];o=n<.5?n*(1+i):n+i-n*i;const a=2*n-o,l=[0,0,0];for(let e=0;e<3;e++)s=t+1/3*-(e-1),s<0&&s++,s>1&&s--,r=6*s<1?a+6*(o-a)*s:2*s<1?o:3*s<2?a+(o-a)*(2/3-s)*6:a,l[e]=255*r;return l},s.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,n=e[2]/100,o=i;const s=Math.max(n,.01);return n*=2,i*=n<=1?n:2-n,o*=s<=1?s:2-s,[t,100*(0===n?2*o/(s+o):2*i/(n+i)),(n+i)/2*100]},s.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let n=e[2]/100;const o=Math.floor(t)%6,s=t-Math.floor(t),r=255*n*(1-i),a=255*n*(1-i*s),l=255*n*(1-i*(1-s));switch(n*=255,o){case 0:return[n,l,r];case 1:return[a,n,r];case 2:return[r,n,l];case 3:return[r,a,n];case 4:return[l,r,n];case 5:return[n,r,a]}},s.hsv.hsl=function(e){const t=e[0],i=e[1]/100,n=e[2]/100,o=Math.max(n,.01);let s,r;r=(2-i)*n;const a=(2-i)*o;return s=i*o,s/=a<=1?a:2-a,s=s||0,r/=2,[t,100*s,100*r]},s.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,n=e[2]/100;const o=i+n;let s;o>1&&(i/=o,n/=o);const r=Math.floor(6*t),a=1-n;s=6*t-r,0!=(1&r)&&(s=1-s);const l=i+s*(a-i);let c,d,u;switch(r){default:case 6:case 0:c=a,d=l,u=i;break;case 1:c=l,d=a,u=i;break;case 2:c=i,d=a,u=l;break;case 3:c=i,d=l,u=a;break;case 4:c=l,d=i,u=a;break;case 5:c=a,d=i,u=l}return[255*c,255*d,255*u]},s.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,o=e[3]/100;return[255*(1-Math.min(1,t*(1-o)+o)),255*(1-Math.min(1,i*(1-o)+o)),255*(1-Math.min(1,n*(1-o)+o))]},s.xyz.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100;let o,s,r;return o=3.2406*t+-1.5372*i+-.4986*n,s=-.9689*t+1.8758*i+.0415*n,r=.0557*t+-.204*i+1.057*n,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,r=r>.0031308?1.055*r**(1/2.4)-.055:12.92*r,o=Math.min(Math.max(0,o),1),s=Math.min(Math.max(0,s),1),r=Math.min(Math.max(0,r),1),[255*o,255*s,255*r]},s.xyz.lab=function(e){let t=e[0],i=e[1],n=e[2];return t/=95.047,i/=100,n/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,i=i>.008856?i**(1/3):7.787*i+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,[116*i-16,500*(t-i),200*(i-n)]},s.lab.xyz=function(e){let t,i,n;i=(e[0]+16)/116,t=e[1]/500+i,n=i-e[2]/200;const o=i**3,s=t**3,r=n**3;return i=o>.008856?o:(i-16/116)/7.787,t=s>.008856?s:(t-16/116)/7.787,n=r>.008856?r:(n-16/116)/7.787,t*=95.047,i*=100,n*=108.883,[t,i,n]},s.lab.lch=function(e){const t=e[0],i=e[1],n=e[2];let o;return o=360*Math.atan2(n,i)/2/Math.PI,o<0&&(o+=360),[t,Math.sqrt(i*i+n*n),o]},s.lch.lab=function(e){const t=e[0],i=e[1],n=e[2]/360*2*Math.PI;return[t,i*Math.cos(n),i*Math.sin(n)]},s.rgb.ansi16=function(e,t=null){const[i,n,o]=e;let r=null===t?s.rgb.hsv(e)[2]:t;if(r=Math.round(r/50),0===r)return 30;let a=30+(Math.round(o/255)<<2|Math.round(n/255)<<1|Math.round(i/255));return 2===r&&(a+=60),a},s.hsv.ansi16=function(e){return s.rgb.ansi16(s.hsv.rgb(e),e[2])},s.rgb.ansi256=function(e){const t=e[0],i=e[1],n=e[2];return t===i&&i===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)},s.ansi16.rgb=function(e){let t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const i=.5*(1+~~(e>50));return[(1&t)*i*255,(t>>1&1)*i*255,(t>>2&1)*i*255]},s.ansi256.rgb=function(e){if(e>=232){const t=10*(e-232)+8;return[t,t,t]}let t;return e-=16,[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},s.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},s.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let i=t[0];3===t[0].length&&(i=i.split("").map((e=>e+e)).join(""));const n=parseInt(i,16);return[n>>16&255,n>>8&255,255&n]},s.rgb.hcg=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,o=Math.max(Math.max(t,i),n),s=Math.min(Math.min(t,i),n),r=o-s;let a,l;return a=r<1?s/(1-r):0,l=r<=0?0:o===t?(i-n)/r%6:o===i?2+(n-t)/r:4+(t-i)/r,l/=6,l%=1,[360*l,100*r,100*a]},s.hsl.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=i<.5?2*t*i:2*t*(1-i);let o=0;return n<1&&(o=(i-.5*n)/(1-n)),[e[0],100*n,100*o]},s.hsv.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=t*i;let o=0;return n<1&&(o=(i-n)/(1-n)),[e[0],100*n,100*o]},s.hcg.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;if(0===i)return[255*n,255*n,255*n];const o=[0,0,0],s=t%1*6,r=s%1,a=1-r;let l=0;switch(Math.floor(s)){case 0:o[0]=1,o[1]=r,o[2]=0;break;case 1:o[0]=a,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=r;break;case 3:o[0]=0,o[1]=a,o[2]=1;break;case 4:o[0]=r,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=a}return l=(1-i)*n,[255*(i*o[0]+l),255*(i*o[1]+l),255*(i*o[2]+l)]},s.hcg.hsv=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);let n=0;return i>0&&(n=t/i),[e[0],100*n,100*i]},s.hcg.hsl=function(e){const t=e[1]/100,i=e[2]/100*(1-t)+.5*t;let n=0;return i>0&&i<.5?n=t/(2*i):i>=.5&&i<1&&(n=t/(2*(1-i))),[e[0],100*n,100*i]},s.hcg.hwb=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);return[e[0],100*(i-t),100*(1-i)]},s.hwb.hcg=function(e){const t=e[1]/100,i=1-e[2]/100,n=i-t;let o=0;return n<1&&(o=(i-n)/(1-n)),[e[0],100*n,100*o]},s.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},s.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},s.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},s.gray.hsl=function(e){return[0,0,e[0]]},s.gray.hsv=s.gray.hsl,s.gray.hwb=function(e){return[0,100,e[0]]},s.gray.cmyk=function(e){return[0,0,0,e[0]]},s.gray.lab=function(e){return[e[0],0,0]},s.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(i.length)+i},s.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}},2085:(e,t,i)=>{const n=i(8168),o=i(4111),s={};Object.keys(n).forEach((e=>{s[e]={},Object.defineProperty(s[e],"channels",{value:n[e].channels}),Object.defineProperty(s[e],"labels",{value:n[e].labels});const t=o(e);Object.keys(t).forEach((i=>{const n=t[i];s[e][i]=function(e){const t=function(...t){const i=t[0];if(null==i)return i;i.length>1&&(t=i);const n=e(t);if("object"==typeof n)for(let e=n.length,t=0;t1&&(t=i),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(n)}))})),e.exports=s},4111:(e,t,i)=>{const n=i(8168);function o(e,t){return function(i){return t(e(i))}}function s(e,t){const i=[t[e].parent,e];let s=n[t[e].parent][e],r=t[e].parent;for(;t[r].parent;)i.unshift(t[r].parent),s=o(n[t[r].parent][r],s),r=t[r].parent;return s.conversion=i,s}e.exports=function(e){const t=function(e){const t=function(){const e={},t=Object.keys(n);for(let i=t.length,n=0;n{"use strict";e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},3905:(e,t,i)=>{"use strict";i.r(t)},6961:(e,t,i)=>{"use strict";i.r(t)},2170:(e,t,i)=>{"use strict";i.r(t)},6677:(e,t,i)=>{"use strict";i.r(t)},5253:(e,t,i)=>{"use strict";i.r(t)},2946:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=''},7630:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=''},5270:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=''},8217:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=''},366:(e,t,i)=>{var n,o;n=[i,t,i(511),i(6549),i(7971),i(3306),i(6597),i(7833),i(5480),i(1638),i(3457),i(8107),i(5242),i(8691),i(2337),i(7261),i(3531),i(5127),i(6144),i(6335),i(4690),i(7983),i(9501),i(5247),i(8779),i(766),i(9910),i(2823),i(8029),i(3706),i(5600),i(1294),i(8206),i(5825),i(9782),i(4201),i(7080),i(8427),i(5469),i(9402),i(8152)],o=function(e,t,i,n,o,s,r,a,l,c,d,u,h,m,g,f,p,b,w,v,_,y,k,C,A,E,x,T,S,P,I,V,R,O,B,M,N,D,L,F,z){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=void 0;const H={plugins:[n.Autosave,c.Essentials,p.Indent,v.Mention,_.Paragraph,y.PasteFromOffice,A.Undo,i.Alignment,o.Bold,o.Code,d.FontColor,d.FontFamily,d.FontSize,u.Heading,h.Highlight,o.Italic,k.RemoveFormat,o.Strikethrough,o.Subscript,o.Superscript,o.Underline,s.BlockQuote,r.CodeBlock,m.HtmlEmbed,g.HorizontalLine,f.Image,f.ImageInsertUI,f.ImageToolbar,f.ImageResizeEditing,f.ImageResizeHandles,f.ImageStyle,f.ImageUpload,f.ImageUploadUI,b.Link,b.LinkImage,w.List,C.Table,C.TableToolbar,E.WoltlabAttachment,x.WoltlabAutosave,S.WoltlabBlockQuote,T.WoltlabBbcode,P.WoltlabCode,I.WoltlabCodeBlock,V.WoltlabHtmlEmbed,R.WoltlabImage,O.WoltlabMagicParagraph,B.WoltlabMedia,M.WoltlabMention,N.WoltlabMetacode,D.WoltlabSmiley,L.WoltlabSpoiler,F.WoltlabToolbarGroup,z.WoltlabUpload]};t.create=async function(e,t){const i=(t=Object.assign(t,H)).removePlugins||[];i.includes("Image")||(t.image={insert:{integrations:["insertImageViaUrl"],type:"inline"},toolbar:["imageStyle:inline","imageStyle:sideLeft","imageStyle:block","imageStyle:side"],resizeUnit:"px",styles:{options:["inline",{name:"sideLeft",title:"Left aligned image",icon:a.icons.objectLeft,modelElements:["imageBlock"],className:"image-style-side-left"},"block","side"]}},i.includes("Link")||t.image.toolbar.push("|","linkImage")),i.includes("Table")||(t.table={contentToolbar:["tableColumn","tableRow","mergeTableCells"]});const n=await l.ClassicEditor.create(e,t),o=n.plugins.get(b.AutoLink);return o?.forceDisabled("app.ts"),n}}.apply(t,n),void 0===o||(e.exports=o)},766:(e,t,i)=>{var n,o;n=[i,t,i(4815)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabAttachment=void 0,Object.defineProperty(t,"WoltlabAttachment",{enumerable:!0,get:function(){return i.WoltlabAttachment}})}.apply(t,n),void 0===o||(e.exports=o)},4815:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(7261)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabAttachment=void 0;class o extends i.Plugin{static get pluginName(){return"WoltlabAttachment"}static get requires(){return[n.Image]}init(){const{conversion:e,model:t,plugins:i}=this.editor,{schema:n}=t,o=["imageBlock","imageInline"];o.forEach((e=>{n.extend(e,{allowAttributes:["attachmentId"]})}));const s=new Map([["attachmentId","data-attachment-id"]]);Array.from(s.entries()).forEach((([t,i])=>{e.for("upcast").attributeToAttribute({view:i,model:t}),e.for("downcast").add((e=>{o.forEach((n=>{e.on(`attribute:${t}:${n}`,((e,t,n)=>{if(!n.consumable.consume(t.item,e.name))return;const o=n.writer;let s=n.mapper.toViewElement(t.item);s.is("element","figure")&&(s=s.getChild(0)),s.is("element","img")&&(null!==t.attributeNewValue?(o.setAttribute(i,t.attributeNewValue,s),o.addClass("woltlabAttachment",s)):o.removeAttribute(i,s))}))}))}))})),i.get("ImageUploadEditing").on("uploadComplete",((e,{data:i,imageElement:n})=>{t.change((e=>{e.setAttribute("attachmentId",i["data-attachment-id"],n)}))})),this.#e()}#e(){const e=this.editor.config.get("woltlabAttachment");this.editor.plugins.get("WoltlabMetacode").on("upcast",((t,i)=>{if("attach"!==i.name)return;const n=parseInt(i.attributes[0].toString());if(Number.isNaN(n))return;if(!e.inlineImageIds.includes(n))return;let o=i.attributes[1]?i.attributes[1].toString():"none";"left"!==o&&"right"!==o&&"none"!==o&&(o="none");let s=i.attributes[2],r="auto";"boolean"!=typeof s&&("string"==typeof s||"number"==typeof s?"true"===s?s=!0:("false"===s||(s=parseInt(s.toString()),Number.isNaN(s)||0===s||(r=`${s}px`)),s=!1):s=!1),this.#t(i,e.resolveAttachmentUrl,n,o,s,r)&&t.stop()}))}#t(e,t,i,n,o,s){const{conversionApi:r,data:a}=e,{consumable:l,writer:c}=r,{viewItem:d}=a;let u="imageInline",h={attachmentId:i,src:t(i,o),width:s};"left"===n?(u="imageBlock",h.imageStyle="sideLeft"):"right"===n&&(u="imageBlock",h.imageStyle="side");const m=c.createElement(u);return c.setAttributes(h,m),r.convertChildren(d,m),!!r.safeInsert(m,a.modelCursor)&&(l.consume(d,{name:!0}),r.updateConversionResult(m,a),!0)}}t.WoltlabAttachment=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},9910:(e,t,i)=>{var n,o;n=[i,t,i(6076)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabAutosave=void 0,Object.defineProperty(t,"WoltlabAutosave",{enumerable:!0,get:function(){return i.WoltlabAutosave}})}.apply(t,n),void 0===o||(e.exports=o)},6076:(e,t,i)=>{var n,o;n=[i,t,i(6549),i(7833)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabAutosave=void 0;class o extends n.Plugin{static get pluginName(){return"WoltlabAutosave"}static get requires(){return[i.Autosave]}init(){const e=this.editor.plugins.get("PendingActions");e.hasAny=!1,e.on("set:hasAny",(e=>{e.return=!1,e.stop()}),{priority:"highest"})}}t.WoltlabAutosave=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},2823:(e,t,i)=>{var n,o;n=[i,t,i(9800),i(7489)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBbcodeCommand=t.WoltlabBbcode=void 0,Object.defineProperty(t,"WoltlabBbcode",{enumerable:!0,get:function(){return i.WoltlabBbcode}}),Object.defineProperty(t,"WoltlabBbcodeCommand",{enumerable:!0,get:function(){return n.WoltlabBbcodeCommand}})}.apply(t,n),void 0===o||(e.exports=o)},9800:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(2692),i(7489)],o=function(e,t,i,n,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBbcode=void 0;class s extends i.Plugin{static get pluginName(){return"WoltlabBbcode"}init(){const{componentFactory:e}=this.editor.ui,t=this.editor.config.get("woltlabBbcode");if(!t)return;const i=new o.default(this.editor);this.editor.commands.add("insertBbcode",i);for(const n of t)this.#i(n,e,i)}#i(e,t,i){const{icon:o,name:s,label:r}=e;t.add(`woltlabBbcode_${s}`,(()=>{const e=new n.ButtonView;if(e.label=r,e.tooltip=!0,e.withText=!0,o)if(o.includes(";")){const[t,i]=o.split(";",2);let n={name:t};"true"===i&&(n.solid="true"),e.labelView.setTemplate({tag:"fa-icon",attributes:n})}else e.labelView.setTemplate({tag:"img",attributes:{src:o}});return e.bind("isEnabled").to(i,"isEnabled"),this.listenTo(e,"execute",(()=>{this.editor.execute("insertBbcode",s)})),e}))}}t.WoltlabBbcode=s,t.default=s}.apply(t,n),void 0===o||(e.exports=o)},7489:(e,t,i)=>{var n,o;n=[i,t,i(7833)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBbcodeCommand=void 0;class n extends i.Command{execute(e){const{editing:t,model:i}=this.editor,n=this.editor.sourceElement,o=new CustomEvent("ckeditor5:bbcode",{cancelable:!0,detail:{bbcode:e}});n.dispatchEvent(o),o.defaultPrevented||i.change((n=>{const o=i.document.selection,s=n.createText(`[${e}]`),r=i.insertContent(s,o.getFirstPosition()),a=i.insertContent(n.createText(`[/${e}]`),o.isCollapsed?r.end:o.getLastPosition()),l=n.createRange(a.start);n.setSelection(l),t.view.focus()}))}refresh(){this.isEnabled=this.#n()}#n(){const{document:e,schema:t}=this.editor.model,{selection:i}=e;return t.checkAttributeInSelection(i,"bold")}}t.WoltlabBbcodeCommand=n,t.default=n}.apply(t,n),void 0===o||(e.exports=o)},8029:(e,t,i)=>{var n,o;n=[i,t,i(4587)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBlockQuote=void 0,Object.defineProperty(t,"WoltlabBlockQuote",{enumerable:!0,get:function(){return i.WoltlabBlockQuote}})}.apply(t,n),void 0===o||(e.exports=o)},6812:(e,t,i)=>{var n,o;n=[i,t,i(2692),i(6961)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBlockQuoteFormRowView=void 0;class n extends i.View{children;constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("class",t.class||""),this.children=this.createCollection(),t.children&&t.children.forEach((e=>this.children.add(e))),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",i.to("class")]},children:this.children})}}t.WoltlabBlockQuoteFormRowView=n,t.default=n}.apply(t,n),void 0===o||(e.exports=o)},8668:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(2692),i(5044),i(6812)],o=function(e,t,i,n,o,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBlockQuotePanelView=void 0;class r extends n.View{#o;#s;#r;#a;focusTracker;keystrokes;#l;#c;constructor(e){const{locale:t}=e;super(t),this.set("author",""),this.set("link",""),this.focusTracker=new o.FocusTracker,this.keystrokes=new o.KeystrokeHandler,this.#l=new n.ViewCollection,this.#c=this.#d();const i=this.#u(t);this.#r=i.fieldView;const s=this.#h(t);this.#a=s.fieldView,this.#o=this.#m(t),this.#s=this.#g(t),this.#f(t,i,s)}render(){super.render(),(0,n.submitHandler)({view:this});const e=[this.#r,this.#a,this.#o,this.#s];e.forEach((e=>{this.#l.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",(e=>e.stopPropagation())),this.keystrokes.set("arrowleft",(e=>e.stopPropagation())),this.keystrokes.set("arrowup",(e=>e.stopPropagation())),this.keystrokes.set("arrowdown",(e=>e.stopPropagation())),this.listenTo(e[0].element,"selectstart",((e,t)=>{t.stopPropagation()}),{priority:"high"}),this.on("submit",(()=>{this.fire("execute")}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.#c.focusFirst()}#u(e){const t=e.t,i=new n.LabeledFieldView(e,n.createLabeledInputText);return i.label=t("Author"),i.fieldView.bind("value").to(this,"author",(e=>e||"")),i.fieldView.on("input",(()=>{this.author=i.fieldView.element.value})),i}#h(e){const t=e.t,i=new n.LabeledFieldView(e,n.createLabeledInputText);return i.label=t("Link"),i.fieldView.bind("value").to(this,"link",(e=>e||"")),i.fieldView.on("input",(()=>{this.link=i.fieldView.element.value})),i}#m(e){const t=e.t,o=new n.ButtonView(e);return o.set({label:t("Insert"),icon:i.icons.check,class:"ck-button-save",type:"submit",withText:!0,isEnabled:!0}),o}#g(e){const t=e.t,o=new n.ButtonView(e);return o.set({label:t("Cancel"),icon:i.icons.cancel,class:"ck-button-cancel",withText:!0}),o.delegate("execute").to(this,"cancel"),o}#f(e,t,i){this.setTemplate({tag:"form",attributes:{class:["ck","ck-vertical-form","ck-woltlabblockquote-insert-form"],tabindex:"-1"},children:[t,i,new s.default(e,{children:[this.#o,this.#s],class:"ck-woltlabblockquote-insert-form__action-row"})]})}#d(){return new n.FocusCycler({focusables:this.#l,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}})}}t.WoltlabBlockQuotePanelView=r,t.default=r}.apply(t,n),void 0===o||(e.exports=o)},4587:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(2692),i(5044),i(8668),i(3905)],o=function(e,t,i,n,o,s){"use strict";function r(e){switch(typeof e){case"string":return e;case"number":case"boolean":return e.toString();default:return""}}Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabBlockQuote=void 0;class a extends i.Plugin{#p=void 0;static get pluginName(){return"WoltlabBlockQuote"}init(){const e=this.editor;e.model.schema.extend("blockQuote",{allowAttributes:["author","link"]});const t=e.commands.get("blockQuote");this.#b(t),this.#w(),this.#v(),this.#_(),this.listenTo(t,"execute",(()=>{this.#y(this.#p)}))}#b(e){const t=this.editor,o=t.t;this.editor.ui.componentFactory.add("blockQuote",(a=>{const l=(0,n.createDropdown)(a,n.SplitButtonView),c=l.buttonView;c.set({label:o("Block quote"),tooltip:!0,icon:i.icons.quote,isToggleable:!0}),c.bind("isOn").to(e,"value",(e=>!!e)),c.on("execute",(()=>{t.execute("blockQuote"),t.editing.view.focus()})),l.on("submit",(e=>{const i=e.path.find((e=>e instanceof s.WoltlabBlockQuotePanelView));i instanceof s.WoltlabBlockQuotePanelView&&(this.#p=i,t.execute("blockQuote",{forceValue:!0}),this.#p=void 0,t.editing.view.focus(),l.isOpen=!1)})),l.on("cancel",(()=>{t.editing.view.focus(),l.isOpen=!1})),l.bind("isEnabled").to(e);const d=new s.WoltlabBlockQuotePanelView(t);return l.on("change:isOpen",(()=>{if(l.isOpen){const e=this.#k();e?(d.author=r(e.getAttribute("author")),d.link=r(e.getAttribute("link"))):(d.author="",d.link="")}})),l.panelView.children.add(d),d.delegate("submit","cancel").to(l),l}))}#w(){this.editor.data.upcastDispatcher.on("element:woltlab-quote",((e,t,i)=>{const{viewItem:n}=t,{consumable:o,writer:s}=i,r=s.createElement("blockQuote");s.setAttributes({author:n.getAttribute("data-author")||"",link:n.getAttribute("data-link")||""},r),i.convertChildren(n,r),i.safeInsert(r,t.modelCursor)&&(o.consume(n,{name:!0}),i.updateConversionResult(r,t))}),{priority:"high"})}#_(){this.editor.editing.downcastDispatcher.on("insert:blockQuote",((e,t,i)=>{const{writer:n,mapper:o,consumable:s}=i;if(!s.consume(t.item,"insert"))return;const a=r(t.item.getAttribute("author")),l=r(t.item.getAttribute("link")),c=this.getSource(a,l),d={};""!==c&&(d["data-source"]=c);const u=n.createContainerElement("blockquote",d),h=o.toViewPosition(this.editor.model.createPositionBefore(t.item));n.insert(h,u),o.bindElements(t.item,u)}),{priority:"high"}),this.editor.editing.downcastDispatcher.on("attribute:author:blockQuote",((e,t,i)=>{const{writer:n,mapper:o}=i,s=r(t.attributeNewValue),a=r(t.item.getAttribute("link")),l=this.getSource(s,a),c=o.toViewElement(t.item);""===l?n.removeAttribute("data-source",c):n.setAttribute("data-source",l,c)})),this.editor.editing.downcastDispatcher.on("attribute:link:blockQuote",((e,t,i)=>{const{writer:n,mapper:o}=i,s=r(t.item.getAttribute("author")),a=r(t.attributeNewValue),l=this.getSource(s,a),c=o.toViewElement(t.item);""===l?n.removeAttribute("data-source",c):n.setAttribute("data-source",l,c)}))}#v(){this.editor.data.downcastDispatcher.on("insert:blockQuote",((e,t,i)=>{const{writer:n,mapper:o,consumable:s}=i;if(!s.consume(t.item,"insert"))return;const a=r(t.item.getAttribute("author")),l=r(t.item.getAttribute("link")),c=o.toViewPosition(this.editor.model.createPositionBefore(t.item)),d=n.createContainerElement("woltlab-quote",{"data-author":a,"data-link":l});n.insert(c,d),o.bindElements(t.item,d)}),{priority:"high"})}#y(e){const t=this.#k();t&&void 0!==e&&this.editor.model.change((i=>{i.setAttribute("author",e.author,t),i.setAttribute("link",e.link,t)}))}#k(){const e=this.editor.model.document.selection,t=(0,o.first)(e.getSelectedBlocks());return this.#C(t)}#C(e){return e.is("element","blockQuote")?e:e.parent&&!e.parent.is("element","$root")?this.#C(e.parent):null}getSource(e,t){const{t:i}=this.editor;return e?i("Quote from %0",e):i("Quote")}}t.WoltlabBlockQuote=a,t.default=a}.apply(t,n),void 0===o||(e.exports=o)},5600:(e,t,i)=>{var n,o;n=[i,t,i(2806)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabCodeBlock=void 0,Object.defineProperty(t,"WoltlabCodeBlock",{enumerable:!0,get:function(){return i.WoltlabCodeBlock}})}.apply(t,n),void 0===o||(e.exports=o)},8649:(e,t,i)=>{var n,o;n=[i,t,i(2692),i(2170)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabCodeBlockFormRowView=void 0;class n extends i.View{children;constructor(e,t={}){super(e);const i=this.bindTemplate;this.set("class",t.class||""),this.children=this.createCollection(),t.children&&t.children.forEach((e=>this.children.add(e))),this.setTemplate({tag:"div",attributes:{class:["ck","ck-form__row",i.to("class")]},children:this.children})}}t.WoltlabCodeBlockFormRowView=n,t.default=n}.apply(t,n),void 0===o||(e.exports=o)},3953:(e,t,i)=>{var n,o;n=[i,t,i(4934),i(7833),i(2692),i(5044),i(8649)],o=function(e,t,i,n,o,s,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabCodeBlockPanelView=void 0;class a extends o.View{#o;#s;#A;#E;#x;focusTracker;keystrokes;#l;#c;constructor(e){const{locale:t}=e;super(t),this.set("file",""),this.set("highlighter",""),this.set("line",""),this.focusTracker=new s.FocusTracker,this.keystrokes=new s.KeystrokeHandler,this.#l=new o.ViewCollection,this.#c=this.#d();const n=(0,i.getNormalizedAndLocalizedLanguageDefinitions)(e);this.#A=this.#T(t,n);const r=this.#S(t);this.#E=r.fieldView;const a=this.#h(t);this.#x=a.fieldView,this.#o=this.#m(t),this.#s=this.#g(t),this.#f(t,r,a)}render(){super.render(),(0,o.submitHandler)({view:this});const e=[this.#A,this.#E,this.#x,this.#o,this.#s];e.forEach((e=>{this.#l.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",(e=>e.stopPropagation())),this.keystrokes.set("arrowleft",(e=>e.stopPropagation())),this.keystrokes.set("arrowup",(e=>e.stopPropagation())),this.keystrokes.set("arrowdown",(e=>e.stopPropagation())),this.listenTo(e[0].element,"selectstart",((e,t)=>{t.stopPropagation()}),{priority:"high"}),this.on("submit",(()=>{this.fire("execute")}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.#c.focusFirst()}#T(e,t){const i=e.t,n=(0,o.createDropdown)(e),s=this.#P(t);return this.highlighter=s.first.model._codeBlockLanguage,n.buttonView.bind("label").to(this,"highlighter",(e=>{const i=e?e.toString():"";return t.find((e=>e.language==i)).label})),n.buttonView.set({isOn:!1,withText:!0,tooltip:i("Language"),class:["ck-dropdown__button_label-width_auto"]}),n.on("execute",(e=>{this.highlighter=e.source._codeBlockLanguage})),(0,o.addListToDropdown)(n,s),n}#S(e){const t=e.t,i=new o.LabeledFieldView(e,o.createLabeledInputNumber);i.label=t("Line number");const{fieldView:n}=i;return n.min=0,n.bind("value").to(this,"line",(e=>e||"")),n.on("input",(()=>{this.line=n.element.value})),i}#h(e){const t=e.t,i=new o.LabeledFieldView(e,o.createLabeledInputText);return i.label=t("Filename"),i.fieldView.bind("value").to(this,"file",(e=>e||"")),i.fieldView.on("input",(()=>{this.file=i.fieldView.element.value})),i}#P(e){const t=new s.Collection;for(const i of e){const e={type:"button",model:new o.Model({_codeBlockLanguage:i.language,label:i.label,withText:!0})};e.model.bind("isOn").to(this,"highlighter",(t=>t===e.model._codeBlockLanguage)),t.add(e)}return t}#m(e){const t=e.t,i=new o.ButtonView(e);return i.set({label:t("Insert"),icon:n.icons.check,class:"ck-button-save",type:"submit",withText:!0,isEnabled:!0}),i}#g(e){const t=e.t,i=new o.ButtonView(e);return i.set({label:t("Cancel"),icon:n.icons.cancel,class:"ck-button-cancel",withText:!0}),i.delegate("execute").to(this,"cancel"),i}#f(e,t,i){this.setTemplate({tag:"form",attributes:{class:["ck","ck-vertical-form","ck-woltlabcodeblock-insert-form"],tabindex:"-1"},children:[this.#A,t,i,new r.default(e,{children:[this.#o,this.#s],class:"ck-woltlabcodeblock-insert-form__action-row"})]})}#d(){return new o.FocusCycler({focusables:this.#l,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}})}}t.WoltlabCodeBlockPanelView=a,t.default=a}.apply(t,n),void 0===o||(e.exports=o)},2806:(e,t,i)=>{var n,o;n=[i,t,i(4934),i(7833),i(2692),i(5044),i(3953)],o=function(e,t,i,n,o,s,r){"use strict";function a(e){switch(typeof e){case"string":return e;case"number":case"boolean":return e.toString();default:return""}}Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabCodeBlock=void 0;class l extends n.Plugin{#I;#p=void 0;static get pluginName(){return"WoltlabCodeBlock"}init(){const e=this.editor;this.#I=e.commands.get("codeBlock"),e.model.schema.extend("codeBlock",{allowAttributes:["file","line"]}),this.#V(),this.#w(),this.#v(),this.#_(),this.#R(),this.listenTo(this.#I,"execute",(()=>{this.#y(this.#p)}))}#V(){const e=this.editor,t=e.t;e.ui.componentFactory.add("codeBlock",(i=>{const n=(0,o.createDropdown)(i,o.SplitButtonView),s=n.buttonView;s.set({label:t("Insert code block"),tooltip:!0,icon:'',isToggleable:!0}),s.bind("isOn").to(this.#I,"value",(e=>!!e)),s.on("execute",(()=>{e.execute("codeBlock",{usePreviousLanguageChoice:!1}),e.editing.view.focus()})),n.on("submit",(t=>{const i=t.path.find((e=>e instanceof r.WoltlabCodeBlockPanelView));i instanceof r.WoltlabCodeBlockPanelView&&(this.#p=i,e.execute("codeBlock",{language:i.highlighter,forceValue:!0}),this.#p=void 0,e.editing.view.focus(),n.isOpen=!1)})),n.on("cancel",(()=>{e.editing.view.focus(),n.isOpen=!1})),n.bind("isEnabled").to(this.#I);const l=new r.WoltlabCodeBlockPanelView(e);return n.on("change:isOpen",(()=>{if(n.isOpen){const e=this.#O();e?(l.file=a(e.getAttribute("file")),l.highlighter=a(e.getAttribute("language")),l.line=a(e.getAttribute("line"))):(l.file="",l.highlighter="",l.line="")}})),n.panelView.children.add(l),l.delegate("submit","cancel").to(n),n}))}#w(){this.editor.data.upcastDispatcher.on("element:pre",((e,t,i)=>{const{viewItem:n}=t,{consumable:o,writer:s}=i;if(n.hasClass("woltlabHtml"))return;const r=s.createElement("codeBlock");s.setAttributes({file:n.getAttribute("data-file")||"",language:n.getAttribute("data-highlighter")||"",line:n.getAttribute("data-line")||""},r),i.convertChildren(n,r),i.safeInsert(r,t.modelCursor)&&(o.consume(n,{name:!0}),i.updateConversionResult(r,t))}),{priority:"high"})}#_(){const e=(0,i.getNormalizedAndLocalizedLanguageDefinitions)(this.editor);this.editor.editing.downcastDispatcher.on("insert:codeBlock",((t,i,n)=>{const{writer:o,mapper:s,consumable:r}=n;if(!r.consume(i.item,"insert"))return;const l=a(i.item.getAttribute("file")),c=a(i.item.getAttribute("language")),d=a(i.item.getAttribute("line")),u=o.createContainerElement("code",{class:`language-${c}`});let h="";const m=e.find((e=>e.language===c));h+=m?m.label:`Unknown (${c})`,(l||d)&&(h+=" (",l&&(h+=l),d&&(l&&(h+=" "),h+=`@ ${d}`),h+=")");const g=o.createContainerElement("pre",{"data-language":h,spellcheck:"false"},u),f=s.toViewPosition(this.editor.model.createPositionBefore(i.item));o.insert(f,g),s.bindElements(i.item,u)}),{priority:"high"})}#v(){this.editor.data.downcastDispatcher.on("insert:codeBlock",((e,t,i)=>{const{writer:n,mapper:o,consumable:s}=i;if(!s.consume(t.item,"insert"))return;const r=a(t.item.getAttribute("file")),l=a(t.item.getAttribute("language")),c=a(t.item.getAttribute("line")),d=o.toViewPosition(this.editor.model.createPositionBefore(t.item)),u=n.createContainerElement("pre",{"data-file":r,"data-highlighter":l,"data-line":c});n.insert(d,u),o.bindElements(t.item,u)}),{priority:"high"})}#y(e){const t=this.#O();t&&void 0!==e&&this.editor.model.change((i=>{i.setAttribute("file",e.file,t),i.setAttribute("line",e.line,t)}))}#R(){const e=(0,i.getNormalizedAndLocalizedLanguageDefinitions)(this.editor),t=["file","line"];for(const i of t)this.editor.editing.downcastDispatcher.on(`attribute:${i}:codeBlock`,((t,i,n)=>{const{mapper:o}=n,s=o.toViewElement(i.item);if(void 0===s)return;const r=s.getAncestors(),l=r[r.length-1];if(!l.is("element","pre"))return;const c=a(i.item.getAttribute("file")),d=a(i.item.getAttribute("language")),u=a(i.item.getAttribute("line"));let h="";const m=e.find((e=>e.language===d));h+=m?m.label:`Unknown (${d})`,(c||u)&&(h+=" (",c&&(h+=c),u&&(c&&(h+=" "),h+=`@ ${u}`),h+=")"),this.editor.editing.view.change((e=>{e.setAttribute("data-language",h,l)}))}))}#O(){const e=this.editor.model.document.selection,t=(0,s.first)(e.getSelectedBlocks());return t&&t.is("element","codeBlock")?t:null}}t.WoltlabCodeBlock=l,t.default=l}.apply(t,n),void 0===o||(e.exports=o)},3706:(e,t,i)=>{var n,o;n=[i,t,i(2379)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabCode=void 0,Object.defineProperty(t,"WoltlabCode",{enumerable:!0,get:function(){return i.WoltlabCode}})}.apply(t,n),void 0===o||(e.exports=o)},2379:(e,t,i)=>{var n,o;n=[i,t,i(7971),i(7833)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabCode=void 0;class o extends n.Plugin{static get pluginName(){return"WoltlabCode"}static get requires(){return[i.Code]}init(){const{conversion:e}=this.editor;e.for("upcast").elementToAttribute({view:"kbd",model:"code",converterPriority:"high"}),e.for("dataDowncast").attributeToElement({model:"code",view:"kbd",converterPriority:"high"})}}t.WoltlabCode=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},1294:(e,t,i)=>{var n,o;n=[i,t,i(6091)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabHtmlEmbed=void 0,Object.defineProperty(t,"WoltlabHtmlEmbed",{enumerable:!0,get:function(){return i.WoltlabHtmlEmbed}})}.apply(t,n),void 0===o||(e.exports=o)},6091:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(8691)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabHtmlEmbed=void 0;class o extends i.Plugin{static get pluginName(){return"WoltlabHtmlEmbed"}static get requires(){return[n.HtmlEmbed]}init(){const{conversion:e,data:t}=this.editor;t.registerRawContentMatcher({name:"pre",classes:"woltlabHtml"}),e.for("upcast").elementToElement({view:{name:"pre",classes:"woltlabHtml"},model:(e,{writer:t})=>{let i=e.getCustomProperty("$rawContent");return i="string"==typeof i?this.#B(i):"",t.createElement("rawHtml",{value:i})},converterPriority:"high"}),e.for("dataDowncast").elementToElement({model:"rawHtml",view:(e,{writer:t})=>t.createRawElement("pre",{class:"woltlabHtml"},(function(t){t.textContent=e.getAttribute("value")||""})),converterPriority:"high"})}#B(e){return String(e).replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}}t.WoltlabHtmlEmbed=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},8206:(e,t,i)=>{var n,o;n=[i,t,i(2265)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabImage=void 0,Object.defineProperty(t,"WoltlabImage",{enumerable:!0,get:function(){return i.WoltlabImage}})}.apply(t,n),void 0===o||(e.exports=o)},2265:(e,t,i)=>{var n,o;n=[i,t,i(7833)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabImage=void 0;class n extends i.Plugin{static get pluginName(){return"WoltlabImage"}init(){const{conversion:e}=this.editor,t=["imageBlock","imageInline"];for(const i of t)e.for("dataDowncast").add((e=>{e.on(`insert:${i}`,((e,t,i)=>{const{item:n}=t;if(!n.is("element"))return;const o=n.getAttribute("width");if("string"!=typeof o)return;const{mapper:s,writer:r}=i,a=s.toViewElement(n);void 0!==a&&r.setAttribute("data-width",o,a)}),{priority:"lowest"})})),e.for("editingDowncast").add((e=>{e.on(`insert:${i}`,((e,{item:t},i)=>{const{mapper:n,writer:o}=i,{domConverter:s}=this.editor.editing.view,r=n.toViewElement(t);if(!r||!r.is("containerElement")||1!==r.childCount)return;const a=r.getChild(0);if(!a.is("element"))return;const l=s.viewToDom(a);if(!(l instanceof HTMLImageElement))return;const c=()=>{o.setStyle("max-width",`${l.naturalWidth}px`,r)};l.complete&&0!==l.naturalHeight?c():l.addEventListener("load",(()=>c()),{once:!0})}))}))}}t.WoltlabImage=n,t.default=n}.apply(t,n),void 0===o||(e.exports=o)},5825:(e,t,i)=>{var n,o;n=[i,t,i(4413)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMagicParagraph=void 0,Object.defineProperty(t,"WoltlabMagicParagraph",{enumerable:!0,get:function(){return i.WoltlabMagicParagraph}})}.apply(t,n),void 0===o||(e.exports=o)},4413:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(6243)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMagicParagraph=void 0;class o extends i.Plugin{static blockModels=["blockQuote","codeBlock","spoiler","table"];static get pluginName(){return"WoltlabMagicParagraph"}init(){const{mapper:e,view:t}=this.editor.editing,{document:i,domConverter:s}=t;t.addObserver(n.ClickObserver),this.listenTo(i,"click",((t,n)=>{const{domEvent:r,target:a}=n;if(void 0===a)return;const l=a.getAncestors();l.push(a);for(const e of l)if(e.is("element","p")||e.is("element","li"))return;const{clientY:c}=r,d=i.getRoot(),u=d.getChild(0);if(void 0!==u){if(u.is("containerElement")){let i=u,n=e.toModelElement(i);if(void 0===n&&i.childCount>0){const t=i.getChild(0);t.is("containerElement")&&(i=t,n=e.toModelElement(i))}if(n&&o.blockModels.includes(n.name)){const e=s.mapViewToDom(i),{top:n}=e.getBoundingClientRect();if(c<=n)return t.stop(),void this.#M(i)}}if(0!==d.childCount){const i=d.getChild(d.childCount-1);if(i.is("containerElement")){let n=i,r=e.toModelElement(n);if(void 0===r&&n.childCount>0){const t=n.getChild(n.childCount-1);t.is("containerElement")&&(n=t,r=e.toModelElement(n))}if(r&&o.blockModels.includes(r.name)){const e=s.mapViewToDom(n),{bottom:i}=e.getBoundingClientRect();if(c>=i)return t.stop(),void this.#N(n)}}}for(const e of this.#D()){const i=s.mapViewToDom(e),{bottom:n,top:o}=i.getBoundingClientRect(),{marginBottom:r,marginTop:a}=window.getComputedStyle(i),l=o-parseInt(a),d=n+parseInt(r);if(c=l&&c<=o)return this.#M(e),void t.stop();if(c>=n&&c<=d)return this.#N(e),void t.stop()}}}))}#M(e){const{mapper:t}=this.editor.editing;let i;i=e.previousSibling&&e.previousSibling.is("element","p")?t.toModelElement(e.previousSibling):void 0,this.editor.model.change((n=>{if(void 0===i){i=n.createElement("paragraph");const o=n.createPositionBefore(t.toModelElement(e));n.insert(i,o)}n.setSelection(i,"end")}))}#N(e){const{mapper:t}=this.editor.editing;let i;i=e.nextSibling&&e.nextSibling.is("element","p")?t.toModelElement(e.nextSibling):void 0,this.editor.model.change((n=>{if(void 0===i){i=n.createElement("paragraph");const o=n.createPositionAfter(t.toModelElement(e));n.insert(i,o)}n.setSelection(i,"end")}))}*#D(){const{mapper:e,view:t}=this.editor.editing,i=t.document.getRoot(),n=t.createRangeIn(i);for(const t of n.getWalker({ignoreElementEnd:!0})){const i=t.item;if(!i.is("containerElement"))continue;const n=e.toModelElement(i);void 0!==n&&o.blockModels.includes(n.name)&&(yield i)}}}t.WoltlabMagicParagraph=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},9782:(e,t,i)=>{var n,o;n=[i,t,i(6761)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMedia=void 0,Object.defineProperty(t,"WoltlabMedia",{enumerable:!0,get:function(){return i.WoltlabMedia}})}.apply(t,n),void 0===o||(e.exports=o)},6761:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(7261),i(7080)],o=function(e,t,i,n,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMedia=void 0;class s extends i.Plugin{static get pluginName(){return"WoltlabMedia"}static get requires(){return[n.Image,o.WoltlabMetacode]}init(){this.#L(),this.#F()}#L(){const{conversion:e,model:t}=this.editor,{schema:i}=t,n=["imageBlock","imageInline"];n.forEach((e=>{i.extend(e,{allowAttributes:["mediaId","mediaSize"]})})),e.attributeToAttribute({model:{key:"classList",values:["woltlabSuiteMedia"]},view:{woltlabSuiteMedia:{name:"img",key:"class",value:"woltlabSuiteMedia"}}});const o=new Map([["mediaId","data-media-id"],["mediaSize","data-media-size"]]);Array.from(o.entries()).forEach((([t,i])=>{e.for("upcast").attributeToAttribute({view:i,model:t}),e.for("downcast").add((e=>{n.forEach((n=>{e.on(`attribute:${t}:${n}`,((e,t,n)=>{if(!n.consumable.consume(t.item,e.name))return;const o=n.writer;let s=n.mapper.toViewElement(t.item);s.is("element","figure")&&(s=s.getChild(0)),s.is("element","img")&&(null!==t.attributeNewValue?o.setAttribute(i,t.attributeNewValue,s):o.removeAttribute(i,s))}))}))}))}))}#F(){const e=this.editor.config.get("woltlabMedia");this.editor.plugins.get("WoltlabMetacode").on("upcast",((t,i)=>{if("wsm"===i.name){const n=parseInt(i.attributes[0].toString());if(Number.isNaN(n))return;const o=i.attributes[1]?i.attributes[1].toString():"original";this.#z(i,e.resolveMediaUrl,n,o)&&t.stop()}}))}#z(e,t,i,n){const{conversionApi:o,data:s}=e,{consumable:r,writer:a}=o,{viewItem:l}=s,c=a.createElement("imageInline");return a.setAttributes({src:t(i,n),mediaId:i,mediaSize:n},c),o.convertChildren(l,c),!!o.safeInsert(c,s.modelCursor)&&(r.consume(l,{name:!0}),o.updateConversionResult(c,s),!0)}}t.WoltlabMedia=s,t.default=s}.apply(t,n),void 0===o||(e.exports=o)},4201:(e,t,i)=>{var n,o;n=[i,t,i(644)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMention=void 0,Object.defineProperty(t,"WoltlabMention",{enumerable:!0,get:function(){return i.WoltlabMention}})}.apply(t,n),void 0===o||(e.exports=o)},644:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(6335),i(7080),i(5044)],o=function(e,t,i,n,o,s){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMention=void 0;class r extends i.Plugin{static get pluginName(){return"WoltlabMention"}static get requires(){return[n.Mention,o.WoltlabMetacode]}init(){this.editor.plugins.get("WoltlabMetacode").on("upcast",((e,t)=>{"user"===t.name&&1===t.attributes.length&&(Number.isNaN(parseInt(t.attributes[0].toString()))||(e.stop(),this.#H(t)))})),this.#v()}#H(e){const{attributes:t,conversionApi:i,data:n,name:o}=e,{writer:r}=i,{viewItem:a}=n,l=a.getChild(0);Object.assign(n,i.convertChildren(n.viewItem,n.modelCursor));for(const e of Array.from(n.modelRange.getItems()))(e.is("$text")||e.is("$textProxy"))&&r.setAttribute("mention",{id:t[0].toString(),objectId:t[0],type:o,uid:(0,s.uid)(),_text:l.data},e)}#v(){this.editor.conversion.for("dataDowncast").attributeToElement({model:"mention",view:(e,{writer:t})=>{if(!e)return;const i=e.objectId;return t.createAttributeElement("woltlab-metacode",{"data-name":e.type,"data-attributes":btoa(JSON.stringify([i]))},{priority:20,id:e.uid})},converterPriority:"high"})}}t.WoltlabMention=r,t.default=r}.apply(t,n),void 0===o||(e.exports=o)},7080:(e,t,i)=>{var n,o;n=[i,t,i(2505)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMetacode=void 0,Object.defineProperty(t,"WoltlabMetacode",{enumerable:!0,get:function(){return i.WoltlabMetacode}})}.apply(t,n),void 0===o||(e.exports=o)},2505:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(5044)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabMetacode=void 0;class o extends i.Plugin{static get pluginName(){return"WoltlabMetacode"}init(){this.#W()}#W(){this.editor.conversion.for("upcast").add((e=>{e.on("element:woltlab-metacode",((e,t,i)=>{const{consumable:o,convertChildren:s,writer:r}=i,{viewItem:a}=t;if(!o.test(a,{name:!0}))return;const l=a.getAttribute("data-name");if(void 0===l)return;const c=this.#U(a.getAttribute("data-attributes")||""),d=new n.EventInfo(this,"upcast"),u={attributes:c,conversionApi:i,data:t,name:l};if(this.fire(d,u),d.stop.called)return;let{modelCursor:h}=t;const m=this.#j(c),g=r.createText(`[${l}${m}]`),f=r.createText(`[/${l}]`);let p=!1;const b=h.getAncestors();if("$root"===b[b.length-1].name)p=!0;else for(const e of a.getChildren())if(e.is("containerElement")){p=!0;break}if(p){let e=r.createElement("paragraph");r.insert(g,e),r.insert(e,h),h=r.createPositionAfter(e);const i=s(a,h);e=r.createElement("paragraph"),r.insert(f,e),r.insert(e,i.modelCursor),t.modelCursor=r.createPositionAfter(e)}else{r.insert(g,h),h=h.getShiftedBy(g.offsetSize);const e=s(a,h);r.insert(f,e.modelCursor),t.modelCursor=e.modelCursor.getShiftedBy(f.offsetSize)}}))}))}#U(e){if(""===e)return[];const t=atob(e);let i;try{i=JSON.parse(t)}catch(e){return[]}return i}#j(e){return 0===e.length?"":"="+e.map((e=>"number"==typeof e?e.toString():`'${e}'`)).join(",")}}t.WoltlabMetacode=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},8427:(e,t,i)=>{var n,o;n=[i,t,i(4054)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabSmiley=void 0,Object.defineProperty(t,"WoltlabSmiley",{enumerable:!0,get:function(){return i.WoltlabSmiley}})}.apply(t,n),void 0===o||(e.exports=o)},4054:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(7261),i(6677)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabSmiley=void 0;class o extends i.Plugin{static get pluginName(){return"WoltlabSmiley"}static get requires(){return[n.Image]}init(){const{conversion:e,model:t}=this.editor,i=["imageBlock","imageInline"];for(const e of i)t.schema.extend(e,{allowAttributes:["classList"]});e.attributeToAttribute({model:{key:"classList",values:["smiley"]},view:{smiley:{name:"img",key:"class",value:"smiley"}}}),e.for("editingDowncast").add((e=>{e.on("insert:imageInline",((e,t,i)=>{const{item:n}=t;if("smiley"!==n.getAttribute("classList"))return;if(!n.is("element"))return;const{consumable:o,mapper:s,writer:r}=i;if(!o.test(n,"insert"))return;o.consume(n,"insert");const a=r.createEmptyElement("img");r.setAttribute("translate","no",a);const l=s.toViewPosition(this.editor.model.createPositionBefore(n));r.insert(l,a),s.bindElements(n,a)}),{priority:"high"})}))}}t.WoltlabSmiley=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},5469:(e,t,i)=>{var n,o;n=[i,t,i(7591),i(2553)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabSpoilerCommand=t.WoltlabSpoiler=void 0,Object.defineProperty(t,"WoltlabSpoiler",{enumerable:!0,get:function(){return i.WoltlabSpoiler}}),Object.defineProperty(t,"WoltlabSpoilerCommand",{enumerable:!0,get:function(){return n.WoltlabSpoilerCommand}})}.apply(t,n),void 0===o||(e.exports=o)},7591:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(6004)],o=function(e,t,i,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabSpoiler=void 0;class o extends i.Plugin{static get requires(){return[n.default]}static get pluginName(){return"WoltlabSpoiler"}}t.WoltlabSpoiler=o,t.default=o}.apply(t,n),void 0===o||(e.exports=o)},2553:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(6243),i(5044)],o=function(e,t,i,n,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabSpoilerCommand=void 0;class s extends i.Command{execute(){const{model:e}=this.editor,{schema:t}=e,{selection:i}=e.document,n=Array.from(i.getSelectedBlocks());e.change((e=>{if(this.value)this.#$(e,n);else{const i=n.filter((e=>this.#q(e)||this.#K(t,e)));this.#Z(e,i)}}))}refresh(){this.value=this.#G(),this.isEnabled=this.#n()}#$(e,t){for(const i of t){const t=this.#q(i);if(null===t)continue;const o=t.previousSibling;if(null===o||!o.is("element","spoilerTitle"))throw new Error("Invalid structure, expected a `` adjacent to ``",{cause:{spoilerTitle:o}});const s=t.parent;if(!(s instanceof n.Element&&s.is("element","spoiler")))throw new Error("Invalid structure, expected a `` as the parent of a ``",{cause:{spoiler:s}});e.remove(o),e.unwrap(s),e.unwrap(t)}}#Z(e,t){const i=[];this.#J(e,t).reverse().forEach((t=>{let n=this.#q(t.start);n||(n=this.#Y(e,t)),i.push(n.parent)})),i.reverse().reduce(((t,i)=>{if(t.nextSibling===i){const n=t.getChild(1),o=i.getChild(1);return e.move(e.createRangeIn(o),e.createPositionAt(n,"end")),e.remove(i),t}return i}))}#J(e,t){let i=null,n=0;const o=[];for(;n{var n,o;n=[i,t,i(7833),i(1460),i(6243),i(2692),i(2553),i(5253)],o=function(e,t,i,n,o,s,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabSpoilerEditing=void 0;class a extends i.Plugin{static get pluginName(){return"WoltlabSpoilerEditing"}static get requires(){return[n.Widget]}init(){this.#Q(),this.#W(),this.editor.commands.add("insertSpoiler",new r.default(this.editor)),this.#X()}#X(){const{t:e}=this.editor.locale;this.editor.ui.componentFactory.add("spoiler",(t=>{const i=this.editor.commands.get("insertSpoiler"),n=new s.ButtonView(t);return n.set({label:e("Spoiler"),tooltip:!0,withText:!0}),n.labelView.setTemplate({tag:"fa-icon",attributes:{name:"eye-slash"}}),n.bind("isOn").to(i,"value"),n.bind("isEnabled").to(i,"isEnabled"),this.listenTo(n,"execute",(()=>this.editor.execute("insertSpoiler"))),n}))}#Q(){const{schema:e}=this.editor.model;e.register("spoiler",{allowWhere:"$block",isObject:!0}),e.register("spoilerTitle",{allowChildren:"$text",allowIn:"spoiler",isLimit:!0}),e.register("spoilerContent",{allowContentOf:"$root",allowIn:"spoiler",isLimit:!0}),e.addChildCheck(((e,t)=>("spoiler"!==t.name||!Array.from(e.getNames()).includes("spoiler"))&&(!e.endsWith("spoilerContent")||"spoiler"!==t.name)&&(!e.endsWith("spoilerTitle")||"$text"===t.name)&&void 0)),e.addAttributeCheck((e=>{if(e.endsWith("spoilerTitle $text"))return!1}))}#W(){const{conversion:e}=this.editor,{t}=this.editor.locale;e.for("upcast").add((e=>{e.on("element:woltlab-spoiler",((e,t,i)=>{const{consumable:n,writer:o,safeInsert:s,convertChildren:r,updateConversionResult:a}=i,{viewItem:l}=t,c={name:!0};if(!n.test(l,c))return;const d=o.createElement("spoiler"),u=o.createElement("spoilerTitle");o.append(u,d);const h=(l.getAttribute("data-label")||"").trim();o.appendText(h,u);const m=o.createElement("spoilerContent");o.append(m,d),s(d,t.modelCursor)&&(n.consume(l,c),r(l,m),a(d,t))}))})),e.for("dataDowncast").add((e=>{e.on("insert:spoiler",((e,t,i)=>{const{item:n}=t,{consumable:o,mapper:s,writer:r}=i;if(2!==n.childCount)return null;const a=n.getChild(0);if(!a.is("element","spoilerTitle"))return null;if(!o.consume(n,"insert"))return;o.consume(a,"insert");let l="";if(1===a.childCount){const e=a.getChild(0);e.is("$text")&&(l=e.data)}const c=r.createContainerElement("woltlab-spoiler",{"data-label":l}),d=s.toViewPosition(this.editor.model.createPositionBefore(n));r.insert(d,c),s.bindElements(n,c),s.bindElements(a,c);const u=n.getChild(1);u.is("element","spoilerContent")&&(s.bindElements(u,c),o.consume(u,"insert"))})),e.on("insert:$text",((e,t,i)=>{const n=t.item.parent;n&&n.is("element","spoilerTitle")&&i.consumable.consume(t.item,"insert")}))})),e.for("editingDowncast").elementToElement({model:"spoiler",view:(e,{writer:t})=>{const i=t.createContainerElement("div",{class:"ck-woltlabspoiler"});return(0,n.toWidget)(i,t,{hasSelectionHandle:!0,label:"spoiler widget"})}}).elementToElement({model:"spoilerTitle",view:(e,{writer:i})=>{const s=i.createEditableElement("div",{class:"ck-woltlabspoiler__title","data-label":t("Spoiler")});return s.placeholder=t("Type your title"),(0,o.enablePlaceholder)({view:this.editor.editing.view,element:s,keepOnFocus:!0}),(0,n.toWidgetEditable)(s,i)}}).elementToElement({model:"spoilerContent",view:(e,{writer:t})=>{const i=t.createEditableElement("div",{class:"ck-woltlabspoiler__content"});return(0,n.toWidgetEditable)(i,t)}})}}t.WoltlabSpoilerEditing=a,t.default=a}.apply(t,n),void 0===o||(e.exports=o)},9402:(e,t,i)=>{var n,o;n=[i,t,i(6909)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabToolbarGroup=void 0,Object.defineProperty(t,"WoltlabToolbarGroup",{enumerable:!0,get:function(){return i.WoltlabToolbarGroup}})}.apply(t,n),void 0===o||(e.exports=o)},6909:(e,t,i)=>{var n,o;n=[i,t,i(7833)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabToolbarGroup=void 0;class n extends i.Plugin{static get pluginName(){return"WoltlabToolbarGroup"}init(){const e=this.editor.config.get("woltlabToolbarGroup");e&&this.editor.once("ready",(()=>{const t=this.editor.ui.view.toolbar.items;Object.entries(e).forEach((([e,i])=>{const n=t.find((t=>null!==t.element?.querySelector(`[data-cke-tooltip-text="woltlabToolbarGroup_${e}"]`))),o=n.element,s=o.querySelector(".ck-button__icon"),[r,a]=i.icon.split(";",2),l=document.createElement("fa-icon");l.setIcon(r,"true"===a),s.replaceWith(l),n.buttonView.label=i.label,o.dataset.ckeTooltipText=i.label}))}))}}t.WoltlabToolbarGroup=n,t.default=n}.apply(t,n),void 0===o||(e.exports=o)},8152:(e,t,i)=>{var n,o;n=[i,t,i(6916)],o=function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabUpload=void 0,Object.defineProperty(t,"WoltlabUpload",{enumerable:!0,get:function(){return i.WoltlabUpload}})}.apply(t,n),void 0===o||(e.exports=o)},6916:(e,t,i)=>{var n,o;n=[i,t,i(7833),i(1070),i(2263)],o=function(e,t,i,n,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabUpload=void 0;class s extends i.Plugin{static get pluginName(){return"WoltlabUpload"}static get requires(){return[n.FileRepository]}init(){const{config:e,editing:t,plugins:i}=this.editor,s=e.get("woltlabUpload");s&&"function"==typeof s.uploadImage&&(i.get(n.FileRepository).createUploadAdapter=e=>new o.WoltlabUploadAdapter(e,s),"function"==typeof s.uploadOther&&this.listenTo(t.view.document,"clipboardInput",((e,t)=>{if(e.stop.called)return;const{dataTransfer:i,method:n}=t;if("drop"===n){for(const e of i.files)null!==e&&s.uploadOther(e);e.stop()}}),{priority:"lowest"}))}}t.WoltlabUpload=s,t.default=s}.apply(t,n),void 0===o||(e.exports=o)},2263:(e,t,i)=>{var n;n=function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WoltlabUploadAdapter=void 0;class i{#ee;#te;#ie;constructor(e,t){this.#ee=e,this.#te=t}abort(){this.#ie?.abort()}async upload(){const e=await this.#ee.file;return this.#ie=new AbortController,this.#te.uploadImage(e,this.#ie)}}t.WoltlabUploadAdapter=i,t.default=i}.apply(t,[i,t]),void 0===n||(e.exports=n)},2536:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var n=i(9651);const o=function(e,t){for(var i=e.length;i--;)if((0,n.Z)(e[i][0],t))return i;return-1};var s=Array.prototype.splice;function r(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t-1},r.prototype.set=function(e,t){var i=this.__data__,n=o(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this};const a=r},6183:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(2119),o=i(6092);const s=(0,n.Z)(o.Z,"Map")},520:(e,t,i)=>{"use strict";i.d(t,{Z:()=>h});const n=(0,i(2119).Z)(Object,"create");var o=Object.prototype.hasOwnProperty;var s=Object.prototype.hasOwnProperty;function r(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t{"use strict";i.d(t,{Z:()=>a});var n=i(2536);var o=i(6183),s=i(520);function r(e){var t=this.__data__=new n.Z(e);this.size=t.size}r.prototype.clear=function(){this.__data__=new n.Z,this.size=0},r.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},r.prototype.get=function(e){return this.__data__.get(e)},r.prototype.has=function(e){return this.__data__.has(e)},r.prototype.set=function(e,t){var i=this.__data__;if(i instanceof n.Z){var r=i.__data__;if(!o.Z||r.length<199)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new s.Z(r)}return i.set(e,t),this.size=i.size,this};const a=r},7685:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=i(6092).Z.Symbol},4073:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=i(6092).Z.Uint8Array},9001:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c});var n=i(4732),o=i(7771),s=i(6706),r=i(6009),a=i(7212),l=Object.prototype.hasOwnProperty;const c=function(e,t){var i=(0,o.Z)(e),c=!i&&(0,n.Z)(e),d=!i&&!c&&(0,s.Z)(e),u=!i&&!c&&!d&&(0,a.Z)(e),h=i||c||d||u,m=h?function(e,t){for(var i=-1,n=Array(e);++i{"use strict";i.d(t,{Z:()=>n});const n=function(e,t){for(var i=-1,n=t.length,o=e.length;++i{"use strict";i.d(t,{Z:()=>r});var n=i(4752),o=i(9651),s=Object.prototype.hasOwnProperty;const r=function(e,t,i){var r=e[t];s.call(e,t)&&(0,o.Z)(r,i)&&(void 0!==i||t in e)||(0,n.Z)(e,t,i)}},4752:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=i(7904);const o=function(e,t,i){"__proto__"==t&&n.Z?(0,n.Z)(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}},9256:(e,t,i)=>{"use strict";i.d(t,{Z:()=>W});var n=i(5365);var o=i(2954),s=i(1899),r=i(703);var a=i(7590);var l=i(1050),c=i(7215),d=i(3573);var u=i(8694),h=i(2513),m=i(532);const g=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)(0,u.Z)(t,(0,d.Z)(e)),e=(0,h.Z)(e);return t}:m.Z;var f=i(1808),p=i(3327);const b=function(e){return(0,p.Z)(e,a.Z,g)};var w=i(4158),v=Object.prototype.hasOwnProperty;var _=i(1884);var y=/\w*$/;var k=i(7685),C=k.Z?k.Z.prototype:void 0,A=C?C.valueOf:void 0;var E=i(2701);const x=function(e,t,i){var n,o,s,r=e.constructor;switch(t){case"[object ArrayBuffer]":return(0,_.Z)(e);case"[object Boolean]":case"[object Date]":return new r(+e);case"[object DataView]":return function(e,t){var i=t?(0,_.Z)(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}(e,i);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return(0,E.Z)(e,i);case"[object Map]":case"[object Set]":return new r;case"[object Number]":case"[object String]":return new r(e);case"[object RegExp]":return(s=new(o=e).constructor(o.source,y.exec(o))).lastIndex=o.lastIndex,s;case"[object Symbol]":return n=e,A?Object(A.call(n)):{}}};var T=i(5418),S=i(7771),P=i(6706),I=i(8533);var V=i(1162),R=i(8351),O=R.Z&&R.Z.isMap;const B=O?(0,V.Z)(O):function(e){return(0,I.Z)(e)&&"[object Map]"==(0,w.Z)(e)};var M=i(7226);var N=R.Z&&R.Z.isSet;const D=N?(0,V.Z)(N):function(e){return(0,I.Z)(e)&&"[object Set]"==(0,w.Z)(e)};var L="[object Arguments]",F="[object Function]",z="[object Object]",H={};H[L]=H["[object Array]"]=H["[object ArrayBuffer]"]=H["[object DataView]"]=H["[object Boolean]"]=H["[object Date]"]=H["[object Float32Array]"]=H["[object Float64Array]"]=H["[object Int8Array]"]=H["[object Int16Array]"]=H["[object Int32Array]"]=H["[object Map]"]=H["[object Number]"]=H[z]=H["[object RegExp]"]=H["[object Set]"]=H["[object String]"]=H["[object Symbol]"]=H["[object Uint8Array]"]=H["[object Uint8ClampedArray]"]=H["[object Uint16Array]"]=H["[object Uint32Array]"]=!0,H["[object Error]"]=H[F]=H["[object WeakMap]"]=!1;const W=function e(t,i,u,h,m,p){var _,y=1&i,k=2&i,C=4&i;if(u&&(_=m?u(t,h,m,p):u(t)),void 0!==_)return _;if(!(0,M.Z)(t))return t;var A=(0,S.Z)(t);if(A){if(_=function(e){var t=e.length,i=new e.constructor(t);return t&&"string"==typeof e[0]&&v.call(e,"index")&&(i.index=e.index,i.input=e.input),i}(t),!y)return(0,c.Z)(t,_)}else{var E=(0,w.Z)(t),I=E==F||"[object GeneratorFunction]"==E;if((0,P.Z)(t))return(0,l.Z)(t,y);if(E==z||E==L||I&&!m){if(_=k||I?{}:(0,T.Z)(t),!y)return k?function(e,t){return(0,s.Z)(e,g(e),t)}(t,function(e,t){return e&&(0,s.Z)(t,(0,a.Z)(t),e)}(_,t)):function(e,t){return(0,s.Z)(e,(0,d.Z)(e),t)}(t,function(e,t){return e&&(0,s.Z)(t,(0,r.Z)(t),e)}(_,t))}else{if(!H[E])return m?t:{};_=x(t,E,y)}}p||(p=new n.Z);var V=p.get(t);if(V)return V;p.set(t,_),D(t)?t.forEach((function(n){_.add(e(n,i,u,n,t,p))})):B(t)&&t.forEach((function(n,o){_.set(o,e(n,i,u,o,t,p))}));var R=C?k?b:f.Z:k?a.Z:r.Z,O=A?void 0:R(t);return function(e,t){for(var i=-1,n=null==e?0:e.length;++i{"use strict";i.d(t,{Z:()=>s});var n=i(8694),o=i(7771);const s=function(e,t,i){var s=t(e);return(0,o.Z)(e)?s:(0,n.Z)(s,i(e))}},3243:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var n=i(7685),o=Object.prototype,s=o.hasOwnProperty,r=o.toString,a=n.Z?n.Z.toStringTag:void 0;var l=Object.prototype.toString;var c=n.Z?n.Z.toStringTag:void 0;const d=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":c&&c in Object(e)?function(e){var t=s.call(e,a),i=e[a];try{e[a]=void 0;var n=!0}catch(e){}var o=r.call(e);return n&&(t?e[a]=i:delete e[a]),o}(e):function(e){return l.call(e)}(e)}},1152:(e,t,i)=>{"use strict";i.d(t,{Z:()=>S});var n=i(5365),o=i(520);function s(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new o.Z;++tc))return!1;var u=s.get(e),h=s.get(t);if(u&&h)return u==t&&h==e;var m=-1,g=!0,f=2&i?new r:void 0;for(s.set(e,t),s.set(t,e);++m{"use strict";i.d(t,{Z:()=>n});const n=function(e,t,i){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),(i=i>o?o:i)<0&&(i+=o),o=t>i?0:i-t>>>0,t>>>=0;for(var s=Array(o);++n{"use strict";i.d(t,{Z:()=>n});const n=function(e){return function(t){return e(t)}}},1884:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=i(4073);const o=function(e){var t=new e.constructor(e.byteLength);return new n.Z(t).set(new n.Z(e)),t}},1050:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l});var n=i(6092),o="object"==typeof exports&&exports&&!exports.nodeType&&exports,s=o&&"object"==typeof module&&module&&!module.nodeType&&module,r=s&&s.exports===o?n.Z.Buffer:void 0,a=r?r.allocUnsafe:void 0;const l=function(e,t){if(t)return e.slice();var i=e.length,n=a?a(i):new e.constructor(i);return e.copy(n),n}},2701:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=i(1884);const o=function(e,t){var i=t?(0,n.Z)(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}},7215:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e,t){var i=-1,n=e.length;for(t||(t=Array(n));++i{"use strict";i.d(t,{Z:()=>s});var n=i(2954),o=i(4752);const s=function(e,t,i,s){var r=!i;i||(i={});for(var a=-1,l=t.length;++a{"use strict";i.d(t,{Z:()=>b});var n=i(9203);var o=Math.max;var s=i(7904);const r=s.Z?function(e,t){return(0,s.Z)(e,"toString",{configurable:!0,enumerable:!1,value:(i=t,function(){return i}),writable:!0});var i}:n.Z;var a=Date.now;const l=(c=r,d=0,u=0,function(){var e=a(),t=16-(e-u);if(u=e,t>0){if(++d>=800)return arguments[0]}else d=0;return c.apply(void 0,arguments)});var c,d,u;const h=function(e,t){return l(function(e,t,i){return t=o(void 0===t?e.length-1:t,0),function(){for(var n=arguments,s=-1,r=o(n.length-t,0),a=Array(r);++s1?i[o-1]:void 0,r=o>2?i[2]:void 0;for(s=e.length>3&&"function"==typeof s?(o--,s):void 0,r&&function(e,t,i){if(!(0,p.Z)(i))return!1;var n=typeof t;return!!("number"==n?(0,g.Z)(i)&&(0,f.Z)(t,i.length):"string"==n&&t in i)&&(0,m.Z)(i[t],e)}(i[0],i[1],r)&&(s=o<3?void 0:s,o=1),t=Object(t);++n{"use strict";i.d(t,{Z:()=>o});var n=i(2119);const o=function(){try{var e=(0,n.Z)(Object,"defineProperty");return e({},"",{}),e}catch(e){}}()},3413:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n="object"==typeof global&&global&&global.Object===Object&&global},1808:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var n=i(3327),o=i(3573),s=i(703);const r=function(e){return(0,n.Z)(e,s.Z,o.Z)}},2119:(e,t,i)=>{"use strict";i.d(t,{Z:()=>p});var n=i(3234);const o=i(6092).Z["__core-js_shared__"];var s,r=(s=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+s:"";var a=i(7226),l=i(19),c=/^\[object .+?Constructor\]$/,d=Function.prototype,u=Object.prototype,h=d.toString,m=u.hasOwnProperty,g=RegExp("^"+h.call(m).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const f=function(e){return!(!(0,a.Z)(e)||(t=e,r&&r in t))&&((0,n.Z)(e)?g:c).test((0,l.Z)(e));var t},p=function(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return f(i)?i:void 0}},2513:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=(0,i(1851).Z)(Object.getPrototypeOf,Object)},3573:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var n=i(532),o=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols;const r=s?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var i=-1,n=null==e?0:e.length,o=0,s=[];++i{"use strict";i.d(t,{Z:()=>C});var n=i(2119),o=i(6092);const s=(0,n.Z)(o.Z,"DataView");var r=i(6183);const a=(0,n.Z)(o.Z,"Promise"),l=(0,n.Z)(o.Z,"Set"),c=(0,n.Z)(o.Z,"WeakMap");var d=i(3243),u=i(19),h="[object Map]",m="[object Promise]",g="[object Set]",f="[object WeakMap]",p="[object DataView]",b=(0,u.Z)(s),w=(0,u.Z)(r.Z),v=(0,u.Z)(a),_=(0,u.Z)(l),y=(0,u.Z)(c),k=d.Z;(s&&k(new s(new ArrayBuffer(1)))!=p||r.Z&&k(new r.Z)!=h||a&&k(a.resolve())!=m||l&&k(new l)!=g||c&&k(new c)!=f)&&(k=function(e){var t=(0,d.Z)(e),i="[object Object]"==t?e.constructor:void 0,n=i?(0,u.Z)(i):"";if(n)switch(n){case b:return p;case w:return h;case v:return m;case _:return g;case y:return f}return t});const C=k},5418:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l});var n=i(7226),o=Object.create;const s=function(){function e(){}return function(t){if(!(0,n.Z)(t))return{};if(o)return o(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}();var r=i(2513),a=i(2764);const l=function(e){return"function"!=typeof e.constructor||(0,a.Z)(e)?{}:s((0,r.Z)(e))}},6009:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=/^(?:0|[1-9]\d*)$/;const o=function(e,t){var i=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==i||"symbol"!=i&&n.test(e))&&e>-1&&e%1==0&&e{"use strict";i.d(t,{Z:()=>o});var n=Object.prototype;const o=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||n)}},8351:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var n=i(3413),o="object"==typeof exports&&exports&&!exports.nodeType&&exports,s=o&&"object"==typeof module&&module&&!module.nodeType&&module,r=s&&s.exports===o&&n.Z.process;const a=function(){try{return s&&s.require&&s.require("util").types||r&&r.binding&&r.binding("util")}catch(e){}}()},1851:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e,t){return function(i){return e(t(i))}}},6092:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(3413),o="object"==typeof self&&self&&self.Object===Object&&self;const s=n.Z||o||Function("return this")()},19:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=Function.prototype.toString;const o=function(e){if(null!=e){try{return n.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},207:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});var n=i(1899),o=i(288),s=i(7590);const r=(0,o.Z)((function(e,t){(0,n.Z)(t,(0,s.Z)(t),e)}))},4612:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=i(9256);const o=function(e,t){return t="function"==typeof t?t:void 0,(0,n.Z)(e,5,t)}},6682:(e,t,i)=>{"use strict";i.d(t,{Z:()=>b});var n=i(7226),o=i(6092);const s=function(){return o.Z.Date.now()};var r=/\s/;var a=/^\s+/;const l=function(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&r.test(e.charAt(t)););return t}(e)+1).replace(a,""):e};var c=i(2714),d=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,h=/^0o[0-7]+$/i,m=parseInt;const g=function(e){if("number"==typeof e)return e;if((0,c.Z)(e))return NaN;if((0,n.Z)(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=(0,n.Z)(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=l(e);var i=u.test(e);return i||h.test(e)?m(e.slice(2),i?2:8):d.test(e)?NaN:+e};var f=Math.max,p=Math.min;const b=function(e,t,i){var o,r,a,l,c,d,u=0,h=!1,m=!1,b=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function w(t){var i=o,n=r;return o=r=void 0,u=t,l=e.apply(n,i)}function v(e){var i=e-d;return void 0===d||i>=t||i<0||m&&e-u>=a}function _(){var e=s();if(v(e))return y(e);c=setTimeout(_,function(e){var i=t-(e-d);return m?p(i,a-(e-u)):i}(e))}function y(e){return c=void 0,b&&o?w(e):(o=r=void 0,l)}function k(){var e=s(),i=v(e);if(o=arguments,r=this,d=e,i){if(void 0===c)return function(e){return u=e,c=setTimeout(_,t),h?w(e):l}(d);if(m)return clearTimeout(c),c=setTimeout(_,t),w(d)}return void 0===c&&(c=setTimeout(_,t)),l}return t=g(t)||0,(0,n.Z)(i)&&(h=!!i.leading,a=(m="maxWait"in i)?f(g(i.maxWait)||0,t):a,b="trailing"in i?!!i.trailing:b),k.cancel=function(){void 0!==c&&clearTimeout(c),u=0,o=d=r=c=void 0},k.flush=function(){return void 0===c?l:y(s())},k}},9651:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e,t){return e===t||e!=e&&t!=t}},9203:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e){return e}},4732:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c});var n=i(3243),o=i(8533);const s=function(e){return(0,o.Z)(e)&&"[object Arguments]"==(0,n.Z)(e)};var r=Object.prototype,a=r.hasOwnProperty,l=r.propertyIsEnumerable;const c=s(function(){return arguments}())?s:function(e){return(0,o.Z)(e)&&a.call(e,"callee")&&!l.call(e,"callee")}},7771:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=Array.isArray},585:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(3234),o=i(1656);const s=function(e){return null!=e&&(0,o.Z)(e.length)&&!(0,n.Z)(e)}},6706:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var n=i(6092);var o="object"==typeof exports&&exports&&!exports.nodeType&&exports,s=o&&"object"==typeof module&&module&&!module.nodeType&&module,r=s&&s.exports===o?n.Z.Buffer:void 0;const a=(r?r.isBuffer:void 0)||function(){return!1}},3251:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(8533),o=i(7514);const s=function(e){return(0,n.Z)(e)&&1===e.nodeType&&!(0,o.Z)(e)}},576:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var n=i(1152);const o=function(e,t){return(0,n.Z)(e,t)}},3234:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(3243),o=i(7226);const s=function(e){if(!(0,o.Z)(e))return!1;var t=(0,n.Z)(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},1656:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},7226:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},8533:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(e){return null!=e&&"object"==typeof e}},7514:(e,t,i)=>{"use strict";i.d(t,{Z:()=>u});var n=i(3243),o=i(2513),s=i(8533),r=Function.prototype,a=Object.prototype,l=r.toString,c=a.hasOwnProperty,d=l.call(Object);const u=function(e){if(!(0,s.Z)(e)||"[object Object]"!=(0,n.Z)(e))return!1;var t=(0,o.Z)(e);if(null===t)return!0;var i=c.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&l.call(i)==d}},2714:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(3243),o=i(8533);const s=function(e){return"symbol"==typeof e||(0,o.Z)(e)&&"[object Symbol]"==(0,n.Z)(e)}},7212:(e,t,i)=>{"use strict";i.d(t,{Z:()=>d});var n=i(3243),o=i(1656),s=i(8533),r={};r["[object Float32Array]"]=r["[object Float64Array]"]=r["[object Int8Array]"]=r["[object Int16Array]"]=r["[object Int32Array]"]=r["[object Uint8Array]"]=r["[object Uint8ClampedArray]"]=r["[object Uint16Array]"]=r["[object Uint32Array]"]=!0,r["[object Arguments]"]=r["[object Array]"]=r["[object ArrayBuffer]"]=r["[object Boolean]"]=r["[object DataView]"]=r["[object Date]"]=r["[object Error]"]=r["[object Function]"]=r["[object Map]"]=r["[object Number]"]=r["[object Object]"]=r["[object RegExp]"]=r["[object Set]"]=r["[object String]"]=r["[object WeakMap]"]=!1;var a=i(1162),l=i(8351),c=l.Z&&l.Z.isTypedArray;const d=c?(0,a.Z)(c):function(e){return(0,s.Z)(e)&&(0,o.Z)(e.length)&&!!r[(0,n.Z)(e)]}},703:(e,t,i)=>{"use strict";i.d(t,{Z:()=>l});var n=i(9001),o=i(2764);const s=(0,i(1851).Z)(Object.keys,Object);var r=Object.prototype.hasOwnProperty;var a=i(585);const l=function(e){return(0,a.Z)(e)?(0,n.Z)(e):function(e){if(!(0,o.Z)(e))return s(e);var t=[];for(var i in Object(e))r.call(e,i)&&"constructor"!=i&&t.push(i);return t}(e)}},7590:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c});var n=i(9001),o=i(7226),s=i(2764);var r=Object.prototype.hasOwnProperty;const a=function(e){if(!(0,o.Z)(e))return function(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t}(e);var t=(0,s.Z)(e),i=[];for(var n in e)("constructor"!=n||!t&&r.call(e,n))&&i.push(n);return i};var l=i(585);const c=function(e){return(0,l.Z)(e)?(0,n.Z)(e,!0):a(e)}},532:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const n=function(){return[]}},111:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var n=i(6682),o=i(7226);const s=function(e,t,i){var s=!0,r=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return(0,o.Z)(i)&&(s="leading"in i?!!i.leading:s,r="trailing"in i?!!i.trailing:r),(0,n.Z)(e,t,{leading:s,maxWait:t,trailing:r})}},9939:(e,t,i)=>{"use strict";i.d(t,{Z:()=>c});var n=i(7685);var o=i(7771),s=i(2714),r=n.Z?n.Z.prototype:void 0,a=r?r.toString:void 0;const l=function e(t){if("string"==typeof t)return t;if((0,o.Z)(t))return function(e,t){for(var i=-1,n=null==e?0:e.length,o=Array(n);++i{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n=i(366);CKEditor5=n})(); \ No newline at end of file diff --git a/wcfsetup/install/files/style/ckeditor5.css b/wcfsetup/install/files/style/ckeditor5.css index 76b7543a3fd..a857a39e8e2 100644 --- a/wcfsetup/install/files/style/ckeditor5.css +++ b/wcfsetup/install/files/style/ckeditor5.css @@ -76,4 +76,4 @@ .ck.ck-content blockquote{font-style:normal;padding-left:10px}.ck.ck-content blockquote>:first-child{margin-top:10px}.ck.ck-content blockquote>:last-child{margin-bottom:15px}.ck.ck-content blockquote:before{content:attr(data-source);display:block;margin:15px 0 10px} .ck.ck-woltlabcodeblock-insert-form:focus{outline:none}.ck.ck-woltlabcodeblock-insert-form{display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:space-between;padding:var(--ck-spacing-large);row-gap:var(--ck-spacing-large)}.ck.ck-woltlabcodeblock-insert-form>:not(.ck-label){flex-grow:1}.ck.ck-woltlabcodeblock-insert-form__action-row{padding:0}.ck.ck-woltlabcodeblock-insert-form__action-row .ck-button-cancel,.ck.ck-woltlabcodeblock-insert-form__action-row .ck-button-save{justify-content:center}.ck.ck-woltlabcodeblock-insert-form__action-row .ck-button .ck-button__label{color:var(--ck-color-text)} .ck .ck-widget.smiley{pointer-events:none} -.ck.ck-content .ck-woltlabspoiler{margin-top:var(--ck-spacing-large);padding:5px 5px 5px 15px;position:relative}.ck.ck-content .ck-woltlabspoiler:after{border:5px solid #ccc;border-right-width:0;bottom:1px;content:"";left:1px;position:absolute;top:1px;width:5px}.ck.ck-content .ck-woltlabspoiler__title{column-gap:10px;display:flex}.ck.ck-content .ck-woltlabspoiler__title:before{align-self:center;color:#999;content:attr(data-label)} +.ck.ck-content .ck-woltlabspoiler{margin-top:var(--ck-spacing-large);padding:5px 5px 5px 15px;position:relative}.ck.ck-content .ck-woltlabspoiler:after{border:5px solid #ccc;border-right-width:0;bottom:1px;content:"";left:1px;position:absolute;top:1px;width:5px}.ck.ck-content .ck-woltlabspoiler__title:before{align-self:center;color:#999;content:attr(data-label);margin-right:10px}