diff --git a/dist/js/field.js b/dist/js/field.js index 3dfb4fc..e41fae7 100644 --- a/dist/js/field.js +++ b/dist/js/field.js @@ -1,2 +1,2 @@ /*! For license information please see field.js.LICENSE.txt */ -!function(e){const t=e.en=e.en||{};t.dictionary=Object.assign(t.dictionary||{},{"%0 of %1":"%0 of %1","Align center":"Align center","Align left":"Align left","Align right":"Align right",Aquamarine:"Aquamarine",Big:"Big",Black:"Black","Block quote":"Block quote",Blue:"Blue",Bold:"Bold","Break text":"Break text","Bulleted List":"Bulleted List",Cancel:"Cancel","Centered image":"Centered image","Change image text alternative":"Change image text alternative","Choose heading":"Choose heading",Code:"Code",Column:"Column","Decrease indent":"Decrease indent",Default:"Default","Delete column":"Delete column","Delete row":"Delete row","Dim grey":"Dim grey","Document colors":"Document colors",Downloadable:"Downloadable","Dropdown toolbar":"Dropdown toolbar","Edit block":"Edit block","Edit link":"Edit link","Edit source":"Edit source","Editor toolbar":"Editor toolbar","Empty snippet content":"Empty snippet content","Enter image caption":"Enter image caption","Font Background Color":"Font Background Color","Font Color":"Font Color","Font Family":"Font Family","Font Size":"Font Size","Full size image":"Full size image",Green:"Green",Grey:"Grey","Header column":"Header column","Header row":"Header row",Heading:"Heading","Heading 1":"Heading 1","Heading 2":"Heading 2","Heading 3":"Heading 3","Heading 4":"Heading 4","Heading 5":"Heading 5","Heading 6":"Heading 6","Horizontal line":"Horizontal line","HTML snippet":"HTML snippet",Huge:"Huge","Image toolbar":"Image toolbar","image widget":"image widget","In line":"In line","Increase indent":"Increase indent","Insert code block":"Insert code block","Insert column left":"Insert column left","Insert column right":"Insert column right","Insert HTML":"Insert HTML","Insert image":"Insert image","Insert media":"Insert media","Insert paragraph after block":"Insert paragraph after block","Insert paragraph before block":"Insert paragraph before block","Insert row above":"Insert row above","Insert row below":"Insert row below","Insert table":"Insert table",Italic:"Italic",Justify:"Justify","Left aligned image":"Left aligned image","Light blue":"Light blue","Light green":"Light green","Light grey":"Light grey",Link:"Link","Link URL":"Link URL","Media URL":"Media URL","media widget":"media widget","Merge cell down":"Merge cell down","Merge cell left":"Merge cell left","Merge cell right":"Merge cell right","Merge cell up":"Merge cell up","Merge cells":"Merge cells",Next:"Next","No preview available":"No preview available","Numbered List":"Numbered List","Open in a new tab":"Open in a new tab","Open link in new tab":"Open link in new tab",Orange:"Orange",Paragraph:"Paragraph","Paste raw HTML here...":"Paste raw HTML here...","Paste the media URL in the input.":"Paste the media URL in the input.","Plain text":"Plain text",Previous:"Previous",Purple:"Purple",Red:"Red",Redo:"Redo","Remove color":"Remove color","Rich Text Editor":"Rich Text Editor","Rich Text Editor, %0":"Rich Text Editor, %0","Right aligned image":"Right aligned image",Row:"Row",Save:"Save","Save changes":"Save changes","Select all":"Select all","Select column":"Select column","Select row":"Select row","Show more items":"Show more items","Side image":"Side image",Small:"Small",Source:"Source","Split cell horizontally":"Split cell horizontally","Split cell vertically":"Split cell vertically",Strikethrough:"Strikethrough",Subscript:"Subscript",Superscript:"Superscript","Table toolbar":"Table toolbar","Text alignment":"Text alignment","Text alignment toolbar":"Text alignment toolbar","Text alternative":"Text alternative","The URL must not be empty.":"The URL must not be empty.","This link has no URL":"This link has no URL","This media URL is not supported.":"This media URL is not supported.",Tiny:"Tiny","Tip: Paste the URL into the content to embed faster.":"Tip: Paste the URL into the content to embed faster.","Toggle caption off":"Toggle caption off","Toggle caption on":"Toggle caption on",Turquoise:"Turquoise",Underline:"Underline",Undo:"Undo",Unlink:"Unlink","Upload failed":"Upload failed","Upload in progress":"Upload in progress",White:"White","Widget toolbar":"Widget toolbar","Wrap text":"Wrap text",Yellow:"Yellow"})}(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={})),(()=>{var e,t={7757:(e,t,n)=>{e.exports=n(5666)},4074:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});const i={heading:{options:[{model:"paragraph",view:"p",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h1",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h2",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h3",title:"Heading 3",class:"ck-heading_heading3"},{model:"heading4",view:"h4",title:"Heading 4",class:"ck-heading_heading4"},{model:"heading5",view:"h5",title:"Heading 5",class:"ck-heading_heading5"},{model:"heading6",view:"h6",title:"Heading 6",class:"ck-heading_heading6"}]}}},5914:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});const i={htmlEmbed:{showPreviews:!0,sanitizeHtml:function(e){return{html:e,hasChanged:!1}}}}},6713:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});const i={image:{upload:{types:["gif","png","jpg","jpeg","webp"]},toolbar:["imageBrowser","imageStyle:full","imageStyle:alignLeft","imageStyle:alignCenter","imageStyle:alignRight","imageTextAlternative"],styles:["full","alignLeft","alignCenter","alignRight"]}}},4677:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});const i={link:{decorators:{isTargetBlank:{mode:"manual",label:"Target _blank",attributes:{target:"_blank"}},isNoFollow:{mode:"manual",label:"No Follow",attributes:{rel:"nofollow"}}}}}},6305:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});const i={mediaEmbed:{previewsInData:!0,providers:[{name:"youtube",url:[/^https:\/\/www\.youtube\.com\/watch\?v=([\w-]+)/,/^https:\/\/www\.youtube\.com\/v\/([\w-]+)/,/^https:\/\/www\.youtube\.com\/embed\/([\w-]+)/,/^https:\/\/www\.youtu\.be\/([\w-]+)/],html:function(e){return'\n
\n \n
\n ')}}]}}},8179:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});const i={table:{contentToolbar:["tableRow","tableColumn","mergeTableCells"]}}},5215:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});const i={toolbar:{items:["heading","horizontalLine","|","link","|","bold","italic","alignment","subscript","superscript","underline","strikethrough","|","blockQuote","bulletedList","numberedList","|","insertTable","mediaBrowser","mediaEmbed","|","snippetBrowser","htmlEmbed","|","undo","redo"]}}},5022:(e,t,n)=>{"use strict";n.d(t,{Z:()=>i});const i={video:{}}},9910:(e,t,n)=>{"use strict";const i=Vue;var o=["innerHTML"];const r={props:["resourceName","field"],computed:{value:function(){var e=this.field.value.replace(/<[^>]*(>|$)| |‌|»|«|>/g," ").replace(/(<([^>]+)>)/gi,"");return e.length<=this.field.indexLimit?e:e.substring(0,this.field.indexLimit)+"..."}}};var s=n(3744);const a=(0,s.Z)(r,[["render",function(e,t,n,r,s,a){return(0,i.openBlock)(),(0,i.createElementBlock)("div",{innerHTML:a.value},null,8,o)}]]);var c={class:"ckeditor_content"};const l={props:["resource","resourceName","resourceId","field"]};var u=n(3379),d=n.n(u),h=n(8573),f={insert:"head",singleton:!1};d()(h.Z,f);h.Z.locals;const p=(0,s.Z)(l,[["render",function(e,t,n,o,r,s){var a=(0,i.resolveComponent)("excerpt"),l=(0,i.resolveComponent)("panel-item");return(0,i.openBlock)(),(0,i.createBlock)(l,{field:n.field},{value:(0,i.withCtx)((function(){return[(0,i.createElementVNode)("div",c,[(0,i.createVNode)(a,{content:n.field.value,"should-show":n.field.shouldShow,"plain-text":!1},null,8,["content","should-show"])])]})),_:1},8,["field"])}]]);var g=["id","value"];const m=function(){return function e(){e.called=!0}};class b{constructor(e,t){this.source=e,this.name=t,this.path=[],this.stop=m(),this.off=m()}}const w=new Array(256).fill().map(((e,t)=>("0"+t.toString(16)).slice(-2)));function k(){const e=4294967296*Math.random()>>>0,t=4294967296*Math.random()>>>0,n=4294967296*Math.random()>>>0,i=4294967296*Math.random()>>>0;return"e"+w[e>>0&255]+w[e>>8&255]+w[e>>16&255]+w[e>>24&255]+w[t>>0&255]+w[t>>8&255]+w[t>>16&255]+w[t>>24&255]+w[n>>0&255]+w[n>>8&255]+w[n>>16&255]+w[n>>24&255]+w[i>>0&255]+w[i>>8&255]+w[i>>16&255]+w[i>>24&255]}const v={get(e){return"number"!=typeof e?this[e]||this.normal:e},highest:1e5,high:1e3,normal:0,low:-1e3,lowest:-1e5};function _(e,t){const n=v.get(t.priority);for(let i=0;i{if("object"==typeof t&&null!==t){if(n.has(t))return`[object ${t.constructor.name}]`;n.add(t)}return t},o=t?` ${JSON.stringify(t,i)}`:"",r=A(e);return e+o+r}(e,n)),this.name="CKEditorError",this.context=t,this.data=n}is(e){return"CKEditorError"===e}static rethrowUnexpectedError(e,t){if(e.is&&e.is("CKEditorError"))throw e;const n=new y(e.message,t);throw n.stack=e.stack,n}}function x(e,t){console.warn(...E(e,t))}function A(e){return`\nRead more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-${e}`}function E(e,t){const n=A(e);return t?[e,t,n]:[e,n]}const C="34.0.0",T="object"==typeof window?window:n.g;if(T.CKEDITOR_VERSION)throw new y("ckeditor-duplicated-modules",null);T.CKEDITOR_VERSION=C;const S=Symbol("listeningTo"),P=Symbol("emitterId"),I={on(e,t,n={}){this.listenTo(this,e,t,n)},once(e,t,n){let i=!1;this.listenTo(this,e,(function(e,...n){i||(i=!0,e.off(),t.call(this,e,...n))}),n)},off(e,t){this.stopListening(this,e,t)},listenTo(e,t,n,i={}){let o,r;this[S]||(this[S]={});const s=this[S];R(e)||M(e);const a=R(e);(o=s[a])||(o=s[a]={emitter:e,callbacks:{}}),(r=o.callbacks[t])||(r=o.callbacks[t]=[]),r.push(n),function(e,t,n,i,o){t._addEventListener?t._addEventListener(n,i,o):e._addEventListener.call(t,n,i,o)}(this,e,t,n,i)},stopListening(e,t,n){const i=this[S];let o=e&&R(e);const r=i&&o&&i[o],s=r&&t&&r.callbacks[t];if(!(!i||e&&!r||t&&!s))if(n){z(this,e,t,n);-1!==s.indexOf(n)&&(1===s.length?delete r.callbacks[t]:z(this,e,t,n))}else if(s){for(;n=s.pop();)z(this,e,t,n);delete r.callbacks[t]}else if(r){for(t in r.callbacks)this.stopListening(e,t);delete i[o]}else{for(o in i)this.stopListening(i[o].emitter);delete this[S]}},fire(e,...t){try{const n=e instanceof b?e:new b(this,e),i=n.name;let o=D(this,i);if(n.path.push(this),o){const e=[n,...t];o=Array.from(o);for(let t=0;t{this._delegations||(this._delegations=new Map),e.forEach((e=>{const i=this._delegations.get(e);i?i.set(t,n):this._delegations.set(e,new Map([[t,n]]))}))}}},stopDelegating(e,t){if(this._delegations)if(e)if(t){const n=this._delegations.get(e);n&&n.delete(t)}else this._delegations.delete(e);else this._delegations.clear()},_addEventListener(e,t,n){!function(e,t){const n=N(e);if(n[t])return;let i=t,o=null;const r=[];for(;""!==i&&!n[i];)n[i]={callbacks:[],childEvents:[]},r.push(n[i]),o&&n[i].childEvents.push(o),o=i,i=i.substr(0,i.lastIndexOf(":"));if(""!==i){for(const e of r)e.callbacks=n[i].callbacks.slice();n[i].childEvents.push(o)}}(this,e);const i=j(this,e),o={callback:t,priority:v.get(n.priority)};for(const e of i)_(e,o)},_removeEventListener(e,t){const n=j(this,e);for(const e of n)for(let n=0;n-1?D(e,t.substr(0,t.lastIndexOf(":"))):null}function L(e,t,n){for(let[i,o]of e){o?"function"==typeof o&&(o=o(t.name)):o=t.name;const e=new b(t.source,o);e.path=[...t.path],i.fire(e,...n)}}function z(e,t,n,i){t._removeEventListener?t._removeEventListener(n,i):e._removeEventListener.call(t,n,i)}const V=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)};const B="object"==typeof global&&global&&global.Object===Object&&global;var F="object"==typeof self&&self&&self.Object===Object&&self;const H=B||F||Function("return this")();const U=H.Symbol;var W=Object.prototype,q=W.hasOwnProperty,$=W.toString,Z=U?U.toStringTag:void 0;const K=function(e){var t=q.call(e,Z),n=e[Z];try{e[Z]=void 0;var i=!0}catch(e){}var o=$.call(e);return i&&(t?e[Z]=n:delete e[Z]),o};var G=Object.prototype.toString;const Y=function(e){return G.call(e)};var Q=U?U.toStringTag:void 0;const J=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Q&&Q in Object(e)?K(e):Y(e)};const X=function(e){if(!V(e))return!1;var t=J(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};const ee=H["__core-js_shared__"];var te=function(){var e=/[^.]+$/.exec(ee&&ee.keys&&ee.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();const ne=function(e){return!!te&&te in e};var ie=Function.prototype.toString;const oe=function(e){if(null!=e){try{return ie.call(e)}catch(e){}try{return e+""}catch(e){}}return""};var re=/^\[object .+?Constructor\]$/,se=Function.prototype,ae=Object.prototype,ce=se.toString,le=ae.hasOwnProperty,ue=RegExp("^"+ce.call(le).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const de=function(e){return!(!V(e)||ne(e))&&(X(e)?ue:re).test(oe(e))};const he=function(e,t){return null==e?void 0:e[t]};const fe=function(e,t){var n=he(e,t);return de(n)?n:void 0};const pe=function(){try{var e=fe(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();const ge=function(e,t,n){"__proto__"==t&&pe?pe(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n};const me=function(e,t){return e===t||e!=e&&t!=t};var be=Object.prototype.hasOwnProperty;const we=function(e,t,n){var i=e[t];be.call(e,t)&&me(i,n)&&(void 0!==n||t in e)||ge(e,t,n)};const ke=function(e,t,n,i){var o=!n;n||(n={});for(var r=-1,s=t.length;++r0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}};const Se=Te(Ee);const Pe=function(e,t){return Se(xe(e,t,ve),e+"")};const Ie=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991};const Oe=function(e){return null!=e&&Ie(e.length)&&!X(e)};var Me=/^(?:0|[1-9]\d*)$/;const Re=function(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&Me.test(e))&&e>-1&&e%1==0&&e1?n[o-1]:void 0,s=o>2?n[2]:void 0;for(r=e.length>3&&"function"==typeof r?(o--,r):void 0,s&&Ne(n[0],n[1],s)&&(r=o<3?void 0:r,o=1),t=Object(t);++i{this.set(t,e[t])}),this);vt(this);const n=this[ft];if(e in this&&!n.has(e))throw new y("observable-set-cannot-override",this);Object.defineProperty(this,e,{enumerable:!0,configurable:!0,get:()=>n.get(e),set(t){const i=n.get(e);let o=this.fire("set:"+e,e,t,i);void 0===o&&(o=t),i===o&&n.has(e)||(n.set(e,o),this.fire("change:"+e,e,o,i))}}),this[e]=t},bind(...e){if(!e.length||!xt(e))throw new y("observable-bind-wrong-properties",this);if(new Set(e).size!==e.length)throw new y("observable-bind-duplicate-properties",this);vt(this);const t=this[gt];e.forEach((e=>{if(t.has(e))throw new y("observable-bind-rebind",this)}));const n=new Map;return e.forEach((e=>{const i={property:e,to:[]};t.set(e,i),n.set(e,i)})),{to:_t,toMany:yt,_observable:this,_bindProperties:e,_to:[],_bindings:n}},unbind(...e){if(!this[ft])return;const t=this[gt],n=this[pt];if(e.length){if(!xt(e))throw new y("observable-unbind-wrong-properties",this);e.forEach((e=>{const i=t.get(e);if(!i)return;let o,r,s,a;i.to.forEach((e=>{o=e[0],r=e[1],s=n.get(o),a=s[r],a.delete(i),a.size||delete s[r],Object.keys(s).length||(n.delete(o),this.stopListening(o,"change"))})),t.delete(e)}))}else n.forEach(((e,t)=>{this.stopListening(t,"change")})),n.clear(),t.clear()},decorate(e){const t=this[e];if(!t)throw new y("observablemixin-cannot-decorate-undefined",this,{object:this,methodName:e});this.on(e,((e,n)=>{e.return=t.apply(this,n)})),this[e]=function(...t){return this.fire(e,t)},this[e][bt]=t,this[mt]||(this[mt]=[]),this[mt].push(e)}};ht(wt,O),wt.stopListening=function(e,t,n){if(!e&&this[mt]){for(const e of this[mt])this[e]=this[e][bt];delete this[mt]}O.stopListening.call(this,e,t,n)};const kt=wt;function vt(e){e[ft]||(Object.defineProperty(e,ft,{value:new Map}),Object.defineProperty(e,pt,{value:new Map}),Object.defineProperty(e,gt,{value:new Map}))}function _t(...e){const t=function(...e){if(!e.length)throw new y("observable-bind-to-parse-error",null);const t={to:[]};let n;"function"==typeof e[e.length-1]&&(t.callback=e.pop());return e.forEach((e=>{if("string"==typeof e)n.properties.push(e);else{if("object"!=typeof e)throw new y("observable-bind-to-parse-error",null);n={observable:e,properties:[]},t.to.push(n)}})),t}(...e),n=Array.from(this._bindings.keys()),i=n.length;if(!t.callback&&t.to.length>1)throw new y("observable-bind-to-no-callback",this);if(i>1&&t.callback)throw new y("observable-bind-to-extra-callback",this);var o;t.to.forEach((e=>{if(e.properties.length&&e.properties.length!==i)throw new y("observable-bind-to-properties-length",this);e.properties.length||(e.properties=this._bindProperties)})),this._to=t.to,t.callback&&(this._bindings.get(n[0]).callback=t.callback),o=this._observable,this._to.forEach((e=>{const t=o[pt];let n;t.get(e.observable)||o.listenTo(e.observable,"change",((i,r)=>{n=t.get(e.observable)[r],n&&n.forEach((e=>{At(o,e.property)}))}))})),function(e){let t;e._bindings.forEach(((n,i)=>{e._to.forEach((o=>{t=o.properties[n.callback?0:e._bindProperties.indexOf(i)],n.to.push([o.observable,t]),function(e,t,n,i){const o=e[pt],r=o.get(n),s=r||{};s[i]||(s[i]=new Set);s[i].add(t),r||o.set(n,s)}(e._observable,n,o.observable,t)}))}))}(this),this._bindProperties.forEach((e=>{At(this._observable,e)}))}function yt(e,t,n){if(this._bindings.size>1)throw new y("observable-bind-to-many-not-one-binding",this);this.to(...function(e,t){const n=e.map((e=>[e,t]));return Array.prototype.concat.apply([],n)}(e,t),n)}function xt(e){return e.every((e=>"string"==typeof e))}function At(e,t){const n=e[gt].get(t);let i;n.callback?i=n.callback.apply(e,n.to.map((e=>e[0][e[1]]))):(i=n.to[0],i=i[0][i[1]]),Object.prototype.hasOwnProperty.call(e,t)?e[t]=i:e.set(t,i)}function Et(e,...t){t.forEach((t=>{Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t)).forEach((n=>{if(n in e.prototype)return;const i=Object.getOwnPropertyDescriptor(t,n);i.enumerable=!1,Object.defineProperty(e.prototype,n,i)}))}))}class Ct{constructor(e){this.editor=e,this.set("isEnabled",!0),this._disableStack=new Set}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",Tt,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",Tt),this.isEnabled=!0)}destroy(){this.stopListening()}static get isContextPlugin(){return!1}}function Tt(e){e.return=!1,e.stop()}Et(Ct,kt);class St{constructor(e){this.editor=e,this.set("value",void 0),this.set("isEnabled",!1),this.affectsData=!0,this._disableStack=new Set,this.decorate("execute"),this.listenTo(this.editor.model.document,"change",(()=>{this.refresh()})),this.on("execute",(e=>{this.isEnabled||e.stop()}),{priority:"high"}),this.listenTo(e,"change:isReadOnly",((e,t,n)=>{n&&this.affectsData?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")}))}refresh(){this.isEnabled=!0}forceDisabled(e){this._disableStack.add(e),1==this._disableStack.size&&(this.on("set:isEnabled",Pt,{priority:"highest"}),this.isEnabled=!1)}clearForceDisabled(e){this._disableStack.delete(e),0==this._disableStack.size&&(this.off("set:isEnabled",Pt),this.refresh())}execute(){}destroy(){this.stopListening()}}function Pt(e){e.return=!1,e.stop()}Et(St,kt);class It extends St{constructor(e){super(e),this._childCommandsDefinitions=[]}refresh(){}execute(...e){const t=this._getFirstEnabledCommand();return!!t&&t.execute(e)}registerChildCommand(e,t={priority:"normal"}){_(this._childCommandsDefinitions,{command:e,priority:t.priority}),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}}const Ot=function(e,t){return function(n){return e(t(n))}};const Mt=Ot(Object.getPrototypeOf,Object);var Rt=Function.prototype,Nt=Object.prototype,jt=Rt.toString,Dt=Nt.hasOwnProperty,Lt=jt.call(Object);const zt=function(e){if(!Le(e)||"[object Object]"!=J(e))return!1;var t=Mt(e);if(null===t)return!0;var n=Dt.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&jt.call(n)==Lt};const Vt=function(){this.__data__=[],this.size=0};const Bt=function(e,t){for(var n=e.length;n--;)if(me(e[n][0],t))return n;return-1};var Ft=Array.prototype.splice;const Ht=function(e){var t=this.__data__,n=Bt(t,e);return!(n<0)&&(n==t.length-1?t.pop():Ft.call(t,n,1),--this.size,!0)};const Ut=function(e){var t=this.__data__,n=Bt(t,e);return n<0?void 0:t[n][1]};const Wt=function(e){return Bt(this.__data__,e)>-1};const qt=function(e,t){var n=this.__data__,i=Bt(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this};function $t(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t{this._setToTarget(e,i,t[i],n)}))}}function zi(e){return ji(e,Vi)}function Vi(e){return Di(e)?e:void 0}function Bi(e){return!(!e||!e[Symbol.iterator])}class Fi{constructor(e={},t={}){const n=Bi(e);if(n||(t=e),this._items=[],this._itemMap=new Map,this._idProperty=t.idProperty||"id",this._bindToExternalToInternalMap=new WeakMap,this._bindToInternalToExternalMap=new WeakMap,this._skippedIndexesFromExternal=[],n)for(const t of e)this._items.push(t),this._itemMap.set(this._getItemIdBeforeAdding(t),t)}get length(){return this._items.length}get first(){return this._items[0]||null}get last(){return this._items[this.length-1]||null}add(e,t){return this.addMany([e],t)}addMany(e,t){if(void 0===t)t=this._items.length;else if(t>this._items.length||t<0)throw new y("collection-add-item-invalid-index",this);for(let n=0;n{this._setUpBindToBinding((t=>new e(t)))},using:e=>{"function"==typeof e?this._setUpBindToBinding((t=>e(t))):this._setUpBindToBinding((t=>t[e]))}}}_setUpBindToBinding(e){const t=this._bindToCollection,n=(n,i,o)=>{const r=t._bindToCollection==this,s=t._bindToInternalToExternalMap.get(i);if(r&&s)this._bindToExternalToInternalMap.set(i,s),this._bindToInternalToExternalMap.set(s,i);else{const n=e(i);if(!n)return void this._skippedIndexesFromExternal.push(o);let r=o;for(const e of this._skippedIndexesFromExternal)o>e&&r--;for(const e of t._skippedIndexesFromExternal)r>=e&&r++;this._bindToExternalToInternalMap.set(i,n),this._bindToInternalToExternalMap.set(n,i),this.add(n,r);for(let e=0;e{const i=this._bindToExternalToInternalMap.get(t);i&&this.remove(i),this._skippedIndexesFromExternal=this._skippedIndexesFromExternal.reduce(((e,t)=>(nt&&e.push(t),e)),[])}))}_getItemIdBeforeAdding(e){const t=this._idProperty;let n;if(t in e){if(n=e[t],"string"!=typeof n)throw new y("collection-add-invalid-id",this);if(this.get(n))throw new y("collection-add-item-already-exists",this)}else e[t]=n=k();return n}_remove(e){let t,n,i,o=!1;const r=this._idProperty;if("string"==typeof e?(n=e,i=this._itemMap.get(n),o=!i,i&&(t=this._items.indexOf(i))):"number"==typeof e?(t=e,i=this._items[t],o=!i,i&&(n=i[r])):(i=e,n=i[r],t=this._items.indexOf(i),o=-1==t||!this._itemMap.get(n)),o)throw new y("collection-remove-404",this);this._items.splice(t,1),this._itemMap.delete(n);const s=this._bindToInternalToExternalMap.get(i);return this._bindToInternalToExternalMap.delete(i),this._bindToExternalToInternalMap.delete(s),this.fire("remove",i,t),[i,t]}[Symbol.iterator](){return this._items[Symbol.iterator]()}}Et(Fi,O);class Hi{constructor(e,t=[],n=[]){this._context=e,this._plugins=new Map,this._availablePlugins=new Map;for(const e of t)e.pluginName&&this._availablePlugins.set(e.pluginName,e);this._contextPlugins=new Map;for(const[e,t]of n)this._contextPlugins.set(e,t),this._contextPlugins.set(t,e),e.pluginName&&this._availablePlugins.set(e.pluginName,e)}*[Symbol.iterator](){for(const e of this._plugins)"function"==typeof e[0]&&(yield e)}get(e){const t=this._plugins.get(e);if(!t){let t=e;throw"function"==typeof e&&(t=e.pluginName||e.name),new y("plugincollection-plugin-not-loaded",this._context,{plugin:t})}return t}has(e){return this._plugins.has(e)}init(e,t=[],n=[]){const i=this,o=this._context;!function e(t,n=new Set){t.forEach((t=>{a(t)&&(n.has(t)||(n.add(t),t.pluginName&&!i._availablePlugins.has(t.pluginName)&&i._availablePlugins.set(t.pluginName,t),t.requires&&e(t.requires,n)))}))}(e),d(e);const r=[...function e(t,n=new Set){return t.map((e=>a(e)?e:i._availablePlugins.get(e))).reduce(((t,i)=>n.has(i)?t:(n.add(i),i.requires&&(d(i.requires,i),e(i.requires,n).forEach((e=>t.add(e)))),t.add(i))),new Set)}(e.filter((e=>!l(e,t))))];!function(e,t){for(const n of t){if("function"!=typeof n)throw new y("plugincollection-replace-plugin-invalid-type",null,{pluginItem:n});const t=n.pluginName;if(!t)throw new y("plugincollection-replace-plugin-missing-name",null,{pluginItem:n});if(n.requires&&n.requires.length)throw new y("plugincollection-plugin-for-replacing-cannot-have-dependencies",null,{pluginName:t});const o=i._availablePlugins.get(t);if(!o)throw new y("plugincollection-plugin-for-replacing-not-exist",null,{pluginName:t});const r=e.indexOf(o);if(-1===r){if(i._contextPlugins.has(o))return;throw new y("plugincollection-plugin-for-replacing-not-loaded",null,{pluginName:t})}if(o.requires&&o.requires.length)throw new y("plugincollection-replaced-plugin-cannot-have-dependencies",null,{pluginName:t});e.splice(r,1,n),i._availablePlugins.set(t,n)}}(r,n);const s=function(e){return e.map((e=>{const t=i._contextPlugins.get(e)||new e(o);return i._add(e,t),t}))}(r);return h(s,"init").then((()=>h(s,"afterInit"))).then((()=>s));function a(e){return"function"==typeof e}function c(e){return a(e)&&e.isContextPlugin}function l(e,t){return t.some((t=>t===e||(u(e)===t||u(t)===e)))}function u(e){return a(e)?e.pluginName||e.name:e}function d(e,n=null){e.map((e=>a(e)?e:i._availablePlugins.get(e)||e)).forEach((e=>{!function(e,t){if(a(e))return;if(t)throw new y("plugincollection-soft-required",o,{missingPlugin:e,requiredBy:u(t)});throw new y("plugincollection-plugin-not-found",o,{plugin:e})}(e,n),function(e,t){if(!c(t))return;if(c(e))return;throw new y("plugincollection-context-required",o,{plugin:u(e),requiredBy:u(t)})}(e,n),function(e,n){if(!n)return;if(!l(e,t))return;throw new y("plugincollection-required",o,{plugin:u(e),requiredBy:u(n)})}(e,n)}))}function h(e,t){return e.reduce(((e,n)=>n[t]?i._contextPlugins.has(n)?e:e.then(n[t].bind(n)):e),Promise.resolve())}}destroy(){const e=[];for(const[,t]of this)"function"!=typeof t.destroy||this._contextPlugins.has(t)||e.push(t.destroy());return Promise.all(e)}_add(e,t){this._plugins.set(e,t);const n=e.pluginName;if(n){if(this._plugins.has(n))throw new y("plugincollection-plugin-name-conflict",null,{pluginName:n,plugin1:this._plugins.get(n).constructor,plugin2:e});this._plugins.set(n,t)}}}function Ui(e){return Array.isArray(e)?e:[e]}function Wi(e,t,n=1){if("number"!=typeof n)throw new y("translation-service-quantity-not-a-number",null,{quantity:n});const i=Object.keys(window.CKEDITOR_TRANSLATIONS).length;1===i&&(e=Object.keys(window.CKEDITOR_TRANSLATIONS)[0]);const o=t.id||t.string;if(0===i||!function(e,t){return!!window.CKEDITOR_TRANSLATIONS[e]&&!!window.CKEDITOR_TRANSLATIONS[e].dictionary[t]}(e,o))return 1!==n?t.plural:t.string;const r=window.CKEDITOR_TRANSLATIONS[e].dictionary,s=window.CKEDITOR_TRANSLATIONS[e].getPluralForm||(e=>1===e?0:1);if("string"==typeof r[o])return r[o];const a=Number(s(n));return r[o][a]}Et(Hi,O),window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={});const qi=["ar","ara","fa","per","fas","he","heb","ku","kur","ug","uig"];function $i(e){return qi.includes(e)?"rtl":"ltr"}class Zi{constructor(e={}){this.uiLanguage=e.uiLanguage||"en",this.contentLanguage=e.contentLanguage||this.uiLanguage,this.uiLanguageDirection=$i(this.uiLanguage),this.contentLanguageDirection=$i(this.contentLanguage),this.t=(e,t)=>this._t(e,t)}get language(){return console.warn("locale-deprecated-language-property: The Locale#language property has been deprecated and will be removed in the near future. Please use #uiLanguage and #contentLanguage properties instead."),this.uiLanguage}_t(e,t=[]){t=Ui(t),"string"==typeof e&&(e={string:e});const n=!!e.plural?t[0]:1;return function(e,t){return e.replace(/%(\d+)/g,((e,n)=>ne.destroy()))).then((()=>this.plugins.destroy()))}_addEditor(e,t){if(this._contextOwner)throw new y("context-addeditor-private-context");this.editors.add(e),t&&(this._contextOwner=e)}_removeEditor(e){return this.editors.has(e)&&this.editors.remove(e),this._contextOwner===e?this.destroy():Promise.resolve()}_getEditorConfig(){const e={};for(const t of this.config.names())["plugins","removePlugins","extraPlugins"].includes(t)||(e[t]=this.config.get(t));return e}static create(e){return new Promise((t=>{const n=new this(e);t(n.initPlugins().then((()=>n)))}))}}class Gi{constructor(e){this.context=e}destroy(){this.stopListening()}static get isContextPlugin(){return!0}}function Yi(e,t){const n=Math.min(e.length,t.length);for(let i=0;ie.data.length)throw new y("view-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.data.length)throw new y("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+n),this.offsetInText=t}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}is(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e}getAncestors(e={includeSelf:!1,parentFirst:!1}){const t=[];let n=e.includeSelf?this.textNode:this.parent;for(;null!==n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}}function to(e){return Bi(e)?new Map(e):function(e){const t=new Map;for(const n in e)t.set(n,e[n]);return t}(e)}class no{constructor(...e){this._patterns=[],this.add(...e)}add(...e){for(let t of e)("string"==typeof t||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(const t of e)for(const e of this._patterns){const n=io(t,e);if(n)return{element:t,pattern:e,match:n}}return null}matchAll(...e){const t=[];for(const n of e)for(const e of this._patterns){const i=io(n,e);i&&t.push({element:n,pattern:e,match:i})}return t.length>0?t:null}getElementName(){if(1!==this._patterns.length)return null;const e=this._patterns[0],t=e.name;return"function"==typeof e||!t||t instanceof RegExp?null:t}}function io(e,t){if("function"==typeof t)return t(e);const n={};return t.name&&(n.name=function(e,t){if(e instanceof RegExp)return!!t.match(e);return e===t}(t.name,e.name),!n.name)||t.attributes&&(n.attributes=function(e,t){const n=new Set(t.getAttributeKeys());zt(e)?(void 0!==e.style&&x("matcher-pattern-deprecated-attributes-style-key",e),void 0!==e.class&&x("matcher-pattern-deprecated-attributes-class-key",e)):(n.delete("style"),n.delete("class"));return oo(e,n,(e=>t.getAttribute(e)))}(t.attributes,e),!n.attributes)?null:!(t.classes&&(n.classes=function(e,t){return oo(e,t.getClassNames())}(t.classes,e),!n.classes))&&(!(t.styles&&(n.styles=function(e,t){return oo(e,t.getStyleNames(!0),(e=>t.getStyle(e)))}(t.styles,e),!n.styles))&&n)}function oo(e,t,n){const i=function(e){if(Array.isArray(e))return e.map((e=>zt(e)?(void 0!==e.key&&void 0!==e.value||x("matcher-pattern-missing-key-or-value",e),[e.key,e.value]):[e,!0]));if(zt(e))return Object.entries(e);return[[e,!0]]}(e),o=Array.from(t),r=[];return i.forEach((([e,t])=>{o.forEach((i=>{(function(e,t){return!0===e||e===t||e instanceof RegExp&&t.match(e)})(e,i)&&function(e,t,n){if(!0===e)return!0;const i=n(t);return e===i||e instanceof RegExp&&!!String(i).match(e)}(t,i,n)&&r.push(i)}))})),!i.length||r.lengtho?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var r=Array(o);++it===e));return Array.isArray(t)}set(e,t){if(V(e))for(const[t,n]of Object.entries(e))this._styleProcessor.toNormalizedForm(t,n,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t=Uo(e);So(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]&&!V(this._styles[e]))return this._styles[e];const t=this._styleProcessor.getReducedForm(e,this._styles).find((([t])=>t===e));return Array.isArray(t)?t[1]:void 0}getStyleNames(e=!1){if(this.isEmpty)return[];if(e)return this._styleProcessor.getStyleNames(this._styles);return this._getStylesEntries().map((([e])=>e))}clear(){this._styles={}}_getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const n of t)e.push(...this._styleProcessor.getReducedForm(n,this._styles));return e}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const n=t.splice(0,t.length-1).join("."),i=Po(this._styles,n);if(!i)return;!Array.from(Object.keys(i)).length&&this.remove(n)}}class Ho{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,n){if(V(t))Wo(n,Uo(e),t);else if(this._normalizers.has(e)){const i=this._normalizers.get(e),{path:o,value:r}=i(t);Wo(n,o,r)}else Wo(n,e,t)}getNormalized(e,t){if(!e)return zo({},t);if(void 0!==t[e])return t[e];if(this._extractors.has(e)){const n=this._extractors.get(e);if("string"==typeof n)return Po(t,n);const i=n(e,t);if(i)return i}return Po(t,Uo(e))}getReducedForm(e,t){const n=this.getNormalized(e,t);if(void 0===n)return[];if(this._reducers.has(e)){return this._reducers.get(e)(n)}return[[e,n]]}getStyleNames(e){const t=Array.from(this._consumables.keys()).filter((t=>{const n=this.getNormalized(t,e);return n&&"object"==typeof n?Object.keys(n).length:n})),n=new Set([...t,...Object.keys(e)]);return Array.from(n.values())}getRelatedStyles(e){return this._consumables.get(e)||[]}setNormalizer(e,t){this._normalizers.set(e,t)}setExtractor(e,t){this._extractors.set(e,t)}setReducer(e,t){this._reducers.set(e,t)}setStyleRelation(e,t){this._mapStyleNames(e,t);for(const n of t)this._mapStyleNames(n,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function Uo(e){return e.replace("-",".")}function Wo(e,t,n){let i=n;V(n)&&(i=zo({},Po(e,t),n)),Bo(e,t,i)}class qo extends Ji{constructor(e,t,n,i){if(super(e),this.name=t,this._attrs=function(e){e=to(e);for(const[t,n]of e)null===n?e.delete(t):"string"!=typeof n&&e.set(t,String(n));return e}(n),this._children=[],i&&this._insertChild(0,i),this._classes=new Set,this._attrs.has("class")){const e=this._attrs.get("class");$o(this._classes,e),this._attrs.delete("class")}this._styles=new Fo(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style")),this._customProperties=new Map,this._unsafeAttributesToRender=[]}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}is(e,t=null){return t?t===this.name&&("element"===e||"view:element"===e):"element"===e||"view:element"===e||"node"===e||"view:node"===e}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 qo))return!1;if(this===e)return!0;if(this.name!=e.name)return!1;if(this._attrs.size!==e._attrs.size||this._classes.size!==e._classes.size||this._styles.size!==e._styles.size)return!1;for(const[t,n]of this._attrs)if(!e._attrs.has(t)||e._attrs.get(t)!==n)return!1;for(const t of this._classes)if(!e._classes.has(t))return!1;for(const t of this._styles.getStyleNames())if(!e._styles.has(t)||e._styles.getAsString(t)!==this._styles.getAsString(t))return!1;return!0}hasClass(...e){for(const t of e)if(!this._classes.has(t))return!1;return!0}getClassNames(){return this._classes.keys()}getStyle(e){return this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles.getNormalized(e)}getStyleNames(e=!1){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 no(...e);let n=this.parent;for(;n;){if(t.match(n))return n;n=n.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=Array.from(this._classes).sort().join(","),t=this._styles.toString(),n=Array.from(this._attrs).map((e=>`${e[0]}="${e[1]}"`)).sort().join(" ");return this.name+(""==e?"":` class="${e}"`)+(t?` style="${t}"`:"")+(""==n?"":` ${n}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(e=!1){const t=[];if(e)for(const n of this.getChildren())t.push(n._clone(e));const n=new this.constructor(this.document,this.name,this._attrs,t);return n._classes=new Set(this._classes),n._styles.set(this._styles.getNormalized()),n._customProperties=new Map(this._customProperties),n.getFillerOffset=this.getFillerOffset,n}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this);let n=0;const i=function(e,t){if("string"==typeof t)return[new Xi(e,t)];Bi(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new Xi(e,t):t instanceof eo?new Xi(e,t.data):t))}(this.document,t);for(const t of i)null!==t.parent&&t._remove(),t.parent=this,t.document=this.document,this._children.splice(e,0,t),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this);for(let n=e;n0&&(this._classes.clear(),!0):"style"==e?!this._styles.isEmpty&&(this._styles.clear(),!0):this._attrs.delete(e)}_addClass(e){this._fireChange("attributes",this);for(const t of Ui(e))this._classes.add(t)}_removeClass(e){this._fireChange("attributes",this);for(const t of Ui(e))this._classes.delete(t)}_setStyle(e,t){this._fireChange("attributes",this),this._styles.set(e,t)}_removeStyle(e){this._fireChange("attributes",this);for(const t of Ui(e))this._styles.remove(t)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}}function $o(e,t){const n=t.split(/\s+/);e.clear(),n.forEach((t=>e.add(t)))}class Zo extends qo{constructor(e,t,n,i){super(e,t,n,i),this.getFillerOffset=Ko}is(e,t=null){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}}function Ko(){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}class Go extends Zo{constructor(e,t,n,i){super(e,t,n,i),this.set("isReadOnly",!1),this.set("isFocused",!1),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}))}is(e,t=null){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}destroy(){this.stopListening()}}Et(Go,kt);const Yo=Symbol("rootName");class Qo extends Go{constructor(e,t){super(e,t),this.rootName="main"}is(e,t=null){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}get rootName(){return this.getCustomProperty(Yo)}set rootName(e){this._setCustomProperty(Yo,e)}set _name(e){this.name=e}}class Jo{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new y("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new y("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this.position=Xo._createAt(e.startPosition):this.position=Xo._createAt(e.boundaries["backward"==e.direction?"end":"start"]),this.direction=e.direction||"forward",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}skip(e){let t,n,i;do{i=this.position,({done:t,value:n}=this.next())}while(!t&&e(n));t||(this.position=i)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,n=e.parent;if(null===n.parent&&e.offset===n.childCount)return{done:!0};if(n===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0};let i;if(n instanceof Xi){if(e.isAtEnd)return this.position=Xo._createAfter(n),this._next();i=n.data[e.offset]}else i=n.getChild(e.offset);if(i instanceof qo)return this.shallow?e.offset++:e=new Xo(i,0),this.position=e,this._formatReturnValue("elementStart",i,t,e,1);if(i instanceof Xi){if(this.singleCharacters)return e=new Xo(i,0),this.position=e,this._next();{let n,o=i.data.length;return i==this._boundaryEndParent?(o=this.boundaries.end.offset,n=new eo(i,0,o),e=Xo._createAfter(n)):(n=new eo(i,0,i.data.length),e.offset++),this.position=e,this._formatReturnValue("text",n,t,e,o)}}if("string"==typeof i){let i;if(this.singleCharacters)i=1;else{i=(n===this._boundaryEndParent?this.boundaries.end.offset:n.data.length)-e.offset}const o=new eo(n,e.offset,i);return e.offset+=i,this.position=e,this._formatReturnValue("text",o,t,e,i)}return e=Xo._createAfter(n),this.position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",n,t,e)}_previous(){let e=this.position.clone();const t=this.position,n=e.parent;if(null===n.parent&&0===e.offset)return{done:!0};if(n==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0};let i;if(n instanceof Xi){if(e.isAtStart)return this.position=Xo._createBefore(n),this._previous();i=n.data[e.offset-1]}else i=n.getChild(e.offset-1);if(i instanceof qo)return this.shallow?(e.offset--,this.position=e,this._formatReturnValue("elementStart",i,t,e,1)):(e=new Xo(i,i.childCount),this.position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",i,t,e));if(i instanceof Xi){if(this.singleCharacters)return e=new Xo(i,i.data.length),this.position=e,this._previous();{let n,o=i.data.length;if(i==this._boundaryStartParent){const t=this.boundaries.start.offset;n=new eo(i,t,i.data.length-t),o=n.data.length,e=Xo._createBefore(n)}else n=new eo(i,0,i.data.length),e.offset--;return this.position=e,this._formatReturnValue("text",n,t,e,o)}}if("string"==typeof i){let i;if(this.singleCharacters)i=1;else{const t=n===this._boundaryStartParent?this.boundaries.start.offset:0;i=e.offset-t}e.offset-=i;const o=new eo(n,e.offset,i);return this.position=e,this._formatReturnValue("text",o,t,e,i)}return e=Xo._createBefore(n),this.position=e,this._formatReturnValue("elementStart",n,t,e,1)}_formatReturnValue(e,t,n,i,o){return t instanceof eo&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?n=Xo._createAfter(t.textNode):(i=Xo._createAfter(t.textNode),this.position=i)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?n=Xo._createBefore(t.textNode):(i=Xo._createBefore(t.textNode),this.position=i))),{done:!1,value:{type:e,item:t,previousPosition:n,nextPosition:i,length:o}}}}class Xo{constructor(e,t){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 Go);){if(!e.parent)return null;e=e.parent}return e}getShiftedBy(e){const t=Xo._createAt(this),n=t.offset+e;return t.offset=n<0?0:n,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const n=new Jo(t);return n.skip(e),n.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),n=e.getAncestors();let i=0;for(;t[i]==n[i]&&t[i];)i++;return 0===i?null:t[i-1]}is(e){return"position"===e||"view:position"===e}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return"before"==this.compareWith(e)}isAfter(e){return"after"==this.compareWith(e)}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";const t=this.parent.is("node")?this.parent.getPath():[],n=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),n.push(e.offset);const i=Yi(t,n);switch(i){case"prefix":return"before";case"extension":return"after";default:return t[i]0?new this(n,i):new this(i,n)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(Xo._createBefore(e),t)}}function tr(e){return!(!e.item.is("attributeElement")&&!e.item.is("uiElement"))}function nr(e){let t=0;for(const n of e)t++;return t}class ir{constructor(e=null,t,n){this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",this.setTo(e,t,n)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return 1===this.rangeCount&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(const t of this._ranges)e&&!t.start.isBefore(e.start)||(e=t);return e?e.clone():null}getLastRange(){let e=null;for(const t of this._ranges)e&&!t.end.isAfter(e.end)||(e=t);return e?e.clone():null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake)return!1;if(this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel)return!1;if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let n=!1;for(const i of e._ranges)if(t.isEqual(i)){n=!0;break}if(!n)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=nr(this.getRanges());if(t!=nr(e.getRanges()))return!1;if(0==t)return!0;for(let t of this.getRanges()){t=t.getTrimmed();let n=!1;for(let i of e.getRanges())if(i=i.getTrimmed(),t.start.isEqual(i.start)&&t.end.isEqual(i.end)){n=!0;break}if(!n)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(e,t,n){if(null===e)this._setRanges([]),this._setFakeOptions(t);else if(e instanceof ir||e instanceof or)this._setRanges(e.getRanges(),e.isBackward),this._setFakeOptions({fake:e.isFake,label:e.fakeSelectionLabel});else if(e instanceof er)this._setRanges([e],t&&t.backward),this._setFakeOptions(t);else if(e instanceof Xo)this._setRanges([new er(e)]),this._setFakeOptions(t);else if(e instanceof Ji){const i=!!n&&!!n.backward;let o;if(void 0===t)throw new y("view-selection-setto-required-second-parameter",this);o="in"==t?er._createIn(e):"on"==t?er._createOn(e):new er(Xo._createAt(e,t)),this._setRanges([o],i),this._setFakeOptions(n)}else{if(!Bi(e))throw new y("view-selection-setto-not-selectable",this);this._setRanges(e,t&&t.backward),this._setFakeOptions(t)}this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new y("view-selection-setfocus-no-ranges",this);const n=Xo._createAt(e,t);if("same"==n.compareWith(this.focus))return;const i=this.anchor;this._ranges.pop(),"before"==n.compareWith(i)?this._addRange(new er(n,i),!0):this._addRange(new er(i,n)),this.fire("change")}is(e){return"selection"===e||"view:selection"===e}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(const t of e)this._addRange(t);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,t=!1){if(!(e instanceof er))throw new y("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 y("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new er(e.start,e.end))}}Et(ir,O);class or{constructor(e=null,t,n){this._selection=new ir,this._selection.delegate("change").to(this),this._selection.setTo(e,t,n)}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)}is(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e}_setTo(e,t,n){this._selection.setTo(e,t,n)}_setFocus(e,t){this._selection.setFocus(e,t)}}Et(or,O);class rr extends b{constructor(e,t,n){super(e,t),this.startRange=n,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const sr=Symbol("bubbling contexts"),ar={fire(e,...t){try{const n=e instanceof b?e:new b(this,e),i=hr(this);if(!i.size)return;if(lr(n,"capturing",this),ur(i,"$capture",n,...t))return n.return;const o=n.startRange||this.selection.getFirstRange(),r=o?o.getContainedElement():null,s=!!r&&Boolean(dr(i,r));let a=r||function(e){if(!e)return null;const t=e.start.parent,n=e.end.parent,i=t.getPath(),o=n.getPath();return i.length>o.length?t:n}(o);if(lr(n,"atTarget",a),!s){if(ur(i,"$text",n,...t))return n.return;lr(n,"bubbling",a)}for(;a;){if(a.is("rootElement")){if(ur(i,"$root",n,...t))return n.return}else if(a.is("element")&&ur(i,a.name,n,...t))return n.return;if(ur(i,a,n,...t))return n.return;a=a.parent,lr(n,"bubbling",a)}return lr(n,"bubbling",this),ur(i,"$document",n,...t),n.return}catch(e){y.rethrowUnexpectedError(e,this)}},_addEventListener(e,t,n){const i=Ui(n.context||"$document"),o=hr(this);for(const r of i){let i=o.get(r);i||(i=Object.create(O),o.set(r,i)),this.listenTo(i,e,t,n)}},_removeEventListener(e,t){const n=hr(this);for(const i of n.values())this.stopListening(i,e,t)}},cr=ar;function lr(e,t,n){e instanceof rr&&(e._eventPhase=t,e._currentTarget=n)}function ur(e,t,n,...i){const o="string"==typeof t?e.get(t):dr(e,t);return!!o&&(o.fire(n,...i),n.stop.called)}function dr(e,t){for(const[n,i]of e)if("function"==typeof n&&n(t))return i;return null}function hr(e){return e[sr]||(e[sr]=new Map),e[sr]}class fr{constructor(e){this.selection=new or,this.roots=new Fi({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1),this._postFixers=new Set}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.map((e=>e.destroy())),this.stopListening()}_callPostFixers(e){let t=!1;do{for(const n of this._postFixers)if(t=n(e),t)break}while(t)}}Et(fr,cr),Et(fr,kt);class pr extends qo{constructor(e,t,n,i){super(e,t,n,i),this.getFillerOffset=gr,this._priority=10,this._id=null,this._clonesGroup=null}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new y("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}is(e,t=null){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}isSimilar(e){return null!==this.id||null!==e.id?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}_clone(e){const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}}function gr(){if(mr(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(mr(e)>1)return null;e=e.parent}return!e||mr(e)>1?null:this.childCount}function mr(e){return Array.from(e.getChildren()).filter((e=>!e.is("uiElement"))).length}pr.DEFAULT_PRIORITY=10;class br extends qo{constructor(e,t,n,i){super(e,t,n,i),this.getFillerOffset=wr}is(e,t=null){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}_insertChild(e,t){if(t&&(t instanceof Ji||Array.from(t).length>0))throw new y("view-emptyelement-cannot-add",[this,t])}}function wr(){return null}const kr=navigator.userAgent.toLowerCase(),vr={isMac:yr(kr),isWindows:function(e){return e.indexOf("windows")>-1}(kr),isGecko:function(e){return!!e.match(/gecko\/\d+/)}(kr),isSafari:function(e){return e.indexOf(" applewebkit/")>-1&&-1===e.indexOf("chrome")}(kr),isiOS:function(e){return!!e.match(/iphone|ipad/i)||yr(e)&&navigator.maxTouchPoints>0}(kr),isAndroid:function(e){return e.indexOf("android")>-1}(kr),isBlink:function(e){return e.indexOf("chrome/")>-1&&e.indexOf("edge/")<0}(kr),features:{isRegExpUnicodePropertySupported:function(){let e=!1;try{e=0==="ć".search(new RegExp("[\\p{L}]","u"))}catch(e){}return e}()}},_r=vr;function yr(e){return e.indexOf("macintosh")>-1}const xr={ctrl:"⌃",cmd:"⌘",alt:"⌥",shift:"⇧"},Ar={ctrl:"Ctrl+",alt:"Alt+",shift:"Shift+"},Er=function(){const e={arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,backspace:8,delete:46,enter:13,space:32,esc:27,tab:9,ctrl:1114112,shift:2228224,alt:4456448,cmd:8912896};for(let t=65;t<=90;t++){const n=String.fromCharCode(t);e[n.toLowerCase()]=t}for(let t=48;t<=57;t++)e[t-48]=t;for(let t=112;t<=123;t++)e["f"+(t-111)]=t;for(const t of"`-=[];',./\\")e[t]=t.charCodeAt(0);return e}(),Cr=Object.fromEntries(Object.entries(Er).map((([e,t])=>[t,e.charAt(0).toUpperCase()+e.slice(1)])));function Tr(e){let t;if("string"==typeof e){if(t=Er[e.toLowerCase()],!t)throw new y("keyboard-unknown-key",null,{key:e})}else t=e.keyCode+(e.altKey?Er.alt:0)+(e.ctrlKey?Er.ctrl:0)+(e.shiftKey?Er.shift:0)+(e.metaKey?Er.cmd:0);return t}function Sr(e){return"string"==typeof e&&(e=function(e){return e.split("+").map((e=>e.trim()))}(e)),e.map((e=>"string"==typeof e?function(e){if(e.endsWith("!"))return Tr(e.slice(0,-1));const t=Tr(e);return _r.isMac&&t==Er.ctrl?Er.cmd:t}(e):e)).reduce(((e,t)=>t+e),0)}function Pr(e){let t=Sr(e);return Object.entries(_r.isMac?xr:Ar).reduce(((e,[n,i])=>(0!=(t&Er[n])&&(t&=~Er[n],e+=i),e)),"")+(t?Cr[t]:"")}function Ir(e,t){const n="ltr"===t;switch(e){case Er.arrowleft:return n?"left":"right";case Er.arrowright:return n?"right":"left";case Er.arrowup:return"up";case Er.arrowdown:return"down"}}class Or extends qo{constructor(e,t,n,i){super(e,t,n,i),this.getFillerOffset=Rr}is(e,t=null){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}_insertChild(e,t){if(t&&(t instanceof Ji||Array.from(t).length>0))throw new y("view-uielement-cannot-add",this)}render(e){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 Mr(e){e.document.on("arrowKey",((t,n)=>function(e,t,n){if(t.keyCode==Er.arrowright){const e=t.domTarget.ownerDocument.defaultView.getSelection(),i=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(i||t.shiftKey){const t=e.focusNode,o=e.focusOffset,r=n.domPositionToView(t,o);if(null===r)return;let s=!1;const a=r.getLastMatchingPosition((e=>(e.item.is("uiElement")&&(s=!0),!(!e.item.is("uiElement")&&!e.item.is("attributeElement")))));if(s){const t=n.viewPositionToDom(a);i?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}}(0,n,e.domConverter)),{priority:"low"})}function Rr(){return null}class Nr extends qo{constructor(e,t,n,i){super(e,t,n,i),this.getFillerOffset=jr}is(e,t=null){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}_insertChild(e,t){if(t&&(t instanceof Ji||Array.from(t).length>0))throw new y("view-rawelement-cannot-add",[this,t])}}function jr(){return null}class Dr{constructor(e,t){this.document=e,this._children=[],t&&this._insertChild(0,t)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return 0===this.childCount}get root(){return this}get parent(){return null}is(e){return"documentFragment"===e||"view:documentFragment"===e}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,t){this._fireChange("children",this);let n=0;const i=function(e,t){if("string"==typeof t)return[new Xi(e,t)];Bi(t)||(t=[t]);return Array.from(t).map((t=>"string"==typeof t?new Xi(e,t):t instanceof eo?new Xi(e,t.data):t))}(this.document,t);for(const t of i)null!==t.parent&&t._remove(),t.parent=this,this._children.splice(e,0,t),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this);for(let n=e;n{}),i.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),o}setAttribute(e,t,n){n._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){zt(e)&&void 0===n&&(n=t),n._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,n){n._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}breakAttributes(e){return e instanceof Xo?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){const t=e.parent;if(!t.is("containerElement"))throw new y("view-writer-break-non-container-element",this.document);if(!t.parent)throw new y("view-writer-break-root",this.document);if(e.isAtStart)return Xo._createBefore(t);if(!e.isAtEnd){const n=t._clone(!1);this.insert(Xo._createAfter(t),n);const i=new er(e,Xo._createAt(t,"end")),o=new Xo(n,0);this.move(i,o)}return Xo._createAfter(t)}mergeAttributes(e){const t=e.offset,n=e.parent;if(n.is("$text"))return e;if(n.is("attributeElement")&&0===n.childCount){const e=n.parent,t=n.index;return n._remove(),this._removeFromClonedElementsGroup(n),this.mergeAttributes(new Xo(e,t))}const i=n.getChild(t-1),o=n.getChild(t);if(!i||!o)return e;if(i.is("$text")&&o.is("$text"))return Hr(i,o);if(i.is("attributeElement")&&o.is("attributeElement")&&i.isSimilar(o)){const e=i.childCount;return i._appendChild(o.getChildren()),o._remove(),this._removeFromClonedElementsGroup(o),this.mergeAttributes(new Xo(i,e))}return e}mergeContainers(e){const t=e.nodeBefore,n=e.nodeAfter;if(!(t&&n&&t.is("containerElement")&&n.is("containerElement")))throw new y("view-writer-merge-containers-invalid-position",this.document);const i=t.getChild(t.childCount-1),o=i instanceof Xi?Xo._createAt(i,"end"):Xo._createAt(t,"end");return this.move(er._createIn(n),Xo._createAt(t,"end")),this.remove(er._createOn(n)),o}insert(e,t){Ur(t=Bi(t)?[...t]:[t],this.document);const n=t.reduce(((e,t)=>{const n=e[e.length-1],i=!t.is("uiElement");return n&&n.breakAttributes==i?n.nodes.push(t):e.push({breakAttributes:i,nodes:[t]}),e}),[]);let i=null,o=e;for(const{nodes:e,breakAttributes:t}of n){const n=this._insertNodes(o,e,t);i||(i=n.start),o=n.end}return i?new er(i,o):new er(e)}remove(e){const t=e instanceof er?e:er._createOn(e);if($r(t,this.document),t.isCollapsed)return new Dr(this.document);const{start:n,end:i}=this._breakAttributesRange(t,!0),o=n.parent,r=i.offset-n.offset,s=o._removeChildren(n.offset,r);for(const e of s)this._removeFromClonedElementsGroup(e);const a=this.mergeAttributes(n);return t.start=a,t.end=a.clone(),new Dr(this.document,s)}clear(e,t){$r(e,this.document);const n=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const i of n){const n=i.item;let o;if(n.is("element")&&t.isSimilar(n))o=er._createOn(n);else if(!i.nextPosition.isAfter(e.start)&&n.is("$textProxy")){const e=n.getAncestors().find((e=>e.is("element")&&t.isSimilar(e)));e&&(o=er._createIn(e))}o&&(o.end.isAfter(e.end)&&(o.end=e.end),o.start.isBefore(e.start)&&(o.start=e.start),this.remove(o))}}move(e,t){let n;if(t.isAfter(e.end)){const i=(t=this._breakAttributes(t,!0)).parent,o=i.childCount;e=this._breakAttributesRange(e,!0),n=this.remove(e),t.offset+=i.childCount-o}else n=this.remove(e);return this.insert(t,n)}wrap(e,t){if(!(t instanceof pr))throw new y("view-writer-wrap-invalid-attribute",this.document);if($r(e,this.document),e.isCollapsed){let i=e.start;i.parent.is("element")&&(n=i.parent,!Array.from(n.getChildren()).some((e=>!e.is("uiElement"))))&&(i=i.getLastMatchingPosition((e=>e.item.is("uiElement")))),i=this._wrapPosition(i,t);const o=this.document.selection;return o.isCollapsed&&o.getFirstPosition().isEqual(e.start)&&this.setSelection(i),new er(i)}return this._wrapRange(e,t);var n}unwrap(e,t){if(!(t instanceof pr))throw new y("view-writer-unwrap-invalid-attribute",this.document);if($r(e,this.document),e.isCollapsed)return e;const{start:n,end:i}=this._breakAttributesRange(e,!0),o=n.parent,r=this._unwrapChildren(o,n.offset,i.offset,t),s=this.mergeAttributes(r.start);s.isEqual(r.start)||r.end.offset--;const a=this.mergeAttributes(r.end);return new er(s,a)}rename(e,t){const n=new Zo(this.document,e,t.getAttributes());return this.insert(Xo._createAfter(t),n),this.move(er._createIn(t),Xo._createAt(n,0)),this.remove(er._createOn(t)),n}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return Xo._createAt(e,t)}createPositionAfter(e){return Xo._createAfter(e)}createPositionBefore(e){return Xo._createBefore(e)}createRange(e,t){return new er(e,t)}createRangeOn(e){return er._createOn(e)}createRangeIn(e){return er._createIn(e)}createSelection(e,t,n){return new ir(e,t,n)}createSlot(e){if(!this._slotFactory)throw new y("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,n){let i,o;if(i=n?zr(e):e.parent.is("$text")?e.parent.parent:e.parent,!i)throw new y("view-writer-invalid-position-container",this.document);o=n?this._breakAttributes(e,!0):e.parent.is("$text")?Fr(e):e;const r=i._insertChild(o.offset,t);for(const e of t)this._addToClonedElementsGroup(e);const s=o.getShiftedBy(r),a=this.mergeAttributes(o);a.isEqual(o)||s.offset--;const c=this.mergeAttributes(s);return new er(a,c)}_wrapChildren(e,t,n,i){let o=t;const r=[];for(;o!1,e.parent._insertChild(e.offset,n);const i=new er(e,e.getShiftedBy(1));this.wrap(i,t);const o=new Xo(n.parent,n.index);n._remove();const r=o.nodeBefore,s=o.nodeAfter;return r instanceof Xi&&s instanceof Xi?Hr(r,s):Br(o)}_wrapAttributeElement(e,t){if(!Zr(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const n of e.getAttributeKeys())if("class"!==n&&"style"!==n&&t.hasAttribute(n)&&t.getAttribute(n)!==e.getAttribute(n))return!1;for(const n of e.getStyleNames())if(t.hasStyle(n)&&t.getStyle(n)!==e.getStyle(n))return!1;for(const n of e.getAttributeKeys())"class"!==n&&"style"!==n&&(t.hasAttribute(n)||this.setAttribute(n,e.getAttribute(n),t));for(const n of e.getStyleNames())t.hasStyle(n)||this.setStyle(n,e.getStyle(n),t);for(const n of e.getClassNames())t.hasClass(n)||this.addClass(n,t);return!0}_unwrapAttributeElement(e,t){if(!Zr(e,t))return!1;if(e.name!==t.name||e.priority!==t.priority)return!1;for(const n of e.getAttributeKeys())if("class"!==n&&"style"!==n&&(!t.hasAttribute(n)||t.getAttribute(n)!==e.getAttribute(n)))return!1;if(!t.hasClass(...e.getClassNames()))return!1;for(const n of e.getStyleNames())if(!t.hasStyle(n)||t.getStyle(n)!==e.getStyle(n))return!1;for(const n of e.getAttributeKeys())"class"!==n&&"style"!==n&&this.removeAttribute(n,t);return this.removeClass(Array.from(e.getClassNames()),t),this.removeStyle(Array.from(e.getStyleNames()),t),!0}_breakAttributesRange(e,t=!1){const n=e.start,i=e.end;if($r(e,this.document),e.isCollapsed){const n=this._breakAttributes(e.start,t);return new er(n,n)}const o=this._breakAttributes(i,t),r=o.parent.childCount,s=this._breakAttributes(n,t);return o.offset+=o.parent.childCount-r,new er(s,o)}_breakAttributes(e,t=!1){const n=e.offset,i=e.parent;if(e.parent.is("emptyElement"))throw new y("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new y("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new y("view-writer-cannot-break-raw-element",this.document);if(!t&&i.is("$text")&&qr(i.parent))return e.clone();if(qr(i))return e.clone();if(i.is("$text"))return this._breakAttributes(Fr(e),t);if(n==i.childCount){const e=new Xo(i.parent,i.index+1);return this._breakAttributes(e,t)}if(0===n){const e=new Xo(i.parent,i.index);return this._breakAttributes(e,t)}{const e=i.index+1,o=i._clone();i.parent._insertChild(e,o),this._addToClonedElementsGroup(o);const r=i.childCount-n,s=i._removeChildren(n,r);o._appendChild(s);const a=new Xo(i.parent,e);return this._breakAttributes(a,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const t of e.getChildren())this._addToClonedElementsGroup(t);const t=e.id;if(!t)return;let n=this._cloneGroups.get(t);n||(n=new Set,this._cloneGroups.set(t,n)),n.add(e),e._clonesGroup=n}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const t of e.getChildren())this._removeFromClonedElementsGroup(t);const t=e.id;if(!t)return;const n=this._cloneGroups.get(t);n&&n.delete(e)}}function zr(e){let t=e.parent;for(;!qr(t);){if(!t)return;t=t.parent}return t}function Vr(e,t){return e.priorityt.priority)&&e.getIdentity()n instanceof e)))throw new y("view-writer-insert-invalid-node-type",t);n.is("$text")||Ur(n.getChildren(),t)}}const Wr=[Xi,pr,Zo,br,Nr,Or];function qr(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function $r(e,t){const n=zr(e.start),i=zr(e.end);if(!n||!i||n!==i)throw new y("view-writer-invalid-range-container",t)}function Zr(e,t){return null===e.id&&null===t.id}function Kr(e){return"[object Text]"==Object.prototype.toString.call(e)}const Gr=e=>e.createTextNode(" "),Yr=e=>{const t=e.createElement("span");return t.dataset.ckeFiller=!0,t.innerHTML=" ",t},Qr=e=>{const t=e.createElement("br");return t.dataset.ckeFiller=!0,t},Jr="⁠".repeat(7);function Xr(e){return Kr(e)&&e.data.substr(0,7)===Jr}function es(e){return 7==e.data.length&&Xr(e)}function ts(e){return Xr(e)?e.data.slice(7):e.data}function ns(e,t){if(t.keyCode==Er.arrowleft){const e=t.domTarget.ownerDocument.defaultView.getSelection();if(1==e.rangeCount&&e.getRangeAt(0).collapsed){const t=e.getRangeAt(0).startContainer,n=e.getRangeAt(0).startOffset;Xr(t)&&n<=7&&e.collapse(t,0)}}}function is(e,t,n,i=!1){n=n||function(e,t){return e===t},Array.isArray(e)||(e=Array.prototype.slice.call(e)),Array.isArray(t)||(t=Array.prototype.slice.call(t));const o=function(e,t,n){const i=os(e,t,n);if(-1===i)return{firstIndex:-1,lastIndexOld:-1,lastIndexNew:-1};const o=rs(e,i),r=rs(t,i),s=os(o,r,n),a=e.length-s,c=t.length-s;return{firstIndex:i,lastIndexOld:a,lastIndexNew:c}}(e,t,n);return i?function(e,t){const{firstIndex:n,lastIndexOld:i,lastIndexNew:o}=e;if(-1===n)return Array(t).fill("equal");let r=[];n>0&&(r=r.concat(Array(n).fill("equal")));o-n>0&&(r=r.concat(Array(o-n).fill("insert")));i-n>0&&(r=r.concat(Array(i-n).fill("delete")));o0&&n.push({index:i,type:"insert",values:e.slice(i,r)});o-i>0&&n.push({index:i+(r-i),type:"delete",howMany:o-i});return n}(t,o)}function os(e,t,n){for(let i=0;i200||o>200||i+o>300)return ss.fastDiff(e,t,n,!0);let r,s;if(ol?-1:1;u[i+h]&&(u[i]=u[i+h].slice(0)),u[i]||(u[i]=[]),u[i].push(o>l?r:s);let f=Math.max(o,l),p=f-i;for(;pl;f--)d[f]=h(f);d[l]=h(l),p++}while(d[l]!==c);return u[l].slice(1)}function as(e,t,n){e.insertBefore(n,e.childNodes[t]||null)}function cs(e){const t=e.parentNode;t&&t.removeChild(e)}function ls(e){return e&&e.nodeType===Node.COMMENT_NODE}function us(e){if(e){if(e.defaultView)return e instanceof e.defaultView.Document;if(e.ownerDocument&&e.ownerDocument.defaultView)return e instanceof e.ownerDocument.defaultView.Node}return!1}ss.fastDiff=is;var ds=n(1237),hs={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(ds.Z,hs);ds.Z.locals;class fs{constructor(e,t){this.domDocuments=new Set,this.domConverter=e,this.markedAttributes=new Set,this.markedChildren=new Set,this.markedTexts=new Set,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),_r.isBlink&&!_r.isAndroid&&this.on("change:isSelecting",(()=>{this.isSelecting||this.render()})),this._inlineFiller=null,this._fakeSelectionContainer=null}markToSync(e,t){if("text"===e)this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if("attributes"===e)this.markedAttributes.add(t);else{if("children"!==e)throw new y("view-renderer-unknown-type",this);this.markedChildren.add(t)}}}render(){let e;const t=!(_r.isBlink&&!_r.isAndroid)||!this.isSelecting;for(const e of this.markedChildren)this._updateChildrenMappings(e);t?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?e=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(e=this.selection.getFirstPosition(),this.markedChildren.add(e.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(e=this.domConverter.domPositionToView(this._inlineFiller));for(const e of this.markedAttributes)this._updateAttrs(e);for(const t of this.markedChildren)this._updateChildren(t,{inlineFillerPosition:e});for(const t of this.markedTexts)!this.markedChildren.has(t.parent)&&this.domConverter.mapViewToDom(t.parent)&&this._updateText(t,{inlineFillerPosition:e});if(t)if(e){const t=this.domConverter.viewPositionToDom(e),n=t.parent.ownerDocument;Xr(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=ps(n,t.parent,t.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const n=Array.from(this.domConverter.mapViewToDom(e).childNodes),i=Array.from(this.domConverter.viewChildrenToDom(e,t.ownerDocument,{withChildren:!1})),o=this._diffNodeLists(n,i),r=this._findReplaceActions(o,n,i);if(-1!==r.indexOf("replace")){const t={equal:0,insert:0,delete:0};for(const o of r)if("replace"===o){const o=t.equal+t.insert,r=t.equal+t.delete,s=e.getChild(o);!s||s.is("uiElement")||s.is("rawElement")||this._updateElementMappings(s,n[r]),cs(i[o]),t.equal++}else t[o]++}}_updateElementMappings(e,t){this.domConverter.unbindDomElement(t),this.domConverter.bindElements(t,e),this.markedChildren.add(e),this.markedAttributes.add(e)}_getInlineFillerPosition(){const e=this.selection.getFirstPosition();return e.parent.is("$text")?Xo._createBefore(this.selection.getFirstPosition().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&&Kr(t.parent)&&Xr(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!Xr(e))throw new y("view-renderer-filler-was-lost",this);es(e)?e.remove():e.data=e.data.substr(7),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,n=e.offset;if(!this.domConverter.mapViewToDom(t.root))return!1;if(!t.is("element"))return!1;if(!function(e){if("false"==e.getAttribute("contenteditable"))return!1;const t=e.findAncestor((e=>e.hasAttribute("contenteditable")));return!t||"true"==t.getAttribute("contenteditable")}(t))return!1;if(n===t.getFillerOffset())return!1;const i=e.nodeBefore,o=e.nodeAfter;return!(i instanceof Xi||o instanceof Xi)}_updateText(e,t){const n=this.domConverter.findCorrespondingDomText(e),i=this.domConverter.viewToDom(e,n.ownerDocument),o=n.data;let r=i.data;const s=t.inlineFillerPosition;if(s&&s.parent==e.parent&&s.offset==e.index&&(r=Jr+r),o!=r){const e=is(o,r);for(const t of e)"insert"===t.type?n.insertData(t.index,t.values.join("")):n.deleteData(t.index,t.howMany)}}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const n=Array.from(t.attributes).map((e=>e.name)),i=e.getAttributeKeys();for(const n of i)this.domConverter.setDomElementAttribute(t,n,e.getAttribute(n),e);for(const i of n)e.hasAttribute(i)||this.domConverter.removeDomElementAttribute(t,i)}_updateChildren(e,t){const n=this.domConverter.mapViewToDom(e);if(!n)return;const i=t.inlineFillerPosition,o=this.domConverter.mapViewToDom(e).childNodes,r=Array.from(this.domConverter.viewChildrenToDom(e,n.ownerDocument,{bind:!0}));i&&i.parent===e&&ps(n.ownerDocument,r,i.offset);const s=this._diffNodeLists(o,r);let a=0;const c=new Set;for(const e of s)"delete"===e?(c.add(o[a]),cs(o[a])):"equal"===e&&a++;a=0;for(const e of s)"insert"===e?(as(n,a,r[a]),a++):"equal"===e&&(this._markDescendantTextToSync(this.domConverter.domToView(r[a])),a++);for(const e of c)e.parentNode||this.domConverter.unbindDomElement(e)}_diffNodeLists(e,t){return ss(e=function(e,t){const n=Array.from(e);if(0==n.length||!t)return n;n[n.length-1]==t&&n.pop();return n}(e,this._fakeSelectionContainer),t,ms.bind(null,this.domConverter))}_findReplaceActions(e,t,n){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let i=[],o=[],r=[];const s={equal:0,insert:0,delete:0};for(const a of e)"insert"===a?r.push(n[s.equal+s.insert]):"delete"===a?o.push(t[s.equal+s.delete]):(i=i.concat(ss(o,r,gs).map((e=>"equal"===e?"replace":e))),i.push("equal"),o=[],r=[]),s[a]++;return i.concat(ss(o,r,gs).map((e=>"equal"===e?"replace":e)))}_markDescendantTextToSync(e){if(e)if(e.is("$text"))this.markedTexts.add(e);else if(e.is("element"))for(const t of e.getChildren())this._markDescendantTextToSync(t)}_updateSelection(){if(_r.isBlink&&!_r.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(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._removeFakeSelection(),this._updateDomSelection(e)))}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=function(e){const t=e.createElement("div");return t.className="ck-fake-selection-container",Object.assign(t.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),t.textContent=" ",t}(t));const n=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(n,this.selection),!this._fakeSelectionNeedsUpdate(e))return;n.parentElement&&n.parentElement==e||e.appendChild(n),n.textContent=this.selection.fakeSelectionLabel||" ";const i=t.getSelection(),o=t.createRange();i.removeAllRanges(),o.selectNodeContents(n),i.addRange(o)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const n=this.domConverter.viewPositionToDom(this.selection.anchor),i=this.domConverter.viewPositionToDom(this.selection.focus);t.collapse(n.parent,n.offset),t.extend(i.parent,i.offset),_r.isGecko&&function(e,t){const n=e.parent;if(n.nodeType!=Node.ELEMENT_NODE||e.offset!=n.childNodes.length-1)return;const i=n.childNodes[e.offset];i&&"BR"==i.tagName&&t.addRange(t.getRangeAt(0))}(i,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return(!t||!this.selection.isEqual(t))&&!(!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,n=e.ownerDocument.getSelection();return!t||t.parentElement!==e||(n.anchorNode!==t&&!t.contains(n.anchorNode)||t.textContent!==this.selection.fakeSelectionLabel)}_removeDomSelection(){for(const e of this.domDocuments){if(e.getSelection().rangeCount){const t=e.activeElement,n=this.domConverter.mapDomToView(t);t&&n&&e.getSelection().removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function ps(e,t,n){const i=t instanceof Array?t:t.childNodes,o=i[n];if(Kr(o))return o.data=Jr+o.data,o;{const o=e.createTextNode(Jr);return Array.isArray(t)?i.splice(n,0,o):as(t,n,o),o}}function gs(e,t){return us(e)&&us(t)&&!Kr(e)&&!Kr(t)&&!ls(e)&&!ls(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function ms(e,t,n){return t===n||(Kr(t)&&Kr(n)?t.data===n.data:!(!e.isBlockFiller(t)||!e.isBlockFiller(n)))}Et(fs,kt);const bs={window,document};function ws(e){let t=0;for(;e.previousSibling;)e=e.previousSibling,t++;return t}function ks(e){const t=[];for(;e&&e.nodeType!=Node.DOCUMENT_NODE;)t.unshift(e),e=e.parentNode;return t}const vs=Qr(document),_s=Gr(document),ys=Yr(document),xs="data-ck-unsafe-attribute-",As="data-ck-unsafe-element",Es=["script","style"];class Cs{constructor(e,t={}){this.document=e,this.renderingMode=t.renderingMode||"editing",this.blockFillerMode=t.blockFillerMode||("editing"===this.renderingMode?"br":"nbsp"),this.preElements=["pre"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this._domToViewMapping=new WeakMap,this._viewToDomMapping=new WeakMap,this._fakeSelectionMapping=new WeakMap,this._rawContentElementMatcher=new no,this._encounteredRawContentDomNodes=new WeakSet}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new ir(t))}fakeSelectionToView(e){return this._fakeSelectionMapping.get(e)}bindElements(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}unbindDomElement(e){const t=this._domToViewMapping.get(e);if(t){this._domToViewMapping.delete(e),this._viewToDomMapping.delete(t);for(const t of e.childNodes)this.unbindDomElement(t)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,n){return"data"===this.renderingMode||!(e=e.toLowerCase()).startsWith("on")&&(("srcdoc"!==e||!t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i))&&("img"===n&&("src"===e||"srcset"===e)||("source"===n&&"srcset"===e||!t.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))))}setContentOf(e,t){if("data"===this.renderingMode)return void(e.innerHTML=t);const n=(new DOMParser).parseFromString(t,"text/html"),i=n.createDocumentFragment(),o=n.body.childNodes;for(;o.length>0;)i.appendChild(o[0]);const r=n.createTreeWalker(i,NodeFilter.SHOW_ELEMENT),s=[];let a;for(;a=r.nextNode();)s.push(a);for(const e of s){for(const t of e.getAttributeNames())this.setDomElementAttribute(e,t,e.getAttribute(t));const t=e.tagName.toLowerCase();this._shouldRenameElement(t)&&(Ps(t),e.replaceWith(this._createReplacementDomElement(t,e)))}for(;e.firstChild;)e.firstChild.remove();e.append(i)}viewToDom(e,t,n={}){if(e.is("$text")){const n=this._processDataFromViewText(e);return t.createTextNode(n)}{if(this.mapViewToDom(e))return this.mapViewToDom(e);let i;if(e.is("documentFragment"))i=t.createDocumentFragment(),n.bind&&this.bindDocumentFragments(i,e);else{if(e.is("uiElement"))return i="$comment"===e.name?t.createComment(e.getCustomProperty("$rawContent")):e.render(t,this),n.bind&&this.bindElements(i,e),i;this._shouldRenameElement(e.name)?(Ps(e.name),i=this._createReplacementDomElement(e.name)):i=e.hasAttribute("xmlns")?t.createElementNS(e.getAttribute("xmlns"),e.name):t.createElement(e.name),e.is("rawElement")&&e.render(i,this),n.bind&&this.bindElements(i,e);for(const t of e.getAttributeKeys())this.setDomElementAttribute(i,t,e.getAttribute(t),e)}if(!1!==n.withChildren)for(const o of this.viewChildrenToDom(e,t,n))i.appendChild(o);return i}}setDomElementAttribute(e,t,n,i=null){const o=this.shouldRenderAttribute(t,n,e.tagName.toLowerCase())||i&&i.shouldRenderUnsafeAttribute(t);o||x("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:n}),e.hasAttribute(t)&&!o?e.removeAttribute(t):e.hasAttribute(xs+t)&&o&&e.removeAttribute(xs+t),e.setAttribute(o?t:xs+t,n)}removeDomElementAttribute(e,t){t!=As&&(e.removeAttribute(t),e.removeAttribute(xs+t))}*viewChildrenToDom(e,t,n={}){const i=e.getFillerOffset&&e.getFillerOffset();let o=0;for(const r of e.getChildren()){i===o&&(yield this._getBlockFiller(t));const e=r.is("element")&&r.getCustomProperty("dataPipeline:transparentRendering");e&&"data"==this.renderingMode?yield*this.viewChildrenToDom(r,t,n):(e&&x("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:r}),yield this.viewToDom(r,t,n)),o++}i===o&&(yield this._getBlockFiller(t))}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),n=this.viewPositionToDom(e.end),i=document.createRange();return i.setStart(t.parent,t.offset),i.setEnd(n.parent,n.offset),i}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const n=this.findCorrespondingDomText(t);if(!n)return null;let i=e.offset;return Xr(n)&&(i+=7),{parent:n,offset:i}}{let n,i,o;if(0===e.offset){if(n=this.mapViewToDom(t),!n)return null;o=n.childNodes[0]}else{const t=e.nodeBefore;if(i=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(e.nodeBefore),!i)return null;n=i.parentNode,o=i.nextSibling}if(Kr(o)&&Xr(o))return{parent:o,offset:7};return{parent:n,offset:i?ws(i)+1:0}}}domToView(e,t={}){if(this.isBlockFiller(e))return null;const n=this.getHostViewElement(e);if(n)return n;if(ls(e)&&t.skipComments)return null;if(Kr(e)){if(es(e))return null;{const t=this._processDataFromDomText(e);return""===t?null:new Xi(this.document,t)}}{if(this.mapDomToView(e))return this.mapDomToView(e);let n;if(this.isDocumentFragment(e))n=new Dr(this.document),t.bind&&this.bindDocumentFragments(e,n);else{n=this._createViewElement(e,t),t.bind&&this.bindElements(e,n);const i=e.attributes;if(i)for(let e=i.length-1;e>=0;e--)n._setAttribute(i[e].name,i[e].value);if(this._isViewElementWithRawContent(n,t)||ls(e)){const t=ls(e)?e.data:e.innerHTML;return n._setCustomProperty("$rawContent",t),this._encounteredRawContentDomNodes.add(e),n}}if(!1!==t.withChildren)for(const i of this.domChildrenToView(e,t))n._appendChild(i);return n}}*domChildrenToView(e,t={}){for(let n=0;n{const{scrollLeft:t,scrollTop:n}=e;i.push([t,n])})),t.focus(),Ts(t,(e=>{const[t,n]=i.shift();e.scrollLeft=t,e.scrollTop=n})),bs.window.scrollTo(e,n)}}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(e){return"br"==this.blockFillerMode?e.isEqualNode(vs):!("BR"!==e.tagName||!Ss(e,this.blockElements)||1!==e.parentNode.childNodes.length)||(e.isEqualNode(ys)||function(e,t){return e.isEqualNode(_s)&&Ss(e,t)&&1===e.parentNode.childNodes.length}(e,this.blockElements))}isDomSelectionBackward(e){if(e.isCollapsed)return!1;const t=document.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset);const n=t.collapsed;return t.detach(),n}getHostViewElement(e){const t=ks(e);for(t.pop();t.length;){const e=t.pop(),n=this._domToViewMapping.get(e);if(n&&(n.is("uiElement")||n.is("rawElement")))return n}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}_getBlockFiller(e){switch(this.blockFillerMode){case"nbsp":return Gr(e);case"markedNbsp":return Yr(e);case"br":return Qr(e)}}_isDomSelectionPositionCorrect(e,t){if(Kr(e)&&Xr(e)&&t<7)return!1;if(this.isElement(e)&&Xr(e.childNodes[t]))return!1;const n=this.mapDomToView(e);return!n||!n.is("uiElement")&&!n.is("rawElement")}_processDataFromViewText(e){let t=e.data;if(e.getAncestors().some((e=>this.preElements.includes(e.name))))return t;if(" "==t.charAt(0)){const n=this._getTouchingInlineViewNode(e,!1);!(n&&n.is("$textProxy")&&this._nodeEndsWithSpace(n))&&n||(t=" "+t.substr(1))}if(" "==t.charAt(t.length-1)){const n=this._getTouchingInlineViewNode(e,!0),i=n&&n.is("$textProxy")&&" "==n.data.charAt(0);" "!=t.charAt(t.length-2)&&n&&!i||(t=t.substr(0,t.length-1)+" ")}return t.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(e){if(e.getAncestors().some((e=>this.preElements.includes(e.name))))return!1;const t=this._processDataFromViewText(e);return" "==t.charAt(t.length-1)}_processDataFromDomText(e){let t=e.data;if(function(e,t){return ks(e).some((e=>e.tagName&&t.includes(e.tagName.toLowerCase())))}(e,this.preElements))return ts(e);t=t.replace(/[ \n\t\r]{1,}/g," ");const n=this._getTouchingInlineDomNode(e,!1),i=this._getTouchingInlineDomNode(e,!0),o=this._checkShouldLeftTrimDomText(e,n),r=this._checkShouldRightTrimDomText(e,i);o&&(t=t.replace(/^ /,"")),r&&(t=t.replace(/ $/,"")),t=ts(new Text(t)),t=t.replace(/ \u00A0/g," ");const s=i&&this.isElement(i)&&"BR"!=i.tagName,a=i&&Kr(i)&&" "==i.data.charAt(0);return(/( |\u00A0)\u00A0$/.test(t)||!i||s||a)&&(t=t.replace(/\u00A0$/," ")),(o||n&&this.isElement(n)&&"BR"!=n.tagName)&&(t=t.replace(/^\u00A0/," ")),t}_checkShouldLeftTrimDomText(e,t){return!t||(this.isElement(t)?"BR"===t.tagName:!this._encounteredRawContentDomNodes.has(e.previousSibling)&&/[^\S\u00A0]/.test(t.data.charAt(t.data.length-1)))}_checkShouldRightTrimDomText(e,t){return!t&&!Xr(e)}_getTouchingInlineViewNode(e,t){const n=new Jo({startPosition:t?Xo._createAfter(e):Xo._createBefore(e),direction:t?"forward":"backward"});for(const e of n){if(e.item.is("element")&&this.inlineObjectElements.includes(e.item.name))return e.item;if(e.item.is("containerElement"))return null;if(e.item.is("element","br"))return null;if(e.item.is("$textProxy"))return e.item}return null}_getTouchingInlineDomNode(e,t){if(!e.parentNode)return null;const n=t?"firstChild":"lastChild",i=t?"nextSibling":"previousSibling";let o=!0;do{if(!o&&e[n]?e=e[n]:e[i]?(e=e[i],o=!1):(e=e.parentNode,o=!0),!e||this._isBlockElement(e))return null}while(!Kr(e)&&"BR"!=e.tagName&&!this._isInlineObjectElement(e));return e}_isBlockElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isInlineObjectElement(e){return this.isElement(e)&&this.inlineObjectElements.includes(e.tagName.toLowerCase())}_createViewElement(e,t){if(ls(e))return new Or(this.document,"$comment");const n=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new qo(this.document,n)}_isViewElementWithRawContent(e,t){return!1!==t.withChildren&&this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return"editing"===this.renderingMode&&Es.includes(t)}_createReplacementDomElement(e,t=null){const n=document.createElement("span");if(n.setAttribute(As,e),t){for(;t.firstChild;)n.appendChild(t.firstChild);for(const e of t.getAttributeNames())n.setAttribute(e,t.getAttribute(e))}return n}}function Ts(e,t){for(;e&&e!=bs.document;)t(e),e=e.parentNode}function Ss(e,t){const n=e.parentNode;return n&&n.tagName&&t.includes(n.tagName.toLowerCase())}function Ps(e){"script"===e&&x("domconverter-unsafe-script-element-detected"),"style"===e&&x("domconverter-unsafe-style-element-detected")}function Is(e){const t=Object.prototype.toString.apply(e);return"[object Window]"==t||"[object global]"==t}const Os=ht({},O,{listenTo(e,t,n,i={}){if(us(e)||Is(e)){const o={capture:!!i.useCapture,passive:!!i.usePassive},r=this._getProxyEmitter(e,o)||new Rs(e,o);this.listenTo(r,t,n,i)}else O.listenTo.call(this,e,t,n,i)},stopListening(e,t,n){if(us(e)||Is(e)){const i=this._getAllProxyEmitters(e);for(const e of i)this.stopListening(e,t,n)}else O.stopListening.call(this,e,t,n)},_getProxyEmitter(e,t){return n=this,i=Ns(e,t),n[S]&&n[S][i]?n[S][i].emitter:null;var n,i},_getAllProxyEmitters(e){return[{capture:!1,passive:!1},{capture:!1,passive:!0},{capture:!0,passive:!1},{capture:!0,passive:!0}].map((t=>this._getProxyEmitter(e,t))).filter((e=>!!e))}}),Ms=Os;class Rs{constructor(e,t){M(this,Ns(e,t)),this._domNode=e,this._options=t}}function Ns(e,t){let n=function(e){return e["data-ck-expando"]||(e["data-ck-expando"]=k())}(e);for(const e of Object.keys(t).sort())t[e]&&(n+="-"+e);return n}ht(Rs.prototype,O,{attach(e){if(this._domListeners&&this._domListeners[e])return;const t=this._createDomListener(e);this._domNode.addEventListener(e,t,this._options),this._domListeners||(this._domListeners={}),this._domListeners[e]=t},detach(e){let t;!this._domListeners[e]||(t=this._events[e])&&t.callbacks.length||this._domListeners[e].removeListener()},_addEventListener(e,t,n){this.attach(e),O._addEventListener.call(this,e,t,n)},_removeEventListener(e,t){O._removeEventListener.call(this,e,t),this.detach(e)},_createDomListener(e){const t=t=>{this.fire(e,t)};return t.removeListener=()=>{this._domNode.removeEventListener(e,t,this._options),delete this._domListeners[e]},t}});class js{constructor(e){this.view=e,this.document=e.document,this.isEnabled=!1}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(e){return e&&3===e.nodeType&&(e=e.parentNode),!(!e||1!==e.nodeType)&&e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}Et(js,Ms);const Ds=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this};const Ls=function(e){return this.__data__.has(e)};function zs(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new wn;++ta))return!1;var l=r.get(e),u=r.get(t);if(l&&u)return l==t&&u==e;var d=-1,h=!0,f=2&n?new Vs:void 0;for(r.set(e,t),r.set(t,e);++d{this.listenTo(e,t,((e,t)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(t.target)&&this.onDomEvent(t)}),{useCapture:this.useCapture})}))}fire(e,t,n){this.isEnabled&&this.document.fire(e,new oa(this.view,t,n))}}class sa extends ra{constructor(e){super(e),this.domEventType=["keydown","keyup"]}onDomEvent(e){this.fire(e.type,e,{keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return Tr(this)}})}}const aa=function(){return H.Date.now()};var ca=/\s/;const la=function(e){for(var t=e.length;t--&&ca.test(e.charAt(t)););return t};var ua=/^\s+/;const da=function(e){return e?e.slice(0,la(e)+1).replace(ua,""):e};var ha=/^[-+]0x[0-9a-f]+$/i,fa=/^0b[01]+$/i,pa=/^0o[0-7]+$/i,ga=parseInt;const ma=function(e){if("number"==typeof e)return e;if(ro(e))return NaN;if(V(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=V(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=da(e);var n=fa.test(e);return n||pa.test(e)?ga(e.slice(2),n?2:8):ha.test(e)?NaN:+e};var ba=Math.max,wa=Math.min;const ka=function(e,t,n){var i,o,r,s,a,c,l=0,u=!1,d=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){var n=i,r=o;return i=o=void 0,l=t,s=e.apply(r,n)}function p(e){return l=e,a=setTimeout(m,t),u?f(e):s}function g(e){var n=e-c;return void 0===c||n>=t||n<0||d&&e-l>=r}function m(){var e=aa();if(g(e))return b(e);a=setTimeout(m,function(e){var n=t-(e-c);return d?wa(n,r-(e-l)):n}(e))}function b(e){return a=void 0,h&&i?f(e):(i=o=void 0,s)}function w(){var e=aa(),n=g(e);if(i=arguments,o=this,c=e,n){if(void 0===a)return p(c);if(d)return clearTimeout(a),a=setTimeout(m,t),f(c)}return void 0===a&&(a=setTimeout(m,t)),s}return t=ma(t)||0,V(n)&&(u=!!n.leading,r=(d="maxWait"in n)?ba(ma(n.maxWait)||0,t):r,h="trailing"in n?!!n.trailing:h),w.cancel=function(){void 0!==a&&clearTimeout(a),l=0,i=c=o=a=void 0},w.flush=function(){return void 0===a?s:b(aa())},w};class va extends js{constructor(e){super(e),this._fireSelectionChangeDoneDebounced=ka((e=>this.document.fire("selectionChangeDone",e)),200)}observe(){const e=this.document;e.on("arrowKey",((t,n)=>{e.selection.isFake&&this.isEnabled&&n.preventDefault()}),{context:"$capture"}),e.on("arrowKey",((t,n)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(n.keyCode)}),{priority:"lowest"})}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,n=new ir(t.getRanges(),{backward:t.isBackward,fake:!1});e!=Er.arrowleft&&e!=Er.arrowup||n.setTo(n.getFirstPosition()),e!=Er.arrowright&&e!=Er.arrowdown||n.setTo(n.getLastPosition());const i={oldSelection:t,newSelection:n,domSelection:null};this.document.fire("selectionChange",i),this._fireSelectionChangeDoneDebounced(i)}}class _a extends js{constructor(e){super(e),this.mutationObserver=e.getObserver(ia),this.selection=this.document.selection,this.domConverter=e.domConverter,this._documents=new WeakSet,this._fireSelectionChangeDoneDebounced=ka((e=>this.document.fire("selectionChangeDone",e)),200),this._clearInfiniteLoopInterval=setInterval((()=>this._clearInfiniteLoop()),1e3),this._documentIsSelectingInactivityTimeoutDebounced=ka((()=>this.document.isSelecting=!1),5e3),this._loopbackCounter=0}observe(e){const t=e.ownerDocument,n=()=>{this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel()};this.listenTo(e,"selectstart",(()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()}),{priority:"highest"}),this.listenTo(e,"keydown",n,{priority:"highest"}),this.listenTo(e,"keyup",n,{priority:"highest"}),this._documents.has(t)||(this.listenTo(t,"mouseup",n,{priority:"highest"}),this.listenTo(t,"selectionchange",((e,n)=>{this._handleSelectionChange(n,t),this._documentIsSelectingInactivityTimeoutDebounced()})),this._documents.add(t))}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_handleSelectionChange(e,t){if(!this.isEnabled)return;const n=t.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(n.anchorNode))return;this.mutationObserver.flush();const i=this.domConverter.domSelectionToView(n);if(0!=i.rangeCount){if(this.view.hasDomSelection=!0,!(this.selection.isEqual(i)&&this.domConverter.isDomSelectionCorrect(n)||++this._loopbackCounter>60))if(this.selection.isSimilar(i))this.view.forceRender();else{const e={oldSelection:this.selection,newSelection:i,domSelection:n};this.document.fire("selectionChange",e),this._fireSelectionChangeDoneDebounced(e)}}else this.view.hasDomSelection=!1}_clearInfiniteLoop(){this._loopbackCounter=0}}class ya extends ra{constructor(e){super(e),this.domEventType=["focus","blur"],this.useCapture=!0;const t=this.document;t.on("focus",(()=>{t.isFocused=!0,this._renderTimeoutId=setTimeout((()=>e.change((()=>{}))),50)})),t.on("blur",((n,i)=>{const o=t.selection.editableElement;null!==o&&o!==i.target||(t.isFocused=!1,e.change((()=>{})))}))}onDomEvent(e){this.fire(e.type,e)}destroy(){this._renderTimeoutId&&clearTimeout(this._renderTimeoutId),super.destroy()}}class xa extends ra{constructor(e){super(e),this.domEventType=["compositionstart","compositionupdate","compositionend"];const t=this.document;t.on("compositionstart",(()=>{t.isComposing=!0})),t.on("compositionend",(()=>{t.isComposing=!1}))}onDomEvent(e){this.fire(e.type,e)}}class Aa extends ra{constructor(e){super(e),this.domEventType=["beforeinput"]}onDomEvent(e){this.fire(e.type,e)}}class Ea{constructor(){this._replacedElements=[]}replace(e,t){this._replacedElements.push({element:e,newElement:t}),e.style.display="none",t&&e.parentNode.insertBefore(t,e.nextSibling)}restore(){this._replacedElements.forEach((({element:e,newElement:t})=>{e.style.display="",t&&t.remove()})),this._replacedElements=[]}}const Ca=function(e){return"string"==typeof e||!Ue(e)&&Le(e)&&"[object String]"==J(e)};function Ta(e,t,n={},i=[]){const o=n&&n.xmlns,r=o?e.createElementNS(o,t):e.createElement(t);for(const e in n)r.setAttribute(e,n[e]);!Ca(i)&&Bi(i)||(i=[i]);for(let t of i)Ca(t)&&(t=e.createTextNode(t)),r.appendChild(t);return r}function Sa(e){return"[object Range]"==Object.prototype.toString.apply(e)}function Pa(e){const t=e.ownerDocument.defaultView.getComputedStyle(e);return{top:parseInt(t.borderTopWidth,10),right:parseInt(t.borderRightWidth,10),bottom:parseInt(t.borderBottomWidth,10),left:parseInt(t.borderLeftWidth,10)}}const Ia=["top","right","bottom","left","width","height"];class Oa{constructor(e){const t=Sa(e);if(Object.defineProperty(this,"_source",{value:e._source||e,writable:!0,enumerable:!1}),Di(e)||t)if(t){const t=Oa.getDomRangeRects(e);Ma(this,Oa.getBoundingRect(t))}else Ma(this,e.getBoundingClientRect());else if(Is(e)){const{innerWidth:t,innerHeight:n}=e;Ma(this,{top:0,right:t,bottom:n,left:0,width:t,height:n})}else Ma(this,e)}clone(){return new Oa(this)}moveTo(e,t){return this.top=t,this.right=e+this.width,this.bottom=t+this.height,this.left=e,this}moveBy(e,t){return this.top+=t,this.right+=e,this.left+=e,this.bottom+=t,this}getIntersection(e){const t={top:Math.max(this.top,e.top),right:Math.min(this.right,e.right),bottom:Math.min(this.bottom,e.bottom),left:Math.max(this.left,e.left)};return t.width=t.right-t.left,t.height=t.bottom-t.top,t.width<0||t.height<0?null:new Oa(t)}getIntersectionArea(e){const t=this.getIntersection(e);return t?t.getArea():0}getArea(){return this.width*this.height}getVisible(){const e=this._source;let t=this.clone();if(!Ra(e)){let n=e.parentNode||e.commonAncestorContainer;for(;n&&!Ra(n);){const e=new Oa(n),i=t.getIntersection(e);if(!i)return null;i.getArea(){for(const t of e){const e=Na._getElementCallbacks(t.target);if(e)for(const n of e)n(t)}}))}}Na._observerInstance=null,Na._elementCallbacks=null;class ja{constructor(e){this._callback=e,this._elements=new Set,this._previousRects=new Map,this._periodicCheckTimeout=null}observe(e){this._elements.add(e),this._checkElementRectsAndExecuteCallback(),1===this._elements.size&&this._startPeriodicCheck()}unobserve(e){this._elements.delete(e),this._previousRects.delete(e),this._elements.size||this._stopPeriodicCheck()}_startPeriodicCheck(){const e=()=>{this._checkElementRectsAndExecuteCallback(),this._periodicCheckTimeout=setTimeout(e,100)};this.listenTo(bs.window,"resize",(()=>{this._checkElementRectsAndExecuteCallback()})),this._periodicCheckTimeout=setTimeout(e,100)}_stopPeriodicCheck(){clearTimeout(this._periodicCheckTimeout),this.stopListening(),this._previousRects.clear()}_checkElementRectsAndExecuteCallback(){const e=[];for(const t of this._elements)this._hasRectChanged(t)&&e.push({target:t,contentRect:this._previousRects.get(t)});e.length&&this._callback(e)}_hasRectChanged(e){if(!e.ownerDocument.body.contains(e))return!1;const t=new Oa(e),n=this._previousRects.get(e),i=!n||!n.isEqual(t);return this._previousRects.set(e,t),i}}Et(ja,Ms);function Da({target:e,viewportOffset:t=0}){const n=Ua(e);let i=n,o=null;for(;i;){let r;r=Wa(i==n?e:o),za(r,(()=>qa(e,i)));const s=qa(e,i);if(La(i,s,t),i.parent!=i){if(o=i.frameElement,i=i.parent,!o)return}else i=null}}function La(e,t,n){const i=t.clone().moveBy(0,n),o=t.clone().moveBy(0,-n),r=new Oa(e).excludeScrollbarsAndBorders();if(![o,i].every((e=>r.contains(e)))){let{scrollX:s,scrollY:a}=e;Ba(o,r)?a-=r.top-t.top+n:Va(i,r)&&(a+=t.bottom-r.bottom+n),Fa(t,r)?s-=r.left-t.left+n:Ha(t,r)&&(s+=t.right-r.right+n),e.scrollTo(s,a)}}function za(e,t){const n=Ua(e);let i,o;for(;e!=n.document.body;)o=t(),i=new Oa(e).excludeScrollbarsAndBorders(),i.contains(o)||(Ba(o,i)?e.scrollTop-=i.top-o.top:Va(o,i)&&(e.scrollTop+=o.bottom-i.bottom),Fa(o,i)?e.scrollLeft-=i.left-o.left:Ha(o,i)&&(e.scrollLeft+=o.right-i.right)),e=e.parentNode}function Va(e,t){return e.bottom>t.bottom}function Ba(e,t){return e.topt.right}function Ua(e){return Sa(e)?e.startContainer.ownerDocument.defaultView:e.ownerDocument.defaultView}function Wa(e){if(Sa(e)){let t=e.commonAncestorContainer;return Kr(t)&&(t=t.parentNode),t}return e.parentNode}function qa(e,t){const n=Ua(e),i=new Oa(e);if(n===t)return i;{let e=n;for(;e!=t;){const t=e.frameElement,n=new Oa(t).excludeScrollbarsAndBorders();i.moveBy(n.left,n.top),e=e.parent}}return i}function $a(e){const t=e.next();return t.done?null:t.value}Object.assign({},{scrollViewportToShowTarget:Da,scrollAncestorsToShowTarget:function(e){za(Wa(e),(()=>new Oa(e)))}});class Za{constructor(){this.set("isFocused",!1),this.set("focusedElement",null),this._elements=new Set,this._nextEventLoopTimeout=null}add(e){if(this._elements.has(e))throw new y("focustracker-add-element-already-exist",this);this.listenTo(e,"focus",(()=>this._focus(e)),{useCapture:!0}),this.listenTo(e,"blur",(()=>this._blur()),{useCapture:!0}),this._elements.add(e)}remove(e){e===this.focusedElement&&this._blur(e),this._elements.has(e)&&(this.stopListening(e),this._elements.delete(e))}destroy(){this.stopListening()}_focus(e){clearTimeout(this._nextEventLoopTimeout),this.focusedElement=e,this.isFocused=!0}_blur(){clearTimeout(this._nextEventLoopTimeout),this._nextEventLoopTimeout=setTimeout((()=>{this.focusedElement=null,this.isFocused=!1}),0)}}Et(Za,Ms),Et(Za,kt);class Ka{constructor(){this._listener=Object.create(Ms)}listenTo(e){this._listener.listenTo(e,"keydown",((e,t)=>{this._listener.fire("_keydown:"+Tr(t),t)}))}set(e,t,n={}){const i=Sr(e),o=n.priority;this._listener.listenTo(this._listener,"_keydown:"+i,((e,n)=>{t(n,(()=>{n.preventDefault(),n.stopPropagation(),e.stop()})),e.return=!0}),{priority:o})}press(e){return!!this._listener.fire("_keydown:"+Tr(e),e)}destroy(){this._listener.stopListening()}}class Ga extends js{constructor(e){super(e),this.document.on("keydown",((e,t)=>{if(this.isEnabled&&((n=t.keyCode)==Er.arrowright||n==Er.arrowleft||n==Er.arrowup||n==Er.arrowdown)){const n=new rr(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(n,t),n.stop.called&&e.stop()}var n}))}observe(){}}class Ya extends js{constructor(e){super(e);const t=this.document;t.on("keydown",((e,n)=>{if(!this.isEnabled||n.keyCode!=Er.tab||n.ctrlKey)return;const i=new rr(t,"tab",t.selection.getFirstRange());t.fire(i,n),i.stop.called&&e.stop()}))}observe(){}}class Qa{constructor(e){this.document=new fr(e),this.domConverter=new Cs(this.document),this.domRoots=new Map,this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new fs(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting").to(this.document),this._initialDomRootAttributes=new WeakMap,this._observers=new Map,this._ongoingChange=!1,this._postFixersInProgress=!1,this._renderingDisabled=!1,this._hasChangedSinceTheLastRendering=!1,this._writer=new Lr(this.document),this.addObserver(ia),this.addObserver(_a),this.addObserver(ya),this.addObserver(sa),this.addObserver(va),this.addObserver(xa),this.addObserver(Ga),this.addObserver(Ya),_r.isAndroid&&this.addObserver(Aa),this.document.on("arrowKey",ns,{priority:"low"}),Mr(this),this.on("render",(()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1})),this.listenTo(this.document.selection,"change",(()=>{this._hasChangedSinceTheLastRendering=!0})),this.listenTo(this.document,"change:isFocused",(()=>{this._hasChangedSinceTheLastRendering=!0}))}attachDomRoot(e,t="main"){const n=this.document.getRoot(t);n._name=e.tagName.toLowerCase();const i={};for(const{name:t,value:o}of Array.from(e.attributes))i[t]=o,"class"===t?this._writer.addClass(o.split(" "),n):this._writer.setAttribute(t,o,n);this._initialDomRootAttributes.set(e,i);const o=()=>{this._writer.setAttribute("contenteditable",!n.isReadOnly,n),n.isReadOnly?this._writer.addClass("ck-read-only",n):this._writer.removeClass("ck-read-only",n)};o(),this.domRoots.set(t,e),this.domConverter.bindElements(e,n),this._renderer.markToSync("children",n),this._renderer.markToSync("attributes",n),this._renderer.domDocuments.add(e.ownerDocument),n.on("change:children",((e,t)=>this._renderer.markToSync("children",t))),n.on("change:attributes",((e,t)=>this._renderer.markToSync("attributes",t))),n.on("change:text",((e,t)=>this._renderer.markToSync("text",t))),n.on("change:isReadOnly",(()=>this.change(o))),n.on("change",(()=>{this._hasChangedSinceTheLastRendering=!0}));for(const n of this._observers.values())n.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach((({name:e})=>t.removeAttribute(e)));const n=this._initialDomRootAttributes.get(t);for(const e in n)t.setAttribute(e,n[e]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;t=new e(this),this._observers.set(e,t);for(const[e,n]of this.domRoots)t.observe(n,e);return t.enable(),t}getObserver(e){return this._observers.get(e)}disableObservers(){for(const e of this._observers.values())e.disable()}enableObservers(){for(const e of this._observers.values())e.enable()}scrollToTheSelection(){const e=this.document.selection.getFirstRange();e&&Da({target:this.domConverter.viewRangeToDom(e),viewportOffset:20})}focus(){if(!this.document.isFocused){const e=this.document.selection.editableElement;e&&(this.domConverter.focus(e),this.forceRender())}}change(e){if(this.isRenderingInProgress||this._postFixersInProgress)throw new y("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){y.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.change((()=>{}))}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return Xo._createAt(e,t)}createPositionAfter(e){return Xo._createAfter(e)}createPositionBefore(e){return Xo._createBefore(e)}createRange(e,t){return new er(e,t)}createRangeOn(e){return er._createOn(e)}createRangeIn(e){return er._createIn(e)}createSelection(e,t,n){return new ir(e,t,n)}_disableRendering(e){this._renderingDisabled=e,0==e&&this.change((()=>{}))}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}Et(Qa,kt);class Ja{constructor(e){this.parent=null,this._attrs=to(e)}get index(){let e;if(!this.parent)return null;if(null===(e=this.parent.getChildIndex(this)))throw new y("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 y("model-node-not-found-in-parent",this);return e}get offsetSize(){return 1}get endOffset(){return this.parent?this.startOffset+this.offsetSize:null}get nextSibling(){const e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.root.is("rootElement")}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={includeSelf:!1,parentFirst:!1}){const t=[];let n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}getCommonAncestor(e,t={}){const n=this.getAncestors(t),i=e.getAncestors(t);let o=0;for(;n[o]==i[o]&&n[o];)o++;return 0===o?null:n[o-1]}isBefore(e){if(this==e)return!1;if(this.root!==e.root)return!1;const t=this.getPath(),n=e.getPath(),i=Yi(t,n);switch(i){case"prefix":return!0;case"extension":return!1;default:return t[i](e[t[0]]=t[1],e)),{})),e}is(e){return"node"===e||"model:node"===e}_clone(){return new Ja(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,t){this._attrs.set(e,t)}_setAttributesTo(e){this._attrs=to(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}class Xa extends Ja{constructor(e,t){super(t),this._data=e||""}get offsetSize(){return this.data.length}get data(){return this._data}is(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e}toJSON(){const e=super.toJSON();return e.data=this.data,e}_clone(){return new Xa(this.data,this.getAttributes())}static fromJSON(e){return new Xa(e.data,e.attributes)}}class ec{constructor(e,t,n){if(this.textNode=e,t<0||t>e.offsetSize)throw new y("model-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.offsetSize)throw new y("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+n),this.offsetInText=t}get startOffset(){return null!==this.textNode.startOffset?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return null!==this.startOffset?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}is(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e}getPath(){const e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={includeSelf:!1,parentFirst:!1}){const t=[];let n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}class tc{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 y("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){let t=0;for(const n of this._nodes){if(e>=t&&ee.toJSON()))}}class nc extends Ja{constructor(e,t,n){super(t),this.name=e,this._children=new tc,n&&this._insertChild(0,n)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}is(e,t=null){return t?t===this.name&&("element"===e||"model:element"===e):"element"===e||"model:element"===e||"node"===e||"model:node"===e}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let t=this;for(const n of e)t=t.getChild(t.offsetToIndex(n));return t}findAncestor(e,t={includeSelf:!1}){let n=t.includeSelf?this:this.parent;for(;n;){if(n.name===e)return n;n=n.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?Array.from(this._children).map((e=>e._clone(!0))):null;return new nc(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const n=function(e){if("string"==typeof e)return[new Xa(e)];Bi(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Xa(e):e instanceof ec?new Xa(e.data,e.getAttributes()):e))}(t);for(const e of n)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const e of n)e.parent=null;return n}static fromJSON(e){let t=null;if(e.children){t=[];for(const n of e.children)n.name?t.push(nc.fromJSON(n)):t.push(Xa.fromJSON(n))}return new nc(e.name,e.attributes,t)}}class ic{constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new y("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new y("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=rc._createAt(this.boundaries["backward"==this.direction?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null,this._visitedParent=this.position.parent}[Symbol.iterator](){return this}skip(e){let t,n,i,o;do{i=this.position,o=this._visitedParent,({done:t,value:n}=this.next())}while(!t&&e(n));t||(this.position=i,this._visitedParent=o)}next(){return"forward"==this.direction?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),n=this._visitedParent;if(null===n.parent&&t.offset===n.maxOffset)return{done:!0};if(n===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0};const i=sc(t,n),o=i||ac(t,n,i);if(o instanceof nc)return this.shallow?t.offset++:(t.path.push(0),this._visitedParent=o),this.position=t,oc("elementStart",o,e,t,1);if(o instanceof Xa){let i;if(this.singleCharacters)i=1;else{let e=o.endOffset;this._boundaryEndParent==n&&this.boundaries.end.offsete&&(e=this.boundaries.start.offset),i=t.offset-e}const o=t.offset-r.startOffset,s=new ec(r,o-i,i);return t.offset-=i,this.position=t,oc("text",s,e,t,i)}return t.path.pop(),this.position=t,this._visitedParent=n.parent,oc("elementStart",n,e,t,1)}}function oc(e,t,n,i,o){return{done:!1,value:{type:e,item:t,previousPosition:n,nextPosition:i,length:o}}}class rc{constructor(e,t,n="toNone"){if(!e.is("element")&&!e.is("documentFragment"))throw new y("model-position-root-invalid",e);if(!(t instanceof Array)||0===t.length)throw new y("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=n}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;tn.path.length){if(t.offset!==i.maxOffset)return!1;t.path=t.path.slice(0,-1),i=i.parent,t.offset++}else{if(0!==n.offset)return!1;n.path=n.path.slice(0,-1)}}}is(e){return"position"===e||"model:position"===e}hasSameParentAs(e){if(this.root!==e.root)return!1;return"same"==Yi(this.getParentPath(),e.getParentPath())}getTransformedByOperation(e){let t;switch(e.type){case"insert":t=this._getTransformedByInsertOperation(e);break;case"move":case"remove":case"reinsert":t=this._getTransformedByMoveOperation(e);break;case"split":t=this._getTransformedBySplitOperation(e);break;case"merge":t=this._getTransformedByMergeOperation(e);break;default:t=rc._createAt(this)}return t}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){const t=e.movedRange;return t.containsPosition(this)||t.start.isEqual(this)&&"toNext"==this.stickiness?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(e){const t=e.movedRange;let n;return t.containsPosition(this)||t.start.isEqual(this)?(n=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(n=n._getTransformedByDeletion(e.deletionPosition,1))):n=this.isEqual(e.deletionPosition)?rc._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),n}_getTransformedByDeletion(e,t){const n=rc._createAt(this);if(this.root!=e.root)return n;if("same"==Yi(e.getParentPath(),this.getParentPath())){if(e.offsetthis.offset)return null;n.offset-=t}}else if("prefix"==Yi(e.getParentPath(),this.getParentPath())){const i=e.path.length-1;if(e.offset<=this.path[i]){if(e.offset+t>this.path[i])return null;n.path[i]-=t}}return n}_getTransformedByInsertion(e,t){const n=rc._createAt(this);if(this.root!=e.root)return n;if("same"==Yi(e.getParentPath(),this.getParentPath()))(e.offsett+1;){const t=i.maxOffset-n.offset;0!==t&&e.push(new lc(n,n.getShiftedBy(t))),n.path=n.path.slice(0,-1),n.offset++,i=i.parent}for(;n.path.length<=this.end.path.length;){const t=this.end.path[n.path.length-1],i=t-n.offset;0!==i&&e.push(new lc(n,n.getShiftedBy(i))),n.offset=t,n.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new ic(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new ic(e);for(const e of t)yield e.item}*getPositions(e={}){e.boundaries=this;const t=new ic(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 lc(this.start,this.end)]}getTransformedByOperations(e){const t=[new lc(this.start,this.end)];for(const n of e)for(let e=0;e0?new this(n,i):new this(i,n)}static _createIn(e){return new this(rc._createAt(e,0),rc._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(rc._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new y("range-create-from-ranges-empty-array",null);if(1==e.length)return e[0].clone();const t=e[0];e.sort(((e,t)=>e.start.isAfter(t.start)?1:-1));const n=e.indexOf(t),i=new this(t.start,t.end);if(n>0)for(let t=n-1;e[t].end.isEqual(i.start);t++)i.start=rc._createAt(e[t].start);for(let t=n+1;t{if(t.viewPosition)return;const n=this._modelToViewMapping.get(t.modelPosition.parent);if(!n)throw new y("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(n,t.modelPosition.offset)}),{priority:"low"}),this.on("viewToModelPosition",((e,t)=>{if(t.modelPosition)return;const n=this.findMappedViewAncestor(t.viewPosition),i=this._viewToModelMapping.get(n),o=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,n);t.modelPosition=rc._createAt(i,o)}),{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const n=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const t of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(t);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e),this._modelToViewMapping.get(n)==e&&this._modelToViewMapping.delete(n))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)}bindElementToMarker(e,t){const n=this._markerNameToElements.get(t)||new Set;n.add(e);const i=this._elementToMarkerNames.get(e)||new Set;i.add(t),this._markerNameToElements.set(t,n),this._elementToMarkerNames.set(e,i)}unbindElementFromMarkerName(e,t){const n=this._markerNameToElements.get(t);n&&(n.delete(e),0==n.size&&this._markerNameToElements.delete(t));const i=this._elementToMarkerNames.get(e);i&&(i.delete(t),0==i.size&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){const e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(const[e,t]of this._deferredBindingRemovals)e.root==t&&this.unbindViewElement(e);this._deferredBindingRemovals=new Map}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this._deferredBindingRemovals=new Map}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new lc(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new er(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={isPhantom:!1}){const n={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",n),n.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const n=new Set;for(const e of t)if(e.is("attributeElement"))for(const t of e.getElementsWithSameId())n.add(t);else n.add(e);return n}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,n){if(n!=e){return this._toModelOffset(e.parent,e.index,n)+this._toModelOffset(e,t,e)}if(e.is("$text"))return t;let i=0;for(let n=0;n1?t[0]+":"+t[1]:t[0]}class fc{constructor(e){this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,n){const i=this._createConversionApi(n,e.getRefreshedItems());for(const t of e.getMarkersToRemove())this._convertMarkerRemove(t.name,t.range,i);const o=this._reduceChanges(e.getChanges());for(const e of o)"insert"===e.type?this._convertInsert(lc._createFromPositionAndShift(e.position,e.length),i):"reinsert"===e.type?this._convertReinsert(lc._createFromPositionAndShift(e.position,e.length),i):"remove"===e.type?this._convertRemove(e.position,e.length,e.name,i):this._convertAttribute(e.range,e.attributeKey,e.attributeOldValue,e.attributeNewValue,i);for(const e of i.mapper.flushUnboundMarkerNames()){const n=t.get(e).getRange();this._convertMarkerRemove(e,n,i),this._convertMarkerAdd(e,n,i)}for(const t of e.getMarkersToAdd())this._convertMarkerAdd(t.name,t.range,i);i.mapper.flushDeferredBindings(),i.consumable.verifyAllConsumed("insert")}convert(e,t,n,i={}){const o=this._createConversionApi(n,void 0,i);this._convertInsert(e,o);for(const[e,n]of t)this._convertMarkerAdd(e,n,o);o.consumable.verifyAllConsumed("insert")}convertSelection(e,t,n){const i=Array.from(t.getMarkersAtPosition(e.getFirstPosition())),o=this._createConversionApi(n);if(this._addConsumablesForSelection(o.consumable,e,i),this.fire("selection",{selection:e},o),e.isCollapsed){for(const t of i){const n=t.getRange();if(!pc(e.getFirstPosition(),t,o.mapper))continue;const i={item:e,markerName:t.name,markerRange:n};o.consumable.test(e,"addMarker:"+t.name)&&this.fire("addMarker:"+t.name,i,o)}for(const t of e.getAttributeKeys()){const n={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};o.consumable.test(e,"attribute:"+n.attributeKey)&&this.fire("attribute:"+n.attributeKey+":$text",n,o)}}}_convertInsert(e,t,n={}){n.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,Array.from(e));for(const n of Array.from(e.getWalker({shallow:!0})).map(gc))this._testAndFire("insert",n,t)}_convertRemove(e,t,n,i){this.fire("remove:"+n,{position:e,length:t},i)}_convertAttribute(e,t,n,i,o){this._addConsumablesForRange(o.consumable,e,`attribute:${t}`);for(const r of e){const e={item:r.item,range:lc._createFromPositionAndShift(r.previousPosition,r.length),attributeKey:t,attributeOldValue:n,attributeNewValue:i};this._testAndFire(`attribute:${t}`,e,o)}}_convertReinsert(e,t){const n=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,n);for(const e of n.map(gc))this._testAndFire("insert",{...e,reconversion:!0},t)}_convertMarkerAdd(e,t,n){if("$graveyard"==t.root.rootName)return;const i="addMarker:"+e;if(n.consumable.add(t,i),this.fire(i,{markerName:e,markerRange:t},n),n.consumable.consume(t,i)){this._addConsumablesForRange(n.consumable,t,i);for(const o of t.getItems()){if(!n.consumable.test(o,i))continue;const r={item:o,range:lc._createOn(o),markerName:e,markerRange:t};this.fire(i,r,n)}}}_convertMarkerRemove(e,t,n){"$graveyard"!=t.root.rootName&&this.fire("removeMarker:"+e,{markerName:e,markerRange:t},n)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.changes}_addConsumablesForInsert(e,t){for(const n of t){const t=n.item;if(null===e.test(t,"insert")){e.add(t,"insert");for(const n of t.getAttributeKeys())e.add(t,"attribute:"+n)}}return e}_addConsumablesForRange(e,t,n){for(const i of t.getItems())e.add(i,n);return e}_addConsumablesForSelection(e,t,n){e.add(t,"selection");for(const i of n)e.add(t,"addMarker:"+i.name);for(const n of t.getAttributeKeys())e.add(t,"attribute:"+n);return e}_testAndFire(e,t,n){const i=function(e,t){const n=t.item.name||"$text";return`${e}:${n}`}(e,t),o=t.item.is("$textProxy")?n.consumable._getSymbolForTextProxy(t.item):t.item,r=this._firedEventsMap.get(n),s=r.get(o);if(s){if(s.has(i))return;s.add(i)}else r.set(o,new Set([i]));this.fire(i,t,n)}_testAndFireAddAttributes(e,t){const n={item:e,range:lc._createOn(e)};for(const e of n.item.getAttributeKeys())n.attributeKey=e,n.attributeOldValue=null,n.attributeNewValue=n.item.getAttribute(e),this._testAndFire(`attribute:${e}`,n,t)}_createConversionApi(e,t=new Set,n={}){const i={...this._conversionApi,consumable:new dc,writer:e,options:n,convertItem:e=>this._convertInsert(lc._createOn(e),i),convertChildren:e=>this._convertInsert(lc._createIn(e),i,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,i),canReuseView:e=>!t.has(i.mapper.toModelElement(e))};return this._firedEventsMap.set(i,new Map),i}}function pc(e,t,n){const i=t.getRange(),o=Array.from(e.getAncestors());o.shift(),o.reverse();return!o.some((e=>{if(i.containsItem(e)){return!!n.toViewElement(e).getCustomProperty("addHighlight")}}))}function gc(e){return{item:e.item,range:lc._createFromPositionAndShift(e.previousPosition,e.length)}}Et(fc,O);class mc{constructor(e,t,n){this._lastRangeBackward=!1,this._ranges=[],this._attrs=new Map,e&&this.setTo(e,t,n)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return 1===this._ranges.length&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(0===this.rangeCount)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let n=!1;for(const i of e._ranges)if(t.isEqual(i)){n=!0;break}if(!n)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new lc(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 lc(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 lc(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,t,n){if(null===e)this._setRanges([]);else if(e instanceof mc)this._setRanges(e.getRanges(),e.isBackward);else if(e&&"function"==typeof e.getRanges)this._setRanges(e.getRanges(),e.isBackward);else if(e instanceof lc)this._setRanges([e],!!t&&!!t.backward);else if(e instanceof rc)this._setRanges([new lc(e)]);else if(e instanceof Ja){const i=!!n&&!!n.backward;let o;if("in"==t)o=lc._createIn(e);else if("on"==t)o=lc._createOn(e);else{if(void 0===t)throw new y("model-selection-setto-required-second-parameter",[this,e]);o=new lc(rc._createAt(e,t))}this._setRanges([o],i)}else{if(!Bi(e))throw new y("model-selection-setto-not-selectable",[this,e]);this._setRanges(e,t&&!!t.backward)}}_setRanges(e,t=!1){const n=(e=Array.from(e)).some((t=>{if(!(t instanceof lc))throw new y("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every((e=>!e.isEqual(t)))}));if(e.length!==this._ranges.length||n){this._removeAllRanges();for(const t of e)this._pushRange(t);this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0})}}setFocus(e,t){if(null===this.anchor)throw new y("model-selection-setfocus-no-ranges",[this,e]);const n=rc._createAt(e,t);if("same"==n.compareWith(this.focus))return;const i=this.anchor;this._ranges.length&&this._popRange(),"before"==n.compareWith(i)?(this._pushRange(new lc(n,i)),this._lastRangeBackward=!0):(this._pushRange(new lc(i,n)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}is(e){return"selection"===e||"model:selection"===e}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const n=kc(t.start,e);n&&vc(n,t)&&(yield n);for(const n of t.getWalker()){const i=n.item;"elementEnd"==n.type&&wc(i,e,t)&&(yield i)}const i=kc(t.end,e);i&&!t.end.isTouching(rc._createAt(i,0))&&vc(i,t)&&(yield i)}}containsEntireContent(e=this.anchor.root){const t=rc._createAt(e,0),n=rc._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&n.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new lc(e.start,e.end))}_checkRange(e){for(let t=0;t0;)this._popRange()}_popRange(){this._ranges.pop()}}function bc(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&e.parent)}function wc(e,t,n){return bc(e,t)&&vc(e,n)}function kc(e,t){const n=e.parent.root.document.model.schema,i=e.parent.getAncestors({parentFirst:!0,includeSelf:!0});let o=!1;const r=i.find((e=>!o&&(o=n.isLimit(e),!o&&bc(e,t))));return i.forEach((e=>t.add(e))),r}function vc(e,t){const n=function(e){const t=e.root.document.model.schema;let n=e.parent;for(;n;){if(t.isBlock(n))return n;n=n.parent}}(e);if(!n)return!0;return!t.containsRange(lc._createOn(n),!0)}Et(mc,O);class _c extends lc{constructor(e,t){super(e,t),yc.call(this)}detach(){this.stopListening()}is(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e}toRange(){return new lc(this.start,this.end)}static fromRange(e){return new _c(e.start,e.end)}}function yc(){this.listenTo(this.root.document.model,"applyOperation",((e,t)=>{const n=t[0];n.isDocumentOperation&&xc.call(this,n)}),{priority:"low"})}function xc(e){const t=this.getTransformedByOperation(e),n=lc._createFromRanges(t),i=!n.isEqual(this),o=function(e,t){switch(t.type){case"insert":return e.containsPosition(t.position);case"move":case"remove":case"reinsert":case"merge":return e.containsPosition(t.sourcePosition)||e.start.isEqual(t.sourcePosition)||e.containsPosition(t.targetPosition);case"split":return e.containsPosition(t.splitPosition)||e.containsPosition(t.insertionPosition)}return!1}(this,e);let r=null;if(i){"$graveyard"==n.root.rootName&&(r="remove"==e.type?e.sourcePosition:e.deletionPosition);const t=this.toRange();this.start=n.start,this.end=n.end,this.fire("change:range",t,{deletionPosition:r})}else o&&this.fire("change:content",this.toRange(),{deletionPosition:r})}Et(_c,O);const Ac="selection:";class Ec{constructor(e){this._selection=new Cc(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)}is(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(e,t,n){this._selection.setTo(e,t,n)}_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 Ac+e}static _isStoreAttributeKey(e){return e.startsWith(Ac)}}Et(Ec,O);class Cc extends mc{constructor(e){super(),this.markers=new Fi({idProperty:"name"}),this._model=e.model,this._document=e,this._attributePriority=new Map,this._selectionRestorePosition=null,this._hasChangedRange=!1,this._overriddenGravityRegister=new Set,this._observedMarkers=new Set,this.listenTo(this._model,"applyOperation",((e,t)=>{const n=t[0];n.isDocumentOperation&&"marker"!=n.type&&"rename"!=n.type&&"noop"!=n.type&&(0==this._ranges.length&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))}),{priority:"lowest"}),this.on("change:range",(()=>{for(const e of this.getRanges())if(!this._document._validateSelectionRange(e))throw new y("document-selection-wrong-position",this,{range:e})})),this.listenTo(this._model.markers,"update",((e,t,n,i)=>{this._updateMarker(t,i)})),this.listenTo(this._document,"change",((e,t)=>{!function(e,t){const n=e.document.differ;for(const i of n.getChanges()){if("insert"!=i.type)continue;const n=i.position.parent;i.length===n.maxOffset&&e.enqueueChange(t,(e=>{const t=Array.from(n.getAttributeKeys()).filter((e=>e.startsWith(Ac)));for(const i of t)e.removeAttribute(i,n)}))}}(this._model,t)}))}get isCollapsed(){return 0===this._ranges.length?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let e=0;e{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=i.deletionPosition;const e=this._ranges.indexOf(t);this._ranges.splice(e,1),t.detach()}})),t}_updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const t of this._model.markers){const n=t.name.split(":",1)[0];if(!this._observedMarkers.has(n))continue;const i=t.getRange();for(const n of this.getRanges())i.containsRange(n,!n.isCollapsed)&&e.push(t)}const n=Array.from(this.markers);for(const n of e)this.markers.has(n)||(this.markers.add(n),t=!0);for(const n of Array.from(this.markers))e.includes(n)||(this.markers.remove(n),t=!0);t&&this.fire("change:marker",{oldMarkers:n,directChange:!1})}_updateMarker(e,t){const n=e.name.split(":",1)[0];if(!this._observedMarkers.has(n))return;let i=!1;const o=Array.from(this.markers),r=this.markers.has(e);if(t){let n=!1;for(const e of this.getRanges())if(t.containsRange(e,!e.isCollapsed)){n=!0;break}n&&!r?(this.markers.add(e),i=!0):!n&&r&&(this.markers.remove(e),i=!0)}else r&&(this.markers.remove(e),i=!0);i&&this.fire("change:marker",{oldMarkers:o,directChange:!1})}_updateAttributes(e){const t=to(this._getSurroundingAttributes()),n=to(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[e,t]of this._attributePriority)"low"==t&&(this._attrs.delete(e),this._attributePriority.delete(e));this._setAttributesTo(t);const i=[];for(const[e,t]of this.getAttributes())n.has(e)&&n.get(e)===t||i.push(e);for(const[e]of n)this.hasAttribute(e)||i.push(e);i.length>0&&this.fire("change:attribute",{attributeKeys:i,directChange:!1})}_setAttribute(e,t,n=!0){const i=n?"normal":"low";if("low"==i&&"normal"==this._attributePriority.get(e))return!1;return super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,i),!0)}_removeAttribute(e,t=!0){const n=t?"normal":"low";return("low"!=n||"normal"!=this._attributePriority.get(e))&&(this._attributePriority.set(e,n),!!super.hasAttribute(e)&&(this._attrs.delete(e),!0))}_setAttributesTo(e){const t=new Set;for(const[t,n]of this.getAttributes())e.get(t)!==n&&this._removeAttribute(t,!1);for(const[n,i]of e){this._setAttribute(n,i,!1)&&t.add(n)}return t}*_getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())if(t.startsWith(Ac)){const n=t.substr(Ac.length);yield[n,e.getAttribute(t)]}}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;let n=null;if(this.isCollapsed){const i=e.textNode?e.textNode:e.nodeBefore,o=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(n=Tc(i)),n||(n=Tc(o)),!this.isGravityOverridden&&!n){let e=i;for(;e&&!t.isInline(e)&&!n;)e=e.previousSibling,n=Tc(e)}if(!n){let e=o;for(;e&&!t.isInline(e)&&!n;)e=e.nextSibling,n=Tc(e)}n||(n=this._getStoredAttributes())}else{const e=this.getFirstRange();for(const i of e){if(i.item.is("element")&&t.isObject(i.item))break;if("text"==i.type){n=i.item.getAttributes();break}}}return n}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function Tc(e){return e instanceof ec||e instanceof Xa?e.getAttributes():null}class Sc{constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}const Pc=function(e){return Ni(e,5)};class Ic extends Sc{elementToElement(e){return this.add(function(e){(e=Pc(e)).model=Rc(e.model),e.view=Nc(e.view,"container"),e.model.attributes.length&&(e.model.children=!0);return t=>{t.on("insert:"+e.model.name,function(e,t=Hc){return(n,i,o)=>{if(!t(i.item,o.consumable,{preflight:!0}))return;const r=e(i.item,o,i);if(!r)return;t(i.item,o.consumable);const s=o.mapper.toViewPosition(i.range.start);o.mapper.bindElements(i.item,r),o.writer.insert(s,r),o.convertAttributes(i.item),Bc(r,i.item.getChildren(),o,{reconversion:i.reconversion})}}(e.view,Vc(e.model)),{priority:e.converterPriority||"normal"}),(e.model.children||e.model.attributes.length)&&t.on("reduceChanges",zc(e.model),{priority:"low"})}}(e))}elementToStructure(e){return this.add(function(e){return(e=Pc(e)).model=Rc(e.model),e.view=Nc(e.view,"container"),e.model.children=!0,t=>{if(t._conversionApi.schema.checkChild(e.model.name,"$text"))throw new y("conversion-element-to-structure-disallowed-text",t,{elementName:e.model.name});var n,i;t.on("insert:"+e.model.name,(n=e.view,i=Vc(e.model),(e,t,o)=>{if(!i(t.item,o.consumable,{preflight:!0}))return;const r=new Map;o.writer._registerSlotFactory(function(e,t,n){return(i,o="children")=>{const r=i.createContainerElement("$slot");let s=null;if("children"===o)s=Array.from(e.getChildren());else{if("function"!=typeof o)throw new y("conversion-slot-mode-unknown",n.dispatcher,{modeOrFilter:o});s=Array.from(e.getChildren()).filter((e=>o(e)))}return t.set(r,s),r}}(t.item,r,o));const s=n(t.item,o,t);if(o.writer._clearSlotFactory(),!s)return;!function(e,t,n){const i=Array.from(t.values()).flat(),o=new Set(i);if(o.size!=i.length)throw new y("conversion-slot-filter-overlap",n.dispatcher,{element:e});if(o.size!=e.childCount)throw new y("conversion-slot-filter-incomplete",n.dispatcher,{element:e})}(t.item,r,o),i(t.item,o.consumable);const a=o.mapper.toViewPosition(t.range.start);o.mapper.bindElements(t.item,s),o.writer.insert(a,s),o.convertAttributes(t.item),function(e,t,n,i){n.mapper.on("modelToViewPosition",s,{priority:"highest"});let o=null,r=null;for([o,r]of t)Bc(e,r,n,i),n.writer.move(n.writer.createRangeIn(o),n.writer.createPositionBefore(o)),n.writer.remove(o);function s(e,t){const n=t.modelPosition.nodeAfter,i=r.indexOf(n);i<0||(t.viewPosition=t.mapper.findPositionIn(o,i))}n.mapper.off("modelToViewPosition",s)}(s,r,o,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),t.on("reduceChanges",zc(e.model),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){e=Pc(e);let t="attribute:"+(e.model.key?e.model.key:e.model);e.model.name&&(t+=":"+e.model.name);if(e.model.values)for(const t of e.model.values)e.view[t]=Nc(e.view[t],"attribute");else e.view=Nc(e.view,"attribute");const n=jc(e);return i=>{i.on(t,function(e){return(t,n,i)=>{if(!i.consumable.test(n.item,t.name))return;const o=e(n.attributeOldValue,i,n),r=e(n.attributeNewValue,i,n);if(!o&&!r)return;i.consumable.consume(n.item,t.name);const s=i.writer,a=s.document.selection;if(n.item instanceof mc||n.item instanceof Ec)s.wrap(a.getFirstRange(),r);else{let e=i.mapper.toViewRange(n.range);null!==n.attributeOldValue&&o&&(e=s.unwrap(e,o)),null!==n.attributeNewValue&&r&&s.wrap(e,r)}}}(n),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=Pc(e);let t="attribute:"+(e.model.key?e.model.key:e.model);e.model.name&&(t+=":"+e.model.name);if(e.model.values)for(const t of e.model.values)e.view[t]=Dc(e.view[t]);else e.view=Dc(e.view);const n=jc(e);return i=>{var o;i.on(t,(o=n,(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;const i=o(t.attributeOldValue,n,t),r=o(t.attributeNewValue,n,t);if(!i&&!r)return;n.consumable.consume(t.item,e.name);const s=n.mapper.toViewElement(t.item),a=n.writer;if(!s)throw new y("conversion-attribute-to-attribute-on-text",n.dispatcher,t);if(null!==t.attributeOldValue&&i)if("class"==i.key){const e=Ui(i.value);for(const t of e)a.removeClass(t,s)}else if("style"==i.key){const e=Object.keys(i.value);for(const t of e)a.removeStyle(t,s)}else a.removeAttribute(i.key,s);if(null!==t.attributeNewValue&&r)if("class"==r.key){const e=Ui(r.value);for(const t of e)a.addClass(t,s)}else if("style"==r.key){const e=Object.keys(r.value);for(const t of e)a.setStyle(t,r.value[t],s)}else a.setAttribute(r.key,r.value,s)}),{priority:e.converterPriority||"normal"})}}(e))}markerToElement(e){return this.add(function(e){return(e=Pc(e)).view=Nc(e.view,"ui"),t=>{var n;t.on("addMarker:"+e.model,(n=e.view,(e,t,i)=>{t.isOpening=!0;const o=n(t,i);t.isOpening=!1;const r=n(t,i);if(!o||!r)return;const s=t.markerRange;if(s.isCollapsed&&!i.consumable.consume(s,e.name))return;for(const t of s)if(!i.consumable.consume(t.item,e.name))return;const a=i.mapper,c=i.writer;c.insert(a.toViewPosition(s.start),o),i.mapper.bindElementToMarker(o,t.markerName),s.isCollapsed||(c.insert(a.toViewPosition(s.end),r),i.mapper.bindElementToMarker(r,t.markerName)),e.stop()}),{priority:e.converterPriority||"normal"}),t.on("removeMarker:"+e.model,(e.view,(e,t,n)=>{const i=n.mapper.markerNameToElements(t.markerName);if(i){for(const e of i)n.mapper.unbindElementFromMarkerName(e,t.markerName),n.writer.clear(n.writer.createRangeOn(e),e);n.writer.clearClonedElementsGroup(t.markerName),e.stop()}}),{priority:e.converterPriority||"normal"})}}(e))}markerToHighlight(e){return this.add(function(e){return t=>{var n;t.on("addMarker:"+e.model,(n=e.view,(e,t,i)=>{if(!t.item)return;if(!(t.item instanceof mc||t.item instanceof Ec||t.item.is("$textProxy")))return;const o=Lc(n,t,i);if(!o)return;if(!i.consumable.consume(t.item,e.name))return;const r=i.writer,s=Oc(r,o),a=r.document.selection;if(t.item instanceof mc||t.item instanceof Ec)r.wrap(a.getFirstRange(),s,a);else{const e=i.mapper.toViewRange(t.range),n=r.wrap(e,s);for(const e of n.getItems())if(e.is("attributeElement")&&e.isSimilar(s)){i.mapper.bindElementToMarker(e,t.markerName);break}}}),{priority:e.converterPriority||"normal"}),t.on("addMarker:"+e.model,function(e){return(t,n,i)=>{if(!n.item)return;if(!(n.item instanceof nc))return;const o=Lc(e,n,i);if(!o)return;if(!i.consumable.test(n.item,t.name))return;const r=i.mapper.toViewElement(n.item);if(r&&r.getCustomProperty("addHighlight")){i.consumable.consume(n.item,t.name);for(const e of lc._createIn(n.item))i.consumable.consume(e.item,t.name);r.getCustomProperty("addHighlight")(r,o,i.writer),i.mapper.bindElementToMarker(r,n.markerName)}}}(e.view),{priority:e.converterPriority||"normal"}),t.on("removeMarker:"+e.model,function(e){return(t,n,i)=>{if(n.markerRange.isCollapsed)return;const o=Lc(e,n,i);if(!o)return;const r=Oc(i.writer,o),s=i.mapper.markerNameToElements(n.markerName);if(s){for(const e of s)i.mapper.unbindElementFromMarkerName(e,n.markerName),e.is("attributeElement")?i.writer.unwrap(i.writer.createRangeOn(e),r):e.getCustomProperty("removeHighlight")(e,o.id,i.writer);i.writer.clearClonedElementsGroup(n.markerName),t.stop()}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}markerToData(e){return this.add(function(e){const t=(e=Pc(e)).model;e.view||(e.view=n=>({group:t,name:n.substr(e.model.length+1)}));return n=>{var i;n.on("addMarker:"+t,(i=e.view,(e,t,n)=>{const o=i(t.markerName,n);if(!o)return;const r=t.markerRange;n.consumable.consume(r,e.name)&&(Mc(r,!1,n,t,o),Mc(r,!0,n,t,o),e.stop())}),{priority:e.converterPriority||"normal"}),n.on("removeMarker:"+t,function(e){return(t,n,i)=>{const o=e(n.markerName,i);if(!o)return;const r=i.mapper.markerNameToElements(n.markerName);if(r){for(const e of r)i.mapper.unbindElementFromMarkerName(e,n.markerName),e.is("containerElement")?(s(`data-${o.group}-start-before`,e),s(`data-${o.group}-start-after`,e),s(`data-${o.group}-end-before`,e),s(`data-${o.group}-end-after`,e)):i.writer.clear(i.writer.createRangeOn(e),e);i.writer.clearClonedElementsGroup(n.markerName),t.stop()}function s(e,t){if(t.hasAttribute(e)){const n=new Set(t.getAttribute(e).split(","));n.delete(o.name),0==n.size?i.writer.removeAttribute(e,t):i.writer.setAttribute(e,Array.from(n).join(","),t)}}}}(e.view),{priority:e.converterPriority||"normal"})}}(e))}}function Oc(e,t){const n=e.createAttributeElement("span",t.attributes);return t.classes&&n._addClass(t.classes),"number"==typeof t.priority&&(n._priority=t.priority),n._id=t.id,n}function Mc(e,t,n,i,o){const r=t?e.start:e.end,s=r.nodeAfter&&r.nodeAfter.is("element")?r.nodeAfter:null,a=r.nodeBefore&&r.nodeBefore.is("element")?r.nodeBefore:null;if(s||a){let e,r;t&&s||!t&&!a?(e=s,r=!0):(e=a,r=!1);const c=n.mapper.toViewElement(e);if(c)return void function(e,t,n,i,o,r){const s=`data-${r.group}-${t?"start":"end"}-${n?"before":"after"}`,a=e.hasAttribute(s)?e.getAttribute(s).split(","):[];a.unshift(r.name),i.writer.setAttribute(s,a.join(","),e),i.mapper.bindElementToMarker(e,o.markerName)}(c,t,r,n,i,o)}!function(e,t,n,i,o){const r=`${o.group}-${t?"start":"end"}`,s=o.name?{name:o.name}:null,a=n.writer.createUIElement(r,s);n.writer.insert(e,a),n.mapper.bindElementToMarker(a,i.markerName)}(n.mapper.toViewPosition(r),t,n,i,o)}function Rc(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 Nc(e,t){return"function"==typeof e?e:(n,i)=>function(e,t,n){"string"==typeof e&&(e={name:e});let i;const o=t.writer,r=Object.assign({},e.attributes);if("container"==n)i=o.createContainerElement(e.name,r);else if("attribute"==n){const t={priority:e.priority||pr.DEFAULT_PRIORITY};i=o.createAttributeElement(e.name,r,t)}else i=o.createUIElement(e.name,r);if(e.styles){const t=Object.keys(e.styles);for(const n of t)o.setStyle(n,e.styles[n],i)}if(e.classes){const t=e.classes;if("string"==typeof t)o.addClass(t,i);else for(const e of t)o.addClass(e,i)}return i}(e,i,t)}function jc(e){return e.model.values?(t,n)=>{const i=e.view[t];return i?i(t,n):null}:e.view}function Dc(e){return"string"==typeof e?t=>({key:e,value:t}):"object"==typeof e?e.value?()=>e:t=>({key:e.key,value:t}):e}function Lc(e,t,n){const i="function"==typeof e?e(t,n):e;return i?(i.priority||(i.priority=10),i.id||(i.id=t.markerName),i):null}function zc(e){const t=function(e){return(t,n)=>{if(!t.is("element",e.name))return!1;if("attribute"==n.type){if(e.attributes.includes(n.attributeKey))return!0}else if(e.children)return!0;return!1}}(e);return(e,n)=>{const i=[];n.reconvertedElements||(n.reconvertedElements=new Set);for(const e of n.changes){const o=e.position?e.position.parent:e.range.start.nodeAfter;if(o&&t(o,e)){if(!n.reconvertedElements.has(o)){n.reconvertedElements.add(o);const e=rc._createBefore(o);i.push({type:"remove",name:o.name,position:e,length:1},{type:"reinsert",name:o.name,position:e,length:1})}}else i.push(e)}n.changes=i}}function Vc(e){return(t,n,i={})=>{const o=["insert"];for(const n of e.attributes)t.hasAttribute(n)&&o.push(`attribute:${n}`);return!!o.every((e=>n.test(t,e)))&&(i.preflight||o.forEach((e=>n.consume(t,e))),!0)}}function Bc(e,t,n,i){for(const o of t)Fc(e.root,o,n,i)||n.convertItem(o)}function Fc(e,t,n,i){const{writer:o,mapper:r}=n;if(!i.reconversion)return!1;const s=r.toViewElement(t);return!(!s||s.root==e)&&(!!n.canReuseView(s)&&(o.move(o.createRangeOn(s),r.toViewPosition(rc._createBefore(t))),!0))}function Hc(e,t,{preflight:n}={}){return n?t.test(e,"insert"):t.consume(e,"insert")}function Uc(e){const{schema:t,document:n}=e.model;for(const i of n.getRootNames()){const o=n.getRoot(i);if(o.isEmpty&&!t.checkChild(o,"$text")&&t.checkChild(o,"paragraph"))return e.insertElement("paragraph",o),!0}return!1}function Wc(e,t,n){const i=n.createContext(e);return!!n.checkChild(i,"paragraph")&&!!n.checkChild(i.push("paragraph"),t)}function qc(e,t){const n=t.createElement("paragraph");return t.insert(n,e),t.createPositionAt(n,0)}class $c extends Sc{elementToElement(e){return this.add(Zc(e))}elementToAttribute(e){return this.add(function(e){Yc(e=Pc(e));const t=Qc(e,!1),n=Kc(e.view),i=n?"element:"+n:"element";return n=>{n.on(i,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=Pc(e);let t=null;("string"==typeof e.view||e.view.key)&&(t=function(e){"string"==typeof e.view&&(e.view={key:e.view});const t=e.view.key;let n;if("class"==t||"style"==t){n={["class"==t?"classes":"styles"]:e.view.value}}else{n={attributes:{[t]:void 0===e.view.value?/[\s\S]*/:e.view.value}}}e.view.name&&(n.name=e.view.name);return e.view=n,t}(e));Yc(e,t);const n=Qc(e,!0);return t=>{t.on("element",n,{priority:e.converterPriority||"low"})}}(e))}elementToMarker(e){return this.add(function(e){return function(e){const t=e.model;e.model=(e,n)=>{const i="string"==typeof t?t:t(e,n);return n.writer.createElement("$marker",{"data-name":i})}}(e=Pc(e)),Zc(e)}(e))}dataToMarker(e){return this.add(function(e){(e=Pc(e)).model||(e.model=t=>t?e.view+":"+t:e.view);const t=Gc(Jc(e,"start")),n=Gc(Jc(e,"end"));return i=>{i.on("element:"+e.view+"-start",t,{priority:e.converterPriority||"normal"}),i.on("element:"+e.view+"-end",n,{priority:e.converterPriority||"normal"});const o=v.get("low"),r=v.get("highest"),s=v.get(e.converterPriority)/r;i.on("element",function(e){return(t,n,i)=>{const o=`data-${e.view}`;function r(t,o){for(const r of o){const o=e.model(r,i),s=i.writer.createElement("$marker",{"data-name":o});i.writer.insert(s,t),n.modelCursor.isEqual(t)?n.modelCursor=n.modelCursor.getShiftedBy(1):n.modelCursor=n.modelCursor._getTransformedByInsertion(t,1),n.modelRange=n.modelRange._getTransformedByInsertion(t,1)[0]}}(i.consumable.test(n.viewItem,{attributes:o+"-end-after"})||i.consumable.test(n.viewItem,{attributes:o+"-start-after"})||i.consumable.test(n.viewItem,{attributes:o+"-end-before"})||i.consumable.test(n.viewItem,{attributes:o+"-start-before"}))&&(n.modelRange||Object.assign(n,i.convertChildren(n.viewItem,n.modelCursor)),i.consumable.consume(n.viewItem,{attributes:o+"-end-after"})&&r(n.modelRange.end,n.viewItem.getAttribute(o+"-end-after").split(",")),i.consumable.consume(n.viewItem,{attributes:o+"-start-after"})&&r(n.modelRange.end,n.viewItem.getAttribute(o+"-start-after").split(",")),i.consumable.consume(n.viewItem,{attributes:o+"-end-before"})&&r(n.modelRange.start,n.viewItem.getAttribute(o+"-end-before").split(",")),i.consumable.consume(n.viewItem,{attributes:o+"-start-before"})&&r(n.modelRange.start,n.viewItem.getAttribute(o+"-start-before").split(",")))}}(e),{priority:o+s})}}(e))}}function Zc(e){const t=Gc(e=Pc(e)),n=Kc(e.view),i=n?"element:"+n:"element";return n=>{n.on(i,t,{priority:e.converterPriority||"normal"})}}function Kc(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}function Gc(e){const t=new no(e.view);return(n,i,o)=>{const r=t.match(i.viewItem);if(!r)return;const s=r.match;if(s.name=!0,!o.consumable.test(i.viewItem,s))return;const a=function(e,t,n){return e instanceof Function?e(t,n):n.writer.createElement(e)}(e.model,i.viewItem,o);a&&o.safeInsert(a,i.modelCursor)&&(o.consumable.consume(i.viewItem,s),o.convertChildren(i.viewItem,a),o.updateConversionResult(a,i))}}function Yc(e,t=null){const n=null===t||(e=>e.getAttribute(t)),i="object"!=typeof e.model?e.model:e.model.key,o="object"!=typeof e.model||void 0===e.model.value?n:e.model.value;e.model={key:i,value:o}}function Qc(e,t){const n=new no(e.view);return(i,o,r)=>{const s=n.match(o.viewItem);if(!s)return;if(!function(e,t){const n="function"==typeof e?e(t):e;if("object"==typeof n&&!Kc(n))return!1;return!n.classes&&!n.attributes&&!n.styles}(e.view,o.viewItem)?delete s.match.name:s.match.name=!0,!r.consumable.test(o.viewItem,s.match))return;const a=e.model.key,c="function"==typeof e.model.value?e.model.value(o.viewItem,r):e.model.value;if(null===c)return;o.modelRange||Object.assign(o,r.convertChildren(o.viewItem,o.modelCursor));const l=function(e,t,n,i){let o=!1;for(const r of Array.from(e.getItems({shallow:n})))i.schema.checkAttribute(r,t.key)&&(o=!0,r.hasAttribute(t.key)||i.writer.setAttribute(t.key,t.value,r));return o}(o.modelRange,{key:a,value:c},t,r);l&&r.consumable.consume(o.viewItem,s.match)}}function Jc(e,t){const n={};return n.view=e.view+"-"+t,n.model=(t,n)=>{const i=t.getAttribute("name"),o=e.model(i,n);return n.writer.createElement("$marker",{"data-name":o})},n}class Xc{constructor(e,t){this.model=e,this.view=new Qa(t),this.mapper=new uc,this.downcastDispatcher=new fc({mapper:this.mapper,schema:e.schema});const n=this.model.document,i=n.selection,o=this.model.markers;this.listenTo(this.model,"_beforeChanges",(()=>{this.view._disableRendering(!0)}),{priority:"highest"}),this.listenTo(this.model,"_afterChanges",(()=>{this.view._disableRendering(!1)}),{priority:"lowest"}),this.listenTo(n,"change",(()=>{this.view.change((e=>{this.downcastDispatcher.convertChanges(n.differ,o,e),this.downcastDispatcher.convertSelection(i,o,e)}))}),{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(n,i)=>{const o=i.newSelection,r=[];for(const e of o.getRanges())r.push(t.toModelRange(e));const s=e.createSelection(r,{backward:o.isBackward});s.isEqual(e.document.selection)||e.change((e=>{e.setSelection(s)}))}}(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",((e,t,n)=>{if(!n.consumable.consume(t.item,e.name))return;const i=n.writer,o=n.mapper.toViewPosition(t.range.start),r=i.createText(t.item.data);i.insert(o,r)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,n)=>{n.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||n.convertChildren(t.item)}),{priority:"lowest"}),this.downcastDispatcher.on("remove",((e,t,n)=>{const i=n.mapper.toViewPosition(t.position),o=t.position.getShiftedBy(t.length),r=n.mapper.toViewPosition(o,{isPhantom:!0}),s=n.writer.createRange(i,r),a=n.writer.remove(s.getTrimmed());for(const e of n.writer.createRangeIn(a).getItems())n.mapper.unbindViewElement(e,{defer:!0})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,n)=>{const i=n.writer,o=i.document.selection;for(const e of o.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&n.writer.mergeAttributes(e.start);i.setSelection(null)}),{priority:"high"}),this.downcastDispatcher.on("selection",((e,t,n)=>{const i=t.selection;if(i.isCollapsed)return;if(!n.consumable.consume(i,"selection"))return;const o=[];for(const e of i.getRanges()){const t=n.mapper.toViewRange(e);o.push(t)}n.writer.setSelection(o,{backward:i.isBackward})}),{priority:"low"}),this.downcastDispatcher.on("selection",((e,t,n)=>{const i=t.selection;if(!i.isCollapsed)return;if(!n.consumable.consume(i,"selection"))return;const o=n.writer,r=i.getFirstPosition(),s=n.mapper.toViewPosition(r),a=o.breakAttributes(s);o.setSelection(a)}),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using((e=>{if("$graveyard"==e.rootName)return null;const t=new Qo(this.view.document,e.name);return t.rootName=e.rootName,this.mapper.bindElements(e,t),t}))}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const t="string"==typeof e?e:e.name,n=this.model.markers.get(t);if(!n)throw new y("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change((()=>{this.model.markers._refresh(n)}))}reconvertItem(e){this.model.change((()=>{this.model.document.differ._refreshItem(e)}))}}Et(Xc,kt);class el{constructor(){this._commands=new Map}add(e,t){this._commands.set(e,t)}get(e){return this._commands.get(e)}execute(e,...t){const n=this.get(e);if(!n)throw new y("commandcollection-command-not-found",this,{commandName:e});return n.execute(...t)}*names(){yield*this._commands.keys()}*commands(){yield*this._commands.values()}[Symbol.iterator](){return this._commands[Symbol.iterator]()}destroy(){for(const e of this.commands())e.destroy()}}class tl{constructor(){this._consumables=new Map}add(e,t){let n;e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):(this._consumables.has(e)?n=this._consumables.get(e):(n=new nl(e),this._consumables.set(e,n)),n.add(t))}test(e,t){const n=this._consumables.get(e);return void 0===n?null:e.is("$text")||e.is("documentFragment")?n:n.test(t)}consume(e,t){return!!this.test(e,t)&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!1):this._consumables.get(e).consume(t),!0)}revert(e,t){const n=this._consumables.get(e);void 0!==n&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):n.revert(t))}static consumablesFromElement(e){const t={element:e,name:!0,attributes:[],classes:[],styles:[]},n=e.getAttributeKeys();for(const e of n)"style"!=e&&"class"!=e&&t.attributes.push(e);const i=e.getClassNames();for(const e of i)t.classes.push(e);const o=e.getStyleNames();for(const e of o)t.styles.push(e);return t}static createFrom(e,t){if(t||(t=new tl(e)),e.is("$text"))return t.add(e),t;e.is("element")&&t.add(e,tl.consumablesFromElement(e)),e.is("documentFragment")&&t.add(e);for(const n of e.getChildren())t=tl.createFrom(n,t);return t}}class nl{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 in this._consumables)t in e&&this._add(t,e[t])}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const t in this._consumables)if(t in e){const n=this._test(t,e[t]);if(!0!==n)return n}return!0}consume(e){e.name&&(this._canConsumeName=!1);for(const t in this._consumables)t in e&&this._consume(t,e[t])}revert(e){e.name&&(this._canConsumeName=!0);for(const t in this._consumables)t in e&&this._revert(t,e[t])}_add(e,t){const n=Ue(t)?t:[t],i=this._consumables[e];for(const t of n){if("attributes"===e&&("class"===t||"style"===t))throw new y("viewconsumable-invalid-attribute",this);if(i.set(t,!0),"styles"===e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))i.set(e,!0)}}_test(e,t){const n=Ue(t)?t:[t],i=this._consumables[e];for(const t of n)if("attributes"!==e||"class"!==t&&"style"!==t){const e=i.get(t);if(void 0===e)return null;if(!e)return!1}else{const e="class"==t?"classes":"styles",n=this._test(e,[...this._consumables[e].keys()]);if(!0!==n)return n}return!0}_consume(e,t){const n=Ue(t)?t:[t],i=this._consumables[e];for(const t of n)if("attributes"!==e||"class"!==t&&"style"!==t){if(i.set(t,!1),"styles"==e)for(const e of this.element.document.stylesProcessor.getRelatedStyles(t))i.set(e,!1)}else{const e="class"==t?"classes":"styles";this._consume(e,[...this._consumables[e].keys()])}}_revert(e,t){const n=Ue(t)?t:[t],i=this._consumables[e];for(const t of n)if("attributes"!==e||"class"!==t&&"style"!==t){!1===i.get(t)&&i.set(t,!0)}else{const e="class"==t?"classes":"styles";this._revert(e,[...this._consumables[e].keys()])}}}class il{constructor(){this._sourceDefinitions={},this._attributeProperties={},this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",((e,t)=>{t[0]=new ol(t[0])}),{priority:"highest"}),this.on("checkChild",((e,t)=>{t[0]=new ol(t[0]),t[1]=this.getDefinition(t[1])}),{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new y("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 y("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:e.is&&(e.is("$text")||e.is("$textProxy"))?"$text":e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const t=this.getDefinition(e);return!(!t||!t.isBlock)}isLimit(e){const t=this.getDefinition(e);return!!t&&!(!t.isLimit&&!t.isObject)}isObject(e){const t=this.getDefinition(e);return!!t&&!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent)}isInline(e){const t=this.getDefinition(e);return!(!t||!t.isInline)}isSelectable(e){const t=this.getDefinition(e);return!!t&&!(!t.isSelectable&&!t.isObject)}isContent(e){const t=this.getDefinition(e);return!!t&&!(!t.isContent&&!t.isObject)}checkChild(e,t){return!!t&&this._checkContextMatch(t,e)}checkAttribute(e,t){const n=this.getDefinition(e.last);return!!n&&n.allowAttributes.includes(t)}checkMerge(e,t=null){if(e instanceof rc){const t=e.nodeBefore,n=e.nodeAfter;if(!(t instanceof nc))throw new y("schema-check-merge-no-element-before",this);if(!(n instanceof nc))throw new y("schema-check-merge-no-element-after",this);return this.checkMerge(t,n)}for(const n of t.getChildren())if(!this.checkChild(e,n))return!1;return!0}addChildCheck(e){this.on("checkChild",((t,[n,i])=>{if(!i)return;const o=e(n,i);"boolean"==typeof o&&(t.stop(),t.return=o)}),{priority:"high"})}addAttributeCheck(e){this.on("checkAttribute",((t,[n,i])=>{const o=e(n,i);"boolean"==typeof o&&(t.stop(),t.return=o)}),{priority:"high"})}setAttributeProperties(e,t){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),t)}getAttributeProperties(e){return this._attributeProperties[e]||{}}getLimitElement(e){let t;if(e instanceof rc)t=e.parent;else{t=(e instanceof lc?[e]:Array.from(e.getRanges())).reduce(((e,t)=>{const n=t.getCommonAncestor();return e?e.getCommonAncestor(n,{includeSelf:!0}):n}),null)}for(;!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const n=[...e.getFirstPosition().getAncestors(),new Xa("",e.getAttributes())];return this.checkAttribute(n,t)}{const n=e.getRanges();for(const e of n)for(const n of e)if(this.checkAttribute(n.item,t))return!0}return!1}*getValidRanges(e,t){e=function*(e){for(const t of e)yield*t.getMinimalFlatRanges()}(e);for(const n of e)yield*this._getValidRangesForRange(n,t)}getNearestSelectionRange(e,t="both"){if(this.checkChild(e,"$text"))return new lc(e);let n,i;const o=e.getAncestors().reverse().find((e=>this.isLimit(e)))||e.root;"both"!=t&&"backward"!=t||(n=new ic({boundaries:lc._createIn(o),startPosition:e,direction:"backward"})),"both"!=t&&"forward"!=t||(i=new ic({boundaries:lc._createIn(o),startPosition:e}));for(const e of function*(e,t){let n=!1;for(;!n;){if(n=!0,e){const t=e.next();t.done||(n=!1,yield{walker:e,value:t.value})}if(t){const e=t.next();e.done||(n=!1,yield{walker:t,value:e.value})}}}(n,i)){const t=e.walker==n?"elementEnd":"elementStart",i=e.value;if(i.type==t&&this.isObject(i.item))return lc._createOn(i.item);if(this.checkChild(i.nextPosition,"$text"))return new lc(i.nextPosition)}return null}findAllowedParent(e,t){let n=e.parent;for(;n;){if(this.checkChild(n,t))return n;if(this.isLimit(n))return null;n=n.parent}return null}setAllowedAttributes(e,t,n){const i=n.model;for(const[o,r]of Object.entries(t))i.schema.checkAttribute(e,o)&&n.setAttribute(o,r,e)}removeDisallowedAttributes(e,t){for(const n of e)if(n.is("$text"))bl(this,n,t);else{const e=lc._createIn(n).getPositions();for(const n of e){bl(this,n.nodeBefore||n.parent,t)}}}getAttributesWithProperty(e,t,n){const i={};for(const[o,r]of e.getAttributes()){const e=this.getAttributeProperties(o);void 0!==e[t]&&(void 0!==n&&n!==e[t]||(i[o]=r))}return i}createContext(e){return new ol(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,n=Object.keys(t);for(const i of n)e[i]=rl(t[i],i);for(const t of n)sl(e,t);for(const t of n)al(e,t);for(const t of n)cl(e,t);for(const t of n)ll(e,t),ul(e,t);for(const t of n)dl(e,t),hl(e,t),fl(e,t);this._compiledDefinitions=e}_checkContextMatch(e,t,n=t.length-1){const i=t.getItem(n);if(e.allowIn.includes(i.name)){if(0==n)return!0;{const e=this.getDefinition(i);return this._checkContextMatch(e,t,n-1)}}return!1}*_getValidRangesForRange(e,t){let n=e.start,i=e.start;for(const o of e.getItems({shallow:!0}))o.is("element")&&(yield*this._getValidRangesForRange(lc._createIn(o),t)),this.checkAttribute(o,t)||(n.isEqual(i)||(yield new lc(n,i)),n=rc._createAfter(o)),i=rc._createAfter(o);n.isEqual(i)||(yield new lc(n,i))}}Et(il,kt);class ol{constructor(e){if(e instanceof ol)return e;"string"==typeof e?e=[e]:Array.isArray(e)||(e=e.getAncestors({includeSelf:!0})),this._items=e.map(ml)}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 ol([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 rl(e,t){const n={name:t,allowIn:[],allowContentOf:[],allowWhere:[],allowAttributes:[],allowAttributesOf:[],allowChildren:[],inheritTypesFrom:[]};return function(e,t){for(const n of e){const e=Object.keys(n).filter((e=>e.startsWith("is")));for(const i of e)t[i]=n[i]}}(e,n),pl(e,n,"allowIn"),pl(e,n,"allowContentOf"),pl(e,n,"allowWhere"),pl(e,n,"allowAttributes"),pl(e,n,"allowAttributesOf"),pl(e,n,"allowChildren"),pl(e,n,"inheritTypesFrom"),function(e,t){for(const n of e){const e=n.inheritAllFrom;e&&(t.allowContentOf.push(e),t.allowWhere.push(e),t.allowAttributesOf.push(e),t.inheritTypesFrom.push(e))}}(e,n),n}function sl(e,t){const n=e[t];for(const i of n.allowChildren){const n=e[i];n&&n.allowIn.push(t)}n.allowChildren.length=0}function al(e,t){for(const n of e[t].allowContentOf)if(e[n]){gl(e,n).forEach((e=>{e.allowIn.push(t)}))}delete e[t].allowContentOf}function cl(e,t){for(const n of e[t].allowWhere){const i=e[n];if(i){const n=i.allowIn;e[t].allowIn.push(...n)}}delete e[t].allowWhere}function ll(e,t){for(const n of e[t].allowAttributesOf){const i=e[n];if(i){const n=i.allowAttributes;e[t].allowAttributes.push(...n)}}delete e[t].allowAttributesOf}function ul(e,t){const n=e[t];for(const t of n.inheritTypesFrom){const i=e[t];if(i){const e=Object.keys(i).filter((e=>e.startsWith("is")));for(const t of e)t in n||(n[t]=i[t])}}delete n.inheritTypesFrom}function dl(e,t){const n=e[t],i=n.allowIn.filter((t=>e[t]));n.allowIn=Array.from(new Set(i))}function hl(e,t){const n=e[t];for(const i of n.allowIn){e[i].allowChildren.push(t)}}function fl(e,t){const n=e[t];n.allowAttributes=Array.from(new Set(n.allowAttributes))}function pl(e,t,n){for(const i of e)"string"==typeof i[n]?t[n].push(i[n]):Array.isArray(i[n])&&t[n].push(...i[n])}function gl(e,t){const n=e[t];return(i=e,Object.keys(i).map((e=>i[e]))).filter((e=>e.allowIn.includes(n.name)));var i}function ml(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 bl(e,t,n){for(const i of t.getAttributeKeys())e.checkAttribute(t,i)||n.removeAttribute(i,t)}class wl{constructor(e={}){this._splitParts=new Map,this._cursorParents=new Map,this._modelCursor=null,this._emptyElementsToKeep=new Set,this.conversionApi=Object.assign({},e),this.conversionApi.convertItem=this._convertItem.bind(this),this.conversionApi.convertChildren=this._convertChildren.bind(this),this.conversionApi.safeInsert=this._safeInsert.bind(this),this.conversionApi.updateConversionResult=this._updateConversionResult.bind(this),this.conversionApi.splitToAllowedParent=this._splitToAllowedParent.bind(this),this.conversionApi.getSplitParts=this._getSplitParts.bind(this),this.conversionApi.keepEmptyElement=this._keepEmptyElement.bind(this)}convert(e,t,n=["$root"]){this.fire("viewCleanup",e),this._modelCursor=function(e,t){let n;for(const i of new ol(e)){const e={};for(const t of i.getAttributeKeys())e[t]=i.getAttribute(t);const o=t.createElement(i.name,e);n&&t.append(o,n),n=rc._createAt(o,0)}return n}(n,t),this.conversionApi.writer=t,this.conversionApi.consumable=tl.createFrom(e),this.conversionApi.store={};const{modelRange:i}=this._convertItem(e,this._modelCursor),o=t.createDocumentFragment();if(i){this._removeEmptyElements();for(const e of Array.from(this._modelCursor.parent.getChildren()))t.append(e,o);o.markers=function(e,t){const n=new Set,i=new Map,o=lc._createIn(e).getItems();for(const e of o)"$marker"==e.name&&n.add(e);for(const e of n){const n=e.getAttribute("data-name"),o=t.createPositionBefore(e);i.has(n)?i.get(n).end=o.clone():i.set(n,new lc(o.clone())),t.remove(e)}return i}(o,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,o}_convertItem(e,t){const n=Object.assign({viewItem:e,modelCursor:t,modelRange:null});if(e.is("element")?this.fire("element:"+e.name,n,this.conversionApi):e.is("$text")?this.fire("text",n,this.conversionApi):this.fire("documentFragment",n,this.conversionApi),n.modelRange&&!(n.modelRange instanceof lc))throw new y("view-conversion-dispatcher-incorrect-result",this);return{modelRange:n.modelRange,modelCursor:n.modelCursor}}_convertChildren(e,t){let n=t.is("position")?t:rc._createAt(t,0);const i=new lc(n);for(const t of Array.from(e.getChildren())){const e=this._convertItem(t,n);e.modelRange instanceof lc&&(i.end=e.modelRange.end,n=e.modelCursor)}return{modelRange:i,modelCursor:n}}_safeInsert(e,t){const n=this._splitToAllowedParent(e,t);return!!n&&(this.conversionApi.writer.insert(e,n.position),!0)}_updateConversionResult(e,t){const n=this._getSplitParts(e),i=this.conversionApi.writer;t.modelRange||(t.modelRange=i.createRange(i.createPositionBefore(e),i.createPositionAfter(n[n.length-1])));const o=this._cursorParents.get(e);t.modelCursor=o?i.createPositionAt(o,0):t.modelRange.end}_splitToAllowedParent(e,t){const{schema:n,writer:i}=this.conversionApi;let o=n.findAllowedParent(t,e);if(o){if(o===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(o)&&(o=null)}if(!o)return Wc(t,e,n)?{position:qc(t,i)}:null;const r=this.conversionApi.writer.split(t,o),s=[];for(const e of r.range.getWalker())if("elementEnd"==e.type)s.push(e.item);else{const t=s.pop(),n=e.item;this._registerSplitPair(t,n)}const a=r.range.end.parent;return this._cursorParents.set(e,a),{position:r.position,cursorParent:a}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);const n=this._splitParts.get(e);this._splitParts.set(t,n),n.push(t)}_getSplitParts(e){let t;return t=this._splitParts.has(e)?this._splitParts.get(e):[e],t}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){let e=!1;for(const t of this._splitParts.keys())t.isEmpty&&!this._emptyElementsToKeep.has(t)&&(this.conversionApi.writer.remove(t),this._splitParts.delete(t),e=!0);e&&this._removeEmptyElements()}}Et(wl,O);class kl{getHtml(e){const t=document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class vl{constructor(e){this.domParser=new DOMParser,this.domConverter=new Cs(e,{renderingMode:"data"}),this.htmlWriter=new kl}toData(e){const t=this.domConverter.viewToDom(e,document);return this.htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this.domConverter.domToView(t)}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode="marked"==e?"markedNbsp":"nbsp"}_toDom(e){e.match(/<(?:html|body|head|meta)(?:\s[^>]*)?>/i)||(e=`${e}`);const t=this.domParser.parseFromString(e,"text/html"),n=t.createDocumentFragment(),i=t.body.childNodes;for(;i.length>0;)n.appendChild(i[0]);return n}}class _l{constructor(e,t){this.model=e,this.mapper=new uc,this.downcastDispatcher=new fc({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",((e,t,n)=>{if(!n.consumable.consume(t.item,e.name))return;const i=n.writer,o=n.mapper.toViewPosition(t.range.start),r=i.createText(t.item.data);i.insert(o,r)}),{priority:"lowest"}),this.downcastDispatcher.on("insert",((e,t,n)=>{n.convertAttributes(t.item),t.reconversion||!t.item.is("element")||t.item.isEmpty||n.convertChildren(t.item)}),{priority:"lowest"}),this.upcastDispatcher=new wl({schema:e.schema}),this.viewDocument=new fr(t),this.stylesProcessor=t,this.htmlProcessor=new vl(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new Lr(this.viewDocument),this.upcastDispatcher.on("text",((e,t,{schema:n,consumable:i,writer:o})=>{let r=t.modelCursor;if(!i.test(t.viewItem))return;if(!n.checkChild(r,"$text")){if(!Wc(r,"$text",n))return;r=qc(r,o)}i.consume(t.viewItem);const s=o.createText(t.viewItem.data);o.insert(s,r),t.modelRange=o.createRange(r,r.getShiftedBy(s.offsetSize)),t.modelCursor=t.modelRange.end}),{priority:"lowest"}),this.upcastDispatcher.on("element",((e,t,n)=>{if(!t.modelRange&&n.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:i}=n.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=i}}),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",((e,t,n)=>{if(!t.modelRange&&n.consumable.consume(t.viewItem,{name:!0})){const{modelRange:e,modelCursor:i}=n.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=i}}),{priority:"lowest"}),this.decorate("init"),this.decorate("set"),this.decorate("get"),this.on("init",(()=>{this.fire("ready")}),{priority:"lowest"}),this.on("ready",(()=>{this.model.enqueueChange({isUndoable:!1},Uc)}),{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:n="empty"}=e;if(!this._checkIfRootsExists([t]))throw new y("datacontroller-get-non-existent-root",this);const i=this.model.document.getRoot(t);return"empty"!==n||this.model.hasContent(i,{ignoreWhitespaces:!0})?this.stringify(i,e):""}stringify(e,t={}){const n=this.toView(e,t);return this.processor.toData(n)}toView(e,t={}){const n=this.viewDocument,i=this._viewWriter;this.mapper.clearBindings();const o=lc._createIn(e),r=new Dr(n);this.mapper.bindElements(e,r);const s=e.is("documentFragment")?e.markers:function(e){const t=[],n=e.root.document;if(!n)return new Map;const i=lc._createIn(e);for(const e of n.model.markers){const n=e.getRange(),o=n.isCollapsed,r=n.start.isEqual(i.start)||n.end.isEqual(i.end);if(o&&r)t.push([e.name,n]);else{const o=i.getIntersection(n);o&&t.push([e.name,o])}}return t.sort((([e,t],[n,i])=>{if("after"!==t.end.compareWith(i.start))return 1;if("before"!==t.start.compareWith(i.end))return-1;switch(t.start.compareWith(i.start)){case"before":return 1;case"after":return-1;default:switch(t.end.compareWith(i.end)){case"before":return 1;case"after":return-1;default:return n.localeCompare(e)}}})),new Map(t)}(e);return this.downcastDispatcher.convert(o,s,i,t),r}init(e){if(this.model.document.version)throw new y("datacontroller-init-document-not-empty",this);let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new y("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},(e=>{for(const n of Object.keys(t)){const i=this.model.document.getRoot(n);e.insert(this.parse(t[n],i),i,0)}})),Promise.resolve()}set(e,t={}){let n={};if("string"==typeof e?n.main=e:n=e,!this._checkIfRootsExists(Object.keys(n)))throw new y("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},(e=>{e.setSelection(null),e.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const t of Object.keys(n)){const i=this.model.document.getRoot(t);e.remove(e.createRangeIn(i)),e.insert(this.parse(n[t],i),i,0)}}))}parse(e,t="$root"){const n=this.processor.toView(e);return this.toModel(n,t)}toModel(e,t="$root"){return this.model.change((n=>this.upcastDispatcher.convert(e,n,t)))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const t of e)if(!this.model.document.getRootNames().includes(t))return!1;return!0}}Et(_l,kt);class yl{constructor(e,t){this._helpers=new Map,this._downcast=Ui(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=Ui(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const n=this._downcast.includes(t);if(!this._upcast.includes(t)&&!n)throw new y("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:n})}for(e){if(!this._helpers.has(e))throw new y("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:n}of xl(e))this.for("upcast").elementToElement({model:t,view:n,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:n}of xl(e))this.for("upcast").elementToAttribute({view:n,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:n}of xl(e))this.for("upcast").attributeToAttribute({view:n,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:n}){if(this._helpers.has(e))throw new y("conversion-group-exists",this);const i=n?new Ic(t):new $c(t);this._helpers.set(e,i)}}function*xl(e){if(e.model.values)for(const t of e.model.values){const n={key:e.model.key,value:t},i=e.view[t],o=e.upcastAlso?e.upcastAlso[t]:void 0;yield*Al(n,i,o)}else yield*Al(e.model,e.view,e.upcastAlso)}function*Al(e,t,n){if(yield{model:e,view:t},n)for(const t of Ui(n))yield{model:e,view:t}}class El{constructor(e={}){"string"==typeof e&&(e="transparent"===e?{isUndoable:!1}:{},x("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:n=!0,isUndo:i=!1,isTyping:o=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=n,this.isUndo=i,this.isTyping=o}get type(){return x("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 Cl{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){return new this(e.baseVersion)}}class Tl{constructor(e){this.markers=new Map,this._children=new tc,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 root(){return this}get parent(){return null}is(e){return"documentFragment"===e||"model:documentFragment"===e}getChild(e){return this._children.getNode(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(const n of e)t=t.getChild(t.offsetToIndex(n));return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const n of e)n.name?t.push(nc.fromJSON(n)):t.push(Xa.fromJSON(n));return new Tl(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const n=function(e){if("string"==typeof e)return[new Xa(e)];Bi(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Xa(e):e instanceof ec?new Xa(e.data,e.getAttributes()):e))}(t);for(const e of n)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const e of n)e.parent=null;return n}}function Sl(e,t){const n=(t=Ol(t)).reduce(((e,t)=>e+t.offsetSize),0),i=e.parent;Rl(e);const o=e.index;return i._insertChild(o,t),Ml(i,o+t.length),Ml(i,o),new lc(e,e.getShiftedBy(n))}function Pl(e){if(!e.isFlat)throw new y("operation-utils-remove-range-not-flat",this);const t=e.start.parent;Rl(e.start),Rl(e.end);const n=t._removeChildren(e.start.index,e.end.index-e.start.index);return Ml(t,e.start.index),n}function Il(e,t){if(!e.isFlat)throw new y("operation-utils-move-range-not-flat",this);const n=Pl(e);return Sl(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),n)}function Ol(e){const t=[];e instanceof Array||(e=[e]);for(let n=0;ne.maxOffset)throw new y("move-operation-nodes-do-not-exist",this);if(e===t&&n=n&&this.targetPosition.path[e]e._clone(!0)))),t=new Vl(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new rc(e,[0]);return new zl(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffsete._clone(!0)))),Sl(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){const n=[];for(const t of e.nodes)t.name?n.push(nc.fromJSON(t)):n.push(Xa.fromJSON(t));const i=new Vl(rc.fromJSON(e.position,t),n,e.baseVersion);return i.shouldReceiveAttributes=e.shouldReceiveAttributes,i}}class Bl extends Cl{constructor(e,t,n,i,o,r){super(r),this.name=e,this.oldRange=t?t.clone():null,this.newRange=n?n.clone():null,this.affectsData=o,this._markers=i}get type(){return"marker"}clone(){return new Bl(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new Bl(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){const e=this.newRange?"_set":"_remove";this._markers[e](this.name,this.newRange,!0,this.affectsData)}toJSON(){const e=super.toJSON();return this.oldRange&&(e.oldRange=this.oldRange.toJSON()),this.newRange&&(e.newRange=this.newRange.toJSON()),delete e._markers,e}static get className(){return"MarkerOperation"}static fromJSON(e,t){return new Bl(e.name,e.oldRange?lc.fromJSON(e.oldRange,t):null,e.newRange?lc.fromJSON(e.newRange,t):null,t.model.markers,e.affectsData,e.baseVersion)}}class Fl extends Cl{constructor(e,t,n,i){super(i),this.position=e,this.position.stickiness="toNext",this.oldName=t,this.newName=n}get type(){return"rename"}clone(){return new Fl(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new Fl(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const e=this.position.nodeAfter;if(!(e instanceof nc))throw new y("rename-operation-wrong-position",this);if(e.name!==this.oldName)throw new y("rename-operation-wrong-name",this)}_execute(){this.position.nodeAfter.name=this.newName}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e}static get className(){return"RenameOperation"}static fromJSON(e,t){return new Fl(rc.fromJSON(e.position,t),e.oldName,e.newName,e.baseVersion)}}class Hl extends Cl{constructor(e,t,n,i,o){super(o),this.root=e,this.key=t,this.oldValue=n,this.newValue=i}get type(){return null===this.oldValue?"addRootAttribute":null===this.newValue?"removeRootAttribute":"changeRootAttribute"}clone(){return new Hl(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new Hl(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new y("rootattribute-operation-not-a-root",this,{root:this.root,key:this.key});if(null!==this.oldValue&&this.root.getAttribute(this.key)!==this.oldValue)throw new y("rootattribute-operation-wrong-old-value",this,{root:this.root,key:this.key});if(null===this.oldValue&&null!==this.newValue&&this.root.hasAttribute(this.key))throw new y("rootattribute-operation-attribute-exists",this,{root:this.root,key:this.key})}_execute(){null!==this.newValue?this.root._setAttribute(this.key,this.newValue):this.root._removeAttribute(this.key)}toJSON(){const e=super.toJSON();return e.root=this.root.toJSON(),e}static get className(){return"RootAttributeOperation"}static fromJSON(e,t){if(!t.getRoot(e.root))throw new y("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new Hl(t.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}}class Ul extends Cl{constructor(e,t,n,i,o){super(o),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=t,this.targetPosition=n.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=i.clone()}get type(){return"merge"}get deletionPosition(){return new rc(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const e=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new lc(this.sourcePosition,e)}clone(){return new this.constructor(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.targetPosition._getTransformedByMergeOperation(this),t=this.sourcePosition.path.slice(0,-1),n=new rc(this.sourcePosition.root,t)._getTransformedByMergeOperation(this);return new Wl(e,this.howMany,n,this.graveyardPosition,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent;if(!e.parent)throw new y("merge-operation-source-position-invalid",this);if(!t.parent)throw new y("merge-operation-target-position-invalid",this);if(this.howMany!=e.maxOffset)throw new y("merge-operation-how-many-invalid",this)}_execute(){const e=this.sourcePosition.parent;Il(lc._createIn(e),this.targetPosition),Il(lc._createOn(e),this.graveyardPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=e.sourcePosition.toJSON(),e.targetPosition=e.targetPosition.toJSON(),e.graveyardPosition=e.graveyardPosition.toJSON(),e}static get className(){return"MergeOperation"}static fromJSON(e,t){const n=rc.fromJSON(e.sourcePosition,t),i=rc.fromJSON(e.targetPosition,t),o=rc.fromJSON(e.graveyardPosition,t);return new this(n,e.howMany,i,o,e.baseVersion)}}class Wl extends Cl{constructor(e,t,n,i,o){super(o),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=n,this.graveyardPosition=i?i.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new rc(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new lc(this.splitPosition,e)}clone(){return new this.constructor(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new rc(e,[0]);return new Ul(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset{for(const t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof lc)for(const n of e.getItems())t(n);else t(e)}move(e,t,n){if(this._assertWriterUsedCorrectly(),!(e instanceof lc))throw new y("writer-move-invalid-range",this);if(!e.isFlat)throw new y("writer-move-range-not-flat",this);const i=rc._createAt(t,n);if(i.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!Ql(e.root,i.root))throw new y("writer-move-different-document",this);const o=e.root.document?e.root.document.version:null,r=new zl(e.start,e.end.offset-e.start.offset,i,o);this.batch.addOperation(r),this.model.applyOperation(r)}remove(e){this._assertWriterUsedCorrectly();const t=(e instanceof lc?e:lc._createOn(e)).getMinimalFlatRanges().reverse();for(const e of t)this._addOperationForAffectedMarkers("move",e),Yl(e.start,e.end.offset-e.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,n=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof nc))throw new y("writer-merge-no-element-before",this);if(!(n instanceof nc))throw new y("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,n){return this.model.createPositionFromPath(e,t,n)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(e,t,n){return this.model.createSelection(e,t,n)}_mergeDetached(e){const t=e.nodeBefore,n=e.nodeAfter;this.move(lc._createIn(n),rc._createAt(t,"end")),this.remove(n)}_merge(e){const t=rc._createAt(e.nodeBefore,"end"),n=rc._createAt(e.nodeAfter,0),i=e.root.document.graveyard,o=new rc(i,[0]),r=e.root.document.version,s=new Ul(n,e.nodeAfter.maxOffset,t,o,r);this.batch.addOperation(s),this.model.applyOperation(s)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof nc))throw new y("writer-rename-not-element-instance",this);const n=e.root.document?e.root.document.version:null,i=new Fl(rc._createBefore(e),e.name,t,n);this.batch.addOperation(i),this.model.applyOperation(i)}split(e,t){this._assertWriterUsedCorrectly();let n,i,o=e.parent;if(!o.parent)throw new y("writer-split-element-no-parent",this);if(t||(t=o.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new y("writer-split-invalid-limit-element",this);do{const t=o.root.document?o.root.document.version:null,r=o.maxOffset-e.offset,s=Wl.getInsertionPosition(e),a=new Wl(e,r,s,null,t);this.batch.addOperation(a),this.model.applyOperation(a),n||i||(n=o,i=e.parent.nextSibling),o=(e=this.createPositionAfter(e.parent)).parent}while(o!==t);return{position:e,range:new lc(rc._createAt(n,"end"),rc._createAt(i,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new y("writer-wrap-range-not-flat",this);const n=t instanceof nc?t:new nc(t);if(n.childCount>0)throw new y("writer-wrap-element-not-empty",this);if(null!==n.parent)throw new y("writer-wrap-element-attached",this);this.insert(n,e.start);const i=new lc(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(i,rc._createAt(n,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new y("writer-unwrap-element-no-parent",this);this.move(lc._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new y("writer-addmarker-no-usingoperation",this);const n=t.usingOperation,i=t.range,o=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new y("writer-addmarker-marker-exists",this);if(!i)throw new y("writer-addmarker-no-range",this);return n?(Gl(this,e,null,i,o),this.model.markers.get(e)):this.model.markers._set(e,i,n,o)}updateMarker(e,t){this._assertWriterUsedCorrectly();const n="string"==typeof e?e:e.name,i=this.model.markers.get(n);if(!i)throw new y("writer-updatemarker-marker-not-exists",this);if(!t)return x("writer-updatemarker-reconvert-using-editingcontroller",{markerName:n}),void this.model.markers._refresh(i);const o="boolean"==typeof t.usingOperation,r="boolean"==typeof t.affectsData,s=r?t.affectsData:i.affectsData;if(!o&&!t.range&&!r)throw new y("writer-updatemarker-wrong-options",this);const a=i.getRange(),c=t.range?t.range:a;o&&t.usingOperation!==i.managedUsingOperations?t.usingOperation?Gl(this,n,null,c,s):(Gl(this,n,a,null,s),this.model.markers._set(n,c,void 0,s)):i.managedUsingOperations?Gl(this,n,a,c,s):this.model.markers._set(n,c,void 0,s)}removeMarker(e){this._assertWriterUsedCorrectly();const t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new y("writer-removemarker-no-marker",this);const n=this.model.markers.get(t);if(!n.managedUsingOperations)return void this.model.markers._remove(t);Gl(this,t,n.getRange(),null,n.affectsData)}setSelection(e,t,n){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(e,t,n)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._setSelectionAttribute(e,t);else for(const[t,n]of to(e))this._setSelectionAttribute(t,n)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._removeSelectionAttribute(e);else for(const t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){const n=this.model.document.selection;if(n.isCollapsed&&n.anchor.parent.isEmpty){const i=Ec._getStoreAttributeKey(e);this.setAttribute(i,t,n.anchor.parent)}n._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const n=Ec._getStoreAttributeKey(e);this.removeAttribute(n,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new y("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const n of this.model.markers){if(!n.managedUsingOperations)continue;const i=n.getRange();let o=!1;if("move"===e)o=t.containsPosition(i.start)||t.start.isEqual(i.start)||t.containsPosition(i.end)||t.end.isEqual(i.end);else{const e=t.nodeBefore,n=t.nodeAfter,r=i.start.parent==e&&i.start.isAtEnd,s=i.end.parent==n&&0==i.end.offset,a=i.end.nodeAfter==n,c=i.start.nodeAfter==n;o=r||s||a||c}o&&this.updateMarker(n.name,{range:i})}}}function Zl(e,t,n,i){const o=e.model,r=o.document;let s,a,c,l=i.start;for(const e of i.getWalker({shallow:!0}))c=e.item.getAttribute(t),s&&a!=c&&(a!=n&&u(),l=s),s=e.nextPosition,a=c;function u(){const i=new lc(l,s),c=i.root.document?r.version:null,u=new Dl(i,t,a,n,c);e.batch.addOperation(u),o.applyOperation(u)}s instanceof rc&&s!=l&&a!=n&&u()}function Kl(e,t,n,i){const o=e.model,r=o.document,s=i.getAttribute(t);let a,c;if(s!=n){if(i.root===i){const e=i.document?r.version:null;c=new Hl(i,t,s,n,e)}else{a=new lc(rc._createBefore(i),e.createPositionAfter(i));const o=a.root.document?r.version:null;c=new Dl(a,t,s,n,o)}e.batch.addOperation(c),o.applyOperation(c)}}function Gl(e,t,n,i,o){const r=e.model,s=r.document,a=new Bl(t,n,i,r.markers,o,s.version);e.batch.addOperation(a),r.applyOperation(a)}function Yl(e,t,n,i){let o;if(e.root.document){const n=i.document,r=new rc(n.graveyard,[0]);o=new zl(e,t,r,n.version)}else o=new Ll(e,t);n.addOperation(o),i.applyOperation(o)}function Ql(e,t){return e===t||e instanceof ql&&t instanceof ql}class Jl{constructor(e){this._markerCollection=e,this._changesInElement=new Map,this._elementSnapshots=new Map,this._changedMarkers=new Map,this._changeCount=0,this._cachedChanges=null,this._cachedChangesWithGraveyard=null,this._refreshedItems=new Set}get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.size}bufferOperation(e){switch(e.type){case"insert":if(this._isInInsertedElement(e.position.parent))return;this._markInsert(e.position.parent,e.position.offset,e.nodes.maxOffset);break;case"addAttribute":case"removeAttribute":case"changeAttribute":for(const t of e.range.getItems({shallow:!0}))this._isInInsertedElement(t.parent)||this._markAttribute(t);break;case"remove":case"move":case"reinsert":{if(e.sourcePosition.isEqual(e.targetPosition)||e.sourcePosition.getShiftedBy(e.howMany).isEqual(e.targetPosition))return;const t=this._isInInsertedElement(e.sourcePosition.parent),n=this._isInInsertedElement(e.targetPosition.parent);t||this._markRemove(e.sourcePosition.parent,e.sourcePosition.offset,e.howMany),n||this._markInsert(e.targetPosition.parent,e.getMovedRangeStart().offset,e.howMany);break}case"rename":{if(this._isInInsertedElement(e.position.parent))return;this._markRemove(e.position.parent,e.position.offset,1),this._markInsert(e.position.parent,e.position.offset,1);const t=lc._createFromPositionAndShift(e.position,1);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getData();this.bufferMarkerChange(e.name,t,t)}break}case"split":{const t=e.splitPosition.parent;this._isInInsertedElement(t)||this._markRemove(t,e.splitPosition.offset,e.howMany),this._isInInsertedElement(e.insertionPosition.parent)||this._markInsert(e.insertionPosition.parent,e.insertionPosition.offset,1),e.graveyardPosition&&this._markRemove(e.graveyardPosition.parent,e.graveyardPosition.offset,1);break}case"merge":{const t=e.sourcePosition.parent;this._isInInsertedElement(t.parent)||this._markRemove(t.parent,t.startOffset,1);const n=e.graveyardPosition.parent;this._markInsert(n,e.graveyardPosition.offset,1);const i=e.targetPosition.parent;this._isInInsertedElement(i)||this._markInsert(i,e.targetPosition.offset,t.maxOffset);break}}this._cachedChanges=null}bufferMarkerChange(e,t,n){const i=this._changedMarkers.get(e);i?(i.newMarkerData=n,null==i.oldMarkerData.range&&null==n.range&&this._changedMarkers.delete(e)):this._changedMarkers.set(e,{newMarkerData:n,oldMarkerData:t})}getMarkersToRemove(){const e=[];for(const[t,n]of this._changedMarkers)null!=n.oldMarkerData.range&&e.push({name:t,range:n.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,n]of this._changedMarkers)null!=n.newMarkerData.range&&e.push({name:t,range:n.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map((([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}})))}hasDataChanges(){if(this._changesInElement.size>0)return!0;for(const{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){const n=e.range&&!t.range,i=!e.range&&t.range,o=e.range&&t.range&&!e.range.isEqual(t.range);if(n||i||o)return!0}}return!1}getChanges(e={includeChangesInGraveyard:!1}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const e of this._changesInElement.keys()){const n=this._changesInElement.get(e).sort(((e,t)=>e.offset===t.offset?e.type!=t.type?"remove"==e.type?-1:1:0:e.offsete.position.root!=t.position.root?e.position.root.rootNamee));for(const e of t)delete e.changeCount,"attribute"==e.type&&(delete e.position,delete e.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(tu),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementSnapshots.clear(),this._changedMarkers.clear(),this._refreshedItems=new Set,this._cachedChanges=null}_refreshItem(e){if(this._isInInsertedElement(e.parent))return;this._markRemove(e.parent,e.startOffset,e.offsetSize),this._markInsert(e.parent,e.startOffset,e.offsetSize),this._refreshedItems.add(e);const t=lc._createOn(e);for(const e of this._markerCollection.getMarkersIntersectingRange(t)){const t=e.getData();this.bufferMarkerChange(e.name,t,t)}this._cachedChanges=null}_markInsert(e,t,n){const i={type:"insert",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,i)}_markRemove(e,t,n){const i={type:"remove",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,i),this._removeAllNestedChanges(e,t,n)}_markAttribute(e){const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshot(e);const n=this._getChangesForElement(e);this._handleChange(t,n),n.push(t);for(let e=0;en.offset){if(i>o){const e={type:"attribute",offset:o,howMany:i-o,count:this._changeCount++};this._handleChange(e,t),t.push(e)}e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=n.offset&&e.offseto?(e.nodesToHandle=i-o,e.offset=o):e.nodesToHandle=0);if("remove"==n.type&&e.offsetn.offset){const o={type:"attribute",offset:n.offset,howMany:i-n.offset,count:this._changeCount++};this._handleChange(o,t),t.push(o),e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==n.type&&(e.offset>=n.offset&&i<=o?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=n.offset&&i>=o&&(n.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,n){return{type:"insert",position:rc._createAt(e,t),name:n.name,attributes:new Map(n.attributes),length:1,changeCount:this._changeCount++}}_getRemoveDiff(e,t,n){return{type:"remove",position:rc._createAt(e,t),name:n.name,attributes:new Map(n.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,n){const i=[];n=new Map(n);for(const[o,r]of t){const t=n.has(o)?n.get(o):null;t!==r&&i.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:o,attributeOldValue:r,attributeNewValue:t,changeCount:this._changeCount++}),n.delete(o)}for(const[t,o]of n)i.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:o,changeCount:this._changeCount++});return i}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const n=this._changesInElement.get(t),i=e.startOffset;if(n)for(const e of n)if("insert"==e.type&&i>=e.offset&&ii){for(let t=0;t=e&&i.baseVersione.source)).join("|")+")";return new RegExp(`${e}|${t}(?:‍${t})*`,"ug")}();function su(e,t){const n=String(e).matchAll(ru);return Array.from(n).some((e=>e.index{const n=t[0];if(n.isDocumentOperation&&n.baseVersion!==this.version)throw new y("model-document-applyoperation-wrong-version",this,{operation:n})}),{priority:"highest"}),this.listenTo(e,"applyOperation",((e,t)=>{const n=t[0];n.isDocumentOperation&&this.differ.bufferOperation(n)}),{priority:"high"}),this.listenTo(e,"applyOperation",((e,t)=>{const n=t[0];n.isDocumentOperation&&(this.version++,this.history.addOperation(n))}),{priority:"low"}),this.listenTo(this.selection,"change",(()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0})),this.listenTo(e.markers,"update",((e,t,n,i,o)=>{const r={...t.getData(),range:i};this.differ.bufferMarkerChange(t.name,o,r),null===n&&t.on("change",((e,n)=>{const i=t.getData();this.differ.bufferMarkerChange(t.name,{...i,range:n},i)}))}))}get graveyard(){return this.getRoot(au)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new y("model-document-createroot-name-exists",this,{name:t});const n=new ql(this,e,t);return this.roots.add(n),n}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(){return Array.from(this.roots,(e=>e.rootName)).filter((e=>e!=au))}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=Qi(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){for(const e of this.roots)if(e!==this.graveyard)return e;return this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,n=t.schema,i=t.createPositionFromPath(e,[0]);return n.getNearestSelectionRange(i)||t.createRange(i)}_validateSelectionRange(e){return lu(e.start)&&lu(e.end)}_callPostFixers(e){let t=!1;do{for(const n of this._postFixers)if(this.selection.refresh(),t=n(e),t)break}while(t)}}function lu(e){const t=e.textNode;if(t){const n=t.data,i=e.offset-t.startOffset;return!iu(n,i)&&!ou(n,i)}return!0}Et(cu,O);class uu{constructor(){this._markers=new Map}[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof du?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,n=!1,i=!1){const o=e instanceof du?e.name:e;if(o.includes(","))throw new y("markercollection-incorrect-marker-name",this);const r=this._markers.get(o);if(r){const e=r.getData(),s=r.getRange();let a=!1;return s.isEqual(t)||(r._attachLiveRange(_c.fromRange(t)),a=!0),n!=r.managedUsingOperations&&(r._managedUsingOperations=n,a=!0),"boolean"==typeof i&&i!=r.affectsData&&(r._affectsData=i,a=!0),a&&this.fire("update:"+o,r,s,t,e),r}const s=_c.fromRange(t),a=new du(o,s,n,i);return this._markers.set(o,a),this.fire("update:"+o,a,null,t,{...a.getData(),range:null}),a}_remove(e){const t=e instanceof du?e.name:e,n=this._markers.get(t);return!!n&&(this._markers.delete(t),this.fire("update:"+t,n,n.getRange(),null,n.getData()),this._destroyMarker(n),!0)}_refresh(e){const t=e instanceof du?e.name:e,n=this._markers.get(t);if(!n)throw new y("markercollection-refresh-marker-not-exists",this);const i=n.getRange();this.fire("update:"+t,n,i,i,n.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)null!==t.getRange().getIntersection(e)&&(yield t)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}Et(uu,O);class du{constructor(e,t,n,i){this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=n,this._affectsData=i}get managedUsingOperations(){if(!this._liveRange)throw new y("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new y("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new y("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new y("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new y("marker-destroyed",this);return this._liveRange.toRange()}is(e){return"marker"===e||"model:marker"===e}_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}}Et(du,O);class hu extends Cl{get type(){return"noop"}clone(){return new hu(this.baseVersion)}getReversed(){return new hu(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}const fu={};fu[Dl.className]=Dl,fu[Vl.className]=Vl,fu[Bl.className]=Bl,fu[zl.className]=zl,fu[hu.className]=hu,fu[Cl.className]=Cl,fu[Fl.className]=Fl,fu[Hl.className]=Hl,fu[Wl.className]=Wl,fu[Ul.className]=Ul;class pu extends rc{constructor(e,t,n="toNone"){if(super(e,t,n),!this.root.is("rootElement"))throw new y("model-liveposition-root-not-rootelement",e);gu.call(this)}detach(){this.stopListening()}is(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e}toPosition(){return new rc(this.root,this.path.slice(),this.stickiness)}static fromPosition(e,t){return new this(e.root,e.path.slice(),t||e.stickiness)}}function gu(){this.listenTo(this.root.document.model,"applyOperation",((e,t)=>{const n=t[0];n.isDocumentOperation&&mu.call(this,n)}),{priority:"low"})}function mu(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)}}Et(pu,O);class bu{constructor(e,t,n){this.model=e,this.writer=t,this.position=n,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0),this._firstNode=null,this._lastNode=null,this._lastAutoParagraph=null,this._filterAttributesOf=[],this._affectedStart=null,this._affectedEnd=null}handleNodes(e){for(const t of Array.from(e))this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),n=this.writer.createPositionAfter(e);if(n.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new y("insertcontent-invalid-insertion-position",this);this.position=n,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this.nodeToSelect?lc._createOn(this.nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new lc(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=pu.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 y("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=pu.fromPosition(e,"toPrevious")),this._affectedEnd&&!this._affectedEnd.isBefore(e)||(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=pu.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof nc))return;if(!this._canMergeLeft(e))return;const t=pu._createBefore(e);t.stickiness="toNext";const n=pu.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=pu._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=pu._createAt(t.nodeBefore,"end","toNext")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof nc))return;if(!this._canMergeRight(e))return;const t=pu._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new y("insertcontent-invalid-insertion-position",this);this.position=rc._createAt(t.nodeBefore,"end");const n=pu.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=pu._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=pu._createAt(t.nodeBefore,0,"toPrevious")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof nc&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof nc&&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 wu(e,t,n="auto"){const i=e.getSelectedElement();if(i&&t.schema.isObject(i)&&!t.schema.isInline(i))return["before","after"].includes(n)?t.createRange(t.createPositionAt(i,n)):t.createRangeOn(i);const o=$a(e.getSelectedBlocks());if(!o)return t.createRange(e.focus);if(o.isEmpty)return t.createRange(t.createPositionAt(o,0));const r=t.createPositionAfter(o);return e.focus.isTouching(r)?t.createRange(r):t.createRange(t.createPositionBefore(o))}function ku(e,t,n,i,o={}){if(!e.schema.isObject(t))throw new y("insertobject-element-not-an-object",e,{object:t});let r;r=n?n.is("selection")?n:e.createSelection(n,i):e.document.selection;let s=r;o.findOptimalPosition&&e.schema.isBlock(t)&&(s=e.createSelection(wu(r,e,o.findOptimalPosition)));const a=$a(r.getSelectedBlocks()),c={};return a&&Object.assign(c,e.schema.getAttributesWithProperty(a,"copyOnReplace",!0)),e.change((n=>{s.isCollapsed||e.deleteContent(s,{doNotAutoparagraph:!0});let i=t;const r=s.anchor.parent;!e.schema.checkChild(r,t)&&e.schema.checkChild(r,"paragraph")&&e.schema.checkChild("paragraph",t)&&(i=n.createElement("paragraph"),n.insert(t,i)),e.schema.setAllowedAttributes(i,c,n);const a=e.insertContent(i,s);return a.isCollapsed||o.setSelection&&function(e,t,n,i){const o=e.model;if("after"==n){let n=t.nextSibling;!(n&&o.schema.checkChild(n,"$text"))&&o.schema.checkChild(t.parent,"paragraph")&&(n=e.createElement("paragraph"),o.schema.setAllowedAttributes(n,i,e),o.insertContent(n,e.createPositionAfter(t))),n&&e.setSelection(n,0)}else{if("on"!=n)throw new y("insertobject-invalid-place-parameter-value",o);e.setSelection(t,"on")}}(n,t,o.setSelection,c),a}))}function vu(e,t,n={}){if(t.isCollapsed)return;const i=t.getFirstRange();if("$graveyard"==i.root.rootName)return;const o=e.schema;e.change((e=>{if(!n.doNotResetEntireContent&&function(e,t){const n=e.getLimitElement(t);if(!t.containsEntireContent(n))return!1;const i=t.getFirstRange();if(i.start.parent==i.end.parent)return!1;return e.checkChild(n,"paragraph")}(o,t))return void function(e,t){const n=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(n)),Au(e,e.createPositionAt(n,0),t)}(e,t);const r={};if(!n.doNotAutoparagraph){const e=t.getSelectedElement();e&&Object.assign(r,o.getAttributesWithProperty(e,"copyOnReplace",!0))}const[s,a]=function(e){const t=e.root.document.model,n=e.start;let i=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){const n=function(e){const t=e.parent,n=t.root.document.model.schema,i=t.getAncestors({parentFirst:!0,includeSelf:!0});for(const e of i){if(n.isLimit(e))return null;if(n.isBlock(e))return e}}(i);if(n&&i.isTouching(t.createPositionAt(n,0))){const n=t.createSelection(e);t.modifySelection(n,{direction:"backward"});const o=n.getLastPosition(),r=t.createRange(o,i);t.hasContent(r,{ignoreMarkers:!0})||(i=o)}}return[pu.fromPosition(n,"toPrevious"),pu.fromPosition(i,"toNext")]}(i);s.isTouching(a)||e.remove(e.createRange(s,a)),n.leaveUnmerged||(!function(e,t,n){const i=e.model;if(!xu(e.model.schema,t,n))return;const[o,r]=function(e,t){const n=e.getAncestors(),i=t.getAncestors();let o=0;for(;n[o]&&n[o]==i[o];)o++;return[n[o],i[o]]}(t,n);if(!o||!r)return;!i.hasContent(o,{ignoreMarkers:!0})&&i.hasContent(r,{ignoreMarkers:!0})?yu(e,t,n,o.parent):_u(e,t,n,o.parent)}(e,s,a),o.removeDisallowedAttributes(s.parent.getChildren(),e)),Eu(e,t,s),!n.doNotAutoparagraph&&function(e,t){const n=e.checkChild(t,"$text"),i=e.checkChild(t,"paragraph");return!n&&i}(o,s)&&Au(e,s,t,r),s.detach(),a.detach()}))}function _u(e,t,n,i){const o=t.parent,r=n.parent;if(o!=i&&r!=i){for(t=e.createPositionAfter(o),(n=e.createPositionBefore(r)).isEqual(t)||e.insert(r,t),e.merge(t);n.parent.isEmpty;){const t=n.parent;n=e.createPositionBefore(t),e.remove(t)}xu(e.model.schema,t,n)&&_u(e,t,n,i)}}function yu(e,t,n,i){const o=t.parent,r=n.parent;if(o!=i&&r!=i){for(t=e.createPositionAfter(o),(n=e.createPositionBefore(r)).isEqual(t)||e.insert(o,n);t.parent.isEmpty;){const n=t.parent;t=e.createPositionBefore(n),e.remove(n)}n=e.createPositionBefore(r),function(e,t){const n=t.nodeBefore,i=t.nodeAfter;n.name!=i.name&&e.rename(n,i.name);e.clearAttributes(n),e.setAttributes(Object.fromEntries(i.getAttributes()),n),e.merge(t)}(e,n),xu(e.model.schema,t,n)&&yu(e,t,n,i)}}function xu(e,t,n){const i=t.parent,o=n.parent;return i!=o&&(!e.isLimit(i)&&!e.isLimit(o)&&function(e,t,n){const i=new lc(e,t);for(const e of i.getWalker())if(n.isLimit(e.item))return!1;return!0}(t,n,e))}function Au(e,t,n,i={}){const o=e.createElement("paragraph");e.model.schema.setAllowedAttributes(o,i,e),e.insert(o,t),Eu(e,n,e.createPositionAt(o,0))}function Eu(e,t,n){t instanceof Ec?e.setSelection(n):t.setTo(n)}const Cu=' ,.?!:;"-()';function Tu(e,t){const{isForward:n,walker:i,unit:o,schema:r,treatEmojiAsSingleUnit:s}=e,{type:a,item:c,nextPosition:l}=t;if("text"==a)return"word"===e.unit?function(e,t){let n=e.position.textNode;if(n){let i=e.position.offset-n.startOffset;for(;!Pu(n.data,i,t)&&!Iu(n,i,t);){e.next();const o=t?e.position.nodeAfter:e.position.nodeBefore;if(o&&o.is("$text")){const i=o.data.charAt(t?0:o.data.length-1);Cu.includes(i)||(e.next(),n=e.position.textNode)}i=e.position.offset-n.startOffset}}return e.position}(i,n):function(e,t,n){const i=e.position.textNode;if(i){const o=i.data;let r=e.position.offset-i.startOffset;for(;iu(o,r)||"character"==t&&ou(o,r)||n&&su(o,r);)e.next(),r=e.position.offset-i.startOffset}return e.position}(i,o,s);if(a==(n?"elementStart":"elementEnd")){if(r.isSelectable(c))return rc._createAt(c,n?"after":"before");if(r.checkChild(l,"$text"))return l}else{if(r.isLimit(c))return void i.skip((()=>!0));if(r.checkChild(l,"$text"))return l}}function Su(e,t){const n=e.root,i=rc._createAt(n,t?"end":0);return t?new lc(e,i):new lc(i,e)}function Pu(e,t,n){const i=t+(n?0:-1);return Cu.includes(e.charAt(i))}function Iu(e,t,n){return t===(n?e.endOffset:0)}function Ou(e,t){const n=[];Array.from(e.getItems({direction:"backward"})).map((e=>t.createRangeOn(e))).filter((t=>(t.start.isAfter(e.start)||t.start.isEqual(e.start))&&(t.end.isBefore(e.end)||t.end.isEqual(e.end)))).forEach((e=>{n.push(e.start.parent),t.remove(e)})),n.forEach((e=>{let n=e;for(;n.parent&&n.isEmpty;){const e=t.createRangeOn(n);n=n.parent,t.remove(e)}}))}function Mu(e){e.document.registerPostFixer((t=>function(e,t){const n=t.document.selection,i=t.schema,o=[];let r=!1;for(const e of n.getRanges()){const t=Ru(e,i);t&&!t.isEqual(e)?(o.push(t),r=!0):o.push(e)}r&&e.setSelection(function(e){const t=[...e],n=new Set;let i=1;for(;i!n.has(t)));return o}(o),{backward:n.isBackward})}(t,e)))}function Ru(e,t){return e.isCollapsed?function(e,t){const n=e.start,i=t.getNearestSelectionRange(n);if(!i){const e=n.getAncestors().reverse().find((e=>t.isObject(e)));return e?lc._createOn(e):null}if(!i.isCollapsed)return i;const o=i.start;if(n.isEqual(o))return null;return new lc(o)}(e,t):function(e,t){const{start:n,end:i}=e,o=t.checkChild(n,"$text"),r=t.checkChild(i,"$text"),s=t.getLimitElement(n),a=t.getLimitElement(i);if(s===a){if(o&&r)return null;if(function(e,t,n){const i=e.nodeAfter&&!n.isLimit(e.nodeAfter)||n.checkChild(e,"$text"),o=t.nodeBefore&&!n.isLimit(t.nodeBefore)||n.checkChild(t,"$text");return i||o}(n,i,t)){const e=n.nodeAfter&&t.isSelectable(n.nodeAfter)?null:t.getNearestSelectionRange(n,"forward"),o=i.nodeBefore&&t.isSelectable(i.nodeBefore)?null:t.getNearestSelectionRange(i,"backward"),r=e?e.start:n,s=o?o.end:i;return new lc(r,s)}}const c=s&&!s.is("rootElement"),l=a&&!a.is("rootElement");if(c||l){const e=n.nodeAfter&&i.nodeBefore&&n.nodeAfter.parent===i.nodeBefore.parent,o=c&&(!e||!ju(n.nodeAfter,t)),r=l&&(!e||!ju(i.nodeBefore,t));let u=n,d=i;return o&&(u=rc._createBefore(Nu(s,t))),r&&(d=rc._createAfter(Nu(a,t))),new lc(u,d)}return null}(e,t)}function Nu(e,t){let n=e,i=n;for(;t.isLimit(i)&&i.parent;)n=i,i=i.parent;return n}function ju(e,t){return e&&t.isSelectable(e)}class Du{constructor(){this.markers=new uu,this.document=new cu(this),this.schema=new il,this._pendingChanges=[],this._currentWriter=null,["insertContent","insertObject","deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach((e=>this.decorate(e))),this.on("applyOperation",((e,t)=>{t[0]._validate()}),{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck(((e,t)=>{if("$marker"===t.name)return!0})),Mu(this),this.document.registerPostFixer(Uc)}change(e){try{return 0===this._pendingChanges.length?(this._pendingChanges.push({batch:new El,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(e){y.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{e?"function"==typeof e?(t=e,e=new El):e instanceof El||(e=new El(e)):e=new El,this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(e){y.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,n){return function(e,t,n,i){return e.change((o=>{let r;r=n?n instanceof mc||n instanceof Ec?n:o.createSelection(n,i):e.document.selection,r.isCollapsed||e.deleteContent(r,{doNotAutoparagraph:!0});const s=new bu(e,o,r.anchor);let a;a=t.is("documentFragment")?t.getChildren():[t],s.handleNodes(a);const c=s.getSelectionRange();c&&(r instanceof Ec?o.setSelection(c):r.setTo(c));const l=s.getAffectedRange()||e.createRange(r.anchor);return s.destroy(),l}))}(this,e,t,n)}insertObject(e,t,n,i){return ku(this,e,t,n,i)}deleteContent(e,t){vu(this,e,t)}modifySelection(e,t){!function(e,t,n={}){const i=e.schema,o="backward"!=n.direction,r=n.unit?n.unit:"character",s=!!n.treatEmojiAsSingleUnit,a=t.focus,c=new ic({boundaries:Su(a,o),singleCharacters:!0,direction:o?"forward":"backward"}),l={walker:c,schema:i,isForward:o,unit:r,treatEmojiAsSingleUnit:s};let u;for(;u=c.next();){if(u.done)return;const n=Tu(l,u.value);if(n)return void(t instanceof Ec?e.change((e=>{e.setSelectionFocus(n)})):t.setFocus(n))}}(this,e,t)}getSelectedContent(e){return function(e,t){return e.change((e=>{const n=e.createDocumentFragment(),i=t.getFirstRange();if(!i||i.isCollapsed)return n;const o=i.start.root,r=i.start.getCommonPath(i.end),s=o.getNodeByPath(r);let a;a=i.start.parent==i.end.parent?i:e.createRange(e.createPositionAt(s,i.start.path[r.length]),e.createPositionAt(s,i.end.path[r.length]+1));const c=a.end.offset-a.start.offset;for(const t of a.getItems({shallow:!0}))t.is("$textProxy")?e.appendText(t.data,t.getAttributes(),n):e.append(e.cloneElement(t,!0),n);if(a!=i){const t=i._getTransformedByMove(a.start,e.createPositionAt(n,0),c)[0],o=e.createRange(e.createPositionAt(n,0),t.start);Ou(e.createRange(t.end,e.createPositionAt(n,"end")),e),Ou(o,e)}return n}))}(this,e)}hasContent(e,t={}){const n=e instanceof nc?lc._createIn(e):e;if(n.isCollapsed)return!1;const{ignoreWhitespaces:i=!1,ignoreMarkers:o=!1}=t;if(!o)for(const e of this.markers.getMarkersIntersectingRange(n))if(e.affectsData)return!0;for(const e of n.getItems())if(this.schema.isContent(e)){if(!e.is("$textProxy"))return!0;if(!i)return!0;if(-1!==e.data.search(/\S/))return!0}return!1}createPositionFromPath(e,t,n){return new rc(e,t,n)}createPositionAt(e,t){return rc._createAt(e,t)}createPositionAfter(e){return rc._createAfter(e)}createPositionBefore(e){return rc._createBefore(e)}createRange(e,t){return new lc(e,t)}createRangeIn(e){return lc._createIn(e)}createRangeOn(e){return lc._createOn(e)}createSelection(e,t,n){return new mc(e,t,n)}createBatch(e){return new El(e)}createOperationFromJSON(e){return class{static fromJSON(e,t){return fu[e.__className].fromJSON(e,t)}}.fromJSON(e,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const e=[];for(this.fire("_beforeChanges");this._pendingChanges.length;){const t=this._pendingChanges[0].batch;this._currentWriter=new $l(this,t);const n=this._pendingChanges[0].callback(this._currentWriter);e.push(n),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}return this.fire("_afterChanges"),e}}Et(Du,kt);class Lu extends Ka{constructor(e){super(),this.editor=e}set(e,t,n={}){if("string"==typeof t){const e=t;t=(t,n)=>{this.editor.execute(e),n()}}super.set(e,t,n)}}class zu{constructor(e={}){const t=e.language||this.constructor.defaultConfig&&this.constructor.defaultConfig.language;this._context=e.context||new Ki({language:t}),this._context._addEditor(this,!e.context);const n=Array.from(this.constructor.builtinPlugins||[]);this.config=new Li(e,this.constructor.defaultConfig),this.config.define("plugins",n),this.config.define(this._context._getEditorConfig()),this.plugins=new Hi(this,n,this._context.plugins),this.locale=this._context.locale,this.t=this.locale.t,this._readOnlyLocks=new Set,this.commands=new el,this.set("state","initializing"),this.once("ready",(()=>this.state="ready"),{priority:"high"}),this.once("destroy",(()=>this.state="destroyed"),{priority:"high"}),this.model=new Du;const i=new Ho;this.data=new _l(this.model,i),this.editing=new Xc(this.model,i),this.editing.view.document.bind("isReadOnly").to(this),this.conversion=new yl([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 Lu(this),this.keystrokes.listenTo(this.editing.view.document)}get isReadOnly(){return this._readOnlyLocks.size>0}set isReadOnly(e){throw new y("editor-isreadonly-has-no-setter")}enableReadOnlyMode(e){if("string"!=typeof e&&"symbol"!=typeof e)throw new y("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 y("editor-read-only-lock-id-invalid",null,{lockId:e});this._readOnlyLocks.has(e)&&(this._readOnlyLocks.delete(e),0===this._readOnlyLocks.size&&this.fire("change:isReadOnly","isReadOnly",!1,!0))}initPlugins(){const e=this.config,t=e.get("plugins"),n=e.get("removePlugins")||[],i=e.get("extraPlugins")||[],o=e.get("substitutePlugins")||[];return this.plugins.init(t.concat(i),n,o)}destroy(){let e=Promise.resolve();return"initializing"==this.state&&(e=new Promise((e=>this.once("ready",e)))),e.then((()=>{this.fire("destroy"),this.stopListening(),this.commands.destroy()})).then((()=>this.plugins.destroy())).then((()=>{this.model.destroy(),this.data.destroy(),this.editing.destroy(),this.keystrokes.destroy()})).then((()=>this._context._removeEditor(this)))}execute(...e){try{return this.commands.execute(...e)}catch(e){y.rethrowUnexpectedError(e,this)}}focus(){this.editing.view.focus()}}Et(zu,kt);class Vu{constructor(e){this.editor=e,this._components=new Map}*names(){for(const e of this._components.values())yield e.originalName}add(e,t){this._components.set(Bu(e),{callback:t,originalName:e})}create(e){if(!this.has(e))throw new y("componentfactory-item-missing",this,{name:e});return this._components.get(Bu(e)).callback(this.editor.locale)}has(e){return this._components.has(Bu(e))}}function Bu(e){return String(e).toLowerCase()}class Fu{constructor(e){this.editor=e,this.componentFactory=new Vu(e),this.focusTracker=new Za,this.set("viewportOffset",this._readViewportOffsetFromConfig()),this._editableElementsMap=new Map,this.listenTo(e.editing.view.document,"layoutChanged",(()=>this.update()))}get element(){return null}update(){this.fire("update")}destroy(){this.stopListening(),this.focusTracker.destroy();for(const e of this._editableElementsMap.values())e.ckeditorInstance=null;this._editableElementsMap=new Map}setEditableElement(e,t){this._editableElementsMap.set(e,t),t.ckeditorInstance||(t.ckeditorInstance=this.editor)}getEditableElement(e="main"){return this._editableElementsMap.get(e)}getEditableElementsNames(){return this._editableElementsMap.keys()}get _editableElements(){return console.warn("editor-ui-deprecated-editable-elements: The EditorUI#_editableElements property has been deprecated and will be removed in the near future.",{editorUI:this}),this._editableElementsMap}_readViewportOffsetFromConfig(){const e=this.editor,t=e.config.get("ui.viewportOffset");if(t)return t;const n=e.config.get("toolbar.viewportTopOffset");return n?(console.warn("editor-ui-deprecated-viewport-offset-config: The `toolbar.vieportTopOffset` configuration option is deprecated. It will be removed from future CKEditor versions. Use `ui.viewportOffset.top` instead."),{top:n}):{top:0}}}Et(Fu,kt);const Hu={setData(e){this.data.set(e)},getData(e){return this.data.get(e)}},Uu=Hu;const Wu={updateSourceElement(){if(!this.sourceElement)throw new y("editor-missing-sourceelement",this);var e,t;e=this.sourceElement,t=this.data.get(),e instanceof HTMLTextAreaElement&&(e.value=t),e.innerHTML=t}};class qu extends Gi{static get pluginName(){return"PendingActions"}init(){this.set("hasAny",!1),this._actions=new Fi({idProperty:"_id"}),this._actions.delegate("add","remove").to(this)}add(e){if("string"!=typeof e)throw new y("pendingactions-add-invalid-message",this);const t=Object.create(kt);return t.set("message",e),this._actions.add(t),this.hasAny=!0,t}remove(e){this._actions.remove(e),this.hasAny=!!this._actions.length}get first(){return this._actions.get(0)}[Symbol.iterator](){return this._actions[Symbol.iterator]()}}const $u='',Zu='',Ku='',Gu={cancel:$u,caption:'',check:Zu,cog:'',eraser:'',lowVision:'',image:'',alignBottom:'',alignMiddle:'',alignTop:'',alignLeft:'',alignCenter:'',alignRight:'',alignJustify:'',objectLeft:'',objectCenter:'',objectRight:'',objectFullWidth:'',objectInline:'',objectBlockLeft:'',objectBlockRight:'',objectSizeFull:'',objectSizeLarge:'',objectSizeSmall:'',objectSizeMedium:'',pencil:'',pilcrow:'',quote:'',threeVerticalDots:Ku};function Yu({emitter:e,activator:t,callback:n,contextElements:i}){e.listenTo(document,"mousedown",((e,o)=>{if(!t())return;const r="function"==typeof o.composedPath?o.composedPath():[];for(const e of i)if(e.contains(o.target)||r.includes(e))return;n()}))}function Qu(e){e.set("_isCssTransitionsDisabled",!1),e.disableCssTransitions=()=>{e._isCssTransitionsDisabled=!0},e.enableCssTransitions=()=>{e._isCssTransitionsDisabled=!1},e.extendTemplate({attributes:{class:[e.bindTemplate.if("_isCssTransitionsDisabled","ck-transitions-disabled")]}})}function Ju({view:e}){e.listenTo(e.element,"submit",((t,n)=>{n.preventDefault(),e.fire("submit")}),{useCapture:!0})}class Xu extends Fi{constructor(e=[]){super(e,{idProperty:"viewUid"}),this.on("add",((e,t,n)=>{this._renderViewIntoCollectionParent(t,n)})),this.on("remove",((e,t)=>{t.element&&this._parentElement&&t.element.remove()})),this._parentElement=null}destroy(){this.map((e=>e.destroy()))}setParent(e){this._parentElement=e;for(const e of this)this._renderViewIntoCollectionParent(e)}delegate(...e){if(!e.length||!e.every((e=>"string"==typeof e)))throw new y("ui-viewcollection-delegate-wrong-events",this);return{to:t=>{for(const n of this)for(const i of e)n.delegate(i).to(t);this.on("add",((n,i)=>{for(const n of e)i.delegate(n).to(t)})),this.on("remove",((n,i)=>{for(const n of e)i.stopDelegating(n,t)}))}}}_renderViewIntoCollectionParent(e,t){e.isRendered||e.render(),e.element&&this._parentElement&&this._parentElement.insertBefore(e.element,this._parentElement.children[t])}}var ed=n(972),td={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(ed.Z,td);ed.Z.locals;class nd{constructor(e){this.element=null,this.isRendered=!1,this.locale=e,this.t=e&&e.t,this._viewCollections=new Fi,this._unboundChildren=this.createCollection(),this._viewCollections.on("add",((t,n)=>{n.locale=e})),this.decorate("render")}get bindTemplate(){return this._bindTemplate?this._bindTemplate:this._bindTemplate=id.bind(this,this)}createCollection(e){const t=new Xu(e);return this._viewCollections.add(t),t}registerChild(e){Bi(e)||(e=[e]);for(const t of e)this._unboundChildren.add(t)}deregisterChild(e){Bi(e)||(e=[e]);for(const t of e)this._unboundChildren.remove(t)}setTemplate(e){this.template=new id(e)}extendTemplate(e){id.extend(this.template,e)}render(){if(this.isRendered)throw new y("ui-view-render-already-rendered",this);this.template&&(this.element=this.template.render(),this.registerChild(this.template.getViews())),this.isRendered=!0}destroy(){this.stopListening(),this._viewCollections.map((e=>e.destroy())),this.template&&this.template._revertData&&this.template.revert(this.element)}}Et(nd,Ms),Et(nd,kt);class id{constructor(e){Object.assign(this,fd(hd(e))),this._isRendered=!1,this._revertData=null}render(){const e=this._renderNode({intoFragment:!0});return this._isRendered=!0,e}apply(e){return this._revertData={children:[],bindings:[],attributes:{}},this._renderNode({node:e,isApplying:!0,revertData:this._revertData}),e}revert(e){if(!this._revertData)throw new y("ui-template-revert-not-applied",[this,e]);this._revertTemplateFromNode(e,this._revertData)}*getViews(){yield*function*e(t){if(t.children)for(const n of t.children)kd(n)?yield n:vd(n)&&(yield*e(n))}(this)}static bind(e,t){return{to:(n,i)=>new rd({eventNameOrFunction:n,attribute:n,observable:e,emitter:t,callback:i}),if:(n,i,o)=>new sd({observable:e,emitter:t,attribute:n,valueIfTrue:i,callback:o})}}static extend(e,t){if(e._isRendered)throw new y("template-extend-render",[this,e]);bd(e,fd(hd(t)))}_renderNode(e){let t;if(t=e.node?this.tag&&this.text:this.tag?this.text:!this.text,t)throw new y("ui-template-wrong-syntax",this);return this.text?this._renderText(e):this._renderElement(e)}_renderElement(e){let t=e.node;return t||(t=e.node=document.createElementNS(this.ns||"http://www.w3.org/1999/xhtml",this.tag)),this._renderAttributes(e),this._renderElementChildren(e),this._setUpListeners(e),t}_renderText(e){let t=e.node;return t?e.revertData.text=t.textContent:t=e.node=document.createTextNode(""),ad(this.text)?this._bindToObservable({schema:this.text,updater:ld(t),data:e}):t.textContent=this.text.join(""),t}_renderAttributes(e){let t,n,i,o;if(!this.attributes)return;const r=e.node,s=e.revertData;for(t in this.attributes)if(i=r.getAttribute(t),n=this.attributes[t],s&&(s.attributes[t]=i),o=V(n[0])&&n[0].ns?n[0].ns:null,ad(n)){const a=o?n[0].value:n;s&&yd(t)&&a.unshift(i),this._bindToObservable({schema:a,updater:ud(r,t,o),data:e})}else"style"==t&&"string"!=typeof n[0]?this._renderStyleAttribute(n[0],e):(s&&i&&yd(t)&&n.unshift(i),n=n.map((e=>e&&e.value||e)).reduce(((e,t)=>e.concat(t)),[]).reduce(gd,""),wd(n)||r.setAttributeNS(o,t,n))}_renderStyleAttribute(e,t){const n=t.node;for(const i in e){const o=e[i];ad(o)?this._bindToObservable({schema:[o],updater:dd(n,i),data:t}):n.style[i]=o}}_renderElementChildren(e){const t=e.node,n=e.intoFragment?document.createDocumentFragment():t,i=e.isApplying;let o=0;for(const r of this.children)if(_d(r)){if(!i){r.setParent(t);for(const e of r)n.appendChild(e.element)}}else if(kd(r))i||(r.isRendered||r.render(),n.appendChild(r.element));else if(us(r))n.appendChild(r);else if(i){const t={children:[],bindings:[],attributes:{}};e.revertData.children.push(t),r._renderNode({node:n.childNodes[o++],isApplying:!0,revertData:t})}else n.appendChild(r.render());e.intoFragment&&t.appendChild(n)}_setUpListeners(e){if(this.eventListeners)for(const t in this.eventListeners){const n=this.eventListeners[t].map((n=>{const[i,o]=t.split("@");return n.activateDomEventListener(i,o,e)}));e.revertData&&e.revertData.bindings.push(n)}}_bindToObservable({schema:e,updater:t,data:n}){const i=n.revertData;cd(e,t,n);const o=e.filter((e=>!wd(e))).filter((e=>e.observable)).map((i=>i.activateAttributeListener(e,t,n)));i&&i.bindings.push(o)}_revertTemplateFromNode(e,t){for(const e of t.bindings)for(const t of e)t();if(t.text)e.textContent=t.text;else{for(const n in t.attributes){const i=t.attributes[n];null===i?e.removeAttribute(n):e.setAttribute(n,i)}for(let n=0;ncd(e,t,n);return this.emitter.listenTo(this.observable,"change:"+this.attribute,i),()=>{this.emitter.stopListening(this.observable,"change:"+this.attribute,i)}}}class rd extends od{activateDomEventListener(e,t,n){const i=(e,n)=>{t&&!n.target.matches(t)||("function"==typeof this.eventNameOrFunction?this.eventNameOrFunction(n):this.observable.fire(this.eventNameOrFunction,n))};return this.emitter.listenTo(n.node,e,i),()=>{this.emitter.stopListening(n.node,e,i)}}}class sd extends od{getValue(e){return!wd(super.getValue(e))&&(this.valueIfTrue||!0)}}function ad(e){return!!e&&(e.value&&(e=e.value),Array.isArray(e)?e.some(ad):e instanceof od)}function cd(e,t,{node:n}){let i=function(e,t){return e.map((e=>e instanceof od?e.getValue(t):e))}(e,n);i=1==e.length&&e[0]instanceof sd?i[0]:i.reduce(gd,""),wd(i)?t.remove():t.set(i)}function ld(e){return{set(t){e.textContent=t},remove(){e.textContent=""}}}function ud(e,t,n){return{set(i){e.setAttributeNS(n,t,i)},remove(){e.removeAttributeNS(n,t)}}}function dd(e,t){return{set(n){e.style[t]=n},remove(){e.style[t]=null}}}function hd(e){return ji(e,(e=>{if(e&&(e instanceof od||vd(e)||kd(e)||_d(e)))return e}))}function fd(e){if("string"==typeof e?e=function(e){return{text:[e]}}(e):e.text&&function(e){e.text=Ui(e.text)}(e),e.on&&(e.eventListeners=function(e){for(const t in e)pd(e,t);return e}(e.on),delete e.on),!e.text){e.attributes&&function(e){for(const t in e)e[t].value&&(e[t].value=Ui(e[t].value)),pd(e,t)}(e.attributes);const t=[];if(e.children)if(_d(e.children))t.push(e.children);else for(const n of e.children)vd(n)||kd(n)||us(n)?t.push(n):t.push(new id(n));e.children=t}return e}function pd(e,t){e[t]=Ui(e[t])}function gd(e,t){return wd(t)?e:wd(e)?t:`${e} ${t}`}function md(e,t){for(const n in t)e[n]?e[n].push(...t[n]):e[n]=t[n]}function bd(e,t){if(t.attributes&&(e.attributes||(e.attributes={}),md(e.attributes,t.attributes)),t.eventListeners&&(e.eventListeners||(e.eventListeners={}),md(e.eventListeners,t.eventListeners)),t.text&&e.text.push(...t.text),t.children&&t.children.length){if(e.children.length!=t.children.length)throw new y("ui-template-extend-children-mismatch",e);let n=0;for(const i of t.children)bd(e.children[n++],i)}}function wd(e){return!e&&0!==e}function kd(e){return e instanceof nd}function vd(e){return e instanceof id}function _d(e){return e instanceof Xu}function yd(e){return"class"==e||"style"==e}class xd extends Xu{constructor(e,t=[]){super(t),this.locale=e}attachToDom(){this._bodyCollectionContainer=new id({tag:"div",attributes:{class:["ck","ck-reset_all","ck-body","ck-rounded-corners"],dir:this.locale.uiLanguageDirection},children:this}).render();let e=document.querySelector(".ck-body-wrapper");e||(e=Ta(document,"div",{class:"ck-body-wrapper"}),document.body.appendChild(e)),e.appendChild(this._bodyCollectionContainer)}detachFromDom(){super.destroy(),this._bodyCollectionContainer&&this._bodyCollectionContainer.remove();const e=document.querySelector(".ck-body-wrapper");e&&0==e.childElementCount&&e.remove()}}var Ad=n(3872),Ed={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Ad.Z,Ed);Ad.Z.locals;class Cd extends nd{constructor(){super();const e=this.bindTemplate;this.set("content",""),this.set("viewBox","0 0 20 20"),this.set("fillColor",""),this.setTemplate({tag:"svg",ns:"http://www.w3.org/2000/svg",attributes:{class:["ck","ck-icon"],viewBox:e.to("viewBox")}})}render(){super.render(),this._updateXMLContent(),this._colorFillPaths(),this.on("change:content",(()=>{this._updateXMLContent(),this._colorFillPaths()})),this.on("change:fillColor",(()=>{this._colorFillPaths()}))}_updateXMLContent(){if(this.content){const e=(new DOMParser).parseFromString(this.content.trim(),"image/svg+xml").querySelector("svg"),t=e.getAttribute("viewBox");for(t&&(this.viewBox=t),this.element.innerHTML="";e.childNodes.length>0;)this.element.appendChild(e.childNodes[0])}}_colorFillPaths(){this.fillColor&&this.element.querySelectorAll(".ck-icon__fill").forEach((e=>{e.style.fill=this.fillColor}))}}var Td=n(9721),Sd={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Td.Z,Sd);Td.Z.locals;class Pd extends nd{constructor(e){super(e),this.set("text",""),this.set("position","s");const t=this.bindTemplate;this.setTemplate({tag:"span",attributes:{class:["ck","ck-tooltip",t.to("position",(e=>"ck-tooltip_"+e)),t.if("text","ck-hidden",(e=>!e.trim()))]},children:[{tag:"span",attributes:{class:["ck","ck-tooltip__text"]},children:[{text:t.to("text")}]}]})}}var Id=n(9377),Od={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Id.Z,Od);Id.Z.locals;class Md extends nd{constructor(e){super(e);const t=this.bindTemplate,n=k();this.set("class"),this.set("labelStyle"),this.set("icon"),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isVisible",!0),this.set("isToggleable",!1),this.set("keystroke"),this.set("label"),this.set("tabindex",-1),this.set("tooltip"),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.set("withKeystroke",!1),this.children=this.createCollection(),this.tooltipView=this._createTooltipView(),this.labelView=this._createLabelView(n),this.iconView=new Cd,this.iconView.extendTemplate({attributes:{class:"ck-button__icon"}}),this.keystrokeView=this._createKeystrokeView(),this.bind("_tooltipString").to(this,"tooltip",this,"label",this,"keystroke",this._getTooltipString.bind(this)),this.setTemplate({tag:"button",attributes:{class:["ck","ck-button",t.to("class"),t.if("isEnabled","ck-disabled",(e=>!e)),t.if("isVisible","ck-hidden",(e=>!e)),t.to("isOn",(e=>e?"ck-on":"ck-off")),t.if("withText","ck-button_with-text"),t.if("withKeystroke","ck-button_with-keystroke")],type:t.to("type",(e=>e||"button")),tabindex:t.to("tabindex"),"aria-labelledby":`ck-editor__aria-label_${n}`,"aria-disabled":t.if("isEnabled",!0,(e=>!e)),"aria-pressed":t.to("isOn",(e=>!!this.isToggleable&&String(e)))},children:this.children,on:{mousedown:t.to((e=>{e.preventDefault()})),click:t.to((e=>{this.isEnabled?this.fire("execute"):e.preventDefault()}))}})}render(){super.render(),this.icon&&(this.iconView.bind("content").to(this,"icon"),this.children.add(this.iconView)),this.children.add(this.tooltipView),this.children.add(this.labelView),this.withKeystroke&&this.keystroke&&this.children.add(this.keystrokeView)}focus(){this.element.focus()}_createTooltipView(){const e=new Pd;return e.bind("text").to(this,"_tooltipString"),e.bind("position").to(this,"tooltipPosition"),e}_createLabelView(e){const t=new nd,n=this.bindTemplate;return t.setTemplate({tag:"span",attributes:{class:["ck","ck-button__label"],style:n.to("labelStyle"),id:`ck-editor__aria-label_${e}`},children:[{text:this.bindTemplate.to("label")}]}),t}_createKeystrokeView(){const e=new nd;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__keystroke"]},children:[{text:this.bindTemplate.to("keystroke",(e=>Pr(e)))}]}),e}_getTooltipString(e,t,n){return e?"string"==typeof e?e:(n&&(n=Pr(n)),e instanceof Function?e(t,n):`${t}${n?` (${n})`:""}`):""}}var Rd=n(9547),Nd={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Rd.Z,Nd);Rd.Z.locals;class jd extends Md{constructor(e){super(e),this.isToggleable=!0,this.toggleSwitchView=this._createToggleView(),this.extendTemplate({attributes:{class:"ck-switchbutton"}})}render(){super.render(),this.children.add(this.toggleSwitchView)}_createToggleView(){const e=new nd;return e.setTemplate({tag:"span",attributes:{class:["ck","ck-button__toggle"]},children:[{tag:"span",attributes:{class:["ck","ck-button__toggle__inner"]}}]}),e}}function Dd(e){return"string"==typeof e?{model:e,label:e,hasBorder:!1,view:{name:"span",styles:{color:e}}}:{model:e.color,label:e.label||e.color,hasBorder:void 0!==e.hasBorder&&e.hasBorder,view:{name:"span",styles:{color:`${e.color}`}}}}class Ld extends Md{constructor(e){super(e);const t=this.bindTemplate;this.set("color"),this.set("hasBorder"),this.icon='',this.extendTemplate({attributes:{style:{backgroundColor:t.to("color")},class:["ck","ck-color-grid__tile",t.if("hasBorder","ck-color-table__color-tile_bordered")]}})}render(){super.render(),this.iconView.fillColor="hsl(0, 0%, 100%)"}}function zd(e){return!!(e&&e.getClientRects&&e.getClientRects().length)}class Vd{constructor(e){if(Object.assign(this,e),e.actions&&e.keystrokeHandler)for(const t in e.actions){let n=e.actions[t];"string"==typeof n&&(n=[n]);for(const i of n)e.keystrokeHandler.set(i,((e,n)=>{this[t](),n()}))}}get first(){return this.focusables.find(Bd)||null}get last(){return this.focusables.filter(Bd).slice(-1)[0]||null}get next(){return this._getFocusableItem(1)}get previous(){return this._getFocusableItem(-1)}get current(){let e=null;return null===this.focusTracker.focusedElement?null:(this.focusables.find(((t,n)=>{const i=t.element===this.focusTracker.focusedElement;return i&&(e=n),i})),e)}focusFirst(){this._focus(this.first)}focusLast(){this._focus(this.last)}focusNext(){this._focus(this.next)}focusPrevious(){this._focus(this.previous)}_focus(e){e&&e.focus()}_getFocusableItem(e){const t=this.current,n=this.focusables.length;if(!n)return null;if(null===t)return this[1===e?"first":"last"];let i=(t+n+e)%n;do{const t=this.focusables.get(i);if(Bd(t))return t;i=(i+n+e)%n}while(i!==t);return null}}function Bd(e){return!(!e.focus||!zd(e.element))}var Fd=n(6601),Hd={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Fd.Z,Hd);Fd.Z.locals;class Ud extends nd{constructor(e,t){super(e);const n=t&&t.colorDefinitions||[],i={};t&&t.columns&&(i.gridTemplateColumns=`repeat( ${t.columns}, 1fr)`),this.set("selectedColor"),this.items=this.createCollection(),this.focusTracker=new Za,this.keystrokes=new Ka,this._focusCycler=new Vd({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowleft",focusNext:"arrowright"}}),this.items.on("add",((e,t)=>{t.isOn=t.color===this.selectedColor})),n.forEach((e=>{const t=new Ld;t.set({color:e.color,label:e.label,tooltip:!0,hasBorder:e.options.hasBorder}),t.on("execute",(()=>{this.fire("execute",{value:e.color,hasBorder:e.options.hasBorder,label:e.label})})),this.items.add(t)})),this.setTemplate({tag:"div",children:this.items,attributes:{class:["ck","ck-color-grid"],style:i}}),this.on("change:selectedColor",((e,t,n)=>{for(const e of this.items)e.isOn=e.color===n}))}focus(){this.items.length&&this.items.first.focus()}focusLast(){this.items.length&&this.items.last.focus()}render(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",((e,t)=>{this.focusTracker.add(t.element)})),this.items.on("remove",((e,t)=>{this.focusTracker.remove(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}}const Wd='';class qd extends Md{constructor(e){super(e),this.arrowView=this._createArrowView(),this.extendTemplate({attributes:{"aria-haspopup":!0}}),this.delegate("execute").to(this,"open")}render(){super.render(),this.children.add(this.arrowView)}_createArrowView(){const e=new Cd;return e.content=Wd,e.extendTemplate({attributes:{class:"ck-dropdown__arrow"}}),e}}var $d=n(8418),Zd={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()($d.Z,Zd);$d.Z.locals;class Kd extends nd{constructor(e){super(e);const t=this.bindTemplate;this.set("class"),this.set("icon"),this.set("isEnabled",!0),this.set("isOn",!1),this.set("isToggleable",!1),this.set("isVisible",!0),this.set("keystroke"),this.set("label"),this.set("tabindex",-1),this.set("tooltip"),this.set("tooltipPosition","s"),this.set("type","button"),this.set("withText",!1),this.children=this.createCollection(),this.actionView=this._createActionView(),this.arrowView=this._createArrowView(),this.keystrokes=new Ka,this.focusTracker=new Za,this.setTemplate({tag:"div",attributes:{class:["ck","ck-splitbutton",t.to("class"),t.if("isVisible","ck-hidden",(e=>!e)),this.arrowView.bindTemplate.if("isOn","ck-splitbutton_open")]},children:this.children})}render(){super.render(),this.children.add(this.actionView),this.children.add(this.arrowView),this.focusTracker.add(this.actionView.element),this.focusTracker.add(this.arrowView.element),this.keystrokes.listenTo(this.element),this.keystrokes.set("arrowright",((e,t)=>{this.focusTracker.focusedElement===this.actionView.element&&(this.arrowView.focus(),t())})),this.keystrokes.set("arrowleft",((e,t)=>{this.focusTracker.focusedElement===this.arrowView.element&&(this.actionView.focus(),t())}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this.actionView.focus()}_createActionView(){const e=new Md;return e.bind("icon","isEnabled","isOn","isToggleable","keystroke","label","tabindex","tooltip","tooltipPosition","type","withText").to(this),e.extendTemplate({attributes:{class:"ck-splitbutton__action"}}),e.delegate("execute").to(this),e}_createArrowView(){const e=new Md,t=e.bindTemplate;return e.icon=Wd,e.extendTemplate({attributes:{class:"ck-splitbutton__arrow","aria-haspopup":!0,"aria-expanded":t.to("isOn",(e=>String(e)))}}),e.bind("isEnabled").to(this),e.delegate("execute").to(this,"open"),e}}class Gd extends nd{constructor(e){super(e);const t=this.bindTemplate;this.set("isVisible",!1),this.set("position","se"),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-dropdown__panel",t.to("position",(e=>`ck-dropdown__panel_${e}`)),t.if("isVisible","ck-dropdown__panel-visible")]},children:this.children,on:{selectstart:t.to((e=>e.preventDefault()))}})}focus(){this.children.length&&this.children.first.focus()}focusLast(){if(this.children.length){const e=this.children.last;"function"==typeof e.focusLast?e.focusLast():e.focus()}}}var Yd=n(5457),Qd={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Yd.Z,Qd);Yd.Z.locals;function Jd({element:e,target:t,positions:n,limiter:i,fitInViewport:o,viewportOffsetConfig:r}){X(t)&&(t=t()),X(i)&&(i=i());const s=function(e){return e&&e.parentNode?e.offsetParent===bs.document.body?null:e.offsetParent:null}(e),a=new Oa(e);let c;const l={targetRect:new Oa(t),elementRect:a,positionedElementAncestor:s};if(i||o){const e=i&&new Oa(i).getVisible(),t=o&&function(e){e=Object.assign({top:0,bottom:0,left:0,right:0},e);const t=new Oa(bs.window);return t.top+=e.top,t.height-=e.top,t.bottom-=e.bottom,t.height-=e.bottom,t}(r);Object.assign(l,{limiterRect:e,viewportRect:t}),c=function(e,t){const{elementRect:n}=t,i=n.getArea(),o=e.map((e=>new eh(e,t))).filter((e=>!!e.name));let r=0,s=null;for(const e of o){const{_limiterIntersectionArea:t,_viewportIntersectionArea:n}=e;if(t===i)return e;const o=n**2+t**2;o>r&&(r=o,s=e)}return s}(n,l)||new eh(n[0],l)}else c=new eh(n[0],l);return c}function Xd(e){const{scrollX:t,scrollY:n}=bs.window;return e.clone().moveBy(t,n)}class eh{constructor(e,t){const n=e(t.targetRect,t.elementRect,t.viewportRect);if(!n)return;const{left:i,top:o,name:r,config:s}=n;Object.assign(this,{name:r,config:s}),this._positioningFunctionCorrdinates={left:i,top:o},this._options=t}get left(){return this._absoluteRect.left}get top(){return this._absoluteRect.top}get _limiterIntersectionArea(){const e=this._options.limiterRect;if(e){const t=this._options.viewportRect;if(!t)return e.getIntersectionArea(this._rect);{const n=e.getIntersection(t);if(n)return n.getIntersectionArea(this._rect)}}return 0}get _viewportIntersectionArea(){const e=this._options.viewportRect;return e?e.getIntersectionArea(this._rect):0}get _rect(){return this._cachedRect||(this._cachedRect=this._options.elementRect.clone().moveTo(this._positioningFunctionCorrdinates.left,this._positioningFunctionCorrdinates.top)),this._cachedRect}get _absoluteRect(){return this._cachedAbsoluteRect||(this._cachedAbsoluteRect=Xd(this._rect),this._options.positionedElementAncestor&&function(e,t){const n=Xd(new Oa(t)),i=Pa(t);let o=0,r=0;o-=n.left,r-=n.top,o+=t.scrollLeft,r+=t.scrollTop,o-=i.left,r-=i.top,e.moveBy(o,r)}(this._cachedAbsoluteRect,this._options.positionedElementAncestor)),this._cachedAbsoluteRect}}class th extends nd{constructor(e,t,n){super(e);const i=this.bindTemplate;this.buttonView=t,this.panelView=n,this.set("isOpen",!1),this.set("isEnabled",!0),this.set("class"),this.set("id"),this.set("panelPosition","auto"),this.keystrokes=new Ka,this.setTemplate({tag:"div",attributes:{class:["ck","ck-dropdown",i.to("class"),i.if("isEnabled","ck-disabled",(e=>!e))],id:i.to("id"),"aria-describedby":i.to("ariaDescribedById")},children:[t,n]}),t.extendTemplate({attributes:{class:["ck-dropdown__button"]}})}render(){super.render(),this.listenTo(this.buttonView,"open",(()=>{this.isOpen=!this.isOpen})),this.panelView.bind("isVisible").to(this,"isOpen"),this.on("change:isOpen",(()=>{this.isOpen&&("auto"===this.panelPosition?this.panelView.position=th._getOptimalPosition({element:this.panelView.element,target:this.buttonView.element,fitInViewport:!0,positions:this._panelPositions}).name:this.panelView.position=this.panelPosition)})),this.keystrokes.listenTo(this.element);const e=(e,t)=>{this.isOpen&&(this.buttonView.focus(),this.isOpen=!1,t())};this.keystrokes.set("arrowdown",((e,t)=>{this.buttonView.isEnabled&&!this.isOpen&&(this.isOpen=!0,t())})),this.keystrokes.set("arrowright",((e,t)=>{this.isOpen&&t()})),this.keystrokes.set("arrowleft",e),this.keystrokes.set("esc",e)}focus(){this.buttonView.focus()}get _panelPositions(){const{south:e,north:t,southEast:n,southWest:i,northEast:o,northWest:r,southMiddleEast:s,southMiddleWest:a,northMiddleEast:c,northMiddleWest:l}=th.defaultPanelPositions;return"rtl"!==this.locale.uiLanguageDirection?[n,i,s,a,e,o,r,c,l,t]:[i,n,a,s,e,r,o,l,c,t]}}th.defaultPanelPositions={south:(e,t)=>({top:e.bottom,left:e.left-(t.width-e.width)/2,name:"s"}),southEast:e=>({top:e.bottom,left:e.left,name:"se"}),southWest:(e,t)=>({top:e.bottom,left:e.left-t.width+e.width,name:"sw"}),southMiddleEast:(e,t)=>({top:e.bottom,left:e.left-(t.width-e.width)/4,name:"sme"}),southMiddleWest:(e,t)=>({top:e.bottom,left:e.left-3*(t.width-e.width)/4,name:"smw"}),north:(e,t)=>({top:e.top-t.height,left:e.left-(t.width-e.width)/2,name:"n"}),northEast:(e,t)=>({top:e.top-t.height,left:e.left,name:"ne"}),northWest:(e,t)=>({top:e.top-t.height,left:e.left-t.width+e.width,name:"nw"}),northMiddleEast:(e,t)=>({top:e.top-t.height,left:e.left-(t.width-e.width)/4,name:"nme"}),northMiddleWest:(e,t)=>({top:e.top-t.height,left:e.left-3*(t.width-e.width)/4,name:"nmw"})},th._getOptimalPosition=Jd;class nh extends nd{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__separator"]}})}}class ih extends nd{constructor(e){super(e),this.setTemplate({tag:"span",attributes:{class:["ck","ck-toolbar__line-break"]}})}}function oh(e){return Array.isArray(e)?{items:e,removeItems:[]}:e?Object.assign({items:[],removeItems:[]},e):{items:[],removeItems:[]}}var rh=n(7343),sh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(rh.Z,sh);rh.Z.locals;class ah extends nd{constructor(e,t){super(e);const n=this.bindTemplate,i=this.t;this.options=t||{},this.set("ariaLabel",i("Editor toolbar")),this.set("maxWidth","auto"),this.items=this.createCollection(),this.focusTracker=new Za,this.keystrokes=new Ka,this.set("class"),this.set("isCompact",!1),this.itemsView=new ch(e),this.children=this.createCollection(),this.children.add(this.itemsView),this.focusables=this.createCollection();const o="rtl"===e.uiLanguageDirection;this._focusCycler=new Vd({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:[o?"arrowright":"arrowleft","arrowup"],focusNext:[o?"arrowleft":"arrowright","arrowdown"]}});const r=["ck","ck-toolbar",n.to("class"),n.if("isCompact","ck-toolbar_compact")];var s;this.options.shouldGroupWhenFull&&this.options.isFloating&&r.push("ck-toolbar_floating"),this.setTemplate({tag:"div",attributes:{class:r,role:"toolbar","aria-label":n.to("ariaLabel"),style:{maxWidth:n.to("maxWidth")}},children:this.children,on:{mousedown:(s=this,s.bindTemplate.to((e=>{e.target===s.element&&e.preventDefault()})))}}),this._behavior=this.options.shouldGroupWhenFull?new uh(this):new lh(this)}render(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",((e,t)=>{this.focusTracker.add(t.element)})),this.items.on("remove",((e,t)=>{this.focusTracker.remove(t.element)})),this.keystrokes.listenTo(this.element),this._behavior.render(this)}destroy(){return this._behavior.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy(),super.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}fillFromConfig(e,t){const n=oh(e),i=n.items.filter(((e,i,o)=>"|"===e||-1===n.removeItems.indexOf(e)&&("-"===e?!this.options.shouldGroupWhenFull||(x("toolbarview-line-break-ignored-when-grouping-items",o),!1):!!t.has(e)||(x("toolbarview-item-unavailable",{name:e}),!1)))),o=this._cleanSeparators(i).map((e=>"|"===e?new nh:"-"===e?new ih:t.create(e)));this.items.addMany(o)}_cleanSeparators(e){const t=e=>"-"!==e&&"|"!==e,n=e.length,i=e.findIndex(t),o=n-e.slice().reverse().findIndex(t);return e.slice(i,o).filter(((e,n,i)=>{if(t(e))return!0;return!(n>0&&i[n-1]===e)}))}}class ch extends nd{constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-toolbar__items"]},children:this.children})}}class lh{constructor(e){const t=e.bindTemplate;e.set("isVertical",!1),e.itemsView.children.bindTo(e.items).using((e=>e)),e.focusables.bindTo(e.items).using((e=>e)),e.extendTemplate({attributes:{class:[t.if("isVertical","ck-toolbar_vertical")]}})}render(){}destroy(){}}class uh{constructor(e){this.view=e,this.viewChildren=e.children,this.viewFocusables=e.focusables,this.viewItemsView=e.itemsView,this.viewFocusTracker=e.focusTracker,this.viewLocale=e.locale,this.ungroupedItems=e.createCollection(),this.groupedItems=e.createCollection(),this.groupedItemsDropdown=this._createGroupedItemsDropdown(),this.resizeObserver=null,this.cachedPadding=null,this.shouldUpdateGroupingOnNextResize=!1,e.itemsView.children.bindTo(this.ungroupedItems).using((e=>e)),this.ungroupedItems.on("add",this._updateFocusCycleableItems.bind(this)),this.ungroupedItems.on("remove",this._updateFocusCycleableItems.bind(this)),e.children.on("add",this._updateFocusCycleableItems.bind(this)),e.children.on("remove",this._updateFocusCycleableItems.bind(this)),e.items.on("change",((e,t)=>{const n=t.index;for(const e of t.removed)n>=this.ungroupedItems.length?this.groupedItems.remove(e):this.ungroupedItems.remove(e);for(let e=n;ethis.ungroupedItems.length?this.groupedItems.add(i,e-this.ungroupedItems.length):this.ungroupedItems.add(i,e)}this._updateGrouping()})),e.extendTemplate({attributes:{class:["ck-toolbar_grouping"]}})}render(e){this.viewElement=e.element,this._enableGroupingOnResize(),this._enableGroupingOnMaxWidthChange(e)}destroy(){this.groupedItemsDropdown.destroy(),this.resizeObserver.destroy()}_updateGrouping(){if(!this.viewElement.ownerDocument.body.contains(this.viewElement))return;if(!zd(this.viewElement))return void(this.shouldUpdateGroupingOnNextResize=!0);const e=this.groupedItems.length;let t;for(;this._areItemsOverflowing;)this._groupLastItem(),t=!0;if(!t&&this.groupedItems.length){for(;this.groupedItems.length&&!this._areItemsOverflowing;)this._ungroupFirstItem();this._areItemsOverflowing&&this._groupLastItem()}this.groupedItems.length!==e&&this.view.fire("groupedItemsUpdate")}get _areItemsOverflowing(){if(!this.ungroupedItems.length)return!1;const e=this.viewElement,t=this.viewLocale.uiLanguageDirection,n=new Oa(e.lastChild),i=new Oa(e);if(!this.cachedPadding){const n=bs.window.getComputedStyle(e),i="ltr"===t?"paddingRight":"paddingLeft";this.cachedPadding=Number.parseInt(n[i])}return"ltr"===t?n.right>i.right-this.cachedPadding:n.left{e&&e===t.contentRect.width&&!this.shouldUpdateGroupingOnNextResize||(this.shouldUpdateGroupingOnNextResize=!1,this._updateGrouping(),e=t.contentRect.width)})),this._updateGrouping()}_enableGroupingOnMaxWidthChange(e){e.on("change:maxWidth",(()=>{this._updateGrouping()}))}_groupLastItem(){this.groupedItems.length||(this.viewChildren.add(new nh),this.viewChildren.add(this.groupedItemsDropdown),this.viewFocusTracker.add(this.groupedItemsDropdown.element)),this.groupedItems.add(this.ungroupedItems.remove(this.ungroupedItems.last),0)}_ungroupFirstItem(){this.ungroupedItems.add(this.groupedItems.remove(this.groupedItems.first)),this.groupedItems.length||(this.viewChildren.remove(this.groupedItemsDropdown),this.viewChildren.remove(this.viewChildren.last),this.viewFocusTracker.remove(this.groupedItemsDropdown.element))}_createGroupedItemsDropdown(){const e=this.viewLocale,t=e.t,n=vh(e);return n.class="ck-toolbar__grouped-dropdown",n.panelPosition="ltr"===e.uiLanguageDirection?"sw":"se",_h(n,[]),n.buttonView.set({label:t("Show more items"),tooltip:!0,tooltipPosition:"rtl"===e.uiLanguageDirection?"se":"sw",icon:Ku}),n.toolbarView.items.bindTo(this.groupedItems).using((e=>e)),n}_updateFocusCycleableItems(){this.viewFocusables.clear(),this.ungroupedItems.map((e=>{this.viewFocusables.add(e)})),this.groupedItems.length&&this.viewFocusables.add(this.groupedItemsDropdown)}}var dh=n(9647),hh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(dh.Z,hh);dh.Z.locals;class fh extends nd{constructor(){super(),this.items=this.createCollection(),this.focusTracker=new Za,this.keystrokes=new Ka,this._focusCycler=new Vd({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this.setTemplate({tag:"ul",attributes:{class:["ck","ck-reset","ck-list"]},children:this.items})}render(){super.render();for(const e of this.items)this.focusTracker.add(e.element);this.items.on("add",((e,t)=>{this.focusTracker.add(t.element)})),this.items.on("remove",((e,t)=>{this.focusTracker.remove(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}}class ph extends nd{constructor(e){super(e),this.children=this.createCollection(),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__item"]},children:this.children})}focus(){this.children.first.focus()}}class gh extends nd{constructor(e){super(e),this.setTemplate({tag:"li",attributes:{class:["ck","ck-list__separator"]}})}}var mh=n(3505),bh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(mh.Z,bh);mh.Z.locals;var wh=n(6371),kh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(wh.Z,kh);wh.Z.locals;function vh(e,t=qd){const n=new t(e),i=new Gd(e),o=new th(e,n,i);return n.bind("isEnabled").to(o),n instanceof qd?n.bind("isOn").to(o,"isOpen"):n.arrowView.bind("isOn").to(o,"isOpen"),function(e){(function(e){e.on("render",(()=>{Yu({emitter:e,activator:()=>e.isOpen,callback:()=>{e.isOpen=!1},contextElements:[e.element]})}))})(e),function(e){e.on("execute",(t=>{t.source instanceof jd||(e.isOpen=!1)}))}(e),function(e){e.keystrokes.set("arrowdown",((t,n)=>{e.isOpen&&(e.panelView.focus(),n())})),e.keystrokes.set("arrowup",((t,n)=>{e.isOpen&&(e.panelView.focusLast(),n())}))}(e)}(o),o}function _h(e,t){const n=e.locale,i=n.t,o=e.toolbarView=new ah(n);o.set("ariaLabel",i("Dropdown toolbar")),e.extendTemplate({attributes:{class:["ck-toolbar-dropdown"]}}),t.map((e=>o.items.add(e))),e.panelView.children.add(o),o.items.delegate("execute").to(e)}function yh(e,t){const n=e.locale,i=e.listView=new fh(n);i.items.bindTo(t).using((({type:e,model:t})=>{if("separator"===e)return new gh(n);if("button"===e||"switchbutton"===e){const i=new ph(n);let o;return o="button"===e?new Md(n):new jd(n),o.bind(...Object.keys(t)).to(t),o.delegate("execute").to(i),i.children.add(o),i}})),e.panelView.children.add(i),i.items.delegate("execute").to(e)}var xh=n(7456),Ah={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(xh.Z,Ah);xh.Z.locals;class Eh extends nd{constructor(e){super(e),this.body=new xd(e)}render(){super.render(),this.body.attachToDom()}destroy(){return this.body.detachFromDom(),super.destroy()}}var Ch=n(3320),Th={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Ch.Z,Th);Ch.Z.locals;class Sh extends nd{constructor(e){super(e),this.set("text"),this.set("for"),this.id=`ck-editor__label_${k()}`;const t=this.bindTemplate;this.setTemplate({tag:"label",attributes:{class:["ck","ck-label"],id:this.id,for:t.to("for")},children:[{text:t.to("text")}]})}}class Ph extends Eh{constructor(e){super(e),this.top=this.createCollection(),this.main=this.createCollection(),this._voiceLabelView=this._createVoiceLabel(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-reset","ck-editor","ck-rounded-corners"],role:"application",dir:e.uiLanguageDirection,lang:e.uiLanguage,"aria-labelledby":this._voiceLabelView.id},children:[this._voiceLabelView,{tag:"div",attributes:{class:["ck","ck-editor__top","ck-reset_all"],role:"presentation"},children:this.top},{tag:"div",attributes:{class:["ck","ck-editor__main"],role:"presentation"},children:this.main}]})}_createVoiceLabel(){const e=this.t,t=new Sh;return t.text=e("Rich Text Editor"),t.extendTemplate({attributes:{class:"ck-voice-label"}}),t}}class Ih extends nd{constructor(e,t,n){super(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-content","ck-editor__editable","ck-rounded-corners"],lang:e.contentLanguage,dir:e.contentLanguageDirection}}),this.name=null,this.set("isFocused",!1),this._editableElement=n,this._hasExternalElement=!!this._editableElement,this._editingView=t}render(){super.render(),this._hasExternalElement?this.template.apply(this.element=this._editableElement):this._editableElement=this.element,this.on("change:isFocused",(()=>this._updateIsFocusedClasses())),this._updateIsFocusedClasses()}destroy(){this._hasExternalElement&&this.template.revert(this._editableElement),super.destroy()}_updateIsFocusedClasses(){const e=this._editingView;function t(t){e.change((n=>{const i=e.document.getRoot(t.name);n.addClass(t.isFocused?"ck-focused":"ck-blurred",i),n.removeClass(t.isFocused?"ck-blurred":"ck-focused",i)}))}e.isRenderingInProgress?function n(i){e.once("change:isRenderingInProgress",((e,o,r)=>{r?n(i):t(i)}))}(this):t(this)}}class Oh extends Ih{constructor(e,t,n){super(e,t,n),this.extendTemplate({attributes:{role:"textbox",class:"ck-editor__editable_inline"}})}render(){super.render();const e=this._editingView,t=this.t;e.change((n=>{const i=e.document.getRoot(this.name);n.setAttribute("aria-label",t("Rich Text Editor, %0",this.name),i)}))}}var Mh=n(7641),Rh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Mh.Z,Rh);Mh.Z.locals;var Nh=n(7138),jh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Nh.Z,jh);Nh.Z.locals;class Dh extends nd{constructor(e){super(e),this.set("value"),this.set("id"),this.set("placeholder"),this.set("isReadOnly",!1),this.set("hasError",!1),this.set("ariaDescribedById"),this.focusTracker=new Za,this.bind("isFocused").to(this.focusTracker),this.set("isEmpty",!0),this.set("inputMode","text");const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck","ck-input",t.if("isFocused","ck-input_focused"),t.if("isEmpty","ck-input-text_empty"),t.if("hasError","ck-error")],id:t.to("id"),placeholder:t.to("placeholder"),readonly:t.to("isReadOnly"),inputmode:t.to("inputMode"),"aria-invalid":t.if("hasError",!0),"aria-describedby":t.to("ariaDescribedById")},on:{input:t.to(((...e)=>{this.fire("input",...e),this._updateIsEmpty()})),change:t.to(this._updateIsEmpty.bind(this))}})}render(){super.render(),this.focusTracker.add(this.element),this._setDomElementValue(this.value),this._updateIsEmpty(),this.on("change:value",((e,t,n)=>{this._setDomElementValue(n),this._updateIsEmpty()}))}destroy(){super.destroy(),this.focusTracker.destroy()}select(){this.element.select()}focus(){this.element.focus()}_updateIsEmpty(){this.isEmpty=!this.element.value}_setDomElementValue(e){this.element.value=e||0===e?e:""}}class Lh extends Dh{constructor(e){super(e),this.extendTemplate({attributes:{type:"text",class:["ck-input-text"]}})}}var zh=n(7546),Vh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(zh.Z,Vh);zh.Z.locals;class Bh extends nd{constructor(e,t){super(e);const n=`ck-labeled-field-view-${k()}`,i=`ck-labeled-field-view-status-${k()}`;this.fieldView=t(this,n,i),this.set("label"),this.set("isEnabled",!0),this.set("isEmpty",!0),this.set("isFocused",!1),this.set("errorText",null),this.set("infoText",null),this.set("class"),this.set("placeholder"),this.labelView=this._createLabelView(n),this.statusView=this._createStatusView(i),this.bind("_statusText").to(this,"errorText",this,"infoText",((e,t)=>e||t));const o=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view",o.to("class"),o.if("isEnabled","ck-disabled",(e=>!e)),o.if("isEmpty","ck-labeled-field-view_empty"),o.if("isFocused","ck-labeled-field-view_focused"),o.if("placeholder","ck-labeled-field-view_placeholder"),o.if("errorText","ck-error")]},children:[{tag:"div",attributes:{class:["ck","ck-labeled-field-view__input-wrapper"]},children:[this.fieldView,this.labelView]},this.statusView]})}_createLabelView(e){const t=new Sh(this.locale);return t.for=e,t.bind("text").to(this,"label"),t}_createStatusView(e){const t=new nd(this.locale),n=this.bindTemplate;return t.setTemplate({tag:"div",attributes:{class:["ck","ck-labeled-field-view__status",n.if("errorText","ck-labeled-field-view__status_error"),n.if("_statusText","ck-hidden",(e=>!e))],id:e,role:n.if("errorText","alert")},children:[{text:n.to("_statusText")}]}),t}focus(){this.fieldView.focus()}}function Fh(e,t,n){const i=new Lh(e.locale);return i.set({id:t,ariaDescribedById:n}),i.bind("isReadOnly").to(e,"isEnabled",(e=>!e)),i.bind("hasError").to(e,"errorText",(e=>!!e)),i.on("input",(()=>{e.errorText=null})),e.bind("isEmpty","isFocused","placeholder").to(i),i}class Hh extends Gi{static get pluginName(){return"Notification"}init(){this.on("show:warning",((e,t)=>{window.alert(t.message)}),{priority:"lowest"})}showSuccess(e,t={}){this._showNotification({message:e,type:"success",namespace:t.namespace,title:t.title})}showInfo(e,t={}){this._showNotification({message:e,type:"info",namespace:t.namespace,title:t.title})}showWarning(e,t={}){this._showNotification({message:e,type:"warning",namespace:t.namespace,title:t.title})}_showNotification(e){const t=`show:${e.type}`+(e.namespace?`:${e.namespace}`:"");this.fire(t,{message:e.message,type:e.type,title:e.title||""})}}class Uh{constructor(e,t){t&&ht(this,t),e&&this.set(e)}}function Wh(e){return t=>t+e}Et(Uh,kt);var qh=n(9029),$h={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(qh.Z,$h);qh.Z.locals;const Zh=Wh("px"),Kh=bs.document.body;class Gh extends nd{constructor(e){super(e);const t=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("position","arrow_nw"),this.set("isVisible",!1),this.set("withArrow",!0),this.set("class"),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-panel",t.to("position",(e=>`ck-balloon-panel_${e}`)),t.if("isVisible","ck-balloon-panel_visible"),t.if("withArrow","ck-balloon-panel_with-arrow"),t.to("class")],style:{top:t.to("top",Zh),left:t.to("left",Zh)}},children:this.content})}show(){this.isVisible=!0}hide(){this.isVisible=!1}attachTo(e){this.show();const t=Gh.defaultPositions,n=Object.assign({},{element:this.element,positions:[t.southArrowNorth,t.southArrowNorthMiddleWest,t.southArrowNorthMiddleEast,t.southArrowNorthWest,t.southArrowNorthEast,t.northArrowSouth,t.northArrowSouthMiddleWest,t.northArrowSouthMiddleEast,t.northArrowSouthWest,t.northArrowSouthEast,t.viewportStickyNorth],limiter:Kh,fitInViewport:!0},e),i=Gh._getOptimalPosition(n),o=parseInt(i.left),r=parseInt(i.top),{name:s,config:a={}}=i,{withArrow:c=!0}=a;Object.assign(this,{top:r,left:o,position:s,withArrow:c})}pin(e){this.unpin(),this._pinWhenIsVisibleCallback=()=>{this.isVisible?this._startPinning(e):this._stopPinning()},this._startPinning(e),this.listenTo(this,"change:isVisible",this._pinWhenIsVisibleCallback)}unpin(){this._pinWhenIsVisibleCallback&&(this._stopPinning(),this.stopListening(this,"change:isVisible",this._pinWhenIsVisibleCallback),this._pinWhenIsVisibleCallback=null,this.hide())}_startPinning(e){this.attachTo(e);const t=Yh(e.target),n=e.limiter?Yh(e.limiter):Kh;this.listenTo(bs.document,"scroll",((i,o)=>{const r=o.target,s=t&&r.contains(t),a=n&&r.contains(n);!s&&!a&&t&&n||this.attachTo(e)}),{useCapture:!0}),this.listenTo(bs.window,"resize",(()=>{this.attachTo(e)}))}_stopPinning(){this.stopListening(bs.document,"scroll"),this.stopListening(bs.window,"resize")}}function Yh(e){return Di(e)?e:Sa(e)?e.commonAncestorContainer:"function"==typeof e?Yh(e()):null}Gh.arrowHorizontalOffset=25,Gh.arrowVerticalOffset=10,Gh.stickyVerticalOffset=20,Gh._getOptimalPosition=Jd,Gh.defaultPositions=function({horizontalOffset:e=Gh.arrowHorizontalOffset,verticalOffset:t=Gh.arrowVerticalOffset,stickyVerticalOffset:n=Gh.stickyVerticalOffset,config:i}={}){return{northWestArrowSouthWest:(t,n)=>({top:o(t,n),left:t.left-e,name:"arrow_sw",...i&&{config:i}}),northWestArrowSouthMiddleWest:(t,n)=>({top:o(t,n),left:t.left-.25*n.width-e,name:"arrow_smw",...i&&{config:i}}),northWestArrowSouth:(e,t)=>({top:o(e,t),left:e.left-t.width/2,name:"arrow_s",...i&&{config:i}}),northWestArrowSouthMiddleEast:(t,n)=>({top:o(t,n),left:t.left-.75*n.width+e,name:"arrow_sme",...i&&{config:i}}),northWestArrowSouthEast:(t,n)=>({top:o(t,n),left:t.left-n.width+e,name:"arrow_se",...i&&{config:i}}),northArrowSouthWest:(t,n)=>({top:o(t,n),left:t.left+t.width/2-e,name:"arrow_sw",...i&&{config:i}}),northArrowSouthMiddleWest:(t,n)=>({top:o(t,n),left:t.left+t.width/2-.25*n.width-e,name:"arrow_smw",...i&&{config:i}}),northArrowSouth:(e,t)=>({top:o(e,t),left:e.left+e.width/2-t.width/2,name:"arrow_s",...i&&{config:i}}),northArrowSouthMiddleEast:(t,n)=>({top:o(t,n),left:t.left+t.width/2-.75*n.width+e,name:"arrow_sme",...i&&{config:i}}),northArrowSouthEast:(t,n)=>({top:o(t,n),left:t.left+t.width/2-n.width+e,name:"arrow_se",...i&&{config:i}}),northEastArrowSouthWest:(t,n)=>({top:o(t,n),left:t.right-e,name:"arrow_sw",...i&&{config:i}}),northEastArrowSouthMiddleWest:(t,n)=>({top:o(t,n),left:t.right-.25*n.width-e,name:"arrow_smw",...i&&{config:i}}),northEastArrowSouth:(e,t)=>({top:o(e,t),left:e.right-t.width/2,name:"arrow_s",...i&&{config:i}}),northEastArrowSouthMiddleEast:(t,n)=>({top:o(t,n),left:t.right-.75*n.width+e,name:"arrow_sme",...i&&{config:i}}),northEastArrowSouthEast:(t,n)=>({top:o(t,n),left:t.right-n.width+e,name:"arrow_se",...i&&{config:i}}),southWestArrowNorthWest:(t,n)=>({top:r(t),left:t.left-e,name:"arrow_nw",...i&&{config:i}}),southWestArrowNorthMiddleWest:(t,n)=>({top:r(t),left:t.left-.25*n.width-e,name:"arrow_nmw",...i&&{config:i}}),southWestArrowNorth:(e,t)=>({top:r(e),left:e.left-t.width/2,name:"arrow_n",...i&&{config:i}}),southWestArrowNorthMiddleEast:(t,n)=>({top:r(t),left:t.left-.75*n.width+e,name:"arrow_nme",...i&&{config:i}}),southWestArrowNorthEast:(t,n)=>({top:r(t),left:t.left-n.width+e,name:"arrow_ne",...i&&{config:i}}),southArrowNorthWest:(t,n)=>({top:r(t),left:t.left+t.width/2-e,name:"arrow_nw",...i&&{config:i}}),southArrowNorthMiddleWest:(t,n)=>({top:r(t),left:t.left+t.width/2-.25*n.width-e,name:"arrow_nmw",...i&&{config:i}}),southArrowNorth:(e,t)=>({top:r(e),left:e.left+e.width/2-t.width/2,name:"arrow_n",...i&&{config:i}}),southArrowNorthMiddleEast:(t,n)=>({top:r(t),left:t.left+t.width/2-.75*n.width+e,name:"arrow_nme",...i&&{config:i}}),southArrowNorthEast:(t,n)=>({top:r(t),left:t.left+t.width/2-n.width+e,name:"arrow_ne",...i&&{config:i}}),southEastArrowNorthWest:(t,n)=>({top:r(t),left:t.right-e,name:"arrow_nw",...i&&{config:i}}),southEastArrowNorthMiddleWest:(t,n)=>({top:r(t),left:t.right-.25*n.width-e,name:"arrow_nmw",...i&&{config:i}}),southEastArrowNorth:(e,t)=>({top:r(e),left:e.right-t.width/2,name:"arrow_n",...i&&{config:i}}),southEastArrowNorthMiddleEast:(t,n)=>({top:r(t),left:t.right-.75*n.width+e,name:"arrow_nme",...i&&{config:i}}),southEastArrowNorthEast:(t,n)=>({top:r(t),left:t.right-n.width+e,name:"arrow_ne",...i&&{config:i}}),viewportStickyNorth:(e,t,o)=>e.getIntersection(o)?{top:o.top+n,left:e.left+e.width/2-t.width/2,name:"arrowless",config:{withArrow:!1,...i}}:null};function o(e,n){return e.top-n.height-t}function r(e){return e.bottom+t}}();var Qh=n(395),Jh={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Qh.Z,Jh);Qh.Z.locals;var Xh=n(5078),ef={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Xh.Z,ef);Xh.Z.locals;const tf=Wh("px");class nf extends Ct{static get pluginName(){return"ContextualBalloon"}constructor(e){super(e),this.positionLimiter=()=>{const e=this.editor.editing.view,t=e.document.selection.editableElement;return t?e.domConverter.mapViewToDom(t.root):null},this.set("visibleView",null),this.view=new Gh(e.locale),e.ui.view.body.add(this.view),e.ui.focusTracker.add(this.view.element),this._viewToStack=new Map,this._idToStack=new Map,this.set("_numberOfStacks",0),this.set("_singleViewMode",!1),this._rotatorView=this._createRotatorView(),this._fakePanelsView=this._createFakePanelsView()}destroy(){super.destroy(),this.view.destroy(),this._rotatorView.destroy(),this._fakePanelsView.destroy()}hasView(e){return Array.from(this._viewToStack.keys()).includes(e)}add(e){if(this.hasView(e.view))throw new y("contextualballoon-add-view-exist",[this,e]);const t=e.stackId||"main";if(!this._idToStack.has(t))return this._idToStack.set(t,new Map([[e.view,e]])),this._viewToStack.set(e.view,this._idToStack.get(t)),this._numberOfStacks=this._idToStack.size,void(this._visibleStack&&!e.singleViewMode||this.showStack(t));const n=this._idToStack.get(t);e.singleViewMode&&this.showStack(t),n.set(e.view,e),this._viewToStack.set(e.view,n),n===this._visibleStack&&this._showView(e)}remove(e){if(!this.hasView(e))throw new y("contextualballoon-remove-view-not-exist",[this,e]);const t=this._viewToStack.get(e);this._singleViewMode&&this.visibleView===e&&(this._singleViewMode=!1),this.visibleView===e&&(1===t.size?this._idToStack.size>1?this._showNextStack():(this.view.hide(),this.visibleView=null,this._rotatorView.hideView()):this._showView(Array.from(t.values())[t.size-2])),1===t.size?(this._idToStack.delete(this._getStackId(t)),this._numberOfStacks=this._idToStack.size):t.delete(e),this._viewToStack.delete(e)}updatePosition(e){e&&(this._visibleStack.get(this.visibleView).position=e),this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition()}showStack(e){this.visibleStack=e;const t=this._idToStack.get(e);if(!t)throw new y("contextualballoon-showstack-stack-not-exist",this);this._visibleStack!==t&&this._showView(Array.from(t.values()).pop())}get _visibleStack(){return this._viewToStack.get(this.visibleView)}_getStackId(e){return Array.from(this._idToStack.entries()).find((t=>t[1]===e))[0]}_showNextStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)+1;e[t]||(t=0),this.showStack(this._getStackId(e[t]))}_showPrevStack(){const e=Array.from(this._idToStack.values());let t=e.indexOf(this._visibleStack)-1;e[t]||(t=e.length-1),this.showStack(this._getStackId(e[t]))}_createRotatorView(){const e=new of(this.editor.locale),t=this.editor.locale.t;return this.view.content.add(e),e.bind("isNavigationVisible").to(this,"_numberOfStacks",this,"_singleViewMode",((e,t)=>!t&&e>1)),e.on("change:isNavigationVisible",(()=>this.updatePosition()),{priority:"low"}),e.bind("counter").to(this,"visibleView",this,"_numberOfStacks",((e,n)=>{if(n<2)return"";const i=Array.from(this._idToStack.values()).indexOf(this._visibleStack)+1;return t("%0 of %1",[i,n])})),e.buttonNextView.on("execute",(()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showNextStack()})),e.buttonPrevView.on("execute",(()=>{e.focusTracker.isFocused&&this.editor.editing.view.focus(),this._showPrevStack()})),e}_createFakePanelsView(){const e=new rf(this.editor.locale,this.view);return e.bind("numberOfPanels").to(this,"_numberOfStacks",this,"_singleViewMode",((e,t)=>!t&&e>=2?Math.min(e-1,2):0)),e.listenTo(this.view,"change:top",(()=>e.updatePosition())),e.listenTo(this.view,"change:left",(()=>e.updatePosition())),this.editor.ui.view.body.add(e),e}_showView({view:e,balloonClassName:t="",withArrow:n=!0,singleViewMode:i=!1}){this.view.class=t,this.view.withArrow=n,this._rotatorView.showView(e),this.visibleView=e,this.view.pin(this._getBalloonPosition()),this._fakePanelsView.updatePosition(),i&&(this._singleViewMode=!0)}_getBalloonPosition(){let e=Array.from(this._visibleStack.values()).pop().position;return e&&(e.limiter||(e=Object.assign({},e,{limiter:this.positionLimiter})),e=Object.assign({},e,{viewportOffsetConfig:this.editor.ui.viewportOffset})),e}}class of extends nd{constructor(e){super(e);const t=e.t,n=this.bindTemplate;this.set("isNavigationVisible",!0),this.focusTracker=new Za,this.buttonPrevView=this._createButtonView(t("Previous"),''),this.buttonNextView=this._createButtonView(t("Next"),''),this.content=this.createCollection(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-balloon-rotator"],"z-index":"-1"},children:[{tag:"div",attributes:{class:["ck-balloon-rotator__navigation",n.to("isNavigationVisible",(e=>e?"":"ck-hidden"))]},children:[this.buttonPrevView,{tag:"span",attributes:{class:["ck-balloon-rotator__counter"]},children:[{text:n.to("counter")}]},this.buttonNextView]},{tag:"div",attributes:{class:"ck-balloon-rotator__content"},children:this.content}]})}render(){super.render(),this.focusTracker.add(this.element)}destroy(){super.destroy(),this.focusTracker.destroy()}showView(e){this.hideView(),this.content.add(e)}hideView(){this.content.clear()}_createButtonView(e,t){const n=new Md(this.locale);return n.set({label:e,icon:t,tooltip:!0}),n}}class rf extends nd{constructor(e,t){super(e);const n=this.bindTemplate;this.set("top",0),this.set("left",0),this.set("height",0),this.set("width",0),this.set("numberOfPanels",0),this.content=this.createCollection(),this._balloonPanelView=t,this.setTemplate({tag:"div",attributes:{class:["ck-fake-panel",n.to("numberOfPanels",(e=>e?"":"ck-hidden"))],style:{top:n.to("top",tf),left:n.to("left",tf),width:n.to("width",tf),height:n.to("height",tf)}},children:this.content}),this.on("change:numberOfPanels",((e,t,n,i)=>{n>i?this._addPanels(n-i):this._removePanels(i-n),this.updatePosition()}))}_addPanels(e){for(;e--;){const e=new nd;e.setTemplate({tag:"div"}),this.content.add(e),this.registerChild(e)}}_removePanels(e){for(;e--;){const e=this.content.last;this.content.remove(e),this.deregisterChild(e),e.destroy()}}updatePosition(){if(this.numberOfPanels){const{top:e,left:t}=this._balloonPanelView,{width:n,height:i}=new Oa(this._balloonPanelView.element);Object.assign(this,{top:e,left:t,width:n,height:i})}}}var sf=n(3846),af={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(sf.Z,af);sf.Z.locals;const cf=Wh("px");class lf extends nd{constructor(e){super(e);const t=this.bindTemplate;this.set("isActive",!1),this.set("isSticky",!1),this.set("limiterElement",null),this.set("limiterBottomOffset",50),this.set("viewportTopOffset",0),this.set("_marginLeft",null),this.set("_isStickyToTheLimiter",!1),this.set("_hasViewportTopOffset",!1),this.content=this.createCollection(),this._contentPanelPlaceholder=new id({tag:"div",attributes:{class:["ck","ck-sticky-panel__placeholder"],style:{display:t.to("isSticky",(e=>e?"block":"none")),height:t.to("isSticky",(e=>e?cf(this._panelRect.height):null))}}}).render(),this._contentPanel=new id({tag:"div",attributes:{class:["ck","ck-sticky-panel__content",t.if("isSticky","ck-sticky-panel__content_sticky"),t.if("_isStickyToTheLimiter","ck-sticky-panel__content_sticky_bottom-limit")],style:{width:t.to("isSticky",(e=>e?cf(this._contentPanelPlaceholder.getBoundingClientRect().width):null)),top:t.to("_hasViewportTopOffset",(e=>e?cf(this.viewportTopOffset):null)),bottom:t.to("_isStickyToTheLimiter",(e=>e?cf(this.limiterBottomOffset):null)),marginLeft:t.to("_marginLeft")}},children:this.content}).render(),this.setTemplate({tag:"div",attributes:{class:["ck","ck-sticky-panel"]},children:[this._contentPanelPlaceholder,this._contentPanel]})}render(){super.render(),this._checkIfShouldBeSticky(),this.listenTo(bs.window,"scroll",(()=>{this._checkIfShouldBeSticky()})),this.listenTo(this,"change:isActive",(()=>{this._checkIfShouldBeSticky()}))}_checkIfShouldBeSticky(){const e=this._panelRect=this._contentPanel.getBoundingClientRect();let t;this.limiterElement?(t=this._limiterRect=this.limiterElement.getBoundingClientRect(),this.isSticky=this.isActive&&t.topbf(s,e)))),pf.get(s).set(n,{text:i,isDirectHost:o,keepOnFocus:r,hostElement:o?n:null}),t.change((e=>bf(s,e)))}function mf(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function bf(e,t){const n=pf.get(e),i=[];let o=!1;for(const[e,r]of n)r.isDirectHost&&(i.push(e),wf(t,e,r)&&(o=!0));for(const[e,r]of n){if(r.isDirectHost)continue;const n=kf(e);n&&(i.includes(n)||(r.hostElement=n,wf(t,e,r)&&(o=!0)))}return o}function wf(e,t,n){const{text:i,isDirectHost:o,hostElement:r}=n;let s=!1;r.getAttribute("data-placeholder")!==i&&(e.setAttribute("data-placeholder",i,r),s=!0);return(o||1==t.childCount)&&function(e,t){if(!e.isAttached())return!1;const n=Array.from(e.getChildren()).some((e=>!e.is("uiElement")));if(n)return!1;if(t)return!0;const i=e.document;if(!i.isFocused)return!0;const o=i.selection.anchor;return o&&o.parent!==e}(r,n.keepOnFocus)?function(e,t){return!t.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",t),!0)}(e,r)&&(s=!0):mf(e,r)&&(s=!0),s}function kf(e){if(e.childCount){const t=e.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}const vf=new Map;function _f(e,t,n){let i=vf.get(e);i||(i=new Map,vf.set(e,i)),i.set(t,n)}function yf(e){return[e]}function xf(e,t,n={}){const i=function(e,t){const n=vf.get(e);return n&&n.has(t)?n.get(t):yf}(e.constructor,t.constructor);try{return i(e=e.clone(),t,n)}catch(e){throw e}}function Af(e,t,n){e=e.slice(),t=t.slice();const i=new Ef(n.document,n.useRelations,n.forceWeakRemove);i.setOriginalOperations(e),i.setOriginalOperations(t);const o=i.originalOperations;if(0==e.length||0==t.length)return{operationsA:e,operationsB:t,originalOperations:o};const r=new WeakMap;for(const t of e)r.set(t,0);const s={nextBaseVersionA:e[e.length-1].baseVersion+1,nextBaseVersionB:t[t.length-1].baseVersion+1,originalOperationsACount:e.length,originalOperationsBCount:t.length};let a=0;for(;a{if(e.key===t.key&&e.range.start.hasSameParentAs(t.range.start)){const i=e.range.getDifference(t.range).map((t=>new Dl(t,e.key,e.oldValue,e.newValue,0))),o=e.range.getIntersection(t.range);return o&&n.aIsStrong&&i.push(new Dl(o,t.key,t.newValue,e.newValue,0)),0==i.length?[new hu(0)]:i}return[e]})),_f(Dl,Vl,((e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){const n=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map((t=>new Dl(t,e.key,e.oldValue,e.newValue,e.baseVersion)));if(t.shouldReceiveAttributes){const i=Sf(t,e.key,e.oldValue);i&&n.unshift(i)}return n}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]})),_f(Dl,Ul,((e,t)=>{const n=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&n.push(lc._createFromPositionAndShift(t.graveyardPosition,1));const i=e.range._getTransformedByMergeOperation(t);return i.isCollapsed||n.push(i),n.map((t=>new Dl(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),_f(Dl,zl,((e,t)=>{const n=function(e,t){const n=lc._createFromPositionAndShift(t.sourcePosition,t.howMany);let i=null,o=[];n.containsRange(e,!0)?i=e:e.start.hasSameParentAs(n.start)?(o=e.getDifference(n),i=e.getIntersection(n)):o=[e];const r=[];for(let e of o){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);const n=t.getMovedRangeStart(),i=e.start.hasSameParentAs(n);e=e._getTransformedByInsertion(n,t.howMany,i),r.push(...e)}i&&r.push(i._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]);return r}(e.range,t);return n.map((t=>new Dl(t,e.key,e.oldValue,e.newValue,e.baseVersion)))})),_f(Dl,Wl,((e,t)=>{if(e.range.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.range.end.offset++,[e];if(e.range.start.hasSameParentAs(t.splitPosition)&&e.range.containsPosition(t.splitPosition)){const n=e.clone();return n.range=new lc(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness="toPrevious",[e,n]}return e.range=e.range._getTransformedBySplitOperation(t),[e]})),_f(Vl,Dl,((e,t)=>{const n=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){const i=Sf(e,t.key,t.newValue);i&&n.push(i)}return n})),_f(Vl,Vl,((e,t,n)=>(e.position.isEqual(t.position)&&n.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e]))),_f(Vl,zl,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),_f(Vl,Wl,((e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e]))),_f(Vl,Ul,((e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e]))),_f(Bl,Vl,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e]))),_f(Bl,Bl,((e,t,n)=>{if(e.name==t.name){if(!n.aIsStrong)return[new hu(0)];e.oldRange=t.newRange?t.newRange.clone():null}return[e]})),_f(Bl,Ul,((e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e]))),_f(Bl,zl,((e,t,n)=>{if(e.oldRange&&(e.oldRange=lc._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){if(n.abRelation){const i=lc._createFromRanges(e.newRange._getTransformedByMoveOperation(t));if("left"==n.abRelation.side&&t.targetPosition.isEqual(e.newRange.start))return e.newRange.start.path=n.abRelation.path,e.newRange.end=i.end,[e];if("right"==n.abRelation.side&&t.targetPosition.isEqual(e.newRange.end))return e.newRange.start=i.start,e.newRange.end.path=n.abRelation.path,[e]}e.newRange=lc._createFromRanges(e.newRange._getTransformedByMoveOperation(t))}return[e]})),_f(Bl,Wl,((e,t,n)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(n.abRelation){const i=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)&&n.abRelation.wasStartBeforeMergedElement?e.newRange.start=rc._createAt(t.insertionPosition):e.newRange.start.isEqual(t.splitPosition)&&!n.abRelation.wasInLeftElement&&(e.newRange.start=rc._createAt(t.moveTargetPosition)),e.newRange.end.isEqual(t.splitPosition)&&n.abRelation.wasInRightElement?e.newRange.end=rc._createAt(t.moveTargetPosition):e.newRange.end.isEqual(t.splitPosition)&&n.abRelation.wasEndBeforeMergedElement?e.newRange.end=rc._createAt(t.insertionPosition):e.newRange.end=i.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]})),_f(Ul,Vl,((e,t)=>(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e]))),_f(Ul,Ul,((e,t,n)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition)){if(n.bWasUndone){const n=t.graveyardPosition.path.slice();return n.push(0),e.sourcePosition=new rc(t.graveyardPosition.root,n),e.howMany=0,[e]}return[new hu(0)]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!n.bWasUndone&&"splitAtSource"!=n.abRelation){const i="$graveyard"==e.targetPosition.root.rootName,o="$graveyard"==t.targetPosition.root.rootName,r=i&&!o;if(o&&!i||!r&&n.aIsStrong){const n=t.targetPosition._getTransformedByMergeOperation(t),i=e.targetPosition._getTransformedByMergeOperation(t);return[new zl(n,e.howMany,i,0)]}return[new hu(0)]}return e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMergeOperation(t),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),e.graveyardPosition.isEqual(t.graveyardPosition)&&n.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),_f(Ul,zl,((e,t,n)=>{const i=lc._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!n.bWasUndone&&!n.forceWeakRemove&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.sourcePosition)?[new hu(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])})),_f(Ul,Wl,((e,t,n)=>{if(t.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByDeletion(t.graveyardPosition,1),e.deletionPosition.isEqual(t.graveyardPosition)&&(e.howMany=t.howMany)),e.targetPosition.isEqual(t.splitPosition)){const i=0!=t.howMany,o=t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition);if(i||o||"mergeTargetNotMoved"==n.abRelation)return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e]}if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==n.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==n.abRelation||e.sourcePosition.offset>0)return e.sourcePosition=t.moveTargetPosition.clone(),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}return e.sourcePosition.hasSameParentAs(t.splitPosition)&&(e.howMany=t.splitPosition.offset),e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]})),_f(zl,Vl,((e,t)=>{const n=lc._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=n.start,e.howMany=n.end.offset-n.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]})),_f(zl,zl,((e,t,n)=>{const i=lc._createFromPositionAndShift(e.sourcePosition,e.howMany),o=lc._createFromPositionAndShift(t.sourcePosition,t.howMany);let r,s=n.aIsStrong,a=!n.aIsStrong;if("insertBefore"==n.abRelation||"insertAfter"==n.baRelation?a=!0:"insertAfter"!=n.abRelation&&"insertBefore"!=n.baRelation||(a=!1),r=e.targetPosition.isEqual(t.targetPosition)&&a?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Pf(e,t)&&Pf(t,e))return[t.getReversed()];if(i.containsPosition(t.targetPosition)&&i.containsRange(o,!0))return i.start=i.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),i.end=i.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),If([i],r);if(o.containsPosition(e.targetPosition)&&o.containsRange(i,!0))return i.start=i.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),i.end=i.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),If([i],r);const c=Yi(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==c||"extension"==c)return i.start=i.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),i.end=i.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),If([i],r);"remove"!=e.type||"remove"==t.type||n.aWasUndone||n.forceWeakRemove?"remove"==e.type||"remove"!=t.type||n.bWasUndone||n.forceWeakRemove||(s=!1):s=!0;const l=[],u=i.getDifference(o);for(const e of u){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const n="same"==Yi(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),i=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,n);l.push(...i)}const d=i.getIntersection(o);return null!==d&&s&&(d.start=d.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),d.end=d.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===l.length?l.push(d):1==l.length?o.start.isBefore(i.start)||o.start.isEqual(i.start)?l.unshift(d):l.push(d):l.splice(1,0,d)),0===l.length?[new hu(e.baseVersion)]:If(l,r)})),_f(zl,Wl,((e,t,n)=>{let i=e.targetPosition.clone();e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=n.abRelation||(i=e.targetPosition._getTransformedBySplitOperation(t));const o=lc._createFromPositionAndShift(e.sourcePosition,e.howMany);if(o.end.isEqual(t.insertionPosition))return t.graveyardPosition||e.howMany++,e.targetPosition=i,[e];if(o.start.hasSameParentAs(t.splitPosition)&&o.containsPosition(t.splitPosition)){let e=new lc(t.splitPosition,o.end);e=e._getTransformedBySplitOperation(t);return If([new lc(o.start,t.splitPosition),e],i)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==n.abRelation&&(i=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==n.abRelation&&(i=e.targetPosition);const r=[o._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const i=o.start.isEqual(t.graveyardPosition)||o.containsPosition(t.graveyardPosition);e.howMany>1&&i&&!n.aWasUndone&&r.push(lc._createFromPositionAndShift(t.insertionPosition,1))}return If(r,i)})),_f(zl,Ul,((e,t,n)=>{const i=lc._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&i.containsPosition(t.sourcePosition))if("remove"!=e.type||n.forceWeakRemove){if(1==e.howMany)return n.bWasUndone?(e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]):[new hu(0)]}else if(!n.aWasUndone){const n=[];let i=t.graveyardPosition.clone(),o=t.targetPosition._getTransformedByMergeOperation(t);e.howMany>1&&(n.push(new zl(e.sourcePosition,e.howMany-1,e.targetPosition,0)),i=i._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1),o=o._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany-1));const r=t.deletionPosition._getCombined(e.sourcePosition,e.targetPosition),s=new zl(i,1,r,0),a=s.getMovedRangeStart().path.slice();a.push(0);const c=new rc(s.targetPosition.root,a);o=o._getTransformedByMove(i,r,1);const l=new zl(o,t.howMany,c,0);return n.push(s),n.push(l),n}const o=lc._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]})),_f(Fl,Vl,((e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e]))),_f(Fl,Ul,((e,t)=>e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext",[e]):(e.position=e.position._getTransformedByMergeOperation(t),[e]))),_f(Fl,zl,((e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e]))),_f(Fl,Fl,((e,t,n)=>{if(e.position.isEqual(t.position)){if(!n.aIsStrong)return[new hu(0)];e.oldName=t.newName}return[e]})),_f(Fl,Wl,((e,t)=>{if("same"==Yi(e.position.path,t.splitPosition.getParentPath())&&!t.graveyardPosition){const t=new Fl(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]})),_f(Hl,Hl,((e,t,n)=>{if(e.root===t.root&&e.key===t.key){if(!n.aIsStrong||e.newValue===t.newValue)return[new hu(0)];e.oldValue=t.newValue}return[e]})),_f(Wl,Vl,((e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset{if(!e.graveyardPosition&&!n.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){const n=t.graveyardPosition.path.slice();n.push(0);const i=new rc(t.graveyardPosition.root,n),o=Wl.getInsertionPosition(new rc(t.graveyardPosition.root,n)),r=new Wl(i,0,o,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Wl.getInsertionPosition(e.splitPosition),e.graveyardPosition=r.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[r,e]}return e.splitPosition.hasSameParentAs(t.deletionPosition)&&!e.splitPosition.isAfter(t.deletionPosition)&&e.howMany--,e.splitPosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=Wl.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]})),_f(Wl,zl,((e,t,n)=>{const i=lc._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){const o=i.start.isEqual(e.graveyardPosition)||i.containsPosition(e.graveyardPosition);if(!n.bWasUndone&&o){const n=e.splitPosition._getTransformedByMoveOperation(t),i=e.graveyardPosition._getTransformedByMoveOperation(t),o=i.path.slice();o.push(0);const r=new rc(i.root,o);return[new zl(n,e.howMany,r,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}const o=e.splitPosition.isEqual(t.targetPosition);if(o&&("insertAtSource"==n.baRelation||"splitBefore"==n.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=Wl.getInsertionPosition(e.splitPosition),[e];if(o&&n.abRelation&&n.abRelation.howMany){const{howMany:t,offset:i}=n.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(i),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.splitPosition)){const n=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=n,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition)return[new hu(0)];if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new hu(0)];if("splitBefore"==n.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){const i="$graveyard"==e.splitPosition.root.rootName,o="$graveyard"==t.splitPosition.root.rootName,r=i&&!o;if(o&&!i||!r&&n.aIsStrong){const n=[];return t.howMany&&n.push(new zl(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&n.push(new zl(e.splitPosition,e.howMany,e.moveTargetPosition,0)),n}return[new hu(0)]}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==n.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==n.baRelation){const n=t.insertionPosition.path.slice();n.push(0);const i=new rc(t.insertionPosition.root,n);return[e,new zl(e.insertionPosition,1,i,0)]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offsete.replace(/,/g,", ")))}function Xf(e){e.setNormalizer("background",ep),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 ep(e){const t={},n=Jf(e);for(const e of n)i=e,Uf.includes(i)?(t.repeat=t.repeat||[],t.repeat.push(e)):qf(e)?(t.position=t.position||[],t.position.push(e)):Zf(e)?t.attachment=e:Bf(e)?t.color=e:Gf(e)&&(t.image=e);var i;return{path:"background",value:t}}function tp(e){var t,n;e.setNormalizer("margin",(t="margin",e=>({path:t,value:Yf(e)}))),e.setNormalizer("margin-top",(e=>({path:"margin.top",value:e}))),e.setNormalizer("margin-right",(e=>({path:"margin.right",value:e}))),e.setNormalizer("margin-bottom",(e=>({path:"margin.bottom",value:e}))),e.setNormalizer("margin-left",(e=>({path:"margin.left",value:e}))),e.setReducer("margin",(n="margin",e=>{const{top:t,right:i,bottom:o,left:r}=e,s=[];return[t,i,r,o].every((e=>!!e))?s.push([n,Qf(e)]):(t&&s.push([n+"-top",t]),i&&s.push([n+"-right",i]),o&&s.push([n+"-bottom",o]),r&&s.push([n+"-left",r])),s})),e.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}class np extends Fu{constructor(e,t){super(e),this.view=t,this._toolbarConfig=oh(e.config.get("toolbar")),this._elementReplacer=new Ea}get element(){return this.view.element}init(e){const t=this.editor,n=this.view,i=t.editing.view,o=n.editable,r=i.document.getRoot();o.name=r.rootName,n.render();const s=o.element;this.setEditableElement(o.name,s),this.focusTracker.add(s),n.editable.bind("isFocused").to(this.focusTracker),i.attachDomRoot(s),e&&this._elementReplacer.replace(e,this.element),this._initPlaceholder(),this._initToolbar(),this.fire("ready")}destroy(){const e=this.view,t=this.editor.editing.view;this._elementReplacer.restore(),t.detachDomRoot(e.editable.name),e.destroy(),super.destroy()}_initToolbar(){const e=this.editor,t=this.view,n=e.editing.view;t.stickyPanel.bind("isActive").to(this.focusTracker,"isFocused"),t.stickyPanel.limiterElement=t.element,t.stickyPanel.bind("viewportTopOffset").to(this,"viewportOffset",(({top:e})=>e)),t.toolbar.fillFromConfig(this._toolbarConfig,this.componentFactory),function({origin:e,originKeystrokeHandler:t,originFocusTracker:n,toolbar:i,beforeFocus:o,afterBlur:r}){n.add(i.element),t.set("Alt+F10",((e,t)=>{n.isFocused&&!i.focusTracker.isFocused&&(o&&o(),i.focus(),t())})),i.keystrokes.set("Esc",((t,n)=>{i.focusTracker.isFocused&&(e.focus(),r&&r(),n())}))}({origin:n,originFocusTracker:this.focusTracker,originKeystrokeHandler:e.keystrokes,toolbar:t.toolbar})}_initPlaceholder(){const e=this.editor,t=e.editing.view,n=t.document.getRoot(),i=e.sourceElement,o=e.config.get("placeholder")||i&&"textarea"===i.tagName.toLowerCase()&&i.getAttribute("placeholder");o&&gf({view:t,element:n,text:o,isDirectHost:!1,keepOnFocus:!0})}}var ip=n(4090),op={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(ip.Z,op);ip.Z.locals;class rp extends Ph{constructor(e,t,n={}){super(e),this.stickyPanel=new lf(e),this.toolbar=new ah(e,{shouldGroupWhenFull:n.shouldToolbarGroupWhenFull}),this.editable=new Oh(e,t)}render(){super.render(),this.stickyPanel.content.add(this.toolbar),this.top.add(this.stickyPanel),this.main.add(this.editable)}}class sp extends zu{constructor(e,t={}){if(!Di(e)&&void 0!==t.initialData)throw new y("editor-create-initial-data",null);super(t),void 0===this.config.get("initialData")&&this.config.set("initialData",function(e){return Di(e)?(t=e,t instanceof HTMLTextAreaElement?t.value:t.innerHTML):e;var t}(e)),Di(e)&&(this.sourceElement=e),this.model.document.createRoot();const n=!this.config.get("toolbar.shouldNotGroupWhenFull"),i=new rp(this.locale,this.editing.view,{shouldToolbarGroupWhenFull:n});this.ui=new np(this,i),function(e){if(!X(e.updateSourceElement))throw new y("attachtoform-missing-elementapi-interface",e);const t=e.sourceElement;if(t&&"textarea"===t.tagName.toLowerCase()&&t.form){let n;const i=t.form,o=()=>e.updateSourceElement();X(i.submit)&&(n=i.submit,i.submit=()=>{o(),n.apply(i)}),i.addEventListener("submit",o),e.on("destroy",(()=>{i.removeEventListener("submit",o),n&&(i.submit=n)}))}}(this)}destroy(){return this.sourceElement&&this.updateSourceElement(),this.ui.destroy(),super.destroy()}static create(e,t={}){return new Promise((n=>{const i=new this(e,t);n(i.initPlugins().then((()=>i.ui.init(Di(e)?e:null))).then((()=>i.data.init(i.config.get("initialData")))).then((()=>i.fire("ready"))).then((()=>i)))}))}}function*ap(e,t){for(const n of t)n&&e.getAttributeProperties(n[0]).copyOnEnter&&(yield n)}Et(sp,Uu),Et(sp,Wu);class cp extends St{execute(){const e=this.editor.model,t=e.document;e.change((n=>{!function(e,t,n,i){const o=n.isCollapsed,r=n.getFirstRange(),s=r.start.parent,a=r.end.parent;if(i.isLimit(s)||i.isLimit(a))return void(o||s!=a||e.deleteContent(n));if(o){const e=ap(t.model.schema,n.getAttributes());lp(t,r.start),t.setSelectionAttribute(e)}else{const i=!(r.start.isAtStart&&r.end.isAtEnd),o=s==a;e.deleteContent(n,{leaveUnmerged:i}),i&&(o?lp(t,n.focus):t.setSelection(a,0))}}(this.editor.model,n,t.selection,e.schema),this.fire("afterExecute",{writer:n})}))}}function lp(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}class up extends js{constructor(e){super(e);const t=this.document;t.on("keydown",((e,n)=>{if(this.isEnabled&&n.keyCode==Er.enter){const i=new rr(t,"enter",t.selection.getFirstRange());t.fire(i,new oa(t,n.domEvent,{isSoft:n.shiftKey})),i.stop.called&&e.stop()}}))}observe(){}}class dp extends Ct{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,n=t.document;t.addObserver(up),e.commands.add("enter",new cp(e)),this.listenTo(n,"enter",((n,i)=>{i.preventDefault(),i.isSoft||(e.execute("enter"),t.scrollToTheSelection())}),{priority:"low"})}}class hp{constructor(e,t=20){this.model=e,this.size=0,this.limit=t,this.isLocked=!1,this._changeCallback=(e,t)=>{t.isLocal&&t.isUndoable&&t!==this._batch&&this._reset(!0)},this._selectionChangeCallback=()=>{this._reset()},this.model.document.on("change",this._changeCallback),this.model.document.selection.on("change:range",this._selectionChangeCallback),this.model.document.selection.on("change:attribute",this._selectionChangeCallback)}get batch(){return this._batch||(this._batch=this.model.createBatch({isTyping:!0})),this._batch}input(e){this.size+=e,this.size>=this.limit&&this._reset(!0)}lock(){this.isLocked=!0}unlock(){this.isLocked=!1}destroy(){this.model.document.off("change",this._changeCallback),this.model.document.selection.off("change:range",this._selectionChangeCallback),this.model.document.selection.off("change:attribute",this._selectionChangeCallback)}_reset(e){this.isLocked&&!e||(this._batch=null,this.size=0)}}class fp extends St{constructor(e,t){super(e),this.direction=t,this._buffer=new hp(e.model,e.config.get("typing.undoStep"))}get buffer(){return this._buffer}execute(e={}){const t=this.editor.model,n=t.document;t.enqueueChange(this._buffer.batch,(i=>{this._buffer.lock();const o=i.createSelection(e.selection||n.selection),r=e.sequence||1,s=o.isCollapsed;if(o.isCollapsed&&t.modifySelection(o,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(r))return void this._replaceEntireContentWithParagraph(i);if(this._shouldReplaceFirstBlockWithParagraph(o,r))return void this.editor.execute("paragraph",{selection:o});if(o.isCollapsed)return;let a=0;o.getFirstRange().getMinimalFlatRanges().forEach((e=>{a+=nr(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),t.deleteContent(o,{doNotResetEntireContent:s,direction:this.direction}),this._buffer.input(a),i.setSelection(o),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,n=t.document.selection,i=t.schema.getLimitElement(n);if(!(n.isCollapsed&&n.containsEntireContent(i)))return!1;if(!t.schema.checkChild(i,"paragraph"))return!1;const o=i.getChild(0);return!o||"paragraph"!==o.name}_replaceEntireContentWithParagraph(e){const t=this.editor.model,n=t.document.selection,i=t.schema.getLimitElement(n),o=e.createElement("paragraph");e.remove(e.createRangeIn(i)),e.insert(o,i),e.setSelection(o,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const n=this.editor.model;if(t>1||"backward"!=this.direction)return!1;if(!e.isCollapsed)return!1;const i=e.getFirstPosition(),o=n.schema.getLimitElement(i),r=o.getChild(0);return i.parent==r&&(!!e.containsEntireContent(r)&&(!!n.schema.checkChild(o,"paragraph")&&"paragraph"!=r.name))}}function pp(e){if(e.newChildren.length-e.oldChildren.length!=1)return;const t=function(e,t){const n=[];let i,o=0;return e.forEach((e=>{"equal"==e?(r(),o++):"insert"==e?(s("insert")?i.values.push(t[o]):(r(),i={type:"insert",index:o,values:[t[o]]}),o++):s("delete")?i.howMany++:(r(),i={type:"delete",index:o,howMany:1})})),r(),n;function r(){i&&(n.push(i),i=null)}function s(e){return i&&i.type==e}}(ss(e.oldChildren,e.newChildren,gp),e.newChildren);if(t.length>1)return;const n=t[0];return n.values[0]&&n.values[0].is("$text")?n:void 0}function gp(e,t){return e&&e.is("$text")&&t&&t.is("$text")?e.data===t.data:e===t}function mp(e,t){const n=t.selection,i=e.shiftKey&&e.keyCode===Er.delete,o=!n.isCollapsed;return i&&o}class bp extends js{constructor(e){super(e);const t=e.document;let n=0;function i(e,n,i){const o=new rr(t,"delete",t.selection.getFirstRange());t.fire(o,new oa(t,n,i)),o.stop.called&&e.stop()}t.on("keyup",((e,t)=>{t.keyCode!=Er.delete&&t.keyCode!=Er.backspace||(n=0)})),t.on("keydown",((e,o)=>{if(_r.isWindows&&mp(o,t))return;const r={};if(o.keyCode==Er.delete)r.direction="forward",r.unit="character";else{if(o.keyCode!=Er.backspace)return;r.direction="backward",r.unit="codePoint"}const s=_r.isMac?o.altKey:o.ctrlKey;r.unit=s?"word":r.unit,r.sequence=++n,i(e,o.domEvent,r)})),_r.isAndroid&&t.on("beforeinput",((t,n)=>{if("deleteContentBackward"!=n.domEvent.inputType)return;const o={unit:"codepoint",direction:"backward",sequence:1},r=n.domTarget.ownerDocument.defaultView.getSelection();r.anchorNode==r.focusNode&&r.anchorOffset+1!=r.focusOffset&&(o.selectionToRemove=e.domConverter.domSelectionToView(r)),i(t,n.domEvent,o)}))}observe(){}}class wp extends Ct{static get pluginName(){return"Delete"}init(){const e=this.editor,t=e.editing.view,n=t.document,i=e.model.document;t.addObserver(bp),this._undoOnBackspace=!1;const o=new fp(e,"forward");if(e.commands.add("deleteForward",o),e.commands.add("forwardDelete",o),e.commands.add("delete",new fp(e,"backward")),this.listenTo(n,"delete",((n,i)=>{const o={unit:i.unit,sequence:i.sequence};if(i.selectionToRemove){const t=e.model.createSelection(),n=[];for(const t of i.selectionToRemove.getRanges())n.push(e.editing.mapper.toModelRange(t));t.setTo(n),o.selection=t}e.execute("forward"==i.direction?"deleteForward":"delete",o),i.preventDefault(),t.scrollToTheSelection()}),{priority:"low"}),_r.isAndroid){let e=null;this.listenTo(n,"delete",((t,n)=>{const i=n.domTarget.ownerDocument.defaultView.getSelection();e={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}}),{priority:"lowest"}),this.listenTo(n,"keyup",((t,n)=>{if(e){const t=n.domTarget.ownerDocument.defaultView.getSelection();t.collapse(e.anchorNode,e.anchorOffset),t.extend(e.focusNode,e.focusOffset),e=null}}))}this.editor.plugins.has("UndoEditing")&&(this.listenTo(n,"delete",((t,n)=>{this._undoOnBackspace&&"backward"==n.direction&&1==n.sequence&&"codePoint"==n.unit&&(this._undoOnBackspace=!1,e.execute("undo"),n.preventDefault(),t.stop())}),{context:"$capture"}),this.listenTo(i,"change",(()=>{this._undoOnBackspace=!1})))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class kp{constructor(){this._stack=[]}add(e,t){const n=this._stack,i=n[0];this._insertDescriptor(e);const o=n[0];i===o||vp(i,o)||this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:t})}remove(e,t){const n=this._stack,i=n[0];this._removeDescriptor(e);const o=n[0];i===o||vp(i,o)||this.fire("change:top",{oldDescriptor:i,newDescriptor:o,writer:t})}_insertDescriptor(e){const t=this._stack,n=t.findIndex((t=>t.id===e.id));if(vp(e,t[n]))return;n>-1&&t.splice(n,1);let i=0;for(;t[i]&&_p(t[i],e);)i++;t.splice(i,0,e)}_removeDescriptor(e){const t=this._stack,n=t.findIndex((t=>t.id===e));n>-1&&t.splice(n,1)}}function vp(e,t){return e&&t&&e.priority==t.priority&&yp(e.classes)==yp(t.classes)}function _p(e,t){return e.priority>t.priority||!(e.priorityyp(t.classes)}function yp(e){return Array.isArray(e)?e.sort().join(","):e}Et(kp,O);const xp='',Ap="ck-widget_selected";function Ep(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function Cp(e,t,n={}){if(!e.is("containerElement"))throw new y("widget-to-widget-wrong-element-type",null,{element:e});return t.setAttribute("contenteditable","false",e),t.addClass("ck-widget",e),t.setCustomProperty("widget",!0,e),e.getFillerOffset=Rp,n.label&&function(e,t,n){n.setCustomProperty("widgetLabel",t,e)}(e,n.label,t),n.hasSelectionHandle&&function(e,t){const n=t.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(e){const t=this.toDomElement(e),n=new Cd;return n.set("content",xp),n.render(),t.appendChild(n.element),t}));t.insert(t.createPositionAt(e,0),n),t.addClass(["ck-widget_with-selection-handle"],e)}(e,t),Pp(e,t),e}function Tp(e,t,n){if(t.classes&&n.addClass(Ui(t.classes),e),t.attributes)for(const i in t.attributes)n.setAttribute(i,t.attributes[i],e)}function Sp(e,t,n){if(t.classes&&n.removeClass(Ui(t.classes),e),t.attributes)for(const i in t.attributes)n.removeAttribute(i,e)}function Pp(e,t,n=Tp,i=Sp){const o=new kp;o.on("change:top",((t,o)=>{o.oldDescriptor&&i(e,o.oldDescriptor,o.writer),o.newDescriptor&&n(e,o.newDescriptor,o.writer)})),t.setCustomProperty("addHighlight",((e,t,n)=>o.add(t,n)),e),t.setCustomProperty("removeHighlight",((e,t,n)=>o.remove(t,n)),e)}function Ip(e){const t=e.getCustomProperty("widgetLabel");return t?"function"==typeof t?t():t:""}function Op(e,t){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",((n,i,o)=>{t.setAttribute("contenteditable",o?"false":"true",e)})),e.on("change:isFocused",((n,i,o)=>{o?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)})),Pp(e,t),e}function Mp(e,t){const n=e.getSelectedElement();if(n){const i=Dp(e);if(i)return t.createRange(t.createPositionAt(n,i))}return wu(e,t)}function Rp(){return null}const Np="widget-type-around";function jp(e,t,n){return e&&Ep(e)&&!n.isInline(t)}function Dp(e){return e.getAttribute(Np)}const Lp=[Tr("arrowUp"),Tr("arrowRight"),Tr("arrowDown"),Tr("arrowLeft"),9,16,17,18,19,20,27,33,34,35,36,45,91,93,144,145,173,174,175,176,177,178,179,255];for(let e=112;e<=135;e++)Lp.push(e);function zp(e){return!(!e.ctrlKey&&!e.metaKey)||Lp.includes(e.keyCode)}var Vp=n(5485),Bp={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Vp.Z,Bp);Vp.Z.locals;const Fp=["before","after"],Hp=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,Up="ck-widget__type-around_disabled";class Wp extends Ct{static get pluginName(){return"WidgetTypeAround"}static get requires(){return[dp,wp]}constructor(e){super(e),this._currentFakeCaretModelElement=null}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",((n,i,o)=>{t.change((e=>{for(const n of t.document.roots)o?e.removeClass(Up,n):e.addClass(Up,n)})),o||e.model.change((e=>{e.removeSelectionAttribute(Np)}))})),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableInsertObjectIntegration(),this._enableDeleteContentIntegration()}destroy(){this._currentFakeCaretModelElement=null}_insertParagraph(e,t){const n=this.editor,i=n.editing.view,o=n.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);n.execute("insertParagraph",{position:n.model.createPositionAt(e,t),attributes:o}),i.focus(),i.scrollToTheSelection()}_listenToIfEnabled(e,t,n,i){this.listenTo(e,t,((...e)=>{this.isEnabled&&n(...e)}),i)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=Dp(e);if(!t)return!1;const n=e.getSelectedElement();return this._insertParagraph(n,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,n=e.locale.t,i={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",((e,n,o)=>{const r=o.mapper.toViewElement(n.item);jp(r,n.item,t)&&function(e,t,n){const i=e.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(e){const n=this.toDomElement(e);return function(e,t){for(const n of Fp){const i=new id({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${n}`],title:t[n]},children:[e.ownerDocument.importNode(Hp,!0)]});e.appendChild(i.render())}}(n,t),function(e){const t=new id({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(n),n}));e.insert(e.createPositionAt(n,"end"),i)}(o.writer,i,r)}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,n=t.document.selection,i=t.schema,o=e.editing.view;function r(e){return`ck-widget_type-around_show-fake-caret_${e}`}this._listenToIfEnabled(o.document,"arrowKey",((e,t)=>{this._handleArrowKeyPress(e,t)}),{context:[Ep,"$text"],priority:"high"}),this._listenToIfEnabled(n,"change:range",((t,n)=>{n.directChange&&e.model.change((e=>{e.removeSelectionAttribute(Np)}))})),this._listenToIfEnabled(t.document,"change:data",(()=>{const t=n.getSelectedElement();if(t){if(jp(e.editing.mapper.toViewElement(t),t,i))return}e.model.change((e=>{e.removeSelectionAttribute(Np)}))})),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",((e,t,n)=>{const o=n.writer;if(this._currentFakeCaretModelElement){const e=n.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(o.removeClass(Fp.map(r),e),this._currentFakeCaretModelElement=null)}const s=t.selection.getSelectedElement();if(!s)return;const a=n.mapper.toViewElement(s);if(!jp(a,s,i))return;const c=Dp(t.selection);c&&(o.addClass(r(c),a),this._currentFakeCaretModelElement=s)})),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",((t,n,i)=>{i||e.model.change((e=>{e.removeSelectionAttribute(Np)}))}))}_handleArrowKeyPress(e,t){const n=this.editor,i=n.model,o=i.document.selection,r=i.schema,s=n.editing.view,a=function(e,t){const n=Ir(e,t);return"down"===n||"right"===n}(t.keyCode,n.locale.contentLanguageDirection),c=s.document.selection.getSelectedElement();let l;jp(c,n.editing.mapper.toModelElement(c),r)?l=this._handleArrowKeyPressOnSelectedWidget(a):o.isCollapsed?l=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):t.shiftKey||(l=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),l&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,n=Dp(t.document.selection);return t.change((t=>{if(!n)return t.setSelectionAttribute(Np,e?"after":"before"),!0;if(!(n===(e?"after":"before")))return t.removeSelectionAttribute(Np),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,n=t.model,i=n.schema,o=t.plugins.get("Widget"),r=o._getObjectElementNextToSelection(e);return!!jp(t.editing.mapper.toViewElement(r),r,i)&&(n.change((t=>{o._setSelectionOverElement(r),t.setSelectionAttribute(Np,e?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,n=t.model,i=n.schema,o=t.editing.mapper,r=n.document.selection,s=e?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter;return!!jp(o.toViewElement(s),s,i)&&(n.change((t=>{t.setSelection(s,"on"),t.setSelectionAttribute(Np,e?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",((n,i)=>{const o=i.domTarget.closest(".ck-widget__type-around__button");if(!o)return;const r=function(e){return e.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(o),s=function(e,t){const n=e.closest(".ck-widget");return t.mapDomToView(n)}(o,t.domConverter),a=e.editing.mapper.toModelElement(s);this._insertParagraph(a,r),i.preventDefault(),n.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,n=e.editing.view;this._listenToIfEnabled(n.document,"enter",((n,i)=>{if("atTarget"!=n.eventPhase)return;const o=t.getSelectedElement(),r=e.editing.mapper.toViewElement(o),s=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:jp(r,o,s)&&(this._insertParagraph(o,i.isSoft?"before":"after"),a=!0),a&&(i.preventDefault(),n.stop())}),{context:Ep})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view,t=[Er.enter,Er.delete,Er.backspace];this._listenToIfEnabled(e.document,"keydown",((e,n)=>{t.includes(n.keyCode)||zp(n)||this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,n=e.model,i=n.schema;this._listenToIfEnabled(t.document,"delete",((t,o)=>{if("atTarget"!=t.eventPhase)return;const r=Dp(n.document.selection);if(!r)return;const s=o.direction,a=n.document.selection.getSelectedElement(),c="forward"==s;if("before"===r===c)e.execute("delete",{selection:n.createSelection(a,"on")});else{const t=i.getNearestSelectionRange(n.createPositionAt(a,r),s);if(t)if(t.isCollapsed){const o=n.createSelection(t.start);if(n.modifySelection(o,{direction:s}),o.focus.isEqual(t.start)){const e=function(e,t){let n=t;for(const i of t.getAncestors({parentFirst:!0})){if(i.childCount>1||e.isLimit(i))break;n=i}return n}(i,t.start.parent);n.deleteContent(n.createSelection(e,"on"),{doNotAutoparagraph:!0})}else n.change((n=>{n.setSelection(t),e.execute(c?"deleteForward":"delete")}))}else n.change((n=>{n.setSelection(t),e.execute(c?"deleteForward":"delete")}))}o.preventDefault(),t.stop()}),{context:Ep})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,n=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",((e,[i,o])=>{if(o&&!o.is("documentSelection"))return;const r=Dp(n);return r?(e.stop(),t.change((e=>{const o=n.getSelectedElement(),s=t.createPositionAt(o,r),a=e.createSelection(s),c=t.insertContent(i,a);return e.setSelection(a),c}))):void 0}),{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",((e,n)=>{const[,i,,o={}]=n;if(i&&!i.is("documentSelection"))return;const r=Dp(t);r&&(o.findOptimalPosition=r,n[3]=o)}),{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",((e,[n])=>{if(n&&!n.is("documentSelection"))return;Dp(t)&&e.stop()}),{priority:"high"})}}function qp(e){const t=e.model;return(n,i)=>{const o=i.keyCode==Er.arrowup,r=i.keyCode==Er.arrowdown,s=i.shiftKey,a=t.document.selection;if(!o&&!r)return;const c=r;if(s&&function(e,t){return!e.isCollapsed&&e.isBackward==t}(a,c))return;const l=function(e,t,n){const i=e.model;if(n){const e=t.isCollapsed?t.focus:t.getLastPosition(),n=$p(i,e,"forward");if(!n)return null;const o=i.createRange(e,n),r=Zp(i.schema,o,"backward");return r?i.createRange(e,r):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),n=$p(i,e,"backward");if(!n)return null;const o=i.createRange(n,e),r=Zp(i.schema,o,"forward");return r?i.createRange(r,e):null}}(e,a,c);if(l){if(l.isCollapsed){if(a.isCollapsed)return;if(s)return}(l.isCollapsed||function(e,t,n){const i=e.model,o=e.view.domConverter;if(n){const e=i.createSelection(t.start);i.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=i.createRange(e.focus,t.end))}const r=e.mapper.toViewRange(t),s=o.viewRangeToDom(r),a=Oa.getDomRangeRects(s);let c;for(const e of a)if(void 0!==c){if(Math.round(e.top)>=c)return!1;c=Math.max(c,Math.round(e.bottom))}else c=Math.round(e.bottom);return!0}(e,l,c))&&(t.change((e=>{const n=c?l.end:l.start;if(s){const i=t.createSelection(a.anchor);i.setFocus(n),e.setSelection(i)}else e.setSelection(n)})),n.stop(),i.preventDefault(),i.stopPropagation())}}}function $p(e,t,n){const i=e.schema,o=e.createRangeIn(t.root),r="forward"==n?"elementStart":"elementEnd";for(const{previousPosition:e,item:s,type:a}of o.getWalker({startPosition:t,direction:n})){if(i.isLimit(s)&&!i.isInline(s))return e;if(a==r&&i.isBlock(s))return null}return null}function Zp(e,t,n){const i="backward"==n?t.end:t.start;if(e.checkChild(i,"$text"))return i;for(const{nextPosition:i}of t.getWalker({direction:n}))if(e.checkChild(i,"$text"))return i;return null}var Kp=n(1014),Gp={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Kp.Z,Gp);Kp.Z.locals;class Yp extends Ct{static get pluginName(){return"Widget"}static get requires(){return[Wp,wp]}init(){const e=this.editor,t=e.editing.view,n=t.document;this._previouslySelected=new Set,this.editor.editing.downcastDispatcher.on("selection",((t,n,i)=>{const o=i.writer,r=n.selection;if(r.isCollapsed)return;const s=r.getSelectedElement();if(!s)return;const a=e.editing.mapper.toViewElement(s);Ep(a)&&i.consumable.consume(r,"selection")&&o.setSelection(o.createRangeOn(a),{fake:!0,label:Ip(a)})})),this.editor.editing.downcastDispatcher.on("selection",((e,t,n)=>{this._clearPreviouslySelectedWidgets(n.writer);const i=n.writer,o=i.document.selection;let r=null;for(const e of o.getRanges())for(const t of e){const e=t.item;Ep(e)&&!Qp(e,r)&&(i.addClass(Ap,e),this._previouslySelected.add(e),r=e)}}),{priority:"low"}),t.addObserver(Mf),this.listenTo(n,"mousedown",((...e)=>this._onMousedown(...e))),this.listenTo(n,"arrowKey",((...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)}),{context:[Ep,"$text"]}),this.listenTo(n,"arrowKey",((...e)=>{this._preventDefaultOnArrowKeyPress(...e)}),{context:"$root"}),this.listenTo(n,"arrowKey",qp(this.editor.editing),{context:"$text"}),this.listenTo(n,"delete",((e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())}),{context:"$root"})}_onMousedown(e,t){const n=this.editor,i=n.editing.view,o=i.document;let r=t.target;if(function(e){for(;e;){if(e.is("editableElement")&&!e.is("rootElement"))return!0;if(Ep(e))return!1;e=e.parent}return!1}(r)){if((_r.isSafari||_r.isGecko)&&t.domEvent.detail>=3){const e=n.editing.mapper,i=r.is("attributeElement")?r.findAncestor((e=>!e.is("attributeElement"))):r,o=e.toModelElement(i);t.preventDefault(),this.editor.model.change((e=>{e.setSelection(o,"in")}))}return}if(!Ep(r)&&(r=r.findAncestor(Ep),!r))return;_r.isAndroid&&t.preventDefault(),o.isFocused||i.focus();const s=n.editing.mapper.toModelElement(r);this._setSelectionOverElement(s)}_handleSelectionChangeOnArrowKeyPress(e,t){const n=t.keyCode,i=this.editor.model,o=i.schema,r=i.document.selection,s=r.getSelectedElement(),a=Ir(n,this.editor.locale.contentLanguageDirection),c="down"==a||"right"==a,l="up"==a||"down"==a;if(s&&o.isObject(s)){const n=c?r.getLastPosition():r.getFirstPosition(),s=o.getNearestSelectionRange(n,c?"forward":"backward");return void(s&&(i.change((e=>{e.setSelection(s)})),t.preventDefault(),e.stop()))}if(!r.isCollapsed&&!t.shiftKey){const n=r.getFirstPosition(),s=r.getLastPosition(),a=n.nodeAfter,l=s.nodeBefore;return void((a&&o.isObject(a)||l&&o.isObject(l))&&(i.change((e=>{e.setSelection(c?s:n)})),t.preventDefault(),e.stop()))}if(!r.isCollapsed)return;const u=this._getObjectElementNextToSelection(c);if(u&&o.isObject(u)){if(o.isInline(u)&&l)return;this._setSelectionOverElement(u),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const n=this.editor.model,i=n.schema,o=n.document.selection.getSelectedElement();o&&i.isObject(o)&&(t.preventDefault(),e.stop())}_handleDelete(e){if(this.editor.isReadOnly)return;const t=this.editor.model.document.selection;if(!t.isCollapsed)return;const n=this._getObjectElementNextToSelection(e);return n?(this.editor.model.change((e=>{let i=t.anchor.parent;for(;i.isEmpty;){const t=i;i=t.parent,e.remove(t)}this._setSelectionOverElement(n)})),!0):void 0}_setSelectionOverElement(e){this.editor.model.change((t=>{t.setSelection(t.createRangeOn(e))}))}_getObjectElementNextToSelection(e){const t=this.editor.model,n=t.schema,i=t.document.selection,o=t.createSelection(i);if(t.modifySelection(o,{direction:e?"forward":"backward"}),o.isEqual(i))return null;const r=e?o.focus.nodeBefore:o.focus.nodeAfter;return r&&n.isObject(r)?r:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(Ap,t);this._previouslySelected.clear()}}function Qp(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}class Jp extends Ct{static get requires(){return[nf]}static get pluginName(){return"WidgetToolbarRepository"}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",(t=>{(function(e){const t=e.getSelectedElement();return!(!t||!Ep(t))})(e.editing.view.document.selection)&&t.stop()}),{priority:"high"})}this._toolbarDefinitions=new Map,this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui,"update",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const e of this._toolbarDefinitions.values())e.view.destroy()}register(e,{ariaLabel:t,items:n,getRelatedElement:i,balloonClassName:o="ck-toolbar-container"}){if(!n.length)return void x("widget-toolbar-no-items",{toolbarId:e});const r=this.editor,s=r.t,a=new ah(r.locale);if(a.ariaLabel=t||s("Widget toolbar"),this._toolbarDefinitions.has(e))throw new y("widget-toolbar-duplicated",this,{toolbarId:e});a.fillFromConfig(n,r.ui.componentFactory),this._toolbarDefinitions.set(e,{view:a,getRelatedElement:i,balloonClassName:o})}_updateToolbarsVisibility(){let e=0,t=null,n=null;for(const i of this._toolbarDefinitions.values()){const o=i.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&o)if(this.editor.ui.focusTracker.isFocused){const r=o.getAncestors().length;r>e&&(e=r,t=o,n=i)}else this._isToolbarVisible(i)&&this._hideToolbar(i);else this._isToolbarInBalloon(i)&&this._hideToolbar(i)}n&&this._showToolbar(n,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?Xp(this.editor,t):this._isToolbarInBalloon(e)||(this._balloon.add({view:e.view,position:eg(this.editor,t),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",(()=>{for(const e of this._toolbarDefinitions.values())if(this._isToolbarVisible(e)){const t=e.getRelatedElement(this.editor.editing.view.document.selection);Xp(this.editor,t)}})))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function Xp(e,t){const n=e.plugins.get("ContextualBalloon"),i=eg(e,t);n.updatePosition(i)}function eg(e,t){const n=e.editing.view,i=Gh.defaultPositions;return{target:n.domConverter.mapViewToDom(t),positions:[i.northArrowSouth,i.northArrowSouthWest,i.northArrowSouthEast,i.southArrowNorth,i.southArrowNorthWest,i.southArrowNorthEast,i.viewportStickyNorth]}}class tg{constructor(e){this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=e,this._referenceCoordinates=null}begin(e,t,n){const i=new Oa(t);this.activeHandlePosition=function(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const n of t)if(e.classList.contains(ng(n)))return n}(e),this._referenceCoordinates=function(e,t){const n=new Oa(e),i=t.split("-"),o={x:"right"==i[1]?n.right:n.left,y:"bottom"==i[0]?n.bottom:n.top};return o.x+=e.ownerDocument.defaultView.scrollX,o.y+=e.ownerDocument.defaultView.scrollY,o}(t,function(e){const t=e.split("-"),n={top:"bottom",bottom:"top",left:"right",right:"left"};return`${n[t[0]]}-${n[t[1]]}`}(this.activeHandlePosition)),this.originalWidth=i.width,this.originalHeight=i.height,this.aspectRatio=i.width/i.height;const o=n.style.width;o&&o.match(/^\d+(\.\d*)?%$/)?this.originalWidthPercents=parseFloat(o):this.originalWidthPercents=function(e,t){const n=e.parentElement,i=parseFloat(n.ownerDocument.defaultView.getComputedStyle(n).width);return t.width/i*100}(n,i)}update(e){this.proposedWidth=e.width,this.proposedHeight=e.height,this.proposedWidthPercents=e.widthPercents,this.proposedHandleHostWidth=e.handleHostWidth,this.proposedHandleHostHeight=e.handleHostHeight}}function ng(e){return`ck-widget__resizer__handle-${e}`}Et(tg,kt);class ig extends nd{constructor(){super();const e=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",e.to("_viewPosition",(e=>e?`ck-orientation-${e}`:""))],style:{display:e.if("_isVisible","none",(e=>!e))}},children:[{text:e.to("_label")}]})}_bindToState(e,t){this.bind("_isVisible").to(t,"proposedWidth",t,"proposedHeight",((e,t)=>null!==e&&null!==t)),this.bind("_label").to(t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",t,"proposedWidthPercents",((t,n,i)=>"px"===e.unit?`${t}×${n}`:`${i}%`)),this.bind("_viewPosition").to(t,"activeHandlePosition",t,"proposedHandleHostWidth",t,"proposedHandleHostHeight",((e,t,n)=>t<50||n<50?"above-center":e))}_dismiss(){this.unbind(),this._isVisible=!1}}class og{constructor(e){this._options=e,this._viewResizerWrapper=null,this.set("isEnabled",!0),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",(e=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),e.stop())}),{priority:"high"}),this.on("change:isEnabled",(()=>{this.isEnabled&&this.redraw()}))}attach(){const e=this,t=this._options.viewElement;this._options.editor.editing.view.change((n=>{const i=n.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(t){const n=this.toDomElement(t);return e._appendHandles(n),e._appendSizeUI(n),e.on("change:isEnabled",((e,t,i)=>{n.style.display=i?"":"none"})),n.style.display=e.isEnabled?"":"none",n}));n.insert(n.createPositionAt(t,"end"),i),n.addClass("ck-widget_with-resizer",t),this._viewResizerWrapper=i}))}begin(e){this.state=new tg(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(e,this._getHandleHost(),this._getResizeHost())}updateSize(e){const t=this._proposeNewSize(e);this._options.editor.editing.view.change((e=>{const n=this._options.unit||"%",i=("%"===n?t.widthPercents:t.width)+n;e.setStyle("width",i,this._options.viewElement)}));const n=this._getHandleHost(),i=new Oa(n);t.handleHostWidth=Math.round(i.width),t.handleHostHeight=Math.round(i.height);const o=new Oa(n);t.width=Math.round(o.width),t.height=Math.round(o.height),this.redraw(i),this.state.update(t)}commit(){const e=this._options.unit||"%",t=("%"===e?this.state.proposedWidthPercents:this.state.proposedWidth)+e;this._options.editor.editing.view.change((()=>{this._cleanup(),this._options.onCommit(t)}))}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(e){const t=this._domResizerWrapper;if(!((n=t)&&n.ownerDocument&&n.ownerDocument.contains(n)))return;var n;const i=t.parentElement,o=this._getHandleHost(),r=this._viewResizerWrapper,s=[r.getStyle("width"),r.getStyle("height"),r.getStyle("left"),r.getStyle("top")];let a;if(i.isSameNode(o)){const t=e||new Oa(o);a=[t.width+"px",t.height+"px",void 0,void 0]}else a=[o.offsetWidth+"px",o.offsetHeight+"px",o.offsetLeft+"px",o.offsetTop+"px"];"same"!==Yi(s,a)&&this._options.editor.editing.view.change((e=>{e.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},r)}))}containsHandle(e){return this._domResizerWrapper.contains(e)}static isResizeHandle(e){return e.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss();this._options.editor.editing.view.change((e=>{e.setStyle("width",this._initialViewWidth,this._options.viewElement)}))}_proposeNewSize(e){const t=this.state,n={x:(i=e).pageX,y:i.pageY};var i;const o=!this._options.isCentered||this._options.isCentered(this),r={x:t._referenceCoordinates.x-(n.x+t.originalWidth),y:n.y-t.originalHeight-t._referenceCoordinates.y};o&&t.activeHandlePosition.endsWith("-right")&&(r.x=n.x-(t._referenceCoordinates.x+t.originalWidth)),o&&(r.x*=2);const s={width:Math.abs(t.originalWidth+r.x),height:Math.abs(t.originalHeight+r.y)};s.dominant=s.width/t.aspectRatio>s.height?"width":"height",s.max=s[s.dominant];const a={width:s.width,height:s.height};return"width"==s.dominant?a.height=a.width/t.aspectRatio:a.width=a.height*t.aspectRatio,{width:Math.round(a.width),height:Math.round(a.height),widthPercents:Math.min(Math.round(t.originalWidthPercents/t.originalWidth*a.width*100)/100,100)}}_getResizeHost(){const e=this._domResizerWrapper.parentElement;return this._options.getResizeHost(e)}_getHandleHost(){const e=this._domResizerWrapper.parentElement;return this._options.getHandleHost(e)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(e){const t=["top-left","top-right","bottom-right","bottom-left"];for(const i of t)e.appendChild(new id({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(n=i,`ck-widget__resizer__handle-${n}`)}}).render());var n}_appendSizeUI(e){this._sizeView=new ig,this._sizeView.render(),e.appendChild(this._sizeView.element)}}Et(og,kt);const rg=function(e,t,n){var i=!0,o=!0;if("function"!=typeof e)throw new TypeError("Expected a function");return V(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),ka(e,t,{leading:i,maxWait:t,trailing:o})};var sg=n(6036),ag={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(sg.Z,ag);sg.Z.locals;Et(class extends Ct{static get pluginName(){return"WidgetResize"}init(){const e=this.editor.editing,t=bs.window.document;this.set("visibleResizer",null),this.set("_activeResizer",null),this._resizers=new Map,e.view.addObserver(Mf),this._observer=Object.create(Ms),this.listenTo(e.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(t,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(t,"mouseup",this._mouseUpListener.bind(this));const n=()=>{this.visibleResizer&&this.visibleResizer.redraw()};this._redrawFocusedResizerThrottled=rg(n,200),this.on("change:visibleResizer",n),this.editor.ui.on("update",this._redrawFocusedResizerThrottled),this.editor.model.document.on("change",(()=>{for(const[e,t]of this._resizers)e.isAttached()||(this._resizers.delete(e),t.destroy())}),{priority:"lowest"}),this._observer.listenTo(bs.window,"resize",this._redrawFocusedResizerThrottled);const i=this.editor.editing.view.document.selection;i.on("change",(()=>{const e=i.getSelectedElement();this.visibleResizer=this.getResizerByViewElement(e)||null}))}destroy(){this._observer.stopListening();for(const e of this._resizers.values())e.destroy();this._redrawFocusedResizerThrottled.cancel()}attachTo(e){const t=new og(e),n=this.editor.plugins;if(t.attach(),n.has("WidgetToolbarRepository")){const e=n.get("WidgetToolbarRepository");t.on("begin",(()=>{e.forceDisabled("resize")}),{priority:"lowest"}),t.on("cancel",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"}),t.on("commit",(()=>{e.clearForceDisabled("resize")}),{priority:"highest"})}this._resizers.set(e.viewElement,t);const i=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(i)==t&&(this.visibleResizer=t),t}getResizerByViewElement(e){return this._resizers.get(e)}_getResizerByHandle(e){for(const t of this._resizers.values())if(t.containsHandle(e))return t}_mouseDownListener(e,t){const n=t.domTarget;og.isResizeHandle(n)&&(this._activeResizer=this._getResizerByHandle(n),this._activeResizer&&(this._activeResizer.begin(n),e.stop(),t.preventDefault()))}_mouseMoveListener(e,t){this._activeResizer&&this._activeResizer.updateSize(t)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}},kt);class cg extends St{refresh(){const e=this.editor.model,t=e.schema,n=e.document.selection;this.isEnabled=function(e,t,n){const i=function(e,t){const n=Mp(e,t).start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(e,n);return t.checkChild(i,"horizontalLine")}(n,t,e)}execute(){const e=this.editor.model;e.change((t=>{const n=t.createElement("horizontalLine");e.insertObject(n,null,null,{setSelection:"after"})}))}}var lg=n(4383),ug={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(lg.Z,ug);lg.Z.locals;class dg extends Ct{static get pluginName(){return"HorizontalLineEditing"}init(){const e=this.editor,t=e.model.schema,n=e.t,i=e.conversion;t.register("horizontalLine",{inheritAllFrom:"$blockObject"}),i.for("dataDowncast").elementToElement({model:"horizontalLine",view:(e,{writer:t})=>t.createEmptyElement("hr")}),i.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(e,{writer:t})=>{const i=n("Horizontal line"),o=t.createContainerElement("div",null,t.createEmptyElement("hr"));return t.addClass("ck-horizontal-line",o),t.setCustomProperty("hr",!0,o),function(e,t,n){return t.setCustomProperty("horizontalLine",!0,e),Cp(e,t,{label:n})}(o,t,i)}}),i.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),e.commands.add("horizontalLine",new cg(e))}}class hg extends Ct{static get pluginName(){return"HorizontalLineUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("horizontalLine",(n=>{const i=e.commands.get("horizontalLine"),o=new Md(n);return o.set({label:t("Horizontal line"),icon:'',tooltip:!0}),o.bind("isEnabled").to(i,"isEnabled"),this.listenTo(o,"execute",(()=>{e.execute("horizontalLine"),e.editing.view.focus()})),o}))}}class fg extends Ct{static get requires(){return[dg,hg,Yp]}static get pluginName(){return"HorizontalLine"}}function pg(e){const t=e.getSelectedElement();return t&&mg(t)?t:null}function gg(e){let t=e.getFirstPosition().parent;for(;t;){if(t.is("element")&&mg(t))return t;t=t.parent}return null}function mg(e){return!!e.getCustomProperty("table")&&Ep(e)}class bg extends Ct{static get requires(){return[Jp]}static get pluginName(){return"TableToolbar"}afterInit(){const e=this.editor,t=e.t,n=e.plugins.get(Jp),i=e.config.get("table.contentToolbar"),o=e.config.get("table.tableToolbar");i&&n.register("tableContent",{ariaLabel:t("Table toolbar"),items:i,getRelatedElement:gg}),o&&n.register("table",{ariaLabel:t("Table toolbar"),items:o,getRelatedElement:pg})}}function wg(e,t,n,i,o=1){t>o?i.setAttribute(e,t,n):i.removeAttribute(e,n)}function kg(e,t,n={}){const i=e.createElement("tableCell",n);return e.insertElement("paragraph",i),e.insert(i,t),i}function vg(e,t){const n=t.parent.parent,i=parseInt(n.getAttribute("headingColumns")||0),{column:o}=e.getCellLocation(t);return!!i&&o{e.on("element:table",((e,t,n)=>{const i=t.viewItem;if(!n.consumable.test(i,{name:!0}))return;const{rows:o,headingRows:r,headingColumns:s}=function(e){const t={headingRows:0,headingColumns:0},n=[],i=[];let o;for(const r of Array.from(e.getChildren()))if("tbody"===r.name||"thead"===r.name||"tfoot"===r.name){"thead"!==r.name||o||(o=r);const e=Array.from(r.getChildren()).filter((e=>e.is("element","tr")));for(const r of e)if("thead"===r.parent.name&&r.parent===o)t.headingRows++,n.push(r);else{i.push(r);const e=xg(r);e>t.headingColumns&&(t.headingColumns=e)}}return t.rows=[...n,...i],t}(i),a={};s&&(a.headingColumns=s),r&&(a.headingRows=r);const c=n.writer.createElement("table",a);if(n.safeInsert(c,t.modelCursor)){if(n.consumable.consume(i,{name:!0}),o.forEach((e=>n.convertItem(e,n.writer.createPositionAt(c,"end")))),n.convertChildren(i,n.writer.createPositionAt(c,"end")),c.isEmpty){const e=n.writer.createElement("tableRow");n.writer.insert(e,n.writer.createPositionAt(c,"end")),kg(n.writer,n.writer.createPositionAt(e,"end"))}n.updateConversionResult(c,t)}}))}}function yg(e){return t=>{t.on(`element:${e}`,((e,t,n)=>{if(t.modelRange&&t.viewItem.isEmpty){const e=t.modelRange.start.nodeAfter,i=n.writer.createPositionAt(e,0);n.writer.insertElement("paragraph",i)}}),{priority:"low"})}}function xg(e){let t=0,n=0;const i=Array.from(e.getChildren()).filter((e=>"th"===e.name||"td"===e.name));for(;n1||o>1)&&this._recordSpans(n,o,i),this._shouldSkipSlot()||(t=this._formatOutValue(n)),this._nextCellAtColumn=this._column+i}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,t||this.next()}skipRow(e){this._skipRows.add(e)}_advanceToNextRow(){return this._row++,this._rowIndex++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return void 0!==this._endRow&&this._row>this._endRow}_isOverEndColumn(){return void 0!==this._endColumn&&this._column>this._endColumn}_formatOutValue(e,t=this._row,n=this._column){return{done:!1,value:new Eg(this,e,t,n)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._rowthis._endColumn;return e||t||n||i}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,n){const i={cell:e,row:this._row,column:this._column};for(let e=this._row;e{const o=n.getAttribute("headingRows")||0,r=[];o>0&&r.push(i.createContainerElement("thead",null,i.createSlot((e=>e.is("element","tableRow")&&e.indexe.is("element","tableRow")&&e.index>=o))));const s=i.createContainerElement("figure",{class:"table"},[i.createContainerElement("table",null,r),i.createSlot((e=>!e.is("element","tableRow")))]);return t.asWidget?function(e,t){return t.setCustomProperty("table",!0,e),Cp(e,t,{hasSelectionHandle:!0})}(s,i):s}}function Tg(e={}){return(t,{writer:n})=>{const i=t.parent,o=i.parent,r=o.getChildIndex(i),s=new Ag(o,{row:r}),a=o.getAttribute("headingRows")||0,c=o.getAttribute("headingColumns")||0;for(const i of s)if(i.cell==t){const t=i.row{if(t.parent.is("element","tableCell")&&Pg(t))return e.asWidget?n.createContainerElement("span",{class:"ck-table-bogus-paragraph"}):(i.consume(t,"insert"),void o.bindElements(t,o.toViewElement(t.parent)))}}function Pg(e){return 1==e.parent.childCount&&![...e.getAttributeKeys()].length}class Ig extends St{refresh(){const e=this.editor.model,t=e.document.selection,n=e.schema;this.isEnabled=function(e,t){const n=e.getFirstPosition().parent,i=n===n.root?n:n.parent;return t.checkChild(i,"table")}(t,n)}execute(e={}){const t=this.editor.model,n=this.editor.plugins.get("TableUtils"),i=this.editor.config.get("table"),o=i.defaultHeadings.rows,r=i.defaultHeadings.columns;void 0===e.headingRows&&o&&(e.headingRows=o),void 0===e.headingColumns&&r&&(e.headingColumns=r),t.change((i=>{const o=n.createTable(i,e);t.insertObject(o,null,null,{findOptimalPosition:"auto"}),i.setSelection(i.createPositionAt(o.getNodeByPath([0,0,0]),0))}))}}class Og extends St{constructor(e,t={}){super(e),this.order=t.order||"below"}refresh(){const e=this.editor.model.document.selection,t=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=t}execute(){const e=this.editor,t=e.model.document.selection,n=e.plugins.get("TableUtils"),i="above"===this.order,o=n.getSelectionAffectedTableCells(t),r=n.getRowIndexes(o),s=i?r.first:r.last,a=o[0].findAncestor("table");n.insertRows(a,{at:i?s:s+1,copyStructureFromAbove:!i})}}class Mg extends St{constructor(e,t={}){super(e),this.order=t.order||"right"}refresh(){const e=this.editor.model.document.selection,t=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=t}execute(){const e=this.editor,t=e.model.document.selection,n=e.plugins.get("TableUtils"),i="left"===this.order,o=n.getSelectionAffectedTableCells(t),r=n.getColumnIndexes(o),s=i?r.first:r.last,a=o[0].findAncestor("table");n.insertColumns(a,{columns:1,at:i?s:s+1})}}class Rg extends St{constructor(e,t={}){super(e),this.direction=t.direction||"horizontally"}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=1===e.length}execute(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];"horizontally"===this.direction?e.splitCellHorizontally(t,2):e.splitCellVertically(t,2)}}function Ng(e,t,n){const{startRow:i,startColumn:o,endRow:r,endColumn:s}=t,a=n.createElement("table"),c=r-i+1;for(let e=0;e0){wg("headingRows",r-n,e,o,0)}const s=parseInt(t.getAttribute("headingColumns")||0);if(s>0){wg("headingColumns",s-i,e,o,0)}}(a,e,i,o,n),a}function jg(e,t,n=0){const i=[],o=new Ag(e,{startRow:n,endRow:t-1});for(const e of o){const{row:n,cellHeight:o}=e,r=n+o-1;n1&&(a.rowspan=c);const l=parseInt(e.getAttribute("colspan")||1);l>1&&(a.colspan=l);const u=r+s,d=[...new Ag(o,{startRow:r,endRow:u,includeAllSlots:!0})];let h,f=null;for(const t of d){const{row:i,column:o,cell:r}=t;r===e&&void 0===h&&(h=o),void 0!==h&&h===o&&i===u&&(f=kg(n,t.getPositionBefore(),a))}return wg("rowspan",s,e,n),f}function Lg(e,t){const n=[],i=new Ag(e);for(const e of i){const{column:i,cellWidth:o}=e,r=i+o-1;i1&&(r.colspan=s);const a=parseInt(e.getAttribute("rowspan")||1);a>1&&(r.rowspan=a);const c=kg(i,i.createPositionAfter(e),r);return wg("colspan",o,e,i),c}function Vg(e,t,n,i,o,r){const s=parseInt(e.getAttribute("colspan")||1),a=parseInt(e.getAttribute("rowspan")||1);if(n+s-1>o){wg("colspan",o-n+1,e,r,1)}if(t+a-1>i){wg("rowspan",i-t+1,e,r,1)}}function Bg(e,t){const n=t.getColumns(e),i=new Array(n).fill(0);for(const{column:t}of new Ag(e))i[t]++;const o=i.reduce(((e,t,n)=>t?e:[...e,n]),[]);if(o.length>0){const n=o[o.length-1];return t.removeColumns(e,{at:n}),!0}return!1}function Fg(e,t){const n=[],i=t.getRows(e);for(let t=0;t0){const i=n[n.length-1];return t.removeRows(e,{at:i}),!0}return!1}function Hg(e,t){Bg(e,t)||Fg(e,t)}function Ug(e,t){const n=Array.from(new Ag(e,{startColumn:t.firstColumn,endColumn:t.lastColumn,row:t.lastRow}));if(n.every((({cellHeight:e})=>1===e)))return t.lastRow;const i=n[0].cellHeight-1;return t.lastRow+i}function Wg(e,t){const n=Array.from(new Ag(e,{startRow:t.firstRow,endRow:t.lastRow,column:t.lastColumn}));if(n.every((({cellWidth:e})=>1===e)))return t.lastColumn;const i=n[0].cellWidth-1;return t.lastColumn+i}class qg extends St{constructor(e,t){super(e),this.direction=t.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}refresh(){const e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){const e=this.editor.model,t=e.document,n=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(t.selection)[0],i=this.value,o=this.direction;e.change((e=>{const t="right"==o||"down"==o,r=t?n:i,s=t?i:n,a=s.parent;!function(e,t,n){$g(e)||($g(t)&&n.remove(n.createRangeIn(t)),n.move(n.createRangeIn(e),n.createPositionAt(t,"end")));n.remove(e)}(s,r,e);const c=this.isHorizontal?"colspan":"rowspan",l=parseInt(n.getAttribute(c)||1),u=parseInt(i.getAttribute(c)||1);e.setAttribute(c,l+u,r),e.setSelection(e.createRangeIn(r));const d=this.editor.plugins.get("TableUtils");Hg(a.findAncestor("table"),d)}))}_getMergeableCell(){const e=this.editor.model.document,t=this.editor.plugins.get("TableUtils"),n=t.getTableCellsContainingSelection(e.selection)[0];if(!n)return;const i=this.isHorizontal?function(e,t,n){const i=e.parent.parent,o="right"==t?e.nextSibling:e.previousSibling,r=(i.getAttribute("headingColumns")||0)>0;if(!o)return;const s="right"==t?e:o,a="right"==t?o:e,{column:c}=n.getCellLocation(s),{column:l}=n.getCellLocation(a),u=parseInt(s.getAttribute("colspan")||1),d=vg(n,s),h=vg(n,a);if(r&&d!=h)return;return c+u===l?o:void 0}(n,this.direction,t):function(e,t,n){const i=e.parent,o=i.parent,r=o.getChildIndex(i);if("down"==t&&r===n.getRows(o)-1||"up"==t&&0===r)return;const s=parseInt(e.getAttribute("rowspan")||1),a=o.getAttribute("headingRows")||0,c="down"==t&&r+s===a,l="up"==t&&r===a;if(a&&(c||l))return;const u=parseInt(e.getAttribute("rowspan")||1),d="down"==t?r+u:r,h=[...new Ag(o,{endRow:d})],f=h.find((t=>t.cell===e)).column,p=h.find((({row:e,cellHeight:n,column:i})=>i===f&&("down"==t?e===d:d===e+n)));return p&&p.cell}(n,this.direction,t);if(!i)return;const o=this.isHorizontal?"rowspan":"colspan",r=parseInt(n.getAttribute(o)||1);return parseInt(i.getAttribute(o)||1)===r?i:void 0}}function $g(e){return 1==e.childCount&&e.getChild(0).is("element","paragraph")&&e.getChild(0).isEmpty}class Zg extends St{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),n=t[0];if(n){const i=n.findAncestor("table"),o=this.editor.plugins.get("TableUtils").getRows(i)-1,r=e.getRowIndexes(t),s=0===r.first&&r.last===o;this.isEnabled=!s}else this.isEnabled=!1}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),n=t.getSelectionAffectedTableCells(e.document.selection),i=t.getRowIndexes(n),o=n[0],r=o.findAncestor("table"),s=t.getCellLocation(o).column;e.change((e=>{const n=i.last-i.first+1;t.removeRows(r,{at:i.first,rows:n});const o=function(e,t,n,i){const o=e.getChild(Math.min(t,i-1));let r=o.getChild(0),s=0;for(const e of o.getChildren()){if(s>n)return r;r=e,s+=parseInt(e.getAttribute("colspan")||1)}return r}(r,i.first,s,t.getRows(r));e.setSelection(e.createPositionAt(o,0))}))}}class Kg extends St{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),n=t[0];if(n){const i=n.findAncestor("table"),o=e.getColumns(i),{first:r,last:s}=e.getColumnIndexes(t);this.isEnabled=s-re.cell===t)).column,last:o.find((e=>e.cell===n)).column},s=function(e,t,n,i){return parseInt(n.getAttribute("colspan")||1)>1?n:t.previousSibling||n.nextSibling?n.nextSibling||t.previousSibling:i.first?e.reverse().find((({column:e})=>ee>i.last)).cell}(o,t,n,r);this.editor.model.change((e=>{const t=r.last-r.first+1;this.editor.plugins.get("TableUtils").removeColumns(i,{at:r.first,columns:t}),e.setSelection(e.createPositionAt(s,0))}))}}class Gg extends St{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,n=e.getSelectionAffectedTableCells(t.document.selection),i=n.length>0;this.isEnabled=i,this.value=i&&n.every((e=>this._isInHeading(e,e.parent.parent)))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),n=this.editor.model,i=t.getSelectionAffectedTableCells(n.document.selection),o=i[0].findAncestor("table"),{first:r,last:s}=t.getRowIndexes(i),a=this.value?r:s+1,c=o.getAttribute("headingRows")||0;n.change((e=>{if(a){const t=jg(o,a,a>c?c:0);for(const{cell:n}of t)Dg(n,a,e)}wg("headingRows",a,o,e,0)}))}_isInHeading(e,t){const n=parseInt(t.getAttribute("headingRows")||0);return!!n&&e.parent.index0;this.isEnabled=i,this.value=i&&n.every((e=>vg(t,e)))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),n=this.editor.model,i=t.getSelectionAffectedTableCells(n.document.selection),o=i[0].findAncestor("table"),{first:r,last:s}=t.getColumnIndexes(i),a=this.value?r:s+1;n.change((e=>{if(a){const t=Lg(o,a);for(const{cell:n,column:i}of t)zg(n,i,a,e)}wg("headingColumns",a,o,e,0)}))}}class Qg extends Ct{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,n=t.parent,i=n.getChildIndex(t),o=new Ag(n,{row:i});for(const{cell:t,row:n,column:i}of o)if(t===e)return{row:n,column:i}}createTable(e,t){const n=e.createElement("table"),i=parseInt(t.rows)||2,o=parseInt(t.columns)||2;return Jg(e,n,0,i,o),t.headingRows&&wg("headingRows",Math.min(t.headingRows,i),n,e,0),t.headingColumns&&wg("headingColumns",Math.min(t.headingColumns,o),n,e,0),n}insertRows(e,t={}){const n=this.editor.model,i=t.at||0,o=t.rows||1,r=void 0!==t.copyStructureFromAbove,s=t.copyStructureFromAbove?i-1:i,a=this.getRows(e),c=this.getColumns(e);if(i>a)throw new y("tableutils-insertrows-insert-out-of-range",this,{options:t});n.change((t=>{const n=e.getAttribute("headingRows")||0;if(n>i&&wg("headingRows",n+o,e,t,0),!r&&(0===i||i===a))return void Jg(t,e,i,o,c);const l=r?Math.max(i,s):i,u=new Ag(e,{endRow:l}),d=new Array(c).fill(1);for(const{row:e,column:n,cellHeight:a,cellWidth:c,cell:l}of u){const u=e+a-1,h=e<=s&&s<=u;e0&&kg(t,o,i>1?{colspan:i}:null),e+=Math.abs(i)-1}}}))}insertColumns(e,t={}){const n=this.editor.model,i=t.at||0,o=t.columns||1;n.change((t=>{const n=e.getAttribute("headingColumns");io-1)throw new y("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});n.change((t=>{const{cellsToMove:n,cellsToTrim:i}=function(e,t,n){const i=new Map,o=[];for(const{row:r,column:s,cellHeight:a,cell:c}of new Ag(e,{endRow:n})){const e=r+a-1;if(r>=t&&r<=n&&e>n){const e=a-(n-r+1);i.set(s,{cell:c,rowspan:e})}if(r=t){let i;i=e>=n?n-t+1:e-t+1,o.push({cell:c,rowspan:a-i})}}return{cellsToMove:i,cellsToTrim:o}}(e,r,s);if(n.size){!function(e,t,n,i){const o=[...new Ag(e,{includeAllSlots:!0,row:t})],r=e.getChild(t);let s;for(const{column:e,cell:t,isAnchor:a}of o)if(n.has(e)){const{cell:t,rowspan:o}=n.get(e),a=s?i.createPositionAfter(s):i.createPositionAt(r,0);i.move(i.createRangeOn(t),a),wg("rowspan",o,t,i),s=t}else a&&(s=t)}(e,s+1,n,t)}for(let n=s;n>=r;n--)t.remove(e.getChild(n));for(const{rowspan:e,cell:n}of i)wg("rowspan",e,n,t);!function(e,t,n,i){const o=e.getAttribute("headingRows")||0;if(t{!function(e,t,n){const i=e.getAttribute("headingColumns")||0;if(i&&t.first=i;n--)for(const{cell:i,column:o,cellWidth:r}of[...new Ag(e)])o<=n&&r>1&&o+r>n?wg("colspan",r-1,i,t):o===n&&t.remove(i);Fg(e,this)||Bg(e,this)}))}splitCellVertically(e,t=2){const n=this.editor.model,i=e.parent.parent,o=parseInt(e.getAttribute("rowspan")||1),r=parseInt(e.getAttribute("colspan")||1);n.change((n=>{if(r>1){const{newCellsSpan:i,updatedSpan:s}=em(r,t);wg("colspan",s,e,n);const a={};i>1&&(a.colspan=i),o>1&&(a.rowspan=o);Xg(r>t?t-1:r-1,n,n.createPositionAfter(e),a)}if(rt===e)),l=a.filter((({cell:t,cellWidth:n,column:i})=>t!==e&&i===c||ic));for(const{cell:e,cellWidth:t}of l)n.setAttribute("colspan",t+s,e);const u={};o>1&&(u.rowspan=o),Xg(s,n,n.createPositionAfter(e),u);const d=i.getAttribute("headingColumns")||0;d>c&&wg("headingColumns",d+s,i,n)}}))}splitCellHorizontally(e,t=2){const n=this.editor.model,i=e.parent,o=i.parent,r=o.getChildIndex(i),s=parseInt(e.getAttribute("rowspan")||1),a=parseInt(e.getAttribute("colspan")||1);n.change((n=>{if(s>1){const i=[...new Ag(o,{startRow:r,endRow:r+s-1,includeAllSlots:!0})],{newCellsSpan:c,updatedSpan:l}=em(s,t);wg("rowspan",l,e,n);const{column:u}=i.find((({cell:t})=>t===e)),d={};c>1&&(d.rowspan=c),a>1&&(d.colspan=a);for(const e of i){const{column:t,row:i}=e,o=t===u,s=(i+r+l)%c==0;i>=r+l&&o&&s&&Xg(1,n,e.getPositionBefore(),d)}}if(sr){const e=o+i;n.setAttribute("rowspan",e,t)}const l={};a>1&&(l.colspan=a),Jg(n,o,r+1,i,1,l);const u=o.getAttribute("headingRows")||0;u>r&&wg("headingRows",u+i,o,n)}}))}getColumns(e){return[...e.getChild(0).getChildren()].reduce(((e,t)=>e+parseInt(t.getAttribute("colspan")||1)),0)}getRows(e){return Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0)}createTableWalker(e,t={}){return new Ag(e,t)}getSelectedTableCells(e){const t=[];for(const n of this.sortRanges(e.getRanges())){const e=n.getContainedElement();e&&e.is("element","tableCell")&&t.push(e)}return t}getTableCellsContainingSelection(e){const t=[];for(const n of e.getRanges()){const e=n.start.findAncestor("tableCell");e&&t.push(e)}return t}getSelectionAffectedTableCells(e){const t=this.getSelectedTableCells(e);return t.length?t:this.getTableCellsContainingSelection(e)}getRowIndexes(e){const t=e.map((e=>e.parent.index));return this._getFirstLastIndexesObject(t)}getColumnIndexes(e){const t=e[0].findAncestor("table"),n=[...new Ag(t)].filter((t=>e.includes(t.cell))).map((e=>e.column));return this._getFirstLastIndexesObject(n)}isSelectionRectangular(e){if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;const t=new Set,n=new Set;let i=0;for(const o of e){const{row:e,column:r}=this.getCellLocation(o),s=parseInt(o.getAttribute("rowspan")||1),a=parseInt(o.getAttribute("colspan")||1);t.add(e),n.add(r),s>1&&t.add(e+s-1),a>1&&n.add(r+a-1),i+=s*a}const o=function(e,t){const n=Array.from(e.values()),i=Array.from(t.values()),o=Math.max(...n),r=Math.min(...n),s=Math.max(...i),a=Math.min(...i);return(o-r+1)*(s-a+1)}(t,n);return o==i}sortRanges(e){return Array.from(e).sort(tm)}_getFirstLastIndexesObject(e){const t=e.sort(((e,t)=>e-t));return{first:t[0],last:t[t.length-1]}}_areCellInTheSameTableSection(e){const t=e[0].findAncestor("table"),n=this.getRowIndexes(e),i=parseInt(t.getAttribute("headingRows")||0);if(!this._areIndexesInSameSection(n,i))return!1;const o=parseInt(t.getAttribute("headingColumns")||0),r=this.getColumnIndexes(e);return this._areIndexesInSameSection(r,o)}_areIndexesInSameSection({first:e,last:t},n){return e{const i=t.getSelectedTableCells(e.document.selection),o=i.shift(),{mergeWidth:r,mergeHeight:s}=function(e,t,n){let i=0,o=0;for(const e of t){const{row:t,column:r}=n.getCellLocation(e);i=rm(e,r,i,"colspan"),o=rm(e,t,o,"rowspan")}const{row:r,column:s}=n.getCellLocation(e);return{mergeWidth:i-s,mergeHeight:o-r}}(o,i,t);wg("colspan",r,o,n),wg("rowspan",s,o,n);for(const e of i)im(e,o,n);Hg(o.findAncestor("table"),t),n.setSelection(o,"in")}))}}function im(e,t,n){om(e)||(om(t)&&n.remove(n.createRangeIn(t)),n.move(n.createRangeIn(e),n.createPositionAt(t,"end"))),n.remove(e)}function om(e){return 1==e.childCount&&e.getChild(0).is("element","paragraph")&&e.getChild(0).isEmpty}function rm(e,t,n,i){const o=parseInt(e.getAttribute(i)||1);return Math.max(n,t+o)}class sm extends St{constructor(e){super(e),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),n=t.getSelectionAffectedTableCells(e.document.selection),i=t.getRowIndexes(n),o=n[0].findAncestor("table"),r=[];for(let t=i.first;t<=i.last;t++)for(const n of o.getChild(t).getChildren())r.push(e.createRangeOn(n));e.change((e=>{e.setSelection(r)}))}}class am extends St{constructor(e){super(e),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,n=e.getSelectionAffectedTableCells(t.document.selection),i=n[0],o=n.pop(),r=i.findAncestor("table"),s=e.getCellLocation(i),a=e.getCellLocation(o),c=Math.min(s.column,a.column),l=Math.max(s.column,a.column),u=[];for(const e of new Ag(r,{startColumn:c,endColumn:l}))u.push(t.createRangeOn(e.cell));t.change((e=>{e.setSelection(u)}))}}function cm(e){e.document.registerPostFixer((t=>function(e,t){const n=t.document.differ.getChanges();let i=!1;const o=new Set;for(const t of n){let n;"table"==t.name&&"insert"==t.type&&(n=t.position.nodeAfter),"tableRow"!=t.name&&"tableCell"!=t.name||(n=t.position.findAncestor("table")),dm(t)&&(n=t.range.start.findAncestor("table")),n&&!o.has(n)&&(i=lm(n,e)||i,i=um(n,e)||i,o.add(n))}return i}(t,e)))}function lm(e,t){let n=!1;const i=function(e){const t=parseInt(e.getAttribute("headingRows")||0),n=Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0),i=[];for(const{row:o,cell:r,cellHeight:s}of new Ag(e)){if(s<2)continue;const e=oe){const t=e-o;i.push({cell:r,rowspan:t})}}return i}(e);if(i.length){n=!0;for(const e of i)wg("rowspan",e.rowspan,e.cell,t,1)}return n}function um(e,t){let n=!1;const i=function(e){const t=new Array(e.childCount).fill(0);for(const{rowIndex:n}of new Ag(e,{includeAllSlots:!0}))t[n]++;return t}(e),o=[];for(const[t,n]of i.entries())!n&&e.getChild(t).is("element","tableRow")&&o.push(t);if(o.length){n=!0;for(const n of o.reverse())t.remove(e.getChild(n)),i.splice(n,1)}const r=i.filter(((t,n)=>e.getChild(n).is("element","tableRow"))),s=r[0];if(!r.every((e=>e===s))){const i=r.reduce(((e,t)=>t>e?t:e),0);for(const[o,s]of r.entries()){const r=i-s;if(r){for(let n=0;nfunction(e,t){const n=t.document.differ.getChanges();let i=!1;for(const t of n)"insert"==t.type&&"table"==t.name&&(i=fm(t.position.nodeAfter,e)||i),"insert"==t.type&&"tableRow"==t.name&&(i=pm(t.position.nodeAfter,e)||i),"insert"==t.type&&"tableCell"==t.name&&(i=gm(t.position.nodeAfter,e)||i),mm(t)&&(i=gm(t.position.parent,e)||i);return i}(t,e)))}function fm(e,t){let n=!1;for(const i of e.getChildren())i.is("element","tableRow")&&(n=pm(i,t)||n);return n}function pm(e,t){let n=!1;for(const i of e.getChildren())n=gm(i,t)||n;return n}function gm(e,t){if(0==e.childCount)return t.insertElement("paragraph",e),!0;const n=Array.from(e.getChildren()).filter((e=>e.is("$text")));for(const e of n)t.wrap(t.createRangeOn(e),"paragraph");return!!n.length}function mm(e){return!(!e.position||!e.position.parent.is("element","tableCell"))&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)}function bm(e,t){if(!e.is("element","paragraph"))return!1;const n=t.toViewElement(e);return!!n&&Pg(e)!==n.is("element","span")}var wm=n(3137),km={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(wm.Z,km);wm.Z.locals;class vm extends Ct{static get pluginName(){return"TableEditing"}static get requires(){return[Qg]}init(){const e=this.editor,t=e.model,n=t.schema,i=e.conversion,o=e.plugins.get(Qg);n.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),n.register("tableRow",{allowIn:"table",isLimit:!0}),n.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),i.for("upcast").add((e=>{e.on("element:figure",((e,t,n)=>{if(!n.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const i=function(e){for(const t of e.getChildren())if(t.is("element","table"))return t}(t.viewItem);if(!i||!n.consumable.test(i,{name:!0}))return;n.consumable.consume(t.viewItem,{name:!0,classes:"table"});const o=$a(n.convertItem(i,t.modelCursor).modelRange.getItems());o?(n.convertChildren(t.viewItem,n.writer.createPositionAt(o,"end")),n.updateConversionResult(o,t)):n.consumable.revert(t.viewItem,{name:!0,classes:"table"})}))})),i.for("upcast").add(_g()),i.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Cg(o,{asWidget:!0})}),i.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Cg(o)}),i.for("upcast").elementToElement({model:"tableRow",view:"tr"}),i.for("upcast").add((e=>{e.on("element:tr",((e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()}),{priority:"high"})})),i.for("downcast").elementToElement({model:"tableRow",view:(e,{writer:t})=>e.isEmpty?t.createEmptyElement("tr"):t.createContainerElement("tr")}),i.for("upcast").elementToElement({model:"tableCell",view:"td"}),i.for("upcast").elementToElement({model:"tableCell",view:"th"}),i.for("upcast").add(yg("td")),i.for("upcast").add(yg("th")),i.for("editingDowncast").elementToElement({model:"tableCell",view:Tg({asWidget:!0})}),i.for("dataDowncast").elementToElement({model:"tableCell",view:Tg()}),i.for("editingDowncast").elementToElement({model:"paragraph",view:Sg({asWidget:!0}),converterPriority:"high"}),i.for("dataDowncast").elementToElement({model:"paragraph",view:Sg(),converterPriority:"high"}),i.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),i.for("upcast").attributeToAttribute({model:{key:"colspan",value:_m("colspan")},view:"colspan"}),i.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),i.for("upcast").attributeToAttribute({model:{key:"rowspan",value:_m("rowspan")},view:"rowspan"}),e.data.mapper.on("modelToViewPosition",((e,t)=>{const n=t.modelPosition.parent,i=t.modelPosition.nodeBefore;if(!n.is("element","tableCell"))return;if(!i||!i.is("element","paragraph"))return;const o=t.mapper.toViewElement(i),r=t.mapper.toViewElement(n);o===r&&(t.viewPosition=t.mapper.findPositionIn(r,i.maxOffset))})),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new Ig(e)),e.commands.add("insertTableRowAbove",new Og(e,{order:"above"})),e.commands.add("insertTableRowBelow",new Og(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new Mg(e,{order:"left"})),e.commands.add("insertTableColumnRight",new Mg(e,{order:"right"})),e.commands.add("removeTableRow",new Zg(e)),e.commands.add("removeTableColumn",new Kg(e)),e.commands.add("splitTableCellVertically",new Rg(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new Rg(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new nm(e)),e.commands.add("mergeTableCellRight",new qg(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new qg(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new qg(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new qg(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new Yg(e)),e.commands.add("setTableRowHeader",new Gg(e)),e.commands.add("selectTableRow",new sm(e)),e.commands.add("selectTableColumn",new am(e)),cm(t),hm(t),this.listenTo(t.document,"change:data",(()=>{!function(e,t){const n=e.document.differ;for(const e of n.getChanges()){let n,i=!1;if("attribute"==e.type){const t=e.range.start.nodeAfter;if(!t||!t.is("element","table"))continue;if("headingRows"!=e.attributeKey&&"headingColumns"!=e.attributeKey)continue;n=t,i="headingRows"==e.attributeKey}else"tableRow"!=e.name&&"tableCell"!=e.name||(n=e.position.findAncestor("table"),i="tableRow"==e.name);if(!n)continue;const o=n.getAttribute("headingRows")||0,r=n.getAttribute("headingColumns")||0,s=new Ag(n);for(const e of s){const n=e.rowbm(e,t.mapper)));for(const e of n)t.reconvertItem(e)}}(t,e.editing)}))}}function _m(e){return t=>{const n=parseInt(t.getAttribute(e));return Number.isNaN(n)||n<=0?null:n}}var ym=n(6516),xm={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(ym.Z,xm);ym.Z.locals;class Am extends nd{constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",((e,t)=>`${t} × ${e}`)),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":t.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck-insert-table-dropdown__label"]},children:[{text:t.to("label")}]}],on:{mousedown:t.to((e=>{e.preventDefault()})),click:t.to((()=>{this.fire("execute")}))}}),this.on("boxover",((e,t)=>{const{row:n,column:i}=t.target.dataset;this.set({rows:parseInt(n),columns:parseInt(i)})})),this.on("change:columns",(()=>{this._highlightGridBoxes()})),this.on("change:rows",(()=>{this._highlightGridBoxes()}))}focus(){}focusLast(){}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map(((n,i)=>{const o=Math.floor(i/10){const i=e.commands.get("insertTable"),o=vh(n);let r;return o.bind("isEnabled").to(i),o.buttonView.set({icon:'',label:t("Insert table"),tooltip:!0}),o.on("change:isOpen",(()=>{r||(r=new Am(n),o.panelView.children.add(r),r.delegate("execute").to(o),o.buttonView.on("open",(()=>{r.rows=0,r.columns=0})),o.on("execute",(()=>{e.execute("insertTable",{rows:r.rows,columns:r.columns}),e.editing.view.focus()})))})),o})),e.ui.componentFactory.add("tableColumn",(e=>{const i=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:n?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:n?"insertTableColumnRight":"insertTableColumnLeft",label:t("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:t("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:t("Select column")}}];return this._prepareDropdown(t("Column"),'',i,e)})),e.ui.componentFactory.add("tableRow",(e=>{const n=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:t("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:t("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:t("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:t("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:t("Select row")}}];return this._prepareDropdown(t("Row"),'',n,e)})),e.ui.componentFactory.add("mergeTableCells",(e=>{const i=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:n?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:n?"mergeTableCellLeft":"mergeTableCellRight",label:t("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:t("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:t("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(t("Merge cells"),'',i,e)}))}_prepareDropdown(e,t,n,i){const o=this.editor,r=vh(i),s=this._fillDropdownWithListOptions(r,n);return r.buttonView.set({label:e,icon:t,tooltip:!0}),r.bind("isEnabled").toMany(s,"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(r,"execute",(e=>{o.execute(e.source.commandName),o.editing.view.focus()})),r}_prepareMergeSplitButtonDropdown(e,t,n,i){const o=this.editor,r=vh(i,Kd),s="mergeTableCells",a=o.commands.get(s),c=this._fillDropdownWithListOptions(r,n);return r.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),r.bind("isEnabled").toMany([a,...c],"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(r.buttonView,"execute",(()=>{o.execute(s),o.editing.view.focus()})),this.listenTo(r,"execute",(e=>{o.execute(e.source.commandName),o.editing.view.focus()})),r}_fillDropdownWithListOptions(e,t){const n=this.editor,i=[],o=new Fi;for(const e of t)Tm(e,n,i,o);return yh(e,o,n.ui.componentFactory),i}}function Tm(e,t,n,i){const o=e.model=new Uh(e.model),{commandName:r,bindIsOn:s}=e.model;if("button"===e.type||"switchbutton"===e.type){const e=t.commands.get(r);n.push(e),o.set({commandName:r}),o.bind("isEnabled").to(e),s&&o.bind("isOn").to(e,"value")}o.set({withText:!0}),i.add(e)}var Sm=n(2794),Pm={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Sm.Z,Pm);Sm.Z.locals;class Im extends Ct{static get pluginName(){return"TableSelection"}static get requires(){return[Qg,Qg]}init(){const e=this.editor.model;this.listenTo(e,"deleteContent",((e,t)=>this._handleDeleteContent(e,t)),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=this.editor.plugins.get(Qg),t=this.editor.model.document.selection,n=e.getSelectedTableCells(t);return 0==n.length?null:n}getSelectionAsFragment(){const e=this.editor.plugins.get(Qg),t=this.getSelectedTableCells();return t?this.editor.model.change((n=>{const i=n.createDocumentFragment(),{first:o,last:r}=e.getColumnIndexes(t),{first:s,last:a}=e.getRowIndexes(t),c=t[0].findAncestor("table");let l=a,u=r;if(e.isSelectionRectangular(t)){const e={firstColumn:o,lastColumn:r,firstRow:s,lastRow:a};l=Ug(c,e),u=Wg(c,e)}const d=Ng(c,{startRow:s,startColumn:o,endRow:l,endColumn:u},n);return n.insert(d,i,0),i})):null}setCellSelection(e,t){const n=this._getCellsToSelect(e,t);this.editor.model.change((e=>{e.setSelection(n.cells.map((t=>e.createRangeOn(t))),{backward:n.backward})}))}getFocusCell(){const e=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return e&&e.is("element","tableCell")?e:null}getAnchorCell(){const e=$a(this.editor.model.document.selection.getRanges()).getContainedElement();return e&&e.is("element","tableCell")?e:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add((e=>e.on("selection",((e,n,i)=>{const o=i.writer;!function(e){for(const n of t)e.removeClass("ck-editor__editable_selected",n);t.clear()}(o);const r=this.getSelectedTableCells();if(!r)return;for(const e of r){const n=i.mapper.toViewElement(e);o.addClass("ck-editor__editable_selected",n),t.add(n)}const s=i.mapper.toViewElement(r[r.length-1]);o.setSelection(s,0)}),{priority:"lowest"})))}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",(()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change((n=>{const i=n.createPositionAt(t[0],0),o=e.model.schema.getNearestSelectionRange(i);n.setSelection(o)}))}}))}_handleDeleteContent(e,t){const n=this.editor.plugins.get(Qg),[i,o]=t,r=this.editor.model,s=!o||"backward"==o.direction,a=n.getSelectedTableCells(i);a.length&&(e.stop(),r.change((e=>{const t=a[s?a.length-1:0];r.change((e=>{for(const t of a)r.deleteContent(e.createSelection(t,"in"))}));const n=r.schema.getNearestSelectionRange(e.createPositionAt(t,0));i.is("documentSelection")?e.setSelection(n):i.setTo(n)})))}_getCellsToSelect(e,t){const n=this.editor.plugins.get("TableUtils"),i=n.getCellLocation(e),o=n.getCellLocation(t),r=Math.min(i.row,o.row),s=Math.max(i.row,o.row),a=Math.min(i.column,o.column),c=Math.max(i.column,o.column),l=new Array(s-r+1).fill(null).map((()=>[])),u={startRow:r,endRow:s,startColumn:a,endColumn:c};for(const{row:t,cell:n}of new Ag(e.findAncestor("table"),u))l[t-r].push(n);const d=o.rowe.reverse())),{cells:l.flat(),backward:d||h}}}class Om extends Ct{static get pluginName(){return"TableClipboard"}static get requires(){return[Im,Qg]}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"copy",((e,t)=>this._onCopyCut(e,t))),this.listenTo(t,"cut",((e,t)=>this._onCopyCut(e,t))),this.listenTo(e.model,"insertContent",((e,t)=>this._onInsertContent(e,...t)),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(e,t){const n=this.editor.plugins.get(Im);if(!n.getSelectedTableCells())return;if("cut"==e.name&&this.editor.isReadOnly)return;t.preventDefault(),e.stop();const i=this.editor.data,o=this.editor.editing.view.document,r=i.toView(n.getSelectionAsFragment());o.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:r,method:e.name})}_onInsertContent(e,t,n){if(n&&!n.is("documentSelection"))return;const i=this.editor.model,o=this.editor.plugins.get(Qg);let r=Mm(t,i);if(!r)return;const s=o.getSelectionAffectedTableCells(i.document.selection);s.length?(e.stop(),i.change((e=>{const t={width:o.getColumns(r),height:o.getRows(r)},n=function(e,t,n,i){const o=e[0].findAncestor("table"),r=i.getColumnIndexes(e),s=i.getRowIndexes(e),a={firstColumn:r.first,lastColumn:r.last,firstRow:s.first,lastRow:s.last},c=1===e.length;c&&(a.lastRow+=t.height-1,a.lastColumn+=t.width-1,function(e,t,n,i){const o=i.getColumns(e),r=i.getRows(e);n>o&&i.insertColumns(e,{at:o,columns:n-o});t>r&&i.insertRows(e,{at:r,rows:t-r})}(o,a.lastRow+1,a.lastColumn+1,i));c||!i.isSelectionRectangular(e)?function(e,t,n){const{firstRow:i,lastRow:o,firstColumn:r,lastColumn:s}=t,a={first:i,last:o},c={first:r,last:s};Nm(e,r,a,n),Nm(e,s+1,a,n),Rm(e,i,c,n),Rm(e,o+1,c,n,i)}(o,a,n):(a.lastRow=Ug(o,a),a.lastColumn=Wg(o,a));return a}(s,t,e,o),i=n.lastRow-n.firstRow+1,a=n.lastColumn-n.firstColumn+1,c={startRow:0,startColumn:0,endRow:Math.min(i,t.height)-1,endColumn:Math.min(a,t.width)-1};r=Ng(r,c,e);const l=s[0].findAncestor("table"),u=this._replaceSelectedCellsWithPasted(r,t,l,n,e);if(this.editor.plugins.get("TableSelection").isEnabled){const t=o.sortRanges(u.map((t=>e.createRangeOn(t))));e.setSelection(t)}else e.setSelection(u[0],0)}))):Hg(r,o)}_replaceSelectedCellsWithPasted(e,t,n,i,o){const{width:r,height:s}=t,a=function(e,t,n){const i=new Array(n).fill(null).map((()=>new Array(t).fill(null)));for(const{column:t,row:n,cell:o}of new Ag(e))i[n][t]=o;return i}(e,r,s),c=[...new Ag(n,{startRow:i.firstRow,endRow:i.lastRow,startColumn:i.firstColumn,endColumn:i.lastColumn,includeAllSlots:!0})],l=[];let u;for(const e of c){const{row:t,column:n}=e;n===i.firstColumn&&(u=e.getPositionBefore());const c=t-i.firstRow,d=n-i.firstColumn,h=a[c%s][d%r],f=h?o.cloneElement(h):null,p=this._replaceTableSlotCell(e,f,u,o);p&&(Vg(p,t,n,i.lastRow,i.lastColumn,o),l.push(p),u=o.createPositionAfter(p))}const d=parseInt(n.getAttribute("headingRows")||0),h=parseInt(n.getAttribute("headingColumns")||0),f=i.firstRowjm(e,t,n))).map((({cell:e})=>Dg(e,t,i)))}function Nm(e,t,n,i){if(t<1)return;return Lg(e,t).filter((({row:e,cellHeight:t})=>jm(e,t,n))).map((({cell:e,column:n})=>zg(e,n,t,i)))}function jm(e,t,n){const i=e+t-1,{first:o,last:r}=n;return e>=o&&e<=r||e=o}class Dm extends Ct{static get pluginName(){return"TableKeyboard"}static get requires(){return[Im,Qg]}init(){const e=this.editor.editing.view.document;this.listenTo(e,"arrowKey",((...e)=>this._onArrowKey(...e)),{context:"table"}),this.listenTo(e,"tab",((...e)=>this._handleTabOnSelectedTable(...e)),{context:"figure"}),this.listenTo(e,"tab",((...e)=>this._handleTab(...e)),{context:["th","td"]})}_handleTabOnSelectedTable(e,t){const n=this.editor,i=n.model.document.selection.getSelectedElement();i&&i.is("element","table")&&(t.preventDefault(),t.stopPropagation(),e.stop(),n.model.change((e=>{e.setSelection(e.createRangeIn(i.getChild(0).getChild(0)))})))}_handleTab(e,t){const n=this.editor,i=this.editor.plugins.get(Qg),o=n.model.document.selection,r=!t.shiftKey;let s=i.getTableCellsContainingSelection(o)[0];if(s||(s=this.editor.plugins.get("TableSelection").getFocusCell()),!s)return;t.preventDefault(),t.stopPropagation(),e.stop();const a=s.parent,c=a.parent,l=c.getChildIndex(a),u=a.getChildIndex(s),d=0===u;if(!r&&d&&0===l)return void n.model.change((e=>{e.setSelection(e.createRangeOn(c))}));const h=u===a.childCount-1,f=l===i.getRows(c)-1;if(r&&f&&h&&(n.execute("insertTableRowBelow"),l===i.getRows(c)-1))return void n.model.change((e=>{e.setSelection(e.createRangeOn(c))}));let p;if(r&&h){const e=c.getChild(l+1);p=e.getChild(0)}else if(!r&&d){const e=c.getChild(l-1);p=e.getChild(e.childCount-1)}else p=a.getChild(u+(r?1:-1));n.model.change((e=>{e.setSelection(e.createRangeIn(p))}))}_onArrowKey(e,t){const n=this.editor,i=Ir(t.keyCode,n.locale.contentLanguageDirection);this._handleArrowKeys(i,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const n=this.editor.plugins.get(Qg),i=this.editor.model,o=i.document.selection,r=["right","down"].includes(e),s=n.getSelectedTableCells(o);if(s.length){let n;return n=t?this.editor.plugins.get("TableSelection").getFocusCell():r?s[s.length-1]:s[0],this._navigateFromCellInDirection(n,e,t),!0}const a=o.focus.findAncestor("tableCell");if(!a)return!1;if(!o.isCollapsed)if(t){if(o.isBackward==r&&!o.containsEntireContent(a))return!1}else{const e=o.getSelectedElement();if(!e||!i.schema.isObject(e))return!1}return!!this._isSelectionAtCellEdge(o,a,r)&&(this._navigateFromCellInDirection(a,e,t),!0)}_isSelectionAtCellEdge(e,t,n){const i=this.editor.model,o=this.editor.model.schema,r=n?e.getLastPosition():e.getFirstPosition();if(!o.getLimitElement(r).is("element","tableCell")){return i.createPositionAt(t,n?"end":0).isTouching(r)}const s=i.createSelection(r);return i.modifySelection(s,{direction:n?"forward":"backward"}),r.isEqual(s.focus)}_navigateFromCellInDirection(e,t,n=!1){const i=this.editor.model,o=e.findAncestor("table"),r=[...new Ag(o,{includeAllSlots:!0})],{row:s,column:a}=r[r.length-1],c=r.find((({cell:t})=>t==e));let{row:l,column:u}=c;switch(t){case"left":u--;break;case"up":l--;break;case"right":u+=c.cellWidth;break;case"down":l+=c.cellHeight}if(l<0||l>s||u<0&&l<=0||u>a&&l>=s)return void i.change((e=>{e.setSelection(e.createRangeOn(o))}));u<0?(u=n?0:a,l--):u>a&&(u=n?a:0,l++);const d=r.find((e=>e.row==l&&e.column==u)).cell,h=["right","down"].includes(t),f=this.editor.plugins.get("TableSelection");if(n&&f.isEnabled){const t=f.getAnchorCell()||e;f.setCellSelection(t,d)}else{const e=i.createPositionAt(d,h?0:"end");i.change((t=>{t.setSelection(e)}))}}}class Lm extends ra{constructor(e){super(e),this.domEventType=["mousemove","mouseleave"]}onDomEvent(e){this.fire(e.type,e)}}class zm extends Ct{static get pluginName(){return"TableMouse"}static get requires(){return[Im,Qg]}init(){this.editor.editing.view.addObserver(Lm),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(Qg);let n=!1;const i=e.plugins.get(Im);this.listenTo(e.editing.view.document,"mousedown",((o,r)=>{const s=e.model.document.selection;if(!this.isEnabled||!i.isEnabled)return;if(!r.domEvent.shiftKey)return;const a=i.getAnchorCell()||t.getTableCellsContainingSelection(s)[0];if(!a)return;const c=this._getModelTableCellFromDomEvent(r);c&&Vm(a,c)&&(n=!0,i.setCellSelection(a,c),r.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{n=!1})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{n&&e.stop()}),{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,n,i=!1,o=!1;const r=e.plugins.get(Im);this.listenTo(e.editing.view.document,"mousedown",((e,n)=>{this.isEnabled&&r.isEnabled&&(n.domEvent.shiftKey||n.domEvent.ctrlKey||n.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(n)))})),this.listenTo(e.editing.view.document,"mousemove",((e,s)=>{if(!s.domEvent.buttons)return;if(!t)return;const a=this._getModelTableCellFromDomEvent(s);a&&Vm(t,a)&&(n=a,i||n==t||(i=!0)),i&&(o=!0,r.setCellSelection(t,n),s.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{i=!1,o=!1,t=null,n=null})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{o&&e.stop()}),{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,n=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(n).parent.findAncestor("tableCell",{includeSelf:!0})}}function Vm(e,t){return e.parent.parent==t.parent.parent}var Bm=n(4418),Fm={injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0};d()(Bm.Z,Fm);Bm.Z.locals;class Hm extends Ct{static get requires(){return[vm,Cm,Im,zm,Dm,Om,Yp]}static get pluginName(){return"Table"}}class Um extends St{constructor(e,t){super(e),this._buffer=new hp(e.model,t)}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,n=t.document,i=e.text||"",o=i.length,r=e.range?t.createSelection(e.range):n.selection,s=e.resultRange;t.enqueueChange(this._buffer.batch,(e=>{this._buffer.lock(),t.deleteContent(r),i&&t.insertContent(e.createText(i,n.selection.getAttributes()),r),s?e.setSelection(s):r.is("documentSelection")||e.setSelection(r),this._buffer.unlock(),this._buffer.input(o)}))}}class Wm{constructor(e){this.editor=e,this.editing=this.editor.editing}handle(e,t){if(function(e){if(0==e.length)return!1;for(const t of e)if("children"===t.type&&!pp(t))return!0;return!1}(e))this._handleContainerChildrenMutations(e,t);else for(const n of e)this._handleTextMutation(n,t),this._handleTextNodeInsertion(n)}_handleContainerChildrenMutations(e,t){const n=function(e){const t=e.map((e=>e.node)).reduce(((e,t)=>e.getCommonAncestor(t,{includeSelf:!0})));if(!t)return;return t.getAncestors({includeSelf:!0,parentFirst:!0}).find((e=>e.is("containerElement")||e.is("rootElement")))}(e);if(!n)return;const i=this.editor.editing.view.domConverter.mapViewToDom(n),o=new Cs(this.editor.editing.view.document),r=this.editor.data.toModel(o.domToView(i)).getChild(0),s=this.editor.editing.mapper.toModelElement(n);if(!s)return;const a=Array.from(r.getChildren()),c=Array.from(s.getChildren()),l=a[a.length-1],u=c[c.length-1],d=l&&l.is("element","softBreak"),h=u&&!u.is("element","softBreak");d&&h&&a.pop();const f=this.editor.model.schema;if(!qm(a,f)||!qm(c,f))return;const p=a.map((e=>e.is("$text")?e.data:"@")).join("").replace(/\u00A0/g," "),g=c.map((e=>e.is("$text")?e.data:"@")).join("").replace(/\u00A0/g," ");if(g===p)return;const m=ss(g,p),{firstChangeAt:b,insertions:w,deletions:k}=$m(m);let v=null;t&&(v=this.editing.mapper.toModelRange(t.getFirstRange()));const _=p.substr(b,w),y=this.editor.model.createRange(this.editor.model.createPositionAt(s,b),this.editor.model.createPositionAt(s,b+k));this.editor.execute("input",{text:_,range:y,resultRange:v})}_handleTextMutation(e,t){if("text"!=e.type)return;const n=e.newText.replace(/\u00A0/g," "),i=e.oldText.replace(/\u00A0/g," ");if(i===n)return;const o=ss(i,n),{firstChangeAt:r,insertions:s,deletions:a}=$m(o);let c=null;t&&(c=this.editing.mapper.toModelRange(t.getFirstRange()));const l=this.editing.view.createPositionAt(e.node,r),u=this.editing.mapper.toModelPosition(l),d=this.editor.model.createRange(u,u.getShiftedBy(a)),h=n.substr(r,s);this.editor.execute("input",{text:h,range:d,resultRange:c})}_handleTextNodeInsertion(e){if("children"!=e.type)return;const t=pp(e),n=this.editing.view.createPositionAt(e.node,t.index),i=this.editing.mapper.toModelPosition(n),o=t.values[0].data;this.editor.execute("input",{text:o.replace(/\u00A0/g," "),range:this.editor.model.createRange(i)})}}function qm(e,t){return e.every((e=>t.isInline(e)))}function $m(e){let t=null,n=null;for(let i=0;i{n.deleteContent(n.document.selection)})),e.unlock()}_r.isAndroid?i.document.on("beforeinput",((e,t)=>r(t)),{priority:"lowest"}):i.document.on("keydown",((e,t)=>r(t)),{priority:"lowest"}),i.document.on("compositionstart",(function(){const e=n.document,t=1!==e.selection.rangeCount||e.selection.getFirstRange().isFlat;e.selection.isCollapsed||t||s()}),{priority:"lowest"}),i.document.on("compositionend",(()=>{t=n.createSelection(n.document.selection)}),{priority:"lowest"})}(e),function(e){e.editing.view.document.on("mutations",((t,n,i)=>{new Wm(e).handle(n,i)}))}(e)}}class Km extends Ct{static get requires(){return[Zm,wp]}static get pluginName(){return"Typing"}}function Gm(e,t){let n=e.start;return{text:Array.from(e.getItems()).reduce(((e,i)=>i.is("$text")||i.is("$textProxy")?e+i.data:(n=t.createPositionAfter(i),"")),""),range:t.createRange(n,e.end)}}class Ym{constructor(e,t){this.model=e,this.testCallback=t,this.hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",(()=>{this.isEnabled?this._startListening():(this.stopListening(e.document.selection),this.stopListening(e.document))})),this._startListening()}_startListening(){const e=this.model.document;this.listenTo(e.selection,"change:range",((t,{directChange:n})=>{n&&(e.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this.hasMatch=!1))})),this.listenTo(e,"change:data",((e,t)=>{!t.isUndo&&t.isLocal&&this._evaluateTextBeforeSelection("data",{batch:t})}))}_evaluateTextBeforeSelection(e,t={}){const n=this.model,i=n.document.selection,o=n.createRange(n.createPositionAt(i.focus.parent,0),i.focus),{text:r,range:s}=Gm(o,n),a=this.testCallback(r);if(!a&&this.hasMatch&&this.fire("unmatched"),this.hasMatch=!!a,a){const n=Object.assign(t,{text:r,range:s});"object"==typeof a&&Object.assign(n,a),this.fire(`matched:${e}`,n)}}}Et(Ym,kt);class Qm extends Ct{static get pluginName(){return"TwoStepCaretMovement"}constructor(e){super(e),this.attributes=new Set,this._overrideUid=null}init(){const e=this.editor,t=e.model,n=e.editing.view,i=e.locale,o=t.document.selection;this.listenTo(n.document,"arrowKey",((e,t)=>{if(!o.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const n=t.keyCode==Er.arrowright,r=t.keyCode==Er.arrowleft;if(!n&&!r)return;const s=i.contentLanguageDirection;let a=!1;a="ltr"===s&&n||"rtl"===s&&r?this._handleForwardMovement(t):this._handleBackwardMovement(t),!0===a&&e.stop()}),{context:"$text",priority:"highest"}),this._isNextGravityRestorationSkipped=!1,this.listenTo(o,"change:range",((e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&tb(o.getFirstPosition(),this.attributes)||this._restoreGravity())}))}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,n=this.editor.model.document.selection,i=n.getFirstPosition();return!this._isGravityOverridden&&((!i.isAtStart||!Jm(n,t))&&(tb(i,t)?(eb(e),this._overrideGravity(),!0):void 0))}_handleBackwardMovement(e){const t=this.attributes,n=this.editor.model,i=n.document.selection,o=i.getFirstPosition();return this._isGravityOverridden?(eb(e),this._restoreGravity(),Xm(n,t,o),!0):o.isAtStart?!!Jm(i,t)&&(eb(e),Xm(n,t,o),!0):function(e,t){return tb(e.getShiftedBy(-1),t)}(o,t)?o.isAtEnd&&!Jm(i,t)&&tb(o,t)?(eb(e),Xm(n,t,o),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1):void 0}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change((e=>e.overrideSelectionGravity()))}_restoreGravity(){this.editor.model.change((e=>{e.restoreSelectionGravity(this._overrideUid),this._overrideUid=null}))}}function Jm(e,t){for(const n of t)if(e.hasAttribute(n))return!0;return!1}function Xm(e,t,n){const i=n.nodeBefore;e.change((e=>{i?e.setSelectionAttribute(i.getAttributes()):e.removeSelectionAttribute(t)}))}function eb(e){e.preventDefault()}function tb(e,t){const{nodeBefore:n,nodeAfter:i}=e;for(const e of t){const t=n?n.getAttribute(e):void 0;if((i?i.getAttribute(e):void 0)!==t)return!0}return!1}nb('"'),nb("'"),nb("'"),nb('"'),nb('"'),nb("'");function nb(e){return new RegExp(`(^|\\s)(${e})([^${e}]*)(${e})$`)}function ib(e,t,n,i){return i.createRange(ob(e,t,n,!0,i),ob(e,t,n,!1,i))}function ob(e,t,n,i,o){let r=e.textNode||(i?e.nodeBefore:e.nodeAfter),s=null;for(;r&&r.getAttribute(t)==n;)s=r,r=i?r.previousSibling:r.nextSibling;return s?o.createPositionAt(s,i?"before":"after"):e}function rb(e,t,n,i){const o=e.editing.view,r=new Set;o.document.registerPostFixer((o=>{const s=e.model.document.selection;let a=!1;if(s.hasAttribute(t)){const c=ib(s.getFirstPosition(),t,s.getAttribute(t),e.model),l=e.editing.mapper.toViewRange(c);for(const e of l.getItems())e.is("element",n)&&!e.hasClass(i)&&(o.addClass(i,e),r.add(e),a=!0)}return a})),e.conversion.for("editingDowncast").add((e=>{function t(){o.change((e=>{for(const t of r.values())e.removeClass(i,t),r.delete(t)}))}e.on("insert",t,{priority:"highest"}),e.on("remove",t,{priority:"highest"}),e.on("attribute",t,{priority:"highest"}),e.on("selection",t,{priority:"highest"})}))}function sb(e,t,n,i){let o,r=null;"function"==typeof i?o=i:(r=e.commands.get(i),o=()=>{e.execute(i)}),e.model.document.on("change:data",((s,a)=>{if(r&&!r.isEnabled||!t.isEnabled)return;const c=$a(e.model.document.selection.getRanges());if(!c.isCollapsed)return;if(a.isUndo||!a.isLocal)return;const l=Array.from(e.model.document.differ.getChanges()),u=l[0];if(1!=l.length||"insert"!==u.type||"$text"!=u.name||1!=u.length)return;const d=u.position.parent;if(d.is("element","codeBlock"))return;if(d.is("element","listItem")&&"function"!=typeof i&&!["numberedList","bulletedList","todoList"].includes(i))return;if(r&&!0===r.value)return;const h=d.getChild(0),f=e.model.createRangeOn(h);if(!f.containsRange(c)&&!c.end.isEqual(f.end))return;const p=n.exec(h.data.substr(0,c.end.offset));p&&e.model.enqueueChange((t=>{const n=t.createPositionAt(d,0),i=t.createPositionAt(d,p[0].length),r=new _c(n,i);if(!1!==o({match:p})){t.remove(r);const n=e.model.document.selection.getFirstRange(),i=t.createRangeIn(d);!d.isEmpty||i.isEqual(n)||i.containsRange(n,!0)||t.remove(d)}r.detach(),e.model.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}))}))}function ab(e,t,n,i){let o,r;n instanceof RegExp?o=n:r=n,r=r||(e=>{let t;const n=[],i=[];for(;null!==(t=o.exec(e))&&!(t&&t.length<4);){let{index:e,1:o,2:r,3:s}=t;const a=o+r+s;e+=t[0].length-a.length;const c=[e,e+o.length],l=[e+o.length+r.length,e+o.length+r.length+s.length];n.push(c),n.push(l),i.push([e+o.length,e+o.length+r.length])}return{remove:n,format:i}}),e.model.document.on("change:data",((n,o)=>{if(o.isUndo||!o.isLocal||!t.isEnabled)return;const s=e.model,a=s.document.selection;if(!a.isCollapsed)return;const c=Array.from(s.document.differ.getChanges()),l=c[0];if(1!=c.length||"insert"!==l.type||"$text"!=l.name||1!=l.length)return;const u=a.focus,d=u.parent,{text:h,range:f}=function(e,t){let n=e.start;return{text:Array.from(e.getItems()).reduce(((e,i)=>!i.is("$text")&&!i.is("$textProxy")||i.getAttribute("code")?(n=t.createPositionAfter(i),""):e+i.data),""),range:t.createRange(n,e.end)}}(s.createRange(s.createPositionAt(d,0),u),s),p=r(h),g=cb(f.start,p.format,s),m=cb(f.start,p.remove,s);g.length&&m.length&&s.enqueueChange((t=>{if(!1!==i(t,g)){for(const e of m.reverse())t.remove(e);s.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}}))}))}function cb(e,t,n){return t.filter((e=>void 0!==e[0]&&void 0!==e[1])).map((t=>n.createRange(e.getShiftedBy(t[0]),e.getShiftedBy(t[1]))))}class lb extends Ct{static get requires(){return[wp]}static get pluginName(){return"Autoformat"}afterInit(){this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats()}_addListAutoformats(){const e=this.editor.commands;e.get("bulletedList")&&sb(this.editor,this,/^[*-]\s$/,"bulletedList"),e.get("numberedList")&&sb(this.editor,this,/^1[.|)]\s$/,"numberedList"),e.get("todoList")&&sb(this.editor,this,/^\[\s?\]\s$/,"todoList"),e.get("checkTodoList")&&sb(this.editor,this,/^\[\s?x\s?\]\s$/,(()=>{this.editor.execute("todoList"),this.editor.execute("checkTodoList")}))}_addBasicStylesAutoformats(){const e=this.editor.commands;if(e.get("bold")){const e=ub(this.editor,"bold");ab(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,e),ab(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,e)}if(e.get("italic")){const e=ub(this.editor,"italic");ab(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,e),ab(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,e)}if(e.get("code")){const e=ub(this.editor,"code");ab(this.editor,this,/(`)([^`]+)(`)$/g,e)}if(e.get("strikethrough")){const e=ub(this.editor,"strikethrough");ab(this.editor,this,/(~~)([^~]+)(~~)$/g,e)}}_addHeadingAutoformats(){const e=this.editor.commands.get("heading");e&&e.modelElements.filter((e=>e.match(/^heading[1-6]$/))).forEach((t=>{const n=t[7],i=new RegExp(`^(#{${n}})\\s$`);sb(this.editor,this,i,(()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute("heading",{value:t})}))}))}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&sb(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const e=this.editor,t=e.model.document.selection;e.commands.get("codeBlock")&&sb(e,this,/^```$/,(()=>{if(t.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})}))}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&sb(this.editor,this,/^---$/,"horizontalLine")}}function ub(e,t){return(n,i)=>{if(!e.commands.get(t).isEnabled)return!1;const o=e.model.schema.getValidRanges(i,t);for(const e of o)n.setAttribute(t,!0,e);n.removeSelectionAttribute(t)}}class db{constructor(e){this.files=function(e){const t=Array.from(e.files||[]),n=Array.from(e.items||[]);if(t.length)return t;return n.filter((e=>"file"===e.kind)).map((e=>e.getAsFile()))}(e),this._native=e}get types(){return this._native.types}getData(e){return this._native.getData(e)}setData(e,t){this._native.setData(e,t)}set effectAllowed(e){this._native.effectAllowed=e}get effectAllowed(){return this._native.effectAllowed}set dropEffect(e){this._native.dropEffect=e}get dropEffect(){return this._native.dropEffect}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}class hb extends ra{constructor(e){super(e);const t=this.document;function n(e){return(n,i)=>{i.preventDefault();const o=i.dropRange?[i.dropRange]:null,r=new b(t,e);t.fire(r,{dataTransfer:i.dataTransfer,method:n.name,targetRanges:o,target:i.target}),r.stop.called&&i.stopPropagation()}}this.domEventType=["paste","copy","cut","drop","dragover","dragstart","dragend","dragenter","dragleave"],this.listenTo(t,"paste",n("clipboardInput"),{priority:"low"}),this.listenTo(t,"drop",n("clipboardInput"),{priority:"low"}),this.listenTo(t,"dragover",n("dragging"),{priority:"low"})}onDomEvent(e){const t={dataTransfer:new db(e.clipboardData?e.clipboardData:e.dataTransfer)};"drop"!=e.type&&"dragover"!=e.type||(t.dropRange=function(e,t){const n=t.target.ownerDocument,i=t.clientX,o=t.clientY;let r;n.caretRangeFromPoint&&n.caretRangeFromPoint(i,o)?r=n.caretRangeFromPoint(i,o):t.rangeParent&&(r=n.createRange(),r.setStart(t.rangeParent,t.rangeOffset),r.collapse(!0));if(r)return e.domConverter.domRangeToView(r);return null}(this.view,e)),this.fire(e.type,e,t)}}const fb=["figcaption","li"];function pb(e){let t="";if(e.is("$text")||e.is("$textProxy"))t=e.data;else if(e.is("element","img")&&e.hasAttribute("alt"))t=e.getAttribute("alt");else if(e.is("element","br"))t="\n";else{let n=null;for(const i of e.getChildren()){const e=pb(i);n&&(n.is("containerElement")||i.is("containerElement"))&&(fb.includes(n.name)||fb.includes(i.name)?t+="\n":t+="\n\n"),t+=e,n=i}}return t}class gb extends Ct{static get pluginName(){return"ClipboardPipeline"}init(){this.editor.editing.view.addObserver(hb),this._setupPasteDrop(),this._setupCopyCut()}_setupPasteDrop(){const e=this.editor,t=e.model,n=e.editing.view,i=n.document;this.listenTo(i,"clipboardInput",(t=>{e.isReadOnly&&t.stop()}),{priority:"highest"}),this.listenTo(i,"clipboardInput",((e,t)=>{const i=t.dataTransfer;let o=t.content||"";var r;o||(i.getData("text/html")?o=function(e){return e.replace(/(\s+)<\/span>/g,((e,t)=>1==t.length?" ":t)).replace(//g,"")}(i.getData("text/html")):i.getData("text/plain")&&(((r=(r=i.getData("text/plain")).replace(//g,">").replace(/\r?\n\r?\n/g,"

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

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

${r}

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

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

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

${r}

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