1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4810],{35302:(e,t,i)=>{i.d(t,{$AX:()=>eQ,$Ul:()=>tx,$xF:()=>rj,AA7:()=>rM,BNg:()=>tc,FZK:()=>r1,HZz:()=>rC,JkJ:()=>tA,Kxg:()=>r_,L_G:()=>ir,LwR:()=>iZ,M5m:()=>_,Nu4:()=>eZ,P3x:()=>im,PNe:()=>x,Rer:()=>rb,T4G:()=>q,Tkc:()=>e7,Vgs:()=>ea,WXz:()=>tN,Y2A:()=>rv,_O1:()=>io,cJK:()=>Z,dY0:()=>ig,dq5:()=>iY,fS6:()=>iN,fY7:()=>rz,ghV:()=>rh,mtt:()=>r9,n0Z:()=>rF,nun:()=>eG,oDe:()=>tn,oXW:()=>rP,oZK:()=>eJ,q$Y:()=>ry,r_y:()=>rB,tG:()=>N,vpM:()=>e2});var r=i(95606),n=i(88362),s=i(32605),o=i(66808),a=i(41452),l=i(64102),h=i(27435),d=i(53889),u=i(51643),c=i(19860),f=i(29502),m=i(66389);let g=new WeakMap,p=!1;function _({view:e,element:t,text:i,isDirectHost:n=!0,keepOnFocus:s=!1}){let o=e.document;function a(i){let r={text:i,isDirectHost:n,keepOnFocus:s,hostElement:n?t:null};g.get(o).set(t,r),e.change(e=>b([[t,r]],e))}g.has(o)||(g.set(o,new Map),o.registerPostFixer(e=>b(g.get(o),e)),o.on("change:isComposing",()=>{e.change(e=>b(g.get(o),e))},{priority:"high"})),t.is("editableElement")&&t.on("change:placeholder",(e,t,i)=>a(i)),t.placeholder?a(t.placeholder):i&&a(i),i&&(p||(0,r.FF)("enableViewPlaceholder-deprecated-text-option"),p=!0)}function w(e,t){return!!t.hasClass("ck-placeholder")&&(e.removeClass("ck-placeholder",t),!0)}function b(e,t){let i=[],r=!1;for(let[n,s]of e)s.isDirectHost&&(i.push(n),y(t,n,s)&&(r=!0));for(let[n,s]of e){if(s.isDirectHost)continue;let e=function(e){if(e.childCount){let t=e.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}(n);e!==s.hostElement&&s.hostElement&&(t.removeAttribute("data-placeholder",s.hostElement),w(t,s.hostElement),s.hostElement=null,r=!0),e&&!i.includes(e)&&(s.hostElement=e,y(t,n,s)&&(r=!0))}return r}function y(e,t,i){let{text:r,isDirectHost:n,hostElement:s}=i,o=!1;if(s.getAttribute("data-placeholder")!==r&&(e.setAttribute("data-placeholder",r,s),o=!0),(n||1==t.childCount)&&function(e,t){if(!e.isAttached()||function(e){for(let t of e.getChildren())if(!t.is("uiElement"))return!0;return!1}(e))return!1;let i=e.document,r=i.selection.anchor;return(!i.isComposing||!r||r.parent!==e)&&(!!t||!i.isFocused||!!r&&r.parent!==e)}(s,i.keepOnFocus))!s.hasClass("ck-placeholder")&&(e.addClass("ck-placeholder",s),1)&&(o=!0);else w(e,s)&&(o=!0);return o}class v{is(){throw Error("is() method is abstract")}}class P extends(0,r.Mm)(v){document;parent;constructor(e){super(),this.document=e,this.parent=null}get index(){let e;if(!this.parent)return null;if(-1==(e=this.parent.getChildIndex(this)))throw new r.Yb("view-node-not-found-in-parent",this);return e}get nextSibling(){let e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){let 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(){let e=[],t=this;for(;t.parent;)e.unshift(t.index),t=t.parent;return e}getAncestors(e={}){let t=[],i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){let i=this.getAncestors(t),r=e.getAncestors(t),n=0;for(;i[n]==r[n]&&i[n];)n++;return 0===n?null:i[n-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;let t=this.getPath(),i=e.getPath(),n=(0,r.ww)(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n]<i[n]}}isAfter(e){return this!=e&&this.root===e.root&&!this.isBefore(e)}_remove(){this.parent._removeChildren(this.index)}_fireChange(e,t,i){this.fire(`change:${e}`,t,i),this.parent&&this.parent._fireChange(e,t,i)}toJSON(){let e={path:this.getPath(),type:"Node"};return this!==this.root&&this.root.is("rootElement")&&(e.root=this.root.toJSON()),e}}P.prototype.is=function(e){return"node"===e||"view:node"===e};class C extends P{_textData;constructor(e,t){super(e),this._textData=t}get data(){return this._textData}get _data(){return this.data}set _data(e){this._fireChange("text",this),this._textData=e}isSimilar(e){return e instanceof C&&(this===e||this.data===e.data)}toJSON(){let e=super.toJSON();return e.type="Text",e.data=this.data,e}_clone(){return new C(this.document,this.data)}}C.prototype.is=function(e){return"$text"===e||"view:$text"===e||"text"===e||"view:text"===e||"node"===e||"view:node"===e};class A extends v{textNode;data;offsetInText;constructor(e,t,i){if(super(),this.textNode=e,t<0||t>e.data.length)throw new r.Yb("view-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.data.length)throw new r.Yb("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}getAncestors(e={}){let t=[],i=e.includeSelf?this.textNode:this.parent;for(;null!==i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}}A.prototype.is=function(e){return"$textProxy"===e||"view:$textProxy"===e||"textProxy"===e||"view:textProxy"===e};class k{_consumables=new Map;add(e,t){let i;if(e.is("$text")||e.is("documentFragment"))return void this._consumables.set(e,!0);this._consumables.has(e)?i=this._consumables.get(e):(i=new S(e),this._consumables.set(e,i)),i.add(t?E(t):e._getConsumables())}test(e,t){let i=this._consumables.get(e);return void 0===i?null:e.is("$text")||e.is("documentFragment")?i:i.test(E(t))}consume(e,t){if(e.is("$text")||e.is("documentFragment"))return!!this.test(e,t)&&(this._consumables.set(e,!1),!0);let i=this._consumables.get(e);return void 0!==i&&i.consume(E(t))}revert(e,t){let i=this._consumables.get(e);void 0!==i&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):i.revert(E(t)))}static createFrom(e,t){if(t||(t=new k),e.is("$text"))t.add(e);else if(e.is("element")||e.is("documentFragment"))for(let i of(t.add(e),e.getChildren()))k.createFrom(i,t);return t}}class S{element;_canConsumeName=null;_attributes=new Map;constructor(e){this.element=e}add(e){for(let[t,i]of(e.name&&(this._canConsumeName=!0),e.attributes))if(i){let e=this._attributes.get(t);e&&"boolean"!=typeof e||(e=new Map,this._attributes.set(t,e)),e.set(i,!0)}else if("style"==t||"class"==t)throw new r.Yb("viewconsumable-invalid-attribute",this);else this._attributes.set(t,!0)}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(let[t,i]of e.attributes){let e=this._attributes.get(t);if(void 0===e)return null;if(!1===e)return!1;if(!0!==e){if(i){let t=e.get(i);if(void 0===t)return null;if(!t)return!1}else for(let t of e.values())if(!t)return!1}}return!0}consume(e){if(!this.test(e))return!1;for(let[t,i]of(e.name&&(this._canConsumeName=!1),e.attributes)){let e=this._attributes.get(t);if("boolean"==typeof e)for(let[e]of this.element._getConsumables(t,i).attributes)this._attributes.set(e,!1);else if(i)for(let[,r]of this.element._getConsumables(t,i).attributes)e.set(r,!1);else for(let t of e.keys())e.set(t,!1)}return!0}revert(e){for(let[t,i]of(e.name&&(this._canConsumeName=!0),e.attributes)){let e=this._attributes.get(t);if(!1===e){this._attributes.set(t,!0);continue}if(void 0!==e&&!0!==e)if(i)!1===e.get(i)&&e.set(i,!0);else for(let t of e.keys())e.set(t,!0)}}}function E(e){let t=[];return"attributes"in e&&e.attributes&&R(t,e.attributes),"classes"in e&&e.classes&&R(t,e.classes,"class"),"styles"in e&&e.styles&&R(t,e.styles,"style"),{name:e.name||!1,attributes:t}}function R(e,t,i){if("string"==typeof t)return void e.push(i?[i,t]:[t]);for(let r of t)Array.isArray(r)?e.push(r):e.push(i?[i,r]:[r])}class x{_patterns=[];constructor(...e){this.add(...e)}add(...e){for(let t of e)("string"==typeof t||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(let t of e)for(let e of this._patterns){let i=this._isElementMatching(t,e);if(i)return{element:t,pattern:e,match:i}}return null}matchAll(...e){let t=[];for(let i of e)for(let e of this._patterns){let r=this._isElementMatching(i,e);r&&t.push({element:i,pattern:e,match:r})}return t.length>0?t:null}getElementName(){if(1!==this._patterns.length)return null;let e=this._patterns[0],t=e.name;return"function"==typeof e||!t||t instanceof RegExp?null:t}_isElementMatching(e,t){var i,n,s,o,a,l,h,d,u,c,f;let m;if("function"==typeof t){let i=t(e);return i&&"object"==typeof i?E(i):i}let g={};if(t.name&&(i=t.name,n=e.name,g.name=i instanceof RegExp?!!n.match(i):i===n,!g.name))return null;let p=[];return t.attributes&&(s=t.attributes,o=e,a=p,"object"!=typeof s||s instanceof RegExp||Array.isArray(s)?m=["class","style"]:(void 0!==s.style&&(0,r.FF)("matcher-pattern-deprecated-attributes-style-key",s),void 0!==s.class&&(0,r.FF)("matcher-pattern-deprecated-attributes-class-key",s)),!o._collectAttributesMatch(M(s),a,m))||t.classes&&(l=t.classes,h=e,d=p,!h._collectAttributesMatch(M(l,"class"),d))||t.styles&&(u=t.styles,c=e,f=p,!c._collectAttributesMatch(M(u,"style"),f))?null:(p.length&&(g.attributes=p),g)}}function O(e,t){return!0===e||e===t||e instanceof RegExp&&!!String(t).match(e)}function M(e,t){if(Array.isArray(e))return e.map(e=>"object"!=typeof e||e instanceof RegExp?t?[t,e,!0]:[e,!0]:((void 0===e.key||void 0===e.value)&&(0,r.FF)("matcher-pattern-missing-key-or-value",e),t?[t,e.key,e.value]:[e.key,e.value]));if("object"!=typeof e||e instanceof RegExp)return[t?[t,e,!0]:[e,!0]];let i=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&i.push(t?[t,r,e[r]]:[r,e[r]]);return i}class T{_styles;_cachedStyleNames=null;_cachedExpandedStyleNames=null;_styleProcessor;constructor(e){this._styles={},this._styleProcessor=e}get isEmpty(){return!Object.entries(this._styles).length}get size(){return this.isEmpty?0:this.getStyleNames().length}setTo(e){for(let[t,i]of(this.clear(),function(e){let t=null,i=0,r=0,n=null,s=new Map;if(""===e)return s;";"!=e.charAt(e.length-1)&&(e+=";");for(let o=0;o<e.length;o++){let a=e.charAt(o);if(null===t)switch(a){case":":n||(n=e.substr(i,o-i),r=o+1);break;case'"':case"'":t=a;break;case";":{let t=e.substr(r,o-r);n&&s.set(n.trim(),t.trim()),n=null,i=o+1}}else a===t&&(t=null)}return s}(e)))this._styleProcessor.toNormalizedForm(t,i,this._styles);return this}has(e){return!this.isEmpty&&Array.isArray(this._styleProcessor.getReducedForm(e,this._styles).find(([t])=>t===e))}set(e,t){if(this._cachedStyleNames=null,this._cachedExpandedStyleNames=null,(0,n.G)(e))for(let[t,i]of Object.entries(e))this._styleProcessor.toNormalizedForm(t,i,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){let t={};for(let i of(0,r.$r)(e)){let e=F(i),r=(0,s.J)(this._styles,e);if(r)I(t,e,r);else{let e=this.getAsString(i);void 0!==e&&this._styleProcessor.toNormalizedForm(i,e,t)}}Object.keys(t).length&&(function e(t,i){for(let r of Object.keys(i))null===t[r]||Array.isArray(t[r])||"object"!=typeof t[r]||"object"!=typeof i[r]?delete t[r]:(e(t[r],i[r]),Object.keys(t[r]).length||delete t[r])}(this._styles,t),this._cachedStyleNames=null,this._cachedExpandedStyleNames=null)}getNormalized(e){return this._styleProcessor.getNormalized(e,this._styles)}toString(){return this.isEmpty?"":this.getStylesEntries().map(e=>e.join(":")).sort().join(";")+";"}getAsString(e){if(this.isEmpty)return;if(this._styles[e]&&!(0,n.G)(this._styles[e]))return this._styles[e];let t=this._styleProcessor.getReducedForm(e,this._styles).find(([t])=>t===e);if(Array.isArray(t))return t[1]}getStyleNames(e=!1){return this.isEmpty?[]:e?(this._cachedExpandedStyleNames||=this._styleProcessor.getStyleNames(this._styles),this._cachedExpandedStyleNames):(this._cachedStyleNames||=this.getStylesEntries().map(([e])=>e),this._cachedStyleNames)}
1keys(){return this.getStyleNames()}clear(){this._styles={},this._cachedStyleNames=null,this._cachedExpandedStyleNames=null}isSimilar(e){if(this.size!==e.size)return!1;for(let t of this.getStyleNames())if(!e.has(t)||e.getAsString(t)!==this.getAsString(t))return!1;return!0}getStylesEntries(){let e=[];for(let t of Object.keys(this._styles))e.push(...this._styleProcessor.getReducedForm(t,this._styles));return e}_clone(){let e=new this.constructor(this._styleProcessor);return e.set(this.getNormalized()),e}_getTokensMatch(e,t){let i=[];for(let r of this.getStyleNames(!0))if(O(e,r)){if(!0===t){i.push(r);continue}O(t,this.getAsString(r))&&i.push(r)}return i.length?i:void 0}_getConsumables(e){let t=[];if(e)for(let i of(t.push(e),this._styleProcessor.getRelatedStyles(e)))t.push(i);else for(let e of this.getStyleNames()){for(let i of this._styleProcessor.getRelatedStyles(e))t.push(i);t.push(e)}return t}_canMergeFrom(e){for(let t of e.getStyleNames())if(this.has(t)&&this.getAsString(t)!==e.getAsString(t))return!1;return!0}_mergeFrom(e){for(let t of e.getStyleNames())this.has(t)||this.set(t,e.getAsString(t))}_isMatching(e){for(let t of e.getStyleNames())if(!this.has(t)||this.getAsString(t)!==e.getAsString(t))return!1;return!0}}class N{_normalizers;_extractors;_reducers;_consumables;constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,i){if((0,n.G)(t))return void I(i,F(e),t);if(this._normalizers.has(e)){let{path:r,value:n}=this._normalizers.get(e)(t);I(i,r,n)}else I(i,e,t)}getNormalized(e,t){if(!e)return(0,o.h)({},t);if(void 0!==t[e])return t[e];if(this._extractors.has(e)){let i=this._extractors.get(e);if("string"==typeof i)return(0,s.J)(t,i);let r=i(e,t);if(r)return r}return(0,s.J)(t,F(e))}getReducedForm(e,t){let i=this.getNormalized(e,t);return void 0===i?[]:this._reducers.has(e)?this._reducers.get(e)(i):[[e,i]]}getStyleNames(e){let t=new Set;for(let i of this._consumables.keys()){let r=this.getNormalized(i,e);r&&("object"!=typeof r||Object.keys(r).length)&&t.add(i)}for(let i of Object.keys(e))t.add(i);return Array.from(t)}getRelatedStyles(e){return this._consumables.get(e)||[]}setNormalizer(e,t){this._normalizers.set(e,t)}setExtractor(e,t){this._extractors.set(e,t)}setReducer(e,t){this._reducers.set(e,t)}setStyleRelation(e,t){for(let i of(this._mapStyleNames(e,t),t))this._mapStyleNames(i,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function F(e){return e.replace("-",".")}function I(e,t,i){let r=i;(0,n.G)(i)&&(r=(0,o.h)({},(0,s.J)(e,t),i)),(0,a.h)(e,t,r)}class B{_set=new Set;get isEmpty(){return 0==this._set.size}get size(){return this._set.size}has(e){return this._set.has(e)}keys(){return Array.from(this._set.keys())}setTo(e){for(let t of(this.clear(),e.split(/\s+/)))t&&this._set.add(t);return this}set(e){for(let t of(0,r.$r)(e))t&&this._set.add(t)}remove(e){for(let t of(0,r.$r)(e))this._set.delete(t)}clear(){this._set.clear()}toString(){return Array.from(this._set).join(" ")}isSimilar(e){if(this.size!==e.size)return!1;for(let t of this.keys())if(!e.has(t))return!1;return!0}_clone(){let e=new this.constructor;return e._set=new Set(this._set),e}_getTokensMatch(e){let t=[];if(!0===e){for(let e of this._set.keys())t.push(e);return t}if("string"==typeof e){for(let i of e.split(/\s+/))if(!this._set.has(i))return;else t.push(i);return t}for(let i of this._set.keys())i.match(e)&&t.push(i);return t.length?t:void 0}_getConsumables(e){return e?[e]:this.keys()}_canMergeFrom(){return!0}_mergeFrom(e){for(let t of e._set.keys())this._set.has(t)||this._set.add(t)}_isMatching(e){for(let t of e._set.keys())if(!this._set.has(t))return!1;return!0}}class D extends P{name;_unsafeAttributesToRender=[];_attrs;_children;_customProperties=new Map;get _classes(){return this._attrs.get("class")}get _styles(){return this._attrs.get("style")}constructor(e,t,i,r){super(e),this.name=t,this._attrs=this._parseAttributes(i),this._children=[],r&&this._insertChild(0,r)}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){for(let e of(this._classes&&(yield"class"),this._styles&&(yield"style"),this._attrs.keys()))"class"!=e&&"style"!=e&&(yield e)}*getAttributes(){for(let[e,t]of this._attrs.entries())yield[e,String(t)]}getAttribute(e){return this._attrs.has(e)?String(this._attrs.get(e)):void 0}hasAttribute(e,t){if(!this._attrs.has(e))return!1;if(void 0!==t)if($(this.name,e)||V(this.name,e))return this._attrs.get(e).has(t);else return this._attrs.get(e)===t;return!0}isSimilar(e){if(!(e instanceof D))return!1;if(this===e)return!0;
1if(this.name!=e.name||this._attrs.size!==e._attrs.size)return!1;for(let[t,i]of this._attrs){let r=e._attrs.get(t);if(void 0===r)return!1;if("string"==typeof i||"string"==typeof r){if(r!==i)return!1}else if(!i.isSimilar(r))return!1}return!0}hasClass(...e){for(let t of e)if(!this._classes||!this._classes.has(t))return!1;return!0}getClassNames(){let e=this._classes?this._classes.keys():[],t=e[Symbol.iterator]();return Object.assign(e,{next:t.next.bind(t)})}getStyle(e){return this._styles&&this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles&&this._styles.getNormalized(e)}getStyleNames(e){return this._styles?this._styles.getStyleNames(e):[]}hasStyle(...e){for(let t of e)if(!this._styles||!this._styles.has(t))return!1;return!0}findAncestor(...e){let t=new x(...e),i=this.parent;for(;i&&!i.is("documentFragment");){if(t.match(i))return i;i=i.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){let e=this._classes?this._classes.keys().sort().join(","):"",t=this._styles&&String(this._styles),i=Array.from(this._attrs).filter(([e])=>"style"!=e&&"class"!=e).map(e=>`${e[0]}="${e[1]}"`).sort().join(" ");return this.name+(""==e?"":` class="${e}"`)+(t?` style="${t}"`:"")+(""==i?"":` ${i}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}toJSON(){let e=super.toJSON();if(e.name=this.name,e.type="Element",this._attrs.size&&(e.attributes=Object.fromEntries(this.getAttributes())),this._children.length>0)for(let t of(e.children=[],this._children))e.children.push(t.toJSON());return e}_clone(e=!1){let t=[];if(e)for(let i of this.getChildren())t.push(i._clone(e));let i=new this.constructor(this.document,this.name,this._attrs,t);return i._customProperties=new Map(this._customProperties),i.getFillerOffset=this.getFillerOffset,i._unsafeAttributesToRender=this._unsafeAttributesToRender,i}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this,{index:e});let i=0;for(let n of function(e,t){if("string"==typeof t)return[new C(e,t)];(0,r.xZ)(t)||(t=[t]);let i=[];for(let r of t)"string"==typeof r?i.push(new C(e,r)):r instanceof A?i.push(new C(e,r.data)):i.push(r);return i}(this.document,t))null!==n.parent&&n._remove(),n.parent=this,n.document=this.document,this._children.splice(e,0,n),e++,i++;return i}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let i=e;i<e+t;i++)this._children[i].parent=null;return this._children.splice(e,t)}_setAttribute(e,t,i=!0){if(this._fireChange("attributes",this),$(this.name,e)||V(this.name,e)){let r=this._attrs.get(e);r||(r=$(this.name,e)?new T(this.document.stylesProcessor):new B,this._attrs.set(e,r)),i?r.setTo(String(t)):$(this.name,e)?Array.isArray(t)?r.set(t[0],t[1]):r.set(t):r.set("string"==typeof t?t.split(/\s+/):t)}else this._attrs.set(e,String(t))}_removeAttribute(e,t){if(this._fireChange("attributes",this),void 0!==t&&($(this.name,e)||V(this.name,e))){let i=this._attrs.get(e);return!!i&&(V(this.name,e)&&"string"==typeof t&&(t=t.split(/\s+/)),i.remove(t),!!i.isEmpty&&this._attrs.delete(e))}return this._attrs.delete(e)}_addClass(e){this._setAttribute("class",e,!1)}_removeClass(e){this._removeAttribute("class",e)}_setStyle(e,t){"string"!=typeof e?this._setAttribute("style",e,!1):this._setAttribute("style",[e,t],!1)}_removeStyle(e){this._removeAttribute("style",e)}_collectAttributesMatch(e,t,i){for(let[r,n,s]of e){let e=!1,o=!1;for(let[a,l]of this._attrs)if(!(i&&i.includes(a))&&O(r,a))if(e=!0,"string"==typeof l){if(O(n,l))t.push([a]),o=!0;else if(!(r instanceof RegExp))return!1}else{let e=l._getTokensMatch(n,s||!0);if(e)for(let i of(o=!0,e))t.push([a,i]);else if(!(r instanceof RegExp))return!1}if(!e||!o)return!1}return!0}_getConsumables(e,t){let i=[];if(e){let r=this._attrs.get(e);if(void 0!==r)if("string"==typeof r)i.push([e]);else for(let n of r._getConsumables(t))i.push([e,n])}else for(let[e,t]of this._attrs)if("string"==typeof t)i.push([e]);else for(let r of t._getConsumables())i.push([e,r]);return{name:!e,attributes:i}}_canMergeAttributesFrom(e){if(this.name!=e.name)return!1;for(let[t,i]of e._attrs){let e=this._attrs.get(t);if(void 0!==e){if("string"==typeof e||"string"==typeof i){if(e!==i)return!1}else if(!e._canMergeFrom(i))return!1}}return!0}_mergeAttributesFrom(e){for(let[t,i]of(this._fireChange("attributes",this),e._attrs)){let e=this._attrs.get(t);void 0===e||"string"==typeof e||"string"==typeof i?this._setAttribute(t,i):e._mergeFrom(i)}}_canSubtractAttributesOf(e){if(this.name!=e.name)return!1;for(let[t,i]of e._attrs){let e=this._attrs.get(t);if(void 0===e)return!1;if("string"==typeof e||"string"==typeof i){if(e!==i)return!1}else if(!e._isMatching(i))return!1}return!0}_subtractAttributesOf(e){for(let[t,i]of(this._fireChange("attributes",this),e._attrs)){let e=this._attrs.get(t);"string"==typeof e||"string"==typeof i?this._attrs.delete(t):(e.remove(i.keys()),e.isEmpty&&this._attrs.delete(t))}}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}_parseAttributes(e){let t=(0,r.av)(e);for(let[e,i]of t)if(null===i)t.delete(e);else if($(this.name,e)){let r=i instanceof T?i._clone():new T(this.document.stylesProcessor).setTo(String(i));t.set(e,r)}else if(V(this.name,e)){let r=i instanceof B?i._clone():new B().setTo(String(i));t.set(e,r)}else"string"!=typeof i&&t.set(e,String(i));return t}}function V(e,t){return"class"==t||"a"==e&&"rel"==t}function $(e,t){return"style"==t}D.prototype.is=function(e,t){return t?t===this.name&&("element"===e||"view:element"===e):"element"===e||"view:element"===e||"node"===e||"view:node"===e};class L extends D{constructor(e,t,i,r){super(e,t,i,r),this.getFillerOffset=q}toJSON(){let e=super.toJSON();return e.type="ContainerElement",e}}function q(){let e=[...this.getChildren()],t=e[this.childCount-1];if(t&&t.is("element","br"))return this.childCount;for(let t of e)if(!t.is("uiElement"))return null;return this.childCount}L.prototype.is=function(e,t){return t?t===this.name&&("containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class W extends(0,r.VM)(L){constructor(e,t,i,r){super(e,t,i,r),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("placeholder",void 0),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",t=>t&&e.selection.editableElement==this),this.listenTo(e.selection,"change",()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this})}destroy(){this.stopListening()}toJSON(){let e=super.toJSON();return e.type="EditableElement",e.isReadOnly=this.isReadOnly,e.isFocused=this.isFocused,e}}W.prototype.is=function(e,t){return t?t===this.name&&("editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};let Y=Symbol("rootName");class J extends W{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(Y)}set rootName(e){this._setCustomProperty(Y,e)}
1toJSON(){return this.rootName}set _name(e){this.name=e}}J.prototype.is=function(e,t){return t?t===this.name&&("rootElement"===e||"view:rootElement"===e||"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e):"rootElement"===e||"view:rootElement"===e||"editableElement"===e||"view:editableElement"===e||"containerElement"===e||"view:containerElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class j{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new r.Yb("view-tree-walker-no-start-position",null);if(e.direction&&"forward"!=e.direction&&"backward"!=e.direction)throw new r.Yb("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=z._createAt(e.startPosition):this._position=z._createAt(e.boundaries["backward"==e.direction?"end":"start"]),this.direction=e.direction||"forward",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i;do i=this.position,t=this.next();while(!t.done&&e(t.value));t.done||(this._position=i)}jumpTo(e){this._boundaryStartParent&&e.isBefore(this.boundaries.start)?e=this.boundaries.start:this._boundaryEndParent&&e.isAfter(this.boundaries.end)&&(e=this.boundaries.end),this._position=e.clone()}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let e,t=this.position.clone(),i=this.position,r=t.parent;if(null===r.parent&&t.offset===r.childCount||r===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};if(r&&r.is("view:$text")){if(t.isAtEnd)return this._position=z._createAfter(r),this._next();e=r.data[t.offset]}else e=r.getChild(t.offset);if("string"==typeof e){let e;e=this.singleCharacters?1:(r===this._boundaryEndParent?this.boundaries.end.offset:r.data.length)-t.offset;let n=new A(r,t.offset,e);return t.offset+=e,this._position=t,this._formatReturnValue("text",n,i,t,e)}if(e&&e.is("view:element")){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}else t=new z(e,0);return this._position=t,this._formatReturnValue("elementStart",e,i,t,1)}if(e&&e.is("view:$text")){let r;if(this.singleCharacters)return t=new z(e,0),this._position=t,this._next();let n=e.data.length;return e==this._boundaryEndParent?(r=new A(e,0,n=this.boundaries.end.offset),t=z._createAfter(r)):(r=new A(e,0,e.data.length),t.offset++),this._position=t,this._formatReturnValue("text",r,i,t,n)}return(t=z._createAfter(r),this._position=t,this.ignoreElementEnd)?this._next():this._formatReturnValue("elementEnd",r,i,t)}_previous(){let e,t=this.position.clone(),i=this.position,r=t.parent;if(null===r.parent&&0===t.offset||r==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0,value:void 0};if(r.is("view:$text")){if(t.isAtStart)return this._position=z._createBefore(r),this._previous();e=r.data[t.offset-1]}else e=r.getChild(t.offset-1);if("string"==typeof e){let e;if(this.singleCharacters)e=1;else{let i=r===this._boundaryStartParent?this.boundaries.start.offset:0;e=t.offset-i}t.offset-=e;let n=new A(r,t.offset,e);return this._position=t,this._formatReturnValue("text",n,i,t,e)}if(e&&e.is("view:element"))return this.shallow?(t.offset--,this._position=t,this._formatReturnValue("elementStart",e,i,t,1)):(t=new z(e,e.childCount),this._position=t,this.ignoreElementEnd)?this._previous():this._formatReturnValue("elementEnd",e,i,t);if(e&&e.is("view:$text")){let r;if(this.singleCharacters)return t=new z(e,e.data.length),this._position=t,this._previous();let n=e.data.length;if(e==this._boundaryStartParent){let i=this.boundaries.start.offset;n=(r=new A(e,i,e.data.length-i)).data.length,t=z._createBefore(r)}else r=new A(e,0,e.data.length),t.offset--;return this._position=t,this._formatReturnValue("text",r,i,t,n)}return t=z._createBefore(r),this._position=t,this._formatReturnValue("elementStart",r,i,t,1)}_formatReturnValue(e,t,i,r,n){return t.is("view:$textProxy")&&(t.offsetInText+t.data.length==t.textNode.data.length&&("forward"!=this.direction||this.boundaries&&this.boundaries.end.isEqual(this.position)?i=z._createAfter(t.textNode):(r=z._createAfter(t.textNode),this._position=r)),0===t.offsetInText&&("backward"!=this.direction||this.boundaries&&this.boundaries.start.isEqual(this.position)?i=z._createBefore(t.textNode):(r=z._createBefore(t.textNode),this._position=r))),{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:r,length:n}}}}class z extends v{parent;offset;constructor(e,t){super(),this.parent=e,this.offset=t}get nodeAfter(){return this.parent.is("$text")?null:this.parent.getChild(this.offset)||null}get nodeBefore(){return this.parent.is("$text")?null:this.parent.getChild(this.offset-1)||null}get isAtStart(){return 0===this.offset}get isAtEnd(){let 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 W);)if(!e.parent)return null;else e=e.parent;return e}getShiftedBy(e){let t=z._createAt(this),i=t.offset+e;return t.offset=i<0?0:i,t}getLastMatchingPosition(e,t={}){t.startPosition=this;let i=new j(t);return i.skip(e),i.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){let t=this.getAncestors(),i=e.getAncestors(),r=0;for(;t[r]==i[r]&&t[r];)r++;return 0===r?null:t[r-1]}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return"before"==this.compareWith(e)}isAfter(e){return"after"==this.compareWith(e)}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";let t=this.parent.is("node")?this.parent.getPath():[],i=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),i.push(e.offset);let n=(0,r.ww)(t,i);switch(n){case"prefix":return"before";case"extension":return"after";default:return t[n]<i[n]?"before":"after"}}getWalker(e={}){return e.startPosition=this,new j(e)}clone(){return new z(this.parent,this.offset)}toJSON(){return{parent:this.parent.toJSON(),offset:this.offset}}static _createAt(e,t){if(e instanceof z)return new this(e.parent,e.offset);if("end"==t)t=e.is("$text")?e.data.length:e.childCount;else if("before"==t)return this._createBefore(e);else if("after"==t)return this._createAfter(e);else if(0!==t&&!t)throw new r.Yb("view-createpositionat-offset-required",e);return new z(e,t)}static _createAfter(e){if(e.is("$textProxy"))return new z(e.textNode,e.offsetInText+e.data.length);if(!e.parent)throw new r.Yb("view-position-after-root",e,{root:e});return new z(e.parent,e.index+1)}static _createBefore(e){if(e.is("$textProxy"))return new z(e.textNode,e.offsetInText);if(!e.parent)throw new r.Yb("view-position-before-root",e,{root:e});return new z(e.parent,e.index)}}z.prototype.is=function(e){return"position"===e||"view:position"===e};class U extends v{start;end;constructor(e,t=null){super(),this.start=e.clone(),this.end=t?t.clone():e.clone()}*[Symbol.iterator](){yield*new j({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){return this.start.parent===this.end.parent}get root(){return this.start.root}getEnlarged(){let e=this.start.getLastMatchingPosition(K,{direction:"backward"}),t=this.end.getLastMatchingPosition(K);return e.parent.is("$text")&&e.isAtStart&&(e=z._createBefore(e.parent)),t.parent.is("$text")&&t.isAtEnd&&(t=z._createAfter(t.parent)),new U(e,t)}getTrimmed(){let e=this.start.getLastMatchingPosition(K);if(e.isAfter(this.end)||e.isEqual(this.end))return new U(e,e);let t=this.end.getLastMatchingPosition(K,{direction:"backward"}),i=e.nodeAfter,r=t.nodeBefore;return i&&i.is("$text")&&(e=new z(i,0)),r&&r.is("$text")&&(t=new z(r,r.data.length)),new U(e,t)}isEqual(e){return this==e||this.start.isEqual(e.start)&&this.end.isEqual(e.end)}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,t=!1){e.isCollapsed&&(t=!1);let i=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),r=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return i&&r}getDifference(e){let t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new U(this.start,e.start)),this.containsPosition(e.end)&&t.pu
1sh(new U(e.end,this.end))):t.push(this.clone()),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,i=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(i=e.end),new U(t,i)}return null}getWalker(e={}){return e.boundaries=this,new j(e)}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;let e=this.start.nodeAfter,t=this.end.nodeBefore;return(this.start.parent.is("$text")&&this.start.isAtEnd&&this.start.parent.nextSibling&&(e=this.start.parent.nextSibling),this.end.parent.is("$text")&&this.end.isAtStart&&this.end.parent.previousSibling&&(t=this.end.parent.previousSibling),e&&e.is("element")&&e===t)?e:null}clone(){return new U(this.start,this.end)}*getItems(e={}){for(let t of(e.boundaries=this,e.ignoreElementEnd=!0,new j(e)))yield t.item}*getPositions(e={}){e.boundaries=this;let t=new j(e);for(let e of(yield t.position,t))yield e.nextPosition}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}static _createFromParentsAndOffsets(e,t,i,r){return new this(new z(e,t),new z(i,r))}static _createFromPositionAndShift(e,t){let i=e.getShiftedBy(t);return t>0?new this(e,i):new this(i,e)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){let t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(z._createBefore(e),t)}}function K(e){return!!(e.item.is("attributeElement")||e.item.is("uiElement"))}U.prototype.is=function(e){return"range"===e||"view:range"===e};class H extends(0,r.Mm)(v){_ranges;_lastRangeBackward;_isFake;_fakeSelectionLabel;constructor(...e){super(),this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",e.length&&this.setTo(...e)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;let e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;let 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(let e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(let t of this._ranges)(!e||t.start.isBefore(e.start))&&(e=t);return e?e.clone():null}getLastRange(){let e=null;for(let t of this._ranges)(!e||t.end.isAfter(e.end))&&(e=t);return e?e.clone():null}getFirstPosition(){let e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){let e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake||this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel||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(let t of this._ranges){let i=!1;for(let r of e._ranges)if(t.isEqual(r)){i=!0;break}if(!i)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;let t=(0,r.U9)(this.getRanges());if(t!=(0,r.U9)(e.getRanges()))return!1;if(0==t)return!0;for(let t of this.getRanges()){t=t.getTrimmed();let i=!1;for(let r of e.getRanges())if(r=r.getTrimmed(),t.start.isEqual(r.start)&&t.end.isEqual(r.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,i,n]=e;if("object"==typeof i&&(n=i,i=void 0),null===t)this._setRanges([]),this._setFakeOptions(n);else if(t instanceof H||t instanceof G)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof U)this._setRanges([t],n&&n.backward),this._setFakeOptions(n);else if(t instanceof z)this._setRanges([new U(t)]),this._setFakeOptions(n);else if(t instanceof P){let e,s=!!n&&!!n.backward;if(void 0===i)throw new r.Yb("view-selection-setto-required-second-parameter",this);e="in"==i?U._createIn(t):"on"==i?U._createOn(t):new U(z._createAt(t,i)),this._setRanges([e],s),this._setFakeOptions(n)}else if((0,r.xZ)(t))this._setRanges(t,n&&n.backward),this._setFakeOptions(n);else throw new r.Yb("view-selection-setto-not-selectable",this);this.fire("change")}setFocus(e,t){if(null===this.anchor)throw new r.Yb("view-selection-setfocus-no-ranges",this);let i=z._createAt(e,t);if("same"==i.compareWith(this.focus))return;let n=this.anchor;this._ranges.pop(),"before"==i.compareWith(n)?this._addRange(new U(i,n),!0):this._addRange(new U(n,i)),this.fire("change")}toJSON(){let e={ranges:Array.from(this.getRanges()).map(e=>e.toJSON())};return this.isBackward&&(e.isBackward=!0),this.isFake&&(e.isFake=!0),e}_setRanges(e,t=!1){for(let t of(e=Array.from(e),this._ranges=[],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 U))throw new r.Yb("view-selection-add-range-not-range",this);this._pushRange(e),this._lastRangeBackward=!!t}_pushRange(e){for(let t of this._ranges)if(e.isIntersecting(t))throw new r.Yb("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new U(e.start,e.end))}}H.prototype.is=function(e){return"selection"===e||"view:selection"===e};class G extends(0,r.Mm)(v){_selection;constructor(...e){super(),this._selection=new H,this._selection.delegate("change").to(this),e.length&&this._selection.setTo(...e)}get isFake(){return this._selection.isFake}get fakeSelectionLabel(){return this._selection.fakeSelectionLabel}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get isCollapsed(){return this._selection.isCollapsed}get rangeCount(){return this._selection.rangeCount}get isBackward(){return this._selection.isBackward}get editableElement(){return this._selection.editableElement}get _ranges(){return this._selection._ranges}*getRanges(){yield*this._selection.getRanges()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getSelectedElement(){return this._selection.getSelectedElement()}isEqual(e){return this._selection.isEqual(e)}isSimilar(e){return this._selection.isSimilar(e)}toJSON(){return this._selection.toJSON()}_setTo(...e){this._selection.setTo(...e)}_setFocus(e,t){this._selection.setFocus(e,t)}}G.prototype.is=function(e){return"selection"===e||"documentSelection"==e||"view:selection"==e||"view:documentSelection"==e};class Z extends r.vY{startRange;_eventPhase;_currentTarget;constructor(e,t,i){super(e,t),this.startRange=i,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}let Q=Symbol("bubblingEmitter"),X=Symbol("bubblingCallbacks"),ee=Symbol("bubblingContexts");function et(e){class t extends e{fire(e,...t){try{let i=e instanceof r.vY?e:new r.vY(this,e),n=en(this),s=eo(this);if(ei(i,"capturing",this),er(n,"$capture",i,...t))return i.return;let o=i.startRange||this.selection.getFirstRange(),a=o?o.getContainedElement():null,l=!!a&&function(e,t){for(let i of e)if(i(t))return!0;return!1}(s,a),h=a||function(e){if(!e)return null;let t=e.start.parent,i=e.end.parent,r=t.getPath(),n=i.getPath();return r.length>n.length?t:i}(o);if(ei(i,"atTarget",h),!l){if(er(n,"$text",i,...t))return i.return;ei(i,"bubbling",h)}for(;h;){if(h.is("element")&&er(n,h,i,...t))return i.return;h=h.parent,ei(i,"bubbling",h)}return ei(i,"bubbling",this),er(n,"$document",i,...t),i.return}catch(e){r.Yb.rethrowUnexpectedError(e,this)}}_addEventListener(e,t,i){var n,s,o;let a=(0,r.$r)(i.context||"$document"),l=en(this),h=es(this);for(let e of a)"function"==typeof e&&eo(this).add(e);let d=(n=this,s=a,o=t,function(e,t){let{currentTarget:i,eventArgs:r}=t;if("string"==typeof i){s.includes(i)&&o.call(n,e,...r);return}if(i.is("rootElement")&&s.includes("$root")||s.includes(i.name))return void o.
1call(n,e,...r);for(let t of s)if("function"==typeof t&&t(i))return void o.call(n,e,...r)});h.set(t,d),this.listenTo(l,e,d,i)}_removeEventListener(e,t){let i=en(this),r=es(this),n=r.get(t);n&&(r.delete(t),this.stopListening(i,e,n))}}return t}function ei(e,t,i){e instanceof Z&&(e._eventPhase=t,e._currentTarget=i)}function er(e,t,i,...r){return e.fire(i,{currentTarget:t,eventArgs:r}),!!i.stop.called}function en(e){return e[Q]||(e[Q]=new((0,r.Mm)())),e[Q]}function es(e){return e[X]||(e[X]=new Map),e[X]}function eo(e){return e[ee]||(e[ee]=new Set),e[ee]}class ea extends et((0,r.VM)()){selection;roots;stylesProcessor;_postFixers=new Set;constructor(e){super(),this.selection=new G,this.roots=new r.pM({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.forEach(e=>e.destroy()),this.stopListening()}_callPostFixers(e){let t=!1;do for(let i of this._postFixers)if(t=i(e))break;while(t)}}class el extends D{static DEFAULT_PRIORITY=10;_priority=10;_id=null;_clonesGroup=null;constructor(e,t,i,r){super(e,t,i,r),this.getFillerOffset=eh}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(null===this.id)throw new r.Yb("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}isSimilar(e){return null!==this.id||null!==e.id?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}toJSON(){let e=super.toJSON();return e.type="AttributeElement",e}_clone(e=!1){let t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}_canMergeAttributesFrom(e){return null===this.id&&null===e.id&&this.priority===e.priority&&super._canMergeAttributesFrom(e)}_canSubtractAttributesOf(e){return null===this.id&&null===e.id&&this.priority===e.priority&&super._canSubtractAttributesOf(e)}}function eh(){if(ed(this))return null;let e=this.parent;for(;e&&e.is("attributeElement");){if(ed(e)>1)return null;e=e.parent}return!e||ed(e)>1?null:this.childCount}function ed(e){return Array.from(e.getChildren()).filter(e=>!e.is("uiElement")).length}el.prototype.is=function(e,t){return t?t===this.name&&("attributeElement"===e||"view:attributeElement"===e||"element"===e||"view:element"===e):"attributeElement"===e||"view:attributeElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class eu extends D{constructor(e,t,i,r){super(e,t,i,r),this.getFillerOffset=ec}toJSON(){let e=super.toJSON();return e.type="EmptyElement",e}_insertChild(e,t){if(t&&(t instanceof P||Array.from(t).length>0))throw new r.Yb("view-emptyelement-cannot-add",[this,t]);return 0}}function ec(){return null}eu.prototype.is=function(e,t){return t?t===this.name&&("emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e):"emptyElement"===e||"view:emptyElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class ef extends D{constructor(e,t,i,r){super(e,t,i,r),this.getFillerOffset=em}_insertChild(e,t){if(t&&(t instanceof P||Array.from(t).length>0))throw new r.Yb("view-uielement-cannot-add",[this,t]);return 0}render(e,t){return this.toDomElement(e)}toDomElement(e){let t=e.createElement(this.name);for(let e of this.getAttributeKeys())t.setAttribute(e,this.getAttribute(e));return t}toJSON(){let e=super.toJSON();return e.type="UIElement",e}}function em(){return null}ef.prototype.is=function(e,t){return t?t===this.name&&("uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e):"uiElement"===e||"view:uiElement"===e||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class eg extends D{constructor(e,t,i,r){super(e,t,i,r),this.getFillerOffset=ep}toJSON(){let e=super.toJSON();return e.type="RawElement",e}_insertChild(e,t){if(t&&(t instanceof P||Array.from(t).length>0))throw new r.Yb("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}function ep(){return null}eg.prototype.is=function(e,t){return t?t===this.name&&("rawElement"===e||"view:rawElement"===e||"element"===e||"view:element"===e):"rawElement"===e||"view:rawElement"===e||e===this.name||e==="view:"+this.name||"element"===e||"view:element"===e||"node"===e||"view:node"===e};class e_ extends(0,r.Mm)(v){document;_children=[];_customProperties=new Map;constructor(e,t){super(),this.document=e,t&&this._insertChild(0,t)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return 0===this.childCount}get root(){return this}get parent(){return null}get name(){}get getFillerOffset(){}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}toJSON(){let e=[];for(let t of this._children)e.push(t.toJSON());return e}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,t){var i,n;this._fireChange("children",this,{index:e});let s=0;for(let o of(i=this.document,"string"==typeof(n=t)?[new C(i,n)]:((0,r.xZ)(n)||(n=[n]),Array.from(n).map(e=>"string"==typeof e?new C(i,e):e instanceof A?new C(i,e.data):e))))null!==o.parent&&o._remove(),o.parent=this,this._children.splice(e,0,o),e++,s++;return s}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let i=e;i<e+t;i++)this._children[i].parent=null;return this._children.splice(e,t)}_fireChange(e,t,i){this.fire(`change:${e}`,t,i)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}}e_.prototype.is=function(e){return"documentFragment"===e||"view:documentFragment"===e};class ew{document;_cloneGroups=new Map;_slotFactory=null;constructor(e){this.document=e}setSelection(...e){this.document.selection._setTo(...e)}setSelectionFocus(e,t){this.document.selection._setFocus(e,t)}createDocumentFragment(e){return new e_(this.document,e)}createText(e){return new C(this.document,e)}createAttributeElement(e,t,i={}){let r=new el(this.document,e,t);return"number"==typeof i.priority&&(r._priority=i.priority),i.id&&(r._id=i.id),i.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),r}createContainerElement(e,t,i={},r={}){var n;let s;(n=i,(0,l.Q)(n))?r=i:s=i;let o=new L(this.document,e,t,s);return r.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...r.renderUnsafeAttributes),o}createEditableElement(e,t,i={}){let r=new W(this.document,e,t);return i.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),r}createEmptyElement(e,t,i={}){let r=new eu(this.document,e,t);return i.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...i.renderUnsafeAttributes),r}createUIElement(e,t,i){let r=new ef(this.document,e,t);return i&&(r.render=i),r}createRawElement(e,t,i,r={}){let n=new eg(this.document,e,t);return i&&(n.render=i),r.renderUnsafeAttributes&&n._unsafeAttributesToRender.push(...r.renderUnsafeAttributes),n}setAttribute(e,t,i,r){void 0!==r?r._setAttribute(e,t,i):i._setAttribute(e,t)}removeAttribute(e,t,i){void 0!==i?i._removeAttribute(e,t):t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){(0,l.Q)(e)&&void 0===i?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}breakAttributes(e){return e instanceof z?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){let t=e.parent;if(!t.is("containerElement"))throw new r.Yb("view-writer-break-non-container-element",this.document);if(!t.parent)throw new r.Yb("view-writer-break-root",this.document);if(e.isAtStart)return z._createBefore(t);if(!e.isAtEnd){let i=t._clone(!1);this.insert(z._createAfter(t),i);let r=new U(e,z._createAt(t,"end")),n=new z(i,0);this.move(r,n)}return z._createAfter(t)}mergeAttributes(e){let t=e.offset,i=e.parent;if(i.is("$text"))return e;if(i.is("attributeElement")&&0===i.childCount){let e=i.parent,t=i.index;return i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new z(e,t))}let r=i.getChild(t-1),n=i.getChild(t);if(!r||!n)return e;if(r.is("$text")&&n.is("$text"))return eP(r,n);if(r.is("attributeElement")&&n.is("attributeElement")&&r.isSimilar(n)){let e=r.childCount;return r._appendChild(n.getChildren()),n._remove(),this._removeFromClonedElementsGroup(n),this.mergeAttributes(new z(r,e))}return e}mergeContainers(e){let t=e.nodeBefore,i=e.nodeAfter;if(!t||!i||!t.is("containerElement")||!i.is("containerElement"))throw new r.Yb("view-writer-merge-containers-invalid-position",this.document);let n=t.getChild(t.childCount-1),s=n instanceof C?z._createAt(n,"end"):z._createAt(t,"end");return this.move(U._createIn(i),z._createAt(t,"end")),this.remove(U._createOn(i)),s}insert(e,t){!function e(t,i){for(let n of t){if(!eC.some(e=>n instanceof e))throw new r.Yb("view-writer-insert-invalid-node-type",i);n.is("$text")||e(n.getChildren(),i)}}
1(t=(0,r.xZ)(t)?[...t]:[t],this.document);let i=t.reduce((e,t)=>{let i=e[e.length-1],r=!t.is("uiElement");return i&&i.breakAttributes==r?i.nodes.push(t):e.push({breakAttributes:r,nodes:[t]}),e},[]),n=null,s=e;for(let{nodes:e,breakAttributes:t}of i){let i=this._insertNodes(s,e,t);n||(n=i.start),s=i.end}return n?new U(n,s):new U(e)}remove(e){let t=e instanceof U?e:U._createOn(e);if(ek(t,this.document),t.isCollapsed)return new e_(this.document);let{start:i,end:r}=this._breakAttributesRange(t,!0),n=i.parent,s=r.offset-i.offset,o=n._removeChildren(i.offset,s);for(let e of o)this._removeFromClonedElementsGroup(e);let a=this.mergeAttributes(i);return t.start=a,t.end=a.clone(),new e_(this.document,o)}clear(e,t){for(let i of(ek(e,this.document),e.getWalker({direction:"backward",ignoreElementEnd:!0}))){let r,n=i.item;if(n.is("element")&&t.isSimilar(n))r=U._createOn(n);else if(!i.nextPosition.isAfter(e.start)&&n.is("$textProxy")){let e=n.getAncestors().find(e=>e.is("element")&&t.isSimilar(e));e&&(r=U._createIn(e))}r&&(r.end.isAfter(e.end)&&(r.end=e.end),r.start.isBefore(e.start)&&(r.start=e.start),this.remove(r))}}move(e,t){let i;if(t.isAfter(e.end)){let r=(t=this._breakAttributes(t,!0)).parent,n=r.childCount;e=this._breakAttributesRange(e,!0),i=this.remove(e),t.offset+=r.childCount-n}else i=this.remove(e);return this.insert(t,i)}wrap(e,t){if(!(t instanceof el))throw new r.Yb("view-writer-wrap-invalid-attribute",this.document);if(ek(e,this.document),!e.isCollapsed)return this._wrapRange(e,t);{let i=e.start;i.parent.is("element")&&!Array.from(i.parent.getChildren()).some(e=>!e.is("uiElement"))&&(i=i.getLastMatchingPosition(e=>e.item.is("uiElement"))),i=this._wrapPosition(i,t);let r=this.document.selection;return r.isCollapsed&&r.getFirstPosition().isEqual(e.start)&&this.setSelection(i),new U(i)}}unwrap(e,t){if(!(t instanceof el))throw new r.Yb("view-writer-unwrap-invalid-attribute",this.document);if(ek(e,this.document),e.isCollapsed)return e;let{start:i,end:n}=this._breakAttributesRange(e,!0),s=i.parent,o=this._unwrapChildren(s,i.offset,n.offset,t),a=this.mergeAttributes(o.start);return!a.isEqual(o.start)&&o.end.offset--,new U(a,this.mergeAttributes(o.end))}rename(e,t){let i=new L(this.document,e,t.getAttributes());return this.insert(z._createAfter(t),i),this.move(U._createIn(t),z._createAt(i,0)),this.remove(U._createOn(t)),i}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return z._createAt(e,t)}createPositionAfter(e){return z._createAfter(e)}createPositionBefore(e){return z._createBefore(e)}createRange(e,t){return new U(e,t)}createRangeOn(e){return U._createOn(e)}createRangeIn(e){return U._createIn(e)}createSelection(...e){return new H(...e)}createSlot(e="children"){if(!this._slotFactory)throw new r.Yb("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,i){let n,s;if(!(n=i?eb(e):e.parent.is("$text")?e.parent.parent:e.parent))throw new r.Yb("view-writer-invalid-position-container",this.document);s=i?this._breakAttributes(e,!0):e.parent.is("$text")?ev(e):e;let o=n._insertChild(s.offset,t);for(let e of t)this._addToClonedElementsGroup(e);let a=s.getShiftedBy(o),l=this.mergeAttributes(s);return!l.isEqual(s)&&a.offset--,new U(l,this.mergeAttributes(a))}_wrapChildren(e,t,i,r){let n=t,s=[];for(;n<i;){let t=e.getChild(n),i=t.is("$text"),l=t.is("attributeElement");if(l&&t._canMergeAttributesFrom(r))t._mergeAttributesFrom(r),s.push(new z(e,n));else{var o,a;if(i||!l||(o=r,a=t,o.priority<a.priority||!(o.priority>a.priority)&&o.getIdentity()<a.getIdentity())){let i=r._clone();t._remove(),i._appendChild(t),e._insertChild(n,i),this._addToClonedElementsGroup(i),s.push(new z(e,n))}else this._wrapChildren(t,0,t.childCount,r)}n++}let l=0;for(let e of s)e.offset-=l,e.offset!=t&&!this.mergeAttributes(e).isEqual(e)&&(l++,i--);return U._createFromParentsAndOffsets(e,t,e,i)}_unwrapChildren(e,t,i,r){let n=t,s=[];for(;n<i;){let t=e.getChild(n);if(!t.is("attributeElement")){n++;continue}if(t.isSimilar(r)){let r=t.getChildren(),o=t.childCount;t._remove(),e._insertChild(n,r),this._removeFromClonedElementsGroup(t),s.push(new z(e,n),new z(e,n+o)),n+=o,i+=o-1;continue}if(t._canSubtractAttributesOf(r)){t._subtractAttributesOf(r),s.push(new z(e,n),new z(e,n+1)),n++;continue}this._unwrapChildren(t,0,t.childCount,r),n++}let o=0;for(let e of s)e.offset-=o,e.offset!=t&&e.offset!=i&&!this.mergeAttributes(e).isEqual(e)&&(o++,i--);return U._createFromParentsAndOffsets(e,t,e,i)}_wrapRange(e,t){let{start:i,end:r}=this._breakAttributesRange(e,!0),n=i.parent,s=this._wrapChildren(n,i.offset,r.offset,t),o=this.mergeAttributes(s.start);return!o.isEqual(s.start)&&s.end.offset--,new U(o,this.mergeAttributes(s.end))}_wrapPosition(e,t){if(t.isSimilar(e.parent))return ey(e.clone());e.parent.is("$text")&&(e=ev(e));let i=this.createAttributeElement("_wrapPosition-fake-element");i._priority=1/0,i.isSimilar=()=>!1,e.parent._insertChild(e.offset,i);let r=new U(e,e.getShiftedBy(1));this.wrap(r,t);let n=new z(i.parent,i.index);i._remove();let s=n.nodeBefore,o=n.nodeAfter;return s&&s.is("view:$text")&&o&&o.is("view:$text")?eP(s,o):ey(n)}_breakAttributesRange(e,t=!1){let i=e.start,r=e.end;if(ek(e,this.document),e.isCollapsed){let i=this._breakAttributes(e.start,t);return new U(i,i)}let n=this._breakAttributes(r,t),s=n.parent.childCount,o=this._breakAttributes(i,t);return n.offset+=n.parent.childCount-s,new U(o,n)}_breakAttributes(e,t=!1){let i=e.offset,n=e.parent;if(e.parent.is("emptyElement"))throw new r.Yb("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new r.Yb("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new r.Yb("view-writer-cannot-break-raw-element",this.document);if(!t&&n.is("$text")&&eA(n.parent)||eA(n))return e.clone();
1if(n.is("$text"))return this._breakAttributes(ev(e),t);if(i==n.childCount){let e=new z(n.parent,n.index+1);return this._breakAttributes(e,t)}if(0===i){let e=new z(n.parent,n.index);return this._breakAttributes(e,t)}{let e=n.index+1,r=n._clone();n.parent._insertChild(e,r),this._addToClonedElementsGroup(r);let s=n.childCount-i,o=n._removeChildren(i,s);r._appendChild(o);let a=new z(n.parent,e);return this._breakAttributes(a,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(let t of e.getChildren())this._addToClonedElementsGroup(t);let t=e.id;if(!t)return;let i=this._cloneGroups.get(t);i||(i=new Set,this._cloneGroups.set(t,i)),i.add(e),e._clonesGroup=i}_removeFromClonedElementsGroup(e){if(e.is("element"))for(let t of e.getChildren())this._removeFromClonedElementsGroup(t);let t=e.id;if(!t)return;let i=this._cloneGroups.get(t);i&&i.delete(e)}}function eb(e){let t=e.parent;for(;!eA(t);){if(!t)return;t=t.parent}return t}function ey(e){let t=e.nodeBefore;if(t&&t.is("$text"))return new z(t,t.data.length);let i=e.nodeAfter;return i&&i.is("$text")?new z(i,0):e}function ev(e){if(e.offset==e.parent.data.length)return new z(e.parent.parent,e.parent.index+1);if(0===e.offset)return new z(e.parent.parent,e.parent.index);let t=e.parent.data.slice(e.offset);return e.parent._data=e.parent.data.slice(0,e.offset),e.parent.parent._insertChild(e.parent.index+1,new C(e.root.document,t)),new z(e.parent.parent,e.parent.index+1)}function eP(e,t){let i=e.data.length;return e._data+=t.data,t._remove(),new z(e,i)}let eC=[C,el,L,eu,eg,ef];function eA(e){return e&&(e.is("containerElement")||e.is("documentFragment"))}function ek(e,t){let i=eb(e.start),n=eb(e.end);if(!i||!n||i!==n)throw new r.Yb("view-writer-invalid-range-container",t)}let eS=e=>e.createTextNode("\xa0"),eE=e=>{let t=e.createElement("span");return t.dataset.ckeFiller="true",t.innerText="\xa0",t},eR=e=>{let t=e.createElement("br");return t.dataset.ckeFiller="true",t},ex="â ".repeat(7);function eO(e){return"string"==typeof e?e.substr(0,7)===ex:(0,r.KH)(e)&&e.data.substr(0,7)===ex}function eM(e){return 7==e.data.length&&eO(e)}function eT(e){let t="string"==typeof e?e:e.data;return eO(e)?t.slice(7):t}function eN(e,t){if(t.keyCode==r.uP.arrowleft){let e=t.domTarget.ownerDocument.defaultView.getSelection();if(1==e.rangeCount&&e.getRangeAt(0).collapsed){let t=e.getRangeAt(0).startContainer,i=e.getRangeAt(0).startOffset;eO(t)&&i<=7&&e.collapse(t,0)}}}class eF extends(0,r.VM)(){domDocuments=new Set;domConverter;markedAttributes=new Set;markedChildren=new Set;markedTexts=new Set;selection;_inlineFiller=null;_fakeSelectionContainer=null;constructor(e,t){super(),this.domConverter=e,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1),r._K.isBlink&&!r._K.isAndroid&&this.on("change:isSelecting",()=>{this.isSelecting||this.render()})}markToSync(e,t){if("text"===e)this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if("attributes"===e)this.markedAttributes.add(t);else if("children"===e)this.markedChildren.add(t);else throw new r.Yb("view-renderer-unknown-type",this)}}render(){if(this.isComposing&&!r._K.isAndroid)return;let e=null,t=!r._K.isBlink||!!r._K.isAndroid||!this.isSelecting;for(let e of this.markedChildren)this._updateChildrenMappings(e);for(let i of(t?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?e=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(e=this.selection.getFirstPosition(),this.markedChildren.add(e.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(e=this.domConverter.domPositionToView(this._inlineFiller))&&e.parent.is("$text")&&(e=z._createBefore(e.parent)),this.markedAttributes))this._updateAttrs(i);for(let t of this.markedChildren)this._updateChildren(t,{inlineFillerPosition:e});for(let t of this.markedTexts)!this.markedChildren.has(t.parent)&&this.domConverter.mapViewToDom(t.parent)&&this._updateText(t,{inlineFillerPosition:e});if(t)if(e){let t=this.domConverter.viewPositionToDom(e),i=t.parent.ownerDocument;eO(t.parent)?this._inlineFiller=t.parent:this._inlineFiller=eI(i,t.parent,t.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.domConverter._clearTemporaryCustomProperties(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){let t=this.domConverter.mapViewToDom(e);if(!t)return;let i=Array.from(t.childNodes),n=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),s=this._diffNodeLists(i,n),o=this._findUpdateActions(s,i,n,eB);if(-1!==o.indexOf("update")){let t={equal:0,insert:0,delete:0};for(let s of o)if("update"===s){let s=t.equal+t.insert,o=t.equal+t.delete,a=e.getChild(s);!a||a.is("uiElement")||a.is("rawElement")||this._updateElementMappings(a,i[o]),(0,r.TF)(n[s]),t.equal++}else t[s]++}}_updateElementMappings(e,t){this.domConverter.unbindDomElement(t),this.domConverter.b
1indElements(t,e),this.markedChildren.add(e),this.markedAttributes.add(e)}_getInlineFillerPosition(){let e=this.selection.getFirstPosition();return e.parent.is("$text")?z._createBefore(e.parent):e}_isSelectionInInlineFiller(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;let e=this.selection.getFirstPosition(),t=this.domConverter.viewPositionToDom(e);return!!(t&&(0,r.KH)(t.parent)&&eO(t.parent))}_removeInlineFiller(){let e=this._inlineFiller;if(!eO(e))throw new r.Yb("view-renderer-filler-was-lost",this);eM(e)?e.remove():e.data=e.data.substr(7),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(1!=this.selection.rangeCount||!this.selection.isCollapsed)return!1;let e=this.selection.getFirstPosition(),t=e.parent,i=e.offset;if(!this.domConverter.mapViewToDom(t.root)||!t.is("element")||!function(e){if("false"==e.getAttribute("contenteditable"))return!1;let t=e.findAncestor(e=>e.hasAttribute("contenteditable"));return!t||"true"==t.getAttribute("contenteditable")}(t))return!1;let n=e.nodeBefore,s=e.nodeAfter;return!(n instanceof C)&&!(s instanceof C)&&(i!==t.getFillerOffset()||!!n&&!!n.is("element","br"))&&(!r._K.isAndroid||!n&&!s)}_updateText(e,t){let i=this.domConverter.findCorrespondingDomText(e),r=this.domConverter.viewToDom(e).data,n=t.inlineFillerPosition;n&&n.parent==e.parent&&n.offset==e.index&&(r=ex+r),this._updateTextNode(i,r)}_updateAttrs(e){let t=this.domConverter.mapViewToDom(e);if(t){for(let i of Array.from(t.attributes)){let r=i.name;e.hasAttribute(r)||this.domConverter.removeDomElementAttribute(t,r)}for(let i of e.getAttributeKeys())this.domConverter.setDomElementAttribute(t,i,e.getAttribute(i),e)}}_updateChildren(e,t){let i=this.domConverter.mapViewToDom(e);if(!i)return;if(r._K.isAndroid){let e=null;for(let t of Array.from(i.childNodes)){if(e&&(0,r.KH)(e)&&(0,r.KH)(t)){i.normalize();break}e=t}}let n=t.inlineFillerPosition,s=i.childNodes,o=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));n&&n.parent===e&&eI(i.ownerDocument,o,n.offset);let a=this._diffNodeLists(s,o),l=this._findUpdateActions(a,s,o,eD),h=0,d=new Set;for(let e of l)"delete"===e?(d.add(s[h]),(0,r.TF)(s[h])):("equal"===e||"update"===e)&&h++;for(let e of(h=0,l))"insert"===e?((0,r.PT)(i,h,o[h]),h++):"update"===e?(this._updateTextNode(s[h],o[h].data),h++):"equal"===e&&(this._markDescendantTextToSync(this.domConverter.domToView(o[h])),h++);for(let e of d)e.parentNode||this.domConverter.unbindDomElement(e)}_diffNodeLists(e,t){return e=function(e,t){let i=Array.from(e);return 0!=i.length&&t&&i[i.length-1]==t&&i.pop(),i}(e,this._fakeSelectionContainer),(0,r.Ui)(e,t,eV.bind(null,this.domConverter))}_findUpdateActions(e,t,i,n){if(-1===e.indexOf("insert")||-1===e.indexOf("delete"))return e;let s=[],o=[],a=[],l={equal:0,insert:0,delete:0};for(let h of e)"insert"===h?a.push(i[l.equal+l.insert]):"delete"===h?o.push(t[l.equal+l.delete]):((s=s.concat((0,r.Ui)(o,a,n).map(e=>"equal"===e?"update":e))).push("equal"),o=[],a=[]),l[h]++;return s.concat((0,r.Ui)(o,a,n).map(e=>"equal"===e?"update":e))}_updateTextNode(e,t){let i=e.data;i!=t&&(r._K.isAndroid&&this.isComposing&&i.replace(/\u00A0/g," ")==t.replace(/\u00A0/g," ")||this._updateTextNodeInternal(e,t))}_updateTextNodeInternal(e,t){for(let i of(0,r.Mr)(e.data,t))"insert"===i.type?e.insertData(i.index,i.values.join("")):e.deleteData(i.index,i.howMany)}_markDescendantTextToSync(e){if(e){if(e.is("$text"))this.markedTexts.add(e);else if(e.is("element"))for(let t of e.getChildren())this._markDescendantTextToSync(t)}}_updateSelection(){if(r._K.isBlink&&!r._K.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(0===this.selection.rangeCount){this._removeDomSelection(),this._removeFakeSelection();return}let e=this.domConverter.mapViewToDom(this.selection.editableElement);if(!this.isFocused||!e){!this.selection.isFake&&this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected&&this._removeFakeSelection();return}this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&r._K.isAndroid||this._updateDomSelection(e)}_updateFakeSelection(e){let t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=function(e){let t=e.createElement("div");
1return t.className="ck-fake-selection-container",Object.assign(t.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),t.textContent="\xa0",t}(t));let i=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(i,this.selection),!this._fakeSelectionNeedsUpdate(e))return;i.parentElement&&i.parentElement==e||e.appendChild(i),i.textContent=this.selection.fakeSelectionLabel||"\xa0";let r=t.getSelection(),n=t.createRange();r.removeAllRanges(),n.selectNodeContents(i),r.addRange(n)}_updateDomSelection(e){let t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;let i=this.domConverter.viewPositionToDom(this.selection.anchor),n=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(i.parent,i.offset,n.parent,n.offset),r._K.isGecko&&function(e,t){let i=e.parent,n=e.offset;if((0,r.KH)(i)&&eM(i)&&(n=(0,r.qh)(i)+1,i=i.parentNode),i.nodeType!=Node.ELEMENT_NODE||n!=i.childNodes.length-1)return;let s=i.childNodes[n];s&&"BR"==s.tagName&&t.addRange(t.getRangeAt(0))}(n,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;let t=e&&this.domConverter.domSelectionToView(e);return!(t&&this.selection.isEqual(t)||!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){let t=this._fakeSelectionContainer,i=e.ownerDocument.getSelection();return!(t&&t.parentElement===e&&(i.anchorNode===t||t.contains(i.anchorNode)))||t.textContent!==this.selection.fakeSelectionLabel}_removeDomSelection(){for(let e of this.domDocuments){let t=e.getSelection();if(t.rangeCount){let i=e.activeElement,r=this.domConverter.mapDomToView(i);i&&r&&t.removeAllRanges()}}}_removeFakeSelection(){let e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){let e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function eI(e,t,i){let n=t instanceof Array?t:t.childNodes,s=n[i];if((0,r.KH)(s))return s.data=ex+s.data,s;{let s=e.createTextNode(ex);return Array.isArray(t)?n.splice(i,0,s):(0,r.PT)(t,i,s),s}}function eB(e,t){return(0,r.Ll)(e)&&(0,r.Ll)(t)&&!(0,r.KH)(e)&&!(0,r.KH)(t)&&!(0,r.Cn)(e)&&!(0,r.Cn)(t)&&e.tagName.toLowerCase()===t.tagName.toLowerCase()}function eD(e,t){return(0,r.Ll)(e)&&(0,r.Ll)(t)&&(0,r.KH)(e)&&(0,r.KH)(t)}function eV(e,t,i){return t===i||((0,r.KH)(t)&&(0,r.KH)(i)?t.data===i.data:!!(e.isBlockFiller(t)&&e.isBlockFiller(i))||!1)}let e$=eR(r.Sf.document),eL=eS(r.Sf.document),eq=eE(r.Sf.document),eW="data-ck-unsafe-attribute-",eY="data-ck-unsafe-element";class eJ{document;renderingMode;blockFillerMode;preElements;blockElements;inlineObjectElements;unsafeElements;_domDocument;_domToViewMapping=new WeakMap;_viewToDomMapping=new WeakMap;_fakeSelectionMapping=new WeakMap;_rawContentElementMatcher=new x;_inlineObjectElementMatcher=new x;_elementsWithTemporaryCustomProperties=new Set;constructor(e,{blockFillerMode:t,renderingMode:i="editing"}={}){this.document=e,this.renderingMode=i,this.blockFillerMode=t||("editing"===i?"br":"nbsp"),this.preElements=["pre","textarea"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this.unsafeElements=["script","style"],this._domDocument="editing"===this.renderingMode?r.Sf.document:r.Sf.document.implementation.createHTMLDocument("")}get domDocument(){return this._domDocument}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new H(t))}fakeSelectionToView(e){return this._fakeSelectionMapping.get(e)}bindElements(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}unbindDomElement(e){let t=this._domToViewMapping.get(e);if(t)for(let i of(this._domToViewMapping.delete(e),this._viewToDomMapping.delete(t),e.children))this.unbindDomElement(i)}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,i){return"data"===this.renderingMode||!(e=e.toLowerCase()).startsWith("on")&&"srcdoc"!==e&&("img"===i&&("src"===e||"srcset"===e)||"source"===i&&"srcset"===e||!t.replace(/\s+/g,"").match(/^(javascript:|data:(image\/svg|text\/x?html))/i))}setContentOf(e,t){let i;if("data"===this.renderingMode){e.innerHTML=t;return}let r=new DOMParser().parseFromString(t,"text/html"),n=r.createDocumentFragment(),s=r.body.childNodes;for(;s.length>0;)n.appendChild(s[0]);let o=r.createTreeWalker(n,NodeFilter.SHOW_ELEMENT),a=[];for(;i=o.nextNode();)a.push(i);for(let e of a){for(let t of e.getAttributeNames())this.setDomElementAttribute(e,t,e.getAttribute(t));let t=e.tagName.toLowerCase();this._shouldRenameElement(t)&&(eH(t),e.replaceWith(this._createReplacementDomElement(t,e)))}for(;e.firstChild;)e.firstChild.remove();e.append(n)}viewToDom(e,t={}){if(e.is("$text")){let t=this._processDataFromViewText(e);return this._domDocument.createTextNode(t)}{let i;if(this.mapViewToDom(e))if(!e.getCustomProperty("editingPipeline:doNotReuseOnce"))return this.mapViewToDom(e);else this._elementsWithTemporaryCustomProperties.add(e);if(e.is("documentFragment"))i=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(i,e);else if(e.is("uiElement"))return i="$comment"===e.name?this._domDocument.createComment(e.getCustomProperty("$rawContent")):e.render(this._domDocument,this),t.bind&&this.bindElements(i,e),i;else for(let r of(this._shouldRenameElement(e.name)?(eH(e.name),i=this._createReplacementDomElement(e.name)):i=e.hasAttribute("xmlns")?this._domDocument.createElementNS(e.getAttribute("xmlns"),e.name):this._domDocument.createElement(e.name),e.is("rawElement")&&e.render(i,this),t.bind&&this.bindElements(i,e),e.getAttributeKeys()))this.setDomElementAttribute(i,r,e.getAttribute(r),e);if(!1!==t.withChildren)for(let r of this.viewChildrenToDom(e,t))i instanceof HTMLTemplateElement?i.content.appendChild(r):i.appendChild(r);return i}}setDomElementAttribute(e,t,i,n){let s=this.shouldRenderAttribute(t,i,e.tagName.toLowerCase())||n&&n.shouldRenderUnsafeAttribute(t);if(s||(0,r.FF)("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:i}),!(0,r.i8)(t))return void(0,r.FF)("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:i});e.hasAttribute(t)&&!s?e.removeAttribute(t):e.hasAttribute(eW+t)&&s&&e.removeAttribute(eW+t),e.setAttribute(s?t:eW+t,i)}removeDomElementAttribute(e,t){t!=eY&&(e.removeAttribute(t),e.removeAttribute(eW+t))}*viewChildrenToDom(e,t={}){let i=e.getFillerOffset&&e.getFillerOffset(),n=0;for(let s of e.getChildren()){i===n&&(yield this._getBlockFiller());let e=s.is("element")&&!!s.getCustomProperty("dataPipeline:transparentRendering")&&!(0,r.$1)(s.getAttributes());if(e&&"data"==this.renderingMode)if(s.is("rawElement")){let e=this._domDocument.createElement(s.name);s.render(e,this),yield*[...e.childNodes]}else yield*this.viewChildrenToDom(s,t);else e&&(0,r.FF)("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:s}),yield this.viewToDom(s,t);n++}i===n&&(yield this._getBlockFiller())}viewRangeToDom(e){let t=this.viewPositionToDom(e.start),i=this.viewPositionToDom(e.end),r=this._domDocument.createRange();return r.setStart(t.parent,t.offset),r.setEnd(i.parent,i.offset),r}viewPositionToDom(e){let t=e.parent;if(t.is("$text")){let i=this.findCorrespondingDomText(t);if(!i)return null;let r=e.offset;return eO(i)&&(r+=7),i.data&&r>i.data.length&&(r=i.data.length),{parent:i,offset:r}}{let i,n,s;if(0===e.offset){if(!(i=this.mapViewToDom(t)))return null;
1s=i.childNodes[0]}else{let t=e.nodeBefore;if(!(n=t.is("$text")?this.findCorrespondingDomText(t):this.mapViewToDom(t)))return null;i=n.parentNode,s=n.nextSibling}return(0,r.KH)(s)&&eO(s)?{parent:s,offset:7}:{parent:i,offset:n?(0,r.qh)(n)+1:0}}}domToView(e,t={}){let i=[],r=this._domToView(e,t,i),n=r.next().value;return n?(r.next(),this._processDomInlineNodes(null,i,t),"br"==this.blockFillerMode&&eU(n)||n.is("$text")&&0==n.data.length)?null:n:null}*domChildrenToView(e,t={},i=[]){let r=[];r=e instanceof HTMLTemplateElement?[...e.content.childNodes]:[...e.childNodes];for(let n=0;n<r.length;n++){let s=r[n],o=this._domToView(s,t,i),a=o.next().value;null!==a&&(this._isBlockViewElement(a)&&this._processDomInlineNodes(e,i,t),"br"==this.blockFillerMode&&eU(a)||(yield a),o.next())}this._processDomInlineNodes(e,i,t)}domSelectionToView(e){if(function(e){if(!r._K.isGecko||!e.rangeCount)return!1;let t=e.getRangeAt(0).startContainer;try{Object.prototype.toString.call(t)}catch{return!0}return!1}(e))return new H([]);if(1===e.rangeCount){let t=e.getRangeAt(0).startContainer;(0,r.KH)(t)&&(t=t.parentNode);let i=this.fakeSelectionToView(t);if(i)return i}let t=this.isDomSelectionBackward(e),i=[];for(let t=0;t<e.rangeCount;t++){let r=e.getRangeAt(t),n=this.domRangeToView(r);n&&i.push(n)}return new H(i,{backward:t})}domRangeToView(e){let t=this.domPositionToView(e.startContainer,e.startOffset),i=this.domPositionToView(e.endContainer,e.endOffset);return t&&i?new U(t,i):null}domPositionToView(e,t=0){if(this.isBlockFiller(e))return this.domPositionToView(e.parentNode,(0,r.qh)(e));let i=this.mapDomToView(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return z._createBefore(i);if((0,r.KH)(e)){if(eM(e))return this.domPositionToView(e.parentNode,(0,r.qh)(e));let i=this.findCorrespondingViewText(e),n=t;return i?(eO(e)&&(n-=7,n=n<0?0:n),new z(i,n)):null}if(0===t){let t=this.mapDomToView(e);if(t)return new z(t,0)}else{let i=e.childNodes[t-1];if((0,r.KH)(i)&&eM(i)||i&&this.isBlockFiller(i))return this.domPositionToView(i.parentNode,(0,r.qh)(i));let n=(0,r.KH)(i)?this.findCorrespondingViewText(i):this.mapDomToView(i);if(n&&n.parent)return new z(n.parent,n.index+1)}return null}mapDomToView(e){return this.getHostViewElement(e)||this._domToViewMapping.get(e)}findCorrespondingViewText(e){if(eM(e))return null;let t=this.getHostViewElement(e);if(t)return t;let i=e.previousSibling;if(i){if(!this.isElement(i))return null;let e=this.mapDomToView(i);if(e){let t=e.nextSibling;if(t instanceof C)return t}}else{let t=this.mapDomToView(e.parentNode);if(t){let e=t.getChild(0);if(e instanceof C)return e}}return null}mapViewToDom(e){return this._viewToDomMapping.get(e)}findCorrespondingDomText(e){let t=e.previousSibling;return t&&this.mapViewToDom(t)?this.mapViewToDom(t).nextSibling:!t&&e.parent&&this.mapViewToDom(e.parent)?this.mapViewToDom(e.parent).childNodes[0]:null}focus(e){let t=this.mapViewToDom(e);if(!t||t.ownerDocument.activeElement===t)return;let{scrollX:i,scrollY:n}=r.Sf.window,s=[];ej(t,e=>{let{scrollLeft:t,scrollTop:i}=e;s.push([t,i])}),t.focus({preventScroll:!0}),ej(t,e=>{let[t,i]=s.shift();e.scrollLeft=t,e.scrollTop=i}),r.Sf.window.scrollTo(i,n)}_clearDomSelection(){let e=this.mapViewToDom(this.document.selection.editableElement);if(!e)return;let t=e.ownerDocument.defaultView.getSelection(),i=this.domSelectionToView(t);i&&i.rangeCount>0&&t.removeAllRanges()}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(e){var t,i;return"br"==this.blockFillerMode?e.isEqualNode(e$):!!eK(e,this.blockElements)||e.isEqualNode(eq)||(t=e,i=this.blockElements,t.isEqualNode(eL)&&ez(t,i)&&1===t.parentNode.childNodes.length)}isDomSelectionBackward(e){if(e.isCollapsed)return!1;let t=this._domDocument.createRange();try{t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset)}catch{return!1}let i=t.collapsed;return t.detach(),i}getHostViewElement(e){let t=(0,r.DS)(e);for(t.pop();t.length;){let e=t.pop(),i=this._domToViewMapping.get(e);if(i&&(i.is("uiElement")||i.is("rawElement")))return i}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}registerInlineObjectMatcher(e){this._inlineObjectElementMatcher.add(e)}_clearTemporaryCustomProperties(){for(let e of this._elementsWithTemporaryCustomProperties)e._removeCustomProperty("editingPipeline:doNotReuseOnce");this._elementsWithTemporaryCustomProperties.clear()}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return eS(this._domDocument);case"markedNbsp":return eE(this._domDocument);case"br":return eR(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if((0,r.KH)(e)&&eO(e)&&t<7||this.isElement(e)&&eO(e.childNodes[t]))return!1;let i=this.mapDomToView(e);return!(i&&(i.is("uiElement")||i.is("rawElement")))}*_domToView(e,t,i){if("br"!=this.blockFillerMode&&eK(e,this.blockElements))return null;let n=this.getHostViewElement(e);
1if(n)return n;if((0,r.Cn)(e)&&t.skipComments)return null;if((0,r.KH)(e))if(eM(e))return null;else{let t=e.data;if(""===t)return null;let r=new C(this.document,t);return i.push(r),r}{let n=this.mapDomToView(e);if(n)return this._isInlineObjectElement(n)&&i.push(n),n;if(this.isDocumentFragment(e))n=new e_(this.document),t.bind&&this.bindDocumentFragments(e,n);else{n=this._createViewElement(e,t),t.bind&&this.bindElements(e,n);let s=e.attributes;if(s)for(let e=s.length,t=0;t<e;t++)n._setAttribute(s[t].name,s[t].value);if(this._isViewElementWithRawContent(n,t))return n._setCustomProperty("$rawContent",e.innerHTML),this._isBlockViewElement(n)||i.push(n),n;if((0,r.Cn)(e))return n._setCustomProperty("$rawContent",e.data),n}yield n;let s=[];if(!1!==t.withChildren)for(let i of this.domChildrenToView(e,t,s))n._appendChild(i);if(this._isInlineObjectElement(n))i.push(n),this._processDomInlineNodes(null,s,t);else for(let e of s)i.push(e)}}_processDomInlineNodes(e,t,i){if(!t.length||e&&!this.isDocumentFragment(e)&&!this._isBlockDomElement(e))return;let r=!1;for(let e=0;e<t.length;e++){let l,h=t[e];if(!h.is("$text")){r=!1;continue}let d=!1;if(this._isPreFormatted(h))l=eT(h.data);else{var n,s,o,a;l=h.data.replace(/[ \n\t\r]{1,}/g," "),d=/[^\S\u00A0]/.test(l.charAt(l.length-1));let u=e>0?t[e-1]:null,c=e+1<t.length?t[e+1]:null,f=!u||u.is("element")&&"br"==u.name||r,m=!c&&!eO(h.data);!1!==i.withChildren&&(f&&(l=l.replace(/^ /,"")),m&&(l=l.replace(/ $/,""))),l=eT(l),"br"!=this.blockFillerMode&&h.parent&&((n=h.parent,"\xa0"==l&&n&&n.is("element","span")&&1==n.childCount&&n.hasAttribute("data-cke-filler"))?(l="",h.parent.parent&&(h.parent.parent._setCustomProperty("$hasBlockFiller",!0),h.parent._remove())):(s=h.parent,o=l,a=this.blockElements,"\xa0"==o&&s&&s.is("element")&&1==s.childCount&&a.includes(s.name)&&(l="",h.parent._setCustomProperty("$hasBlockFiller",!0)))),l=l.replace(/ \u00A0/g," ");let g=c&&c.is("element")&&"br"!=c.name,p=c&&c.is("$text")&&" "==c.data.charAt(0);(/[ \u00A0]\u00A0$/.test(l)||!c||g||p)&&(l=l.replace(/\u00A0$/," ")),(f||u&&u.is("element")&&"br"!=u.name)&&(l=l.replace(/^\u00A0/," "))}0==l.length&&h.parent?(h._remove(),t.splice(e,1),e--):(h._data=l,r=d)}t.length=0}_processDataFromViewText(e){let t=e.data;if(this._isPreFormatted(e))return t;if(" "==t.charAt(0)){let i=this._getTouchingInlineViewNode(e,!1);(i&&i.is("$textProxy")&&this._nodeEndsWithSpace(i)||!i)&&(t="\xa0"+t.substr(1))}if(" "==t.charAt(t.length-1)){let i=this._getTouchingInlineViewNode(e,!0),r=i&&i.is("$textProxy")&&" "==i.data.charAt(0);(" "==t.charAt(t.length-2)||!i||r)&&(t=t.substr(0,t.length-1)+"\xa0")}return t.replace(/ {2}/g," \xa0")}_nodeEndsWithSpace(e){if(this._isPreFormatted(e))return!1;let t=this._processDataFromViewText(e);return" "==t.charAt(t.length-1)}_isPreFormatted(e){var t,i;if(t=e,i=this.preElements,t.getAncestors().some(e=>e.is("element")&&i.includes(e.name)))return!0;for(let t of e.getAncestors({parentFirst:!0}))if(t.is("element")&&t.hasStyle("white-space")&&"inherit"!==t.getStyle("white-space"))return["pre","pre-wrap","break-spaces"].includes(t.getStyle("white-space"));return!1}_getTouchingInlineViewNode(e,t){for(let{item:i}of new j({startPosition:t?z._createAfter(e):z._createBefore(e),direction:t?"forward":"backward"}))if(i.is("$textProxy"))return i;else if(i.is("element")&&i.getCustomProperty("dataPipeline:transparentRendering"))continue;else if(i.is("element","br"))break;else if(this._isInlineObjectElement(i))return i;else if(i.is("containerElement")||this._isBlockViewElement(i))break;return null}_isBlockDomElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isBlockViewElement(e){return e.is("element")&&this.blockElements.includes(e.name)}_isInlineObjectElement(e){return!!e.is("element")&&("br"==e.name||this.inlineObjectElements.includes(e.name)||!!this._inlineObjectElementMatcher.match(e))}_createViewElement(e,t){if((0,r.Cn)(e))return new ef(this.document,"$comment");let i=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new D(this.document,i)}_isViewElementWithRawContent(e,t){return!1!==t.withChildren&&e.is("element")&&!!this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){let t=e.toLowerCase();return"editing"===this.renderingMode&&this.unsafeElements.includes(t)}_createReplacementDomElement(e,t){let i=this._domDocument.createElement("span");if(i.setAttribute(eY,e),t){for(;t.firstChild;)i.appendChild(t.firstChild);for(let e of t.getAttributeNames())i.setAttribute(e,t.getAttribute(e))}return i}}function ej(e,t){let i=e;for(;i;)t(i),i=i.parentElement}function ez(e,t){let i=e.parentNode;return!!i&&!!i.tagName&&t.includes(i.tagName.toLowerCase())}function eU(e){return e.is("element","br")&&e.hasAttribute("data-cke-filler")}function eK(e,t){return"BR"===e.tagName&&ez(e,t)&&1===e.parentNode.childNodes.length}function eH(e){"script"===e&&(0,r.FF)("domconverter-unsafe-script-element-detected"),"style"===e&&(0,r.FF)("domconverter-unsafe-style-element-detected")}class eG extends(0,r.c5)(){view;document;_isEnabled=!1;constructor(e){super(),this.view=e,this.document=e.document}get isEnabled(){return this._isEnabled}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}destroy(){this.disable(),this.stopListening()}
1checkShouldIgnoreEventFromTarget(e){return e&&3===e.nodeType&&(e=e.parentNode),!!e&&1===e.nodeType&&e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}class eZ{view;document;domEvent;domTarget;constructor(e,t,i){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,(0,h.J)(this,i)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class eQ extends eG{useCapture=!1;usePassive=!1;observe(e){("string"==typeof this.domEventType?[this.domEventType]:this.domEventType).forEach(t=>{this.listenTo(e,t,(e,t)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(t.target)&&this.onDomEvent(t)},{useCapture:this.useCapture,usePassive:this.usePassive})})}stopObserving(e){this.stopListening(e)}fire(e,t,i){this.isEnabled&&this.document.fire(e,new eZ(this.view,t,i))}}class eX extends eQ{domEventType=["keydown","keyup"];onDomEvent(e){let t={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return(0,r.QC)(this)}};this.fire(e.type,e,t)}}class e0 extends eG{_fireSelectionChangeDoneDebounced;constructor(e){super(e),this._fireSelectionChangeDoneDebounced=(0,d.s)(e=>{this.document.fire("selectionChangeDone",e)},200)}observe(){let e=this.document;e.on("arrowKey",(t,i)=>{e.selection.isFake&&this.isEnabled&&i.preventDefault()},{context:"$capture"}),e.on("arrowKey",(t,i)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(i.keyCode)},{priority:"lowest"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){let t=this.document.selection,i=new H(t.getRanges(),{backward:t.isBackward,fake:!1});(e==r.uP.arrowleft||e==r.uP.arrowup)&&i.setTo(i.getFirstPosition()),(e==r.uP.arrowright||e==r.uP.arrowdown)&&i.setTo(i.getLastPosition());let n={oldSelection:t,newSelection:i,domSelection:null};this.document.fire("selectionChange",n),this._fireSelectionChangeDoneDebounced(n)}}class e1 extends eG{domConverter;_config;_domElements;_mutationObserver;constructor(e){super(e),this._config={childList:!0,characterData:!0,subtree:!0},this.domConverter=e.domConverter,this._domElements=new Set,this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(e){this._domElements.add(e),this.isEnabled&&this._mutationObserver.observe(e,this._config)}stopObserving(e){if(this._domElements.delete(e),this.isEnabled)for(let e of(this._mutationObserver.disconnect(),this._domElements))this._mutationObserver.observe(e,this._config)}enable(){for(let e of(super.enable(),this._domElements))this._mutationObserver.observe(e,this._config)}disable(){super.disable(),this._mutationObserver.disconnect()}destroy(){super.destroy(),this._mutationObserver.disconnect()}_onMutations(e){if(0===e.length)return;let t=this.domConverter,i=new Set,r=new Set;for(let i of e){let e=t.mapDomToView(i.target);e&&!(e.is("uiElement")||e.is("rawElement"))&&("childList"!==i.type||this._isBogusBrMutation(i)||r.add(e))}for(let n of e){let e=t.mapDomToView(n.target);if(!(e&&(e.is("uiElement")||e.is("rawElement")))&&"characterData"===n.type){let e=t.findCorrespondingViewText(n.target);e&&!r.has(e.parent)?i.add(e):!e&&eO(n.target)&&r.add(t.mapDomToView(n.target.parentNode))}}let n=[];for(let e of i)n.push({type:"text",node:e});for(let e of r){let i=t.mapViewToDom(e),r=Array.from(e.getChildren()),s=Array.from(t.domChildrenToView(i,{withChildren:!1}));(0,u.P)(r,s,e9)||n.push({type:"children",node:e})}n.length&&this.document.fire("mutations",{mutations:n})}_isBogusBrMutation(e){let t=null;return null===e.nextSibling&&0===e.removedNodes.length&&1==e.addedNodes.length&&(t=this.domConverter.domToView(e.addedNodes[0],{withChildren:!1})),t&&t.is("element","br")}}function e9(e,t){if(!Array.isArray(e))return e===t||!!(e.is("$text")&&t.is("$text"))&&e.data===t.data}class e2 extends eQ{_renderTimeoutId=null;_isFocusChanging=!1;domEventType=["focus","blur"];constructor(e){super(e),this.useCapture=!0;let t=this.document;t.on("focus",()=>this._handleFocus()),t.on("blur",(e,t)=>this._handleBlur(t)),t.on("beforeinput",()=>{t.isFocused||this._handleFocus()},{priority:"highest"})}flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._clearTimeout(),super.destroy()}_handleFocus(){this._clearTimeout(),this._isFocusChanging=!0,this._renderTimeoutId=setTimeout(()=>{this._renderTimeoutId=null,this.flush(),this.view.change(()=>{})},50)}_handleBlur(e){let t=this.document.selection.editableElement;(null===t||t===e.target)&&(this.document.isFocused=!1,this._isFocusChanging=!1,this.view.change(()=>{}))}_clearTimeout(){this._renderTimeoutId&&(clearTimeout(this._renderTimeoutId),this._renderTimeoutId=null)}}class e3 extends eG{mutationObserver;focusObserver;selection;domConverter;_documents=new WeakSet;_fireSelectionChangeDoneDebounced;_clearInfiniteLoopInterval;_documentIsSelectingInactivityTimeoutDebounced;_loopbackCounter=0;_pendingSelectionChange=new Set;constructor(e){super(e),this.mutationObserver=e.getObserver(e1),this.focusObserver=e.getObserver(e2),this.selection=this.document.selection,this.domConverter=e.domConverter,this._fireSelectionChangeDoneDebounced=(0,d.s)(e=>{this.document.fire("selectionChangeDone",e)},200),this._clearInfiniteLoopInterval=setInterval(()=>this._clearInfiniteLoop(),1e3),this._documentIsSelectingInactivityTimeoutDebounced=(0,d.s)(()=>this.document.isSelecting=!1,5e3),this.view.document.on("change:isFocused",(e,t,i)=>{if(i&&this._pendingSelectionChange.size){for(let e of Array.from(this._pe
1ndingSelectionChange))this._handleSelectionChange(e);this._pendingSelectionChange.clear()}})}observe(e){let t=e.ownerDocument,i=()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()},n=()=>{this.document.isSelecting&&(this._handleSelectionChange(t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",i,{priority:"highest"}),this.listenTo(e,"keydown",n,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",n,{priority:"highest",useCapture:!0}),this._documents.has(t)||(this.listenTo(t,"mouseup",n,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",()=>{(!this.document.isComposing||r._K.isAndroid)&&(this._handleSelectionChange(t),this._documentIsSelectingInactivityTimeoutDebounced())}),this.listenTo(this.view.document,"compositionstart",()=>{this._handleSelectionChange(t)},{priority:"lowest"}),this._documents.add(t))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e){if(!this.isEnabled)return;let t=e.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(t.anchorNode))return;this.mutationObserver.flush();let i=this.domConverter.domSelectionToView(t);if(0==i.rangeCount){this.view.hasDomSelection=!1;return}if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.view.document.isFocused&&!this.view.document.isReadOnly)return void this._pendingSelectionChange.add(e);if(this._pendingSelectionChange.delete(e),!(this.selection.isEqual(i)&&this.domConverter.isDomSelectionCorrect(t))){if(++this._loopbackCounter>60)return void this._reportInfiniteLoop();if(Array.from(i.getRanges()).flatMap(e=>[e.start.root,e.end.root]).every(e=>e&&e.is("rootElement")))if(this.selection.isSimilar(i))this.view.forceRender();else{let e={oldSelection:this.selection,newSelection:i,domSelection:t};this.document.fire("selectionChange",e),this._fireSelectionChangeDoneDebounced(e)}else this.view.forceRender()}}_clearInfiniteLoop(){this._loopbackCounter=0}}class e5 extends eQ{domEventType=["compositionstart","compositionupdate","compositionend"];constructor(e){super(e);let t=this.document;t.on("compositionstart",()=>{t.isComposing=!0}),t.on("compositionend",()=>{t.isComposing=!1})}onDomEvent(e){this.fire(e.type,e,{data:e.data})}}class e7{_files;_native;constructor(e,t={}){this._files=t.cacheFiles?e6(e):null,this._native=e}get files(){return this._files||(this._files=e6(this._native)),this._files}get types(){return this._native.types}getData(e){return this._native.getData(e)}setData(e,t){this._native.setData(e,t)}set effectAllowed(e){this._native.effectAllowed=e}get effectAllowed(){return this._native.effectAllowed}set dropEffect(e){this._native.dropEffect=e}get dropEffect(){return this._native.dropEffect}setDragImage(e,t,i){this._native.setDragImage(e,t,i)}get isCanceled(){return"none"==this._native.dropEffect||!!this._native.mozUserCancelled}}function e6(e){let t=Array.from(e.files||[]),i=Array.from(e.items||[]);return t.length?t:i.filter(e=>"file"===e.kind).map(e=>e.getAsFile())}class e4 extends eQ{domEventType="beforeinput";onDomEvent(e){let t=e.getTargetRanges(),i=this.view,n=i.document,s=null,o=null,a=[];if(e.dataTransfer&&(s=new e7(e.dataTransfer)),null!==e.data?o=e.data:s&&(o=s.getData("text/plain")),n.selection.isFake)a=Array.from(n.selection.getRanges()),e.preventDefault();else if(t.length)a=t.map(t=>{let n=i.domConverter.domPositionToView(t.startContainer,t.startOffset),s=i.domConverter.domPositionToView(t.endContainer,t.endOffset);if(n&&eO(t.startContainer)&&t.startOffset<7){e.preventDefault();let i=7-t.startOffset;n=n.getLastMatchingPosition(e=>!!(e.item.is("attributeElement")||e.item.is("uiElement")||e.item.is("$textProxy")&&i--),{direction:"backward",singleCharacters:!0})}return(function(e,t){for(;e.parentNode;){if((0,r.KH)(e)){if(t!=e.data.length)break}else if(t!=e.childNodes.length)break;if((t=(0,r.qh)(e)+1)<(e=e.parentNode).childNodes.length&&eO(e.childNodes[t]))return!0}return!1}(t.endContainer,t.endOffset)&&e.preventDefault(),n)?i.createRange(n,s):s?i.createRange(s):void 0}).filter(e=>!!e);else if(r._K.isAndroid){let t=e.target.ownerDocument.defaultView.getSelection();a=Array.from(i.domConverter.domSelectionToView(t).getRanges())}if(r._K.isAndroid&&"insertCompositionText"==e.inputType&&o&&o.endsWith("\n"))return void this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[i.createRange(a[0].end)]});if(["insertText","insertReplacementText"].includes(e.inputType)&&o&&o.includes("\n")){let t=
1o.split(/\n{1,2}/g),i=a;e.preventDefault();for(let r=0;r<t.length;r++){let o=t[r];""!=o&&(this.fire(e.type,e,{data:o,dataTransfer:s,targetRanges:i,inputType:e.inputType,isComposing:e.isComposing}),i=[n.selection.getFirstRange()]),r+1<t.length&&(this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:i}),i=[n.selection.getFirstRange()])}return}this.fire(e.type,e,{data:o,dataTransfer:s,targetRanges:a,inputType:e.inputType,isComposing:e.isComposing})}}class e8 extends eG{constructor(e){super(e),this.document.on("keydown",(e,t)=>{if(this.isEnabled&&(0,r.Yt)(t.keyCode)){let i=new Z(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(i,t),i.stop.called&&e.stop()}})}observe(){}stopObserving(){}}class te extends eG{constructor(e){super(e);let t=this.document;t.on("keydown",(e,i)=>{if(!this.isEnabled||i.keyCode!=r.uP.tab||i.ctrlKey)return;let n=new Z(t,"tab",t.selection.getFirstRange());t.fire(n,i),n.stop.called&&e.stop()})}observe(){}stopObserving(){}}class tt extends(0,r.VM)(){document;domConverter;domRoots=new Map;_renderer;_initialDomRootAttributes=new WeakMap;_observers=new Map;_writer;_ongoingChange=!1;_postFixersInProgress=!1;_renderingDisabled=!1;_hasChangedSinceTheLastRendering=!1;constructor(e){super(),this.document=new ea(e),this.domConverter=new eJ(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new eF(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new ew(this.document),this.addObserver(e1),this.addObserver(e2),this.addObserver(e3),this.addObserver(eX),this.addObserver(e0),this.addObserver(e5),this.addObserver(e8),this.addObserver(e4),this.addObserver(te),this.document.on("arrowKey",eN,{priority:"low"}),function(e){e.document.on("arrowKey",(t,i)=>(function(e,t,i){if(t.keyCode==r.uP.arrowright){let e=t.domTarget.ownerDocument.defaultView.getSelection(),r=1==e.rangeCount&&e.getRangeAt(0).collapsed;if(r||t.shiftKey){let t=e.focusNode,n=e.focusOffset,s=i.domPositionToView(t,n);if(null===s)return;let o=!1,a=s.getLastMatchingPosition(e=>(e.item.is("uiElement")&&(o=!0),!!(e.item.is("uiElement")||e.item.is("attributeElement"))));if(o){let t=i.viewPositionToDom(a);r?e.collapse(t.parent,t.offset):e.extend(t.parent,t.offset)}}}})(0,i,e.domConverter),{priority:"low"})}(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}),r._K.isiOS&&this.listenTo(this.document,"blur",(e,t)=>{this.domConverter.mapDomToView(t.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}),this.listenTo(this.document,"mutations",(e,{mutations:t})=>{t.forEach(e=>this._renderer.markToSync(e.type,e.node))},{priority:"low"}),this.listenTo(this.document,"mutations",()=>{this.forceRender()},{priority:"lowest"})}attachDomRoot(e,t="main"){let i=this.document.getRoot(t);i._name=e.tagName.toLowerCase();let r={};for(let{name:t,value:n}of Array.from(e.attributes))r[t]=n,"class"===t?this._writer.addClass(n.split(" "),i):i.hasAttribute(t)||this._writer.setAttribute(t,n,i);this._initialDomRootAttributes.set(e,r);let n=()=>{this._writer.setAttribute("contenteditable",(!i.isReadOnly).toString(),i),i.isReadOnly?this._writer.addClass("ck-read-only",i):this._writer.removeClass("ck-read-only",i)};for(let r of(n(),this.domRoots.set(t,e),this.domConverter.bindElements(e,i),this._renderer.markToSync("children",i),this._renderer.markToSync("attributes",i),this._renderer.domDocuments.add(e.ownerDocument),i.on("change:children",(e,t)=>this._renderer.markToSync("children",t)),i.on("change:attributes",(e,t)=>this._renderer.markToSync("attributes",t)),i.on("change:text",(e,t)=>this._renderer.markToSync("text",t)),i.on("change:isReadOnly",()=>this.change(n)),i.on("change",()=>{this._hasChangedSinceTheLastRendering=!0}
1),this._observers.values()))r.observe(e,t)}detachDomRoot(e){let t=this.domRoots.get(e);Array.from(t.attributes).forEach(({name:e})=>t.removeAttribute(e));let i=this._initialDomRootAttributes.get(t);for(let e in i)t.setAttribute(e,i[e]);for(let i of(this.domRoots.delete(e),this.domConverter.unbindDomElement(t),this._observers.values()))i.stopObserving(t)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;for(let[i,r]of(t=new e(this),this._observers.set(e,t),this.domRoots))t.observe(r,i);return t.enable(),t}getObserver(e){return this._observers.get(e)}disableObservers(){for(let e of this._observers.values())e.disable()}enableObservers(){for(let e of this._observers.values())e.enable()}scrollToTheSelection({alignToTop:e,forceScroll:t,viewportOffset:i=20,ancestorOffset:n=20}={}){let s=this.document.selection.getFirstRange();if(!s)return;let o=(0,c.m)({alignToTop:e,forceScroll:t,viewportOffset:i,ancestorOffset:n});"number"==typeof i&&(i={top:i,bottom:i,left:i,right:i});let a={target:this.domConverter.viewRangeToDom(s),viewportOffset:i,ancestorOffset:n,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",a,o),(0,r.vK)(a)}focus(){if(!this.document.isFocused){let e=this.document.selection.editableElement;e&&(this.domConverter.focus(e),this.forceRender())}}change(e){if(this.isRenderingInProgress||this._postFixersInProgress)throw new r.Yb("cannot-change-view-tree",this);try{if(this._ongoingChange)return e(this._writer);this._ongoingChange=!0;let 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){r.Yb.rethrowUnexpectedError(e,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(e2).flush(),this.change(()=>{})}destroy(){for(let e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return z._createAt(e,t)}createPositionAfter(e){return z._createAfter(e)}createPositionBefore(e){return z._createBefore(e)}createRange(e,t){return new U(e,t)}createRangeOn(e){return U._createOn(e)}createRangeIn(e){return U._createIn(e)}createSelection(...e){return new H(...e)}_disableRendering(e){this._renderingDisabled=e,!1==e&&this.change(()=>{})}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}class ti{is(){throw Error("is() method is abstract")}}class tr extends ti{textNode;data;offsetInText;constructor(e,t,i){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new r.Yb("model-textproxy-wrong-offsetintext",this);if(i<0||t+i>e.offsetSize)throw new r.Yb("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+i),this.offsetInText=t}get startOffset(){return null!==this.textNode.startOffset?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return null!==this.startOffset?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}getPath(){let e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={}){let t=[],i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}tr.prototype.is=function(e){return"$textProxy"===e||"model:$textProxy"===e||"textProxy"===e||"model:textProxy"===e};class tn{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;_visitedParent;constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new r.Yb("model-tree-walker-no-start-position",null);let t=e.direction||"forward";if("forward"!=t&&"backward"!=t)throw new r.Yb("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=to._createAt(this.boundaries["backward"==this.direction?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null,this._visitedParent=this.position.parent}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,i,r,n;do r=this.position,n=this._visitedParent,{done:t,value:i}=this.next();while(!t&&e(i));t||(this._position=r,this._visitedParent=n)}jumpTo(e){this._boundaryStartParent&&e.isBefore(this.boundaries.start)?e=this.boundaries.start:this._boundaryEndParent&&e.isAfter(this.boundaries.end)&&(e=this.boundaries.end),this._position=e.clone(),this._visitedParent=e.parent}next(){return"forward"==this.direction?this._next():this._previous()}_next(){let e=this.position,t=this.position.clone(),i=this._visitedParent;if(null===i.parent&&t.offset===i.maxOffset||i===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let r=ta(t,i),n=r||tl(t,i,r);if(n&&n.is("model:element")){if(this.shallow){if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}else t.path.push(0),this._visitedParent=n;return this._position=t,ts("elementStart",n,e,t,1)}if(n&&n.is("model:$text")){let r;if(this.singleCharacters)r=1;else{let e=n.endOffset;this._boundaryEndParent==i&&this.boundaries.end.offset<e&&(e=this.boundaries.end.offset),r=e-t.offset}let s=t.offset-n.startOffset,o=new tr(n,s,r);return t.offset+=r,this._position=t,ts("text",o,e,t,r)}return(t.path.pop(),t.offset++,this._position=t,this._visitedParent=i.parent,this.ignoreElementEnd)?this._next():ts("elementEnd",i,e,t)}_previous(){let e=this.position,t=this.position.clone(),i=this._visitedParent;if(null===i.parent&&0===t.offset||i==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let r=t.parent,n=ta(t,r),s=n||th(t,r,n);if(s&&s.is("model:element"))return(t.offset--,this.shallow)?(this._position=t,ts("elementStart",s,e,t,1)):(t.path.push(s.maxOffset),this._position=t,this._visitedParent=s,this.ignoreElementEnd)?this._previous():ts("elementEnd",s,e,t);if(s&&s.is("model:$text")){let r;if(this.singleCharacters)r=1;else{let e=s.startOffset;this._boundaryStartParent==i&&this.boundaries.start.offset>e&&(e=this.boundaries.start.offset),r=t.offset-e}let n=t.offset-s.startOffset,o=new tr(s,n-r,r);return t.offset-=r,this._position=t,ts("text",o,e,t,r)}return t.path.pop(),this._position=t,this._visitedParent=i.parent,ts("elementStart",i,e,t,1)}}function ts(e,t,i,r,n){return{done:!1,value:{type:e,item:t,previousPosition:i,nextPosition:r,length:n}}}class to extends ti{root;path;stickiness;constructor(e,t,i="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new r.Yb("model-position-root-invalid",e);if(!Array.isArray(t)||0===t.length)throw new r.Yb("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=i}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;t<this.path.length-1;t++)if(!(e=e.getChildAtOffset(this.path[t])))throw new r.Yb("model-position-path-incorrect",this,{position:this});if(e.is("$text"))throw new r.Yb("model-position-path-incorrect",this,{position:this});return e}get index(){return this.parent.offsetToIndex(this.offset)}get textNode(){return ta(this,this.parent)}get nodeAfter(){let e=this.parent;return tl(this,e,ta(this,e))}get nodeBefore(){let e=this.parent;return th(this,e,ta(this,e))}get isAtStart(){return 0===this.offset}get isAtEnd(){return this.offset==this.parent.maxOffset}isValid(){if(this.offset<0)return!1;let e=this.root;for(let t=0;t<this.path.length-1;t++)if(!(e=e.getChildAtOffset(this.path[t])))return!1;return this.offset<=e.maxOffset}compareWith(e){if(this.root!=e.root)return"different";let t=(0,r.ww)(this.path,e.path);switch(t){case"same":return"same";case"prefix":return"before";case"extension":return"after";default:return this.path[t]<e.path[t]?"before":"after"}}
1getLastMatchingPosition(e,t={}){t.startPosition=this;let i=new tn(t);return i.skip(e),i.position}getParentPath(){return this.path.slice(0,-1)}getAncestors(){let e=this.parent;return e.is("documentFragment")?[e]:e.getAncestors({includeSelf:!0})}findAncestor(e){let t=this.parent;return t.is("element")?t.findAncestor(e,{includeSelf:!0}):null}getCommonPath(e){if(this.root!=e.root)return[];let t=(0,r.ww)(this.path,e.path),i="string"==typeof t?Math.min(this.path.length,e.path.length):t;return this.path.slice(0,i)}getCommonAncestor(e){let t=this.getAncestors(),i=e.getAncestors(),r=0;for(;t[r]==i[r]&&t[r];)r++;return 0===r?null:t[r-1]}getShiftedBy(e){let t=this.clone(),i=t.offset+e;return t.offset=i<0?0:i,t}isAfter(e){return"after"==this.compareWith(e)}isBefore(e){return"before"==this.compareWith(e)}isEqual(e){return"same"==this.compareWith(e)}isTouching(e){if(this.root!==e.root)return!1;let t=Math.min(this.path.length,e.path.length);for(let i=0;i<t;i++){let t=this.path[i]-e.path[i];if(t<-1||t>1)return!1;if(1===t)return td(e,this,i);if(-1===t)return td(this,e,i)}return this.path.length===e.path.length||(this.path.length>e.path.length?tu(this.path,t):tu(e.path,t))}hasSameParentAs(e){if(this.root!==e.root)return!1;let t=this.getParentPath(),i=e.getParentPath();return"same"==(0,r.ww)(t,i)}getTransformedByOperation(e){let t;switch(e.type){case"insert":t=this._getTransformedByInsertOperation(e);break;case"move":case"remove":case"reinsert":t=this._getTransformedByMoveOperation(e);break;case"split":t=this._getTransformedBySplitOperation(e);break;case"merge":t=this._getTransformedByMergeOperation(e);break;default:t=to._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){let 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){let t,i=e.movedRange;return i.containsPosition(this)||i.start.isEqual(this)?(t=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(t=t._getTransformedByDeletion(e.deletionPosition,1))):t=this.isEqual(e.deletionPosition)?to._createAt(e.deletionPosition):this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),t}_getTransformedByDeletion(e,t){let i=to._createAt(this);if(this.root!=e.root)return i;if("same"==(0,r.ww)(e.getParentPath(),this.getParentPath())){if(e.offset<this.offset)if(e.offset+t>this.offset)return null;else i.offset-=t}else if("prefix"==(0,r.ww)(e.getParentPath(),this.getParentPath())){let r=e.path.length-1;if(e.offset<=this.path[r])if(e.offset+t>this.path[r])return null;else i.path[r]-=t}return i}_getTransformedByInsertion(e,t){let i=to._createAt(this);if(this.root!=e.root)return i;if("same"==(0,r.ww)(e.getParentPath(),this.getParentPath()))(e.offset<this.offset||e.offset==this.offset&&"toPrevious"!=this.stickiness)&&(i.offset+=t);else if("prefix"==(0,r.ww)(e.getParentPath(),this.getParentPath())){let r=e.path.length-1;e.offset<=this.path[r]&&(i.path[r]+=t)}return i}_getTransformedByMove(e,t,i){if(t=t._getTransformedByDeletion(e,i),e.isEqual(t))return to._createAt(this);let r=this._getTransformedByDeletion(e,i);return null===r||e.isEqual(this)&&"toNext"==this.stickiness||e.getShiftedBy(i).isEqual(this)&&"toPrevious"==this.stickiness?this._getCombined(e,t):r._getTransformedByInsertion(t,i)}_getCombined(e,t){let i=e.path.length-1,r=to._createAt(t);return r.stickiness=this.stickiness,r.offset=r.offset+this.path[i]-e.offset,r.path=[...r.path,...this.path.slice(i+1)],r}toJSON(){return{root:this.root.toJSON(),path:Array.from(this.path),stickiness:this.stickiness}}clone(){return new this.constructor(this.root,this.path,this.stickiness)}static _createAt(e,t,i="toNone"){if(e.is("model:position"))return new to(e.root,e.path,e.stickiness);{if("end"==t)t=e.maxOffset;else if("before"==t)return this._createBefore(e,i);else if("after"==t)return this._createAfter(e,i);else if(0!==t&&!t)throw new r.Yb("model-createpositionat-offset-required",[this,e]);if(!e.is("element")&&!e.is("documentFragment"))throw new r.Yb("model-position-parent-incorrect",[this,e]);let n=e.getPath();return n.push(t),new this(e.root,n,i)}}static _createAfter(e,t){if(!e.parent)throw new r.Yb("model-position-after-root",[this,e],{root:e});return this._createAt(e.parent,e.endOffset,t)}static _createBefore(e,t){if(!e.parent)throw new r.Yb("model-position-before-root",e,{root:e});return this._createAt(e.parent,e.startOffset,t)}static fromJSON(e,t){if("$graveyard"===e.root){let i=new to(t.graveyard,e.path);return i.stickiness=e.stickiness,i}if(!t.getRoot(e.root))throw new r.Yb("model-position-fromjson-no-root",t,{rootName:e.root});return new to(t.getRoot(e.root),e.path,e.stickiness)}}function ta(e,t){let i=t.getChildAtOffset(e.offset);return i&&i.is("$text")&&i.startOffset<e.offset?i:null}function tl(e,t,i){return null!==i?null:t.getChildAtOffset(e.offset)}function th(e,t,i){return null!==i?null:t.getChild(t.offsetToIndex(e.offset)-1)}function td(e,t,i){return i+1!==e.path.length&&!!tu(t.path,i+1)&&!!function(e,t){let i=e.parent,r=e.path.length-1,n=0;for(;r>=t;){if(e.path[r]+n!==i.maxOffset)return!1;n=1,r--,i=i.parent}return!0}(e,i+1)}function tu(e,t){for(;t<e.length;){if(0!==e[t])return!1;t++}return!0}to.prototype.is=function(e){return"position"===e||"model:position"===e};class tc extends ti{start;end;constructor(e,t){super(),this.start=to._createAt(e),this.end=t?to._createAt(t):to._createAt(e),this.start.stickiness=this.isCollapsed?"toNone":"toNext",this.end.stickiness=this.isCollapsed?"toNone":"toPrevious"}*[Symbol.iterator](){yield*new tn({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){let e=this.start.getParentPath(),t=this.end.getParentPath();return"same"==(0,r.ww)(e,t)}get root(){return this.start.root}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,t=!1){e.isCollapsed&&(t=!1);let i=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),r=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return i&&r}containsItem(e){let t=to._createBefore(e);return this.containsPosition(t)||this.start.isEqual(t)}isEqual(e){return this.start.isEqual(e.start)&&this.end.isEqual(e.end)}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}getDifference(e){let t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new tc(this.start,e.start)),this.containsPosition(e.end)&&t.pu
1sh(new tc(e.end,this.end))):t.push(new tc(this.start,this.end)),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,i=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(i=e.end),new tc(t,i)}return null}getJoined(e,t=!1){let i=this.isIntersecting(e);if(i||(i=this.start.isBefore(e.start)?t?this.end.isTouching(e.start):this.end.isEqual(e.start):t?e.end.isTouching(this.start):e.end.isEqual(this.start)),!i)return null;let r=this.start,n=this.end;return e.start.isBefore(r)&&(r=e.start),e.end.isAfter(n)&&(n=e.end),new tc(r,n)}getMinimalFlatRanges(){let e=[],t=this.start.getCommonPath(this.end).length,i=to._createAt(this.start),r=i.parent;for(;i.path.length>t+1;){let t=r.maxOffset-i.offset;0!==t&&e.push(new tc(i,i.getShiftedBy(t))),i.path=i.path.slice(0,-1),i.offset++,r=r.parent}for(;i.path.length<=this.end.path.length;){let t=this.end.path[i.path.length-1],r=t-i.offset;0!==r&&e.push(new tc(i,i.getShiftedBy(r))),i.offset=t,i.path.push(0)}return e}getWalker(e={}){return e.boun
1daries=this,new tn(e)}*getItems(e={}){for(let t of(e.boundaries=this,e.ignoreElementEnd=!0,new tn(e)))yield t.item}*getPositions(e={}){e.boundaries=this;let t=new tn(e);for(let e of(yield t.position,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 tc(this.start,this.end)]}getTransformedByOperations(e){let t=[new tc(this.start,this.end)];for(let i of e)for(let e=0;e<t.length;e++){let r=t[e].getTransformedByOperation(i);t.splice(e,1,...r),e+=r.length-1}for(let e=0;e<t.length;e++){let i=t[e];for(let r=e+1;r<t.length;r++){let e=t[r];(i.containsRange(e)||e.containsRange(i)||i.isEqual(e))&&t.splice(r,1)}}return t}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;let e=this.start.nodeAfter,t=this.end.nodeBefore;return e&&e.is("element")&&e===t?e:null}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}clone(){return new this.constructor(this.start,this.end)}_getTransformedByInsertOperation(e,t=!1){return this._getTransformedByInsertion(e.position,e.howMany,t)}_getTransformedByMoveOperation(e,t=!1){let i=e.sourcePosition,r=e.howMany,n=e.targetPosition;return this._getTransformedByMove(i,n,r,t)}_getTransformedBySplitOperation(e){let t=this.start._getTransformedBySplitOperation(e),i=this.end._getTransformedBySplitOperation(e);return this.end.isEqual(e.insertionPosition)&&(i=this.end.getShiftedBy(1)),t.root!=i.root&&(i=this.end.getShiftedBy(-1)),new tc(t,i)}_getTransformedByMergeOperation(e){if(this.start.isEqual(e.targetPosition)&&this.end.isEqual(e.deletionPosition))return new tc(this.start);let t=this.start._getTransformedByMergeOperation(e),i=this.end._getTransformedByMergeOperation(e);return t.root!=i.root&&(i=this.end.getShiftedBy(-1)),t.isAfter(i)&&(e.sourcePosition.isBefore(e.targetPosition)?(t=to._createAt(i)).offset=0:(e.deletionPosition.isEqual(t)||(i=e.deletionPosition),t=e.targetPosition)),new tc(t,i)}_getTransformedByInsertion(e,t,i=!1){if(i&&this.containsPosition(e))return[new tc(this.start,e),new tc(e.getShiftedBy(t),this.end._getTransformedByInsertion(e,t))];{let i=new tc(this.start,this.end);return i.start=i.start._getTransformedByInsertion(e,t),i.end=i.end._getTransformedByInsertion(e,t),[i]}}_getTransformedByMove(e,t,i,r=!1){let n;if(this.isCollapsed)return[new tc(this.start._getTransformedByMove(e,t,i))];let s=tc._createFromPositionAndShift(e,i),o=t._getTransformedByDeletion(e,i);if(this.containsPosition(t)&&!r&&(s.containsPosition(this.start)||s.containsPosition(this.end)))return[new tc(this.start._getTransformedByMove(e,t,i),this.end._getTransformedByMove(e,t,i))];let a=this.getDifference(s),l=null,h=this.getIntersection(s);if(1==a.length?l=new tc(a[0].start._getTransformedByDeletion(e,i),a[0].end._getTransformedByDeletion(e,i)):2==a.length&&(l=new tc(this.start,this.end._getTransformedByDeletion(e,i))),n=l?l._getTransformedByInsertion(o,i,null!==h||r):[],h){let e=new tc(h.start._getCombined(s.start,o),h.end._getCombined(s.start,o));2==n.length?n.splice(1,0,e):n.push(e)}return n}_getTransformedByDeletion(e,t){let i=this.start._getTransformedByDeletion(e,t),r=this.end._getTransformedByDeletion(e,t);return null==i&&null==r?null:(null==i&&(i=e),null==r&&(r=e),new tc(i,r))}static _createFromPositionAndShift(e,t){let i=e.getShiftedBy(t);return t>0?new this(e,i):new this(i,e)}static _createIn(e){return new this(to._createAt(e,0),to._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(to._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(0===e.length)throw new r.Yb("range-create-from-ranges-empty-array",null);if(1==e.length)return e[0].clone();let t=e[0];e.sort((e,t)=>e.start.isAfter(t.start)?1:-1);let i=e.indexOf(t),n=new this(t.start,t.end);for(let t=i-1;t>=0;t--)if(e[t].end.isEqual(n.start))n.start=to._createAt(e[t].start);else break;for(let t=i+1;t<e.length;t++)if(e[t].start.isEqual(n.end))n.end=to._createAt(e[t].end);else break;return n}static fromJSON(e,t){return new this(to.fromJSON(e.start,t),to.fromJSON(e.end,t))}}tc.prototype.is=function(e){return"range"===e||"model:range"===e};class tf extends(0,r.Mm)(){_modelToViewMapping=new WeakMap;_viewToModelMapping=new WeakMap;_viewToModelLengthCallbacks=new Map;_markerNameToElements=new Map;_elementToMarkerNames=new Map;_deferredBindingRemovals=new Map;_unboundMarkerNames=new Set;_cache=new tm;constructor(){super(),this.on("modelToViewPosition",(e,t)=>{if(t.viewPosition)return;let i=this._modelToViewMapping.get(t.modelPosition.parent);if(!i)throw new r.Yb("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(i,t.modelPosition.offset)},{priority:"low"}),this.on("viewToModelPosition",(e,t)=>{if(t.modelPosition)return;let i=this.findMappedViewAncestor(t.viewPosition),r=this._viewToModelMapping.get(i),n=this._toModelOff
1set(t.viewPosition.parent,t.viewPosition.offset,i);t.modelPosition=to._createAt(r,n)},{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){let i=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(let t of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(t);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e)&&this._cache.stopTracking(e),this._modelToViewMapping.get(i)==e&&this._modelToViewMapping.delete(i))}unbindModelElement(e){let t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)&&this._cache.stopTracking(t)}bindElementToMarker(e,t){let i=this._markerNameToElements.get(t)||new Set;i.add(e);let r=this._elementToMarkerNames.get(e)||new Set;r.add(t),this._markerNameToElements.set(t,i),this._elementToMarkerNames.set(e,r)}unbindElementFromMarkerName(e,t){let i=this._markerNameToElements.get(t);i&&(i.delete(e),0==i.size&&this._markerNameToElements.delete(t));let r=this._elementToMarkerNames.get(e);r&&(r.delete(t),0==r.size&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){let e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(let[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 tc(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new U(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){let t={viewPosition:e,mapper:this};return this.fire("viewToModelPosition",t),t.modelPosition}toViewPosition(e,t={}){let i={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",i),i.viewPosition}markerNameToElements(e){let t=this._markerNameToElements.get(e);if(!t)return null;let i=new Set;for(let e of t)if(e.is("attributeElement"))for(let t of e.getElementsWithSameId())i.add(t);else i.add(e);return i}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,i){if(i!=e)return this._toModelOffset(e.parent,e.index,i)+this._toModelOffset(e,t,e);if(e.is("$text"))return t;let r=0;for(let i=0;i<t;i++)r+=this.getModelLength(e.getChild(i));return r}getModelLength(e){let t=[e],i=0;for(;t.length>0;){let e=t.pop(),r=e.name&&this._viewToModelLengthCallbacks.size>0&&this._viewToModelLengthCallbacks.get(e.name);if(r)i+=r(e);else if(this._viewToModelMapping.has(e))i+=1;else if(e.is("$text"))i+=e.data.length;else{if(e.is("uiElement"))continue;for(let i of e.getChildren())t.push(i)}}return i}findPositionIn(e,t){if(0===t)return this._moveViewPositionToTextNode(new z(e,0));if(!(0==this._viewToModelLengthCallbacks.size&&this._viewToModelMapping.has(e)))return this._findPositionStartingFrom(new z(e,0),0,t,e,!1);{let i=this._cache.getClosest(e,t);return this._findPositionStartingFrom(i.viewPosition,i.modelOffset,t,e,!0)}}_findPositionStartingFrom(e,t,i,n,s){let o,a=e.parent,l=e.offset;if(a.is("$text"))return new z(a,i-t);let h=t,d=0;for(;h<i;){if(!(o=a.getChild(l)))if(a==n)throw new r.Yb("mapping-model-offset-not-found",this,{modelOffset:i,viewContainer:n});else{l=a.parent.getChildIndex(a)+1,a=a.parent,s&&this._cache.save(a,l,n,h);continue}d=s?this._getModelLengthAndCache(o,n,h):this.getModelLength(o),h+=d,l++}let u=new z(a,l);if(s)for(;u.isAtEnd&&u.parent!==n&&u.parent.parent;){let e=u.parent.parent,t=e.getChildIndex(u.parent)+1;this._cache.save(e,t,n,h),u=new z(e,t)}return h==i?this._moveViewPositionToTextNode(u):this._findPositionStartingFrom(new z(o,0),h-d,i,n,s)}
1_getModelLengthAndCache(e,t,i){let r=0;if(this._viewToModelMapping.has(e))r=1;else if(e.is("$text"))r=e.data.length;else if(!e.is("uiElement"))for(let n of e.getChildren())r+=this._getModelLengthAndCache(n,t,i+r);return this._cache.save(e.parent,e.index+1,t,i+r),r}_moveViewPositionToTextNode(e){let t=e.nodeBefore,i=e.nodeAfter;return t&&t.is("view:$text")?new z(t,t.data.length):i&&i.is("view:$text")?new z(i,0):e}}class tm extends(0,r.Mm)(){_cachedMapping=new WeakMap;_nodeToCacheListIndex=new WeakMap;_invalidateOnChildrenChangeCallback=(e,t,i)=>{this._clearCacheInsideParent(t,i.index)};_invalidateOnTextChangeCallback=(e,t)=>{this._clearCacheAfter(t)};save(e,t,i,r){let n=this._cachedMapping.get(i),s=n.cacheMap.get(r);if(s){let i=e.getChild(t-1),r=s.viewPosition.nodeBefore?this._nodeToCacheListIndex.get(s.viewPosition.nodeBefore):0;this._nodeToCacheListIndex.set(i,r);return}let o={viewPosition:new z(e,t),modelOffset:r};n.maxModelOffset=r>n.maxModelOffset?r:n.maxModelOffset,n.cacheMap.set(r,o);let a=n.cacheList.length-1;for(;a>=0&&n.cacheList[a].modelOffset>r;)a--;if(n.cacheList.splice(a+1,0,o),t>0){let i=e.getChild(t-1);this._nodeToCacheListIndex.set(i,a+1)}}getClosest(e,t){let i,r=this._cachedMapping.get(e);if(r)if(t>r.maxModelOffset)i=r.cacheList[r.cacheList.length-1];else{let e=r.cacheMap.get(t);i=e||this._findInCacheList(r.cacheList,t)}else i=this.startTracking(e);return{modelOffset:i.modelOffset,viewPosition:i.viewPosition.clone()}}startTracking(e){let t={viewPosition:new z(e,0),modelOffset:0},i={maxModelOffset:0,cacheList:[t],cacheMap:new Map([[0,t]])};return this._cachedMapping.set(e,i),e.on("change:children",this._invalidateOnChildrenChangeCallback),e.on("change:text",this._invalidateOnTextChangeCallback),t}stopTracking(e){e.off("change:children",this._invalidateOnChildrenChangeCallback),e.off("change:text",this._invalidateOnTextChangeCallback),this._cachedMapping.delete(e)}_clearCacheInsideParent(e,t){if(0==t)this._cachedMapping.has(e)?this._clearCacheAll(e):this._clearCacheInsideParent(e.parent,e.index);else{let i=e.getChild(t-1);this._clearCacheAfter(i)}}_clearCacheAll(e){let t=this._cachedMapping.get(e);t.maxModelOffset>0&&(t.maxModelOffset=0,t.cacheList.length=1,t.cacheMap.clear(),t.cacheMap.set(0,t.cacheList[0]))}_clearCacheAfter(e){let t=this._nodeToCacheListIndex.get(e);if(void 0===t){let t=e.parent;this._cachedMapping.has(t)||this._clearCacheInsideParent(t.parent,t.index);return}let i=e.parent;for(;!this._cachedMapping.has(i);)i=i.parent;this._clearCacheFromCacheIndex(i,t)}_clearCacheFromCacheIndex(e,t){0===t&&(t=1);let i=this._cachedMapping.get(e),r=i.cacheList[t-1];if(r)for(let e of(i.maxModelOffset=r.modelOffset,i.cacheList.splice(t))){i.cacheMap.delete(e.modelOffset);let t=e.viewPosition.nodeBefore;this._nodeToCacheListIndex.delete(t)}}_findInCacheList(e,t){let i=0,r=e.length-1,n=r-i>>1,s=e[n];for(;i<r;)s.modelOffset<t?i=n+1:r=n-1,s=e[n=i+(r-i>>1)];return s.modelOffset<=t?s:e[n-1]}}class tg{_consumable=new Map;_textProxyRegistry=new Map;add(e,t){t=tp(t),e instanceof tr&&(e=this._getSymbolForTextProxy(e)),this._consumable.has(e)||this._consumable.set(e,new Map),this._consumable.get(e).set(t,!0)}consume(e,t){return t=tp(t),e instanceof tr&&(e=this._getSymbolForTextProxy(e)),!!this.test(e,t)&&(this._consumable.get(e).set(t,!1),!0)}test(e,t){t=tp(t),e instanceof tr&&(e=this._getSymbolForTextProxy(e));let i=this._consumable.get(e);if(void 0===i)return null;let r=i.get(t);return void 0===r?null:r}revert(e,t){t=tp(t),e instanceof tr&&(e=this._getSymbolForTextProxy(e));let i=this.test(e,t);return!1===i?(this._consumable.get(e).set(t,!0),!0):!0!==i&&null}verifyAllConsumed(e){let t=[];for(let[i,r]of this._consumable)for(let[n,s]of r){let r=n.split(":")[0];s&&e==r&&t.push({event:n,item:i.name||i.description})}if(t.length)throw new r.Yb("conversion-model-consumable-not-consumed",null,{items:t})}_getSymbolForTextProxy(e){let t=null,i=this._textProxyRegistry.get(e.startOffset);if(i){let r=i.get(e.endOffset);r&&(t=r.get(e.parent))}return t||(t=this._addSymbolForTextProxy(e)),t}_addSymbolForTextProxy(e){let t,i,r=e.startOffset,n=e.endOffset,s=e.parent,o=Symbol("$textProxy:"+e.data);return(t=this._textProxyRegistry.get(r))||(t=new Map,this._textProxyRegistry.set(r,t)),(i=t.get(n))||(i=new Map,t.set(n,i)),i.set(s,o),o}}function tp(e){let t=e.split(":");return"insert"==t[0]?t[0]:"addMarker"==t[0]||"removeMarker"==t[0]?e:t.length>1?t[0]+":"+t[1]:t[0]}class t_ extends(0,r.Mm)(){_conversionApi;_firedEventsMap;constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,i){let r=e.getRefreshedItems(),n=this._createConversionApi(i,r);for(let t of e.getMarkersToRemove())this._convertMarkerRemove(t.name,t.range,n);for(let t of this._reduceChanges(e.getChanges(),r))"insert"===t.type?this._convertInsert(tc._createFromPositionAndShift(t.position,t.length),n):"reinsert"===t.type?this._convertReinsert(tc._createFromPositionAndShift(t.position,t.length),n):"remove"===t.type?this._convertRemove(t.position,t.length,t.name,n):this._convertAttribute(t.range,t.attributeKey,t.attributeOldValue,t.attributeNewValue,n);for(let e of(n.mapper.flushDeferredBindings(),n.mapper.flushUnboundMarkerNames())){let i=t.get(e).getRange();this._convertMarkerRemove(e,i,n),this._convertMarkerAdd(e,i,n)}for(let t of e.getMarkersToAdd())this._convertMarkerAdd(t.name,t.range,n);n.consumable.verifyAllConsumed("insert")}convert(e,t,i,r={}){let n=this._createConversionApi(i,void 0,r);for(let[i,r]of(this._convertInsert(e,n),t))this._convertMarkerAdd(i,r,n);n.consumable.verifyAllConsumed("insert")}convertSelection(e,t,i){let r=this._createConversionApi(i);this.fire("cleanSelection",{selection:e},r);let n=e.getFirstPosition().root;if(!r.mapper.toViewElement(n))return;let s=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(r.consumable,e,s),this.fire("selection",{selection:e},r),e.isCollapsed){for(let t of s)if(r.consumable.test(e,"addMarker:"+t.name)){let i=t.getRange();if(!function(e,t,i){let r=t.getRange(),n=Array.from(e.getAncestors());return n.shift(),n.reverse(),!n.some(e=>{if(r.containsItem(e))return!!i.toViewElement(e).getCustomProperty("addHighlight")})}(e.getFirstPosition(),t,r.mapper))continue;let n={item:e,markerName:t.name,markerRange:i};
1this.fire(`addMarker:${t.name}`,n,r)}for(let t of e.getAttributeKeys())if(r.consumable.test(e,"attribute:"+t)){let i={item:e,range:e.getFirstRange(),attributeKey:t,attributeOldValue:null,attributeNewValue:e.getAttribute(t)};this.fire(`attribute:${t}:$text`,i,r)}}}_convertInsert(e,t,i={}){for(let r of(i.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,e),e.getWalker({shallow:!0})))this._testAndFire("insert",tw(r),t)}_convertRemove(e,t,i,r){this.fire(`remove:${i}`,{position:e,length:t},r)}_convertAttribute(e,t,i,r,n){for(let s of(this._addConsumablesForRange(n.consumable,e,`attribute:${t}`),e)){let e={item:s.item,range:tc._createFromPositionAndShift(s.previousPosition,s.length),attributeKey:t,attributeOldValue:i,attributeNewValue:r};this._testAndFire(`attribute:${t}`,e,n)}}_convertReinsert(e,t){let i=Array.from(e.getWalker({shallow:!0}));for(let e of(this._addConsumablesForInsert(t.consumable,i),i.map(tw)))this.fire(`remove:${e.item.is("element")?e.item.name:"$text"}`,{position:e.range.start,length:e.item.offsetSize,reconversion:!0},t),this._testAndFire("insert",{...e,reconversion:!0},t)}_convertMarkerAdd(e,t,i){if("$graveyard"==t.root.rootName)return;let r=`addMarker:${e}`;if(i.consumable.add(t,r),this.fire(r,{markerName:e,markerRange:t},i),i.consumable.consume(t,r))for(let n of(this._addConsumablesForRange(i.consumable,t,r),t.getItems())){if(!i.consumable.test(n,r))continue;let s={item:n,range:tc._createOn(n),markerName:e,markerRange:t};this.fire(r,s,i)}}_convertMarkerRemove(e,t,i){"$graveyard"!=t.root.rootName&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},i)}_reduceChanges(e,t){let i={changes:e,refreshedItems:t};return this.fire("reduceChanges",i),i.changes}_addConsumablesForInsert(e,t){for(let i of t){let t=i.item;if(null===e.test(t,"insert"))for(let i of(e.add(t,"insert"),t.getAttributeKeys()))e.add(t,"attribute:"+i)}return e}_addConsumablesForRange(e,t,i){for(let r of t.getItems())e.add(r,i);return e}_addConsumablesForSelection(e,t,i){for(let r of(e.add(t,"selection"),i))e.add(t,"addMarker:"+r.name);for(let i of t.getAttributeKeys())e.add(t,"attribute:"+i);return e}_testAndFire(e,t,i){let r=function(e,t){let i=t.item.is("element")?t.item.name:"$text";return`${e}:${i}`}(e,t),n=t.item.is("$textProxy")?i.consumable._getSymbolForTextProxy(t.item):t.item,s=this._firedEventsMap.get(i),o=s.get(n);if(o)if(o.has(r))return;else o.add(r);else s.set(n,new Set([r]));this.fire(r,t,i)}_testAndFireAddAttributes(e,t){let i={item:e,range:tc._createOn(e)};for(let e of i.item.getAttributeKeys())i.attributeKey=e,i.attributeOldValue=null,i.attributeNewValue=i.item.getAttribute(e),this._testAndFire(`attribute:${e}`,i,t)}_createConversionApi(e,t=new Set,i={}){let r={...this._conversionApi,consumable:new tg,writer:e,options:i,convertItem:e=>this._convertInsert(tc._createOn(e),r),convertChildren:e=>this._convertInsert(tc._createIn(e),r,{doNotAddConsumables:!0}),convertAttributes:e=>this._testAndFireAddAttributes(e,r),canReuseView:e=>!t.has(r.mapper.toModelElement(e))};return this._firedEventsMap.set(r,new Map),r}}function tw(e){return{item:e.item,range:tc._createFromPositionAndShift(e.previousPosition,e.length)}}class tb extends ti{parent=null;_attrs;_index=null;_startOffset=null;constructor(e){super(),this._attrs=(0,r.av)(e)}get document(){return null}get index(){return this._index}get startOffset(){return this._startOffset}get offsetSize(){return 1}get endOffset(){return null===this.startOffset?null:this.startOffset+this.offsetSize}get nextSibling(){let e=this.index;return null!==e&&this.parent.getChild(e+1)||null}get previousSibling(){let e=this.index;return null!==e&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return null!==this.parent&&this.root.isAttached()}getPath(){let e=[],t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={}){let t=[],i=e.includeSelf?this:this.parent;for(;i;)t[e.parentFirst?"push":"unshift"](i),i=i.parent;return t}getCommonAncestor(e,t={}){let i=this.getAncestors(t),r=e.getAncestors(t),n=0;for(;i[n]==r[n]&&i[n];)n++;return 0===n?null:i[n-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;let t=this.getPath(),i=e.getPath(),n=(0,r.ww)(t,i);switch(n){case"prefix":return!0;case"extension":return!1;default:return t[n]<i[n]}}isAfter(e){return this!=e&&this.root===e.root&&!this.isBefore(e)}hasAttribute(e){return this._attrs.has(e)}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}toJSON(){let e={};return this._attrs.size&&(e.attributes=Array.from(this._attrs).reduce((e,t)=>
1(e[t[0]]=t[1],e),{})),e}_clone(e){return new this.constructor(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,t){this._attrs.set(e,t)}_setAttributesTo(e){this._attrs=(0,r.av)(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}tb.prototype.is=function(e){return"node"===e||"model:node"===e};class ty extends(0,r.Mm)(ti){_lastRangeBackward=!1;_attrs=new Map;_ranges=[];constructor(...e){super(),e.length&&this.setTo(...e)}get anchor(){if(this._ranges.length>0){let e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){let 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(let t of this._ranges){let i=!1;for(let r of e._ranges)if(t.isEqual(r)){i=!0;break}if(!i)return!1}return!0}*getRanges(){for(let e of this._ranges)yield new tc(e.start,e.end)}getFirstRange(){let e=null;for(let t of this._ranges)(!e||t.start.isBefore(e.start))&&(e=t);return e?new tc(e.start,e.end):null}getLastRange(){let e=null;for(let t of this._ranges)(!e||t.end.isAfter(e.end))&&(e=t);return e?new tc(e.start,e.end):null}getFirstPosition(){let e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){let e=this.getLastRange();return e?e.end.clone():null}setTo(...e){let[t,i,n]=e;if("object"==typeof i&&(n=i,i=void 0),null===t)this._setRanges([]);else if(t instanceof ty)this._setRanges(t.getRanges(),t.isBackward);else if(t&&"function"==typeof t.getRanges)this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof tc)this._setRanges([t],!!n&&!!n.backward);else if(t instanceof to)this._setRanges([new tc(t)]);else if(t instanceof tb){let e,s=!!n&&!!n.backward;if("in"==i)e=tc._createIn(t);else if("on"==i)e=tc._createOn(t);else if(void 0!==i)e=new tc(to._createAt(t,i));else throw new r.Yb("model-selection-setto-required-second-parameter",[this,t]);this._setRanges([e],s)}else if((0,r.xZ)(t))this._setRanges(t,n&&!!n.backward);else throw new r.Yb("model-selection-setto-not-selectable",[this,t])}_setRanges(e,t=!1){let i=Array.from(e),n=i.some(t=>{if(!(t instanceof tc))throw new r.Yb("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every(e=>!e.isEqual(t))});(i.length!==this._ranges.length||n)&&(this._replaceAllRanges(i),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(null===this.anchor)throw new r.Yb("model-selection-setfocus-no-ranges",[this,e]);let i=to._createAt(e,t);if("same"==i.compareWith(this.focus))return;let n=this.anchor;this._ranges.length&&this._popRange(),"before"==i.compareWith(n)?(this._pushRange(new tc(i,n)),this._lastRangeBackward=!0):(this._pushRange(new tc(n,i)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return 1!==this.rangeCount?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){let e=new WeakSet;for(let l of this.getRanges()){var t,i,r,n,s,o,a;let h=tP(l.start,e);t=h,i=l,t&&(i.isCollapsed||t.isEmpty||!i.start.isTouching(to._createAt(t,t.maxOffset))&&tC(t,i))&&(yield h);let d=l.getWalker();for(let t of d){let i=t.item;"elementEnd"==t.type&&(r=i,n=e,s=l,tv(r,n)&&tC(r,s))?yield i:"elementStart"==t.type&&i.is("model:element")&&i.root.document.model.schema.isBlock(i)&&d.jumpTo(to._createAt(i,"end"))}let u=tP(l.end,e);o=u,a=l,o&&(a.isCollapsed||o.isEmpty||!a.end.isTouching(to._createAt(o,0))&&tC(o,a))&&(yield u)}}containsEntireContent(e=this.anchor.root){let t=to._createAt(e,0),i=to._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&i.isTouching(this.getLastPosition())}toJSON(){let e={ranges:Array.from(this.getRanges()).map(e=>e.toJSON())},t=Object.fromEntries(this.getAttributes());return Object.keys(t).length&&(e.attributes=t),this.isBackward&&(e.isBackward=!0),e}_pushRange(e){this._checkRange(e),this._ranges.push(new tc(e.start,e.end))}_checkRange(e){for(let t=0;t<this._ranges.length;t++)if(e.isIntersecting(this._ranges[t]))throw new r.Yb("model-selection-range-intersects",[this,e],{addedRange:e,intersectingRange:this._ranges[t]})}_replaceAllRanges(e){for(let t of(this._removeAllRanges(),e))this._pushRange(t)}
1_removeAllRanges(){for(;this._ranges.length>0;)this._popRange()}_popRange(){this._ranges.pop()}}function tv(e,t){return!t.has(e)&&(t.add(e),e.root.document.model.schema.isBlock(e)&&!!e.parent)}function tP(e,t){let i=e.parent.root.document.model.schema,r=e.parent.getAncestors({parentFirst:!0,includeSelf:!0}),n=!1,s=r.find(e=>!n&&!(n=i.isLimit(e))&&tv(e,t));return r.forEach(e=>t.add(e)),s}function tC(e,t){let i=function(e){let t=e.root.document.model.schema,i=e.parent;for(;i;){if(t.isBlock(i))return i;i=i.parent}}(e);return!i||!t.containsRange(tc._createOn(i),!0)}ty.prototype.is=function(e){return"selection"===e||"model:selection"===e};class tA extends(0,r.Mm)(tc){constructor(e,t){super(e,t),tk.call(this)}detach(){this.stopListening()}toRange(){return new tc(this.start,this.end)}static fromRange(e){return new tA(e.start,e.end)}}function tk(){this.listenTo(this.root.document.model,"applyOperation",(e,t)=>{let i=t[0];i.isDocumentOperation&&tS.call(this,i)},{priority:"low"})}function tS(e){let t=this.getTransformedByOperation(e),i=tc._createFromRanges(t),r=!i.isEqual(this),n=function(e,t){switch(t.type){case"insert":return e.containsPosition(t.position);case"move":case"remove":case"reinsert":case"merge":return e.containsPosition(t.sourcePosition)||e.start.isEqual(t.sourcePosition)||e.containsPosition(t.targetPosition);case"split":return e.containsPosition(t.splitPosition)||e.containsPosition(t.insertionPosition)}return!1}(this,e),s=null;if(r){"$graveyard"==i.root.rootName&&(s="remove"==e.type?e.sourcePosition:e.deletionPosition);let t=this.toRange();this.start=i.start,this.end=i.end,this.fire("change:range",t,{deletionPosition:s})}else n&&this.fire("change:content",this.toRange(),{deletionPosition:s})}tA.prototype.is=function(e){return"liveRange"===e||"model:liveRange"===e||"range"==e||"model:range"===e};class tE extends tb{_data;constructor(e,t){super(t),this._data=e||""}get offsetSize(){return this.data.length}get data(){return this._data}toJSON(){let e=super.toJSON();return e.data=this.data,e}_clone(){return new tE(this.data,this.getAttributes())}static fromJSON(e){return new tE(e.data,e.attributes)}}tE.prototype.is=function(e){return"$text"===e||"model:$text"===e||"text"===e||"model:text"===e||"node"===e||"model:node"===e};let tR="selection:";class tx extends(0,r.Mm)(ti){_selection;constructor(e){super(),this._selection=new tO(e),this._selection.delegate("change:range").to(this),this._selection.delegate("change:attribute").to(this),this._selection.delegate("change:marker").to(this)}get isCollapsed(){return this._selection.isCollapsed}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get rangeCount(){return this._selection.rangeCount}get hasOwnRange(){return this._selection.hasOwnRange}get isBackward(){return this._selection.isBackward}get isGravityOverridden(){return this._selection.isGravityOverridden}get markers(){return this._selection.markers}get _ranges(){return this._selection._ranges}getRanges(){return this._selection.getRanges()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getSelectedBlocks(){return this._selection.getSelectedBlocks()}getSelectedElement(){return this._selection.getSelectedElement()}containsEntireContent(e){return this._selection.containsEntireContent(e)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(e){return this._selection.getAttribute(e)}hasAttribute(e){return this._selection.hasAttribute(e)}refresh(){this._selection.updateMarkers(),this._selection._updateAttributes(!1)}observeMarkers(e){this._selection.observeMarkers(e)}toJSON(){return this._selection.toJSON()}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(...e){this._selection.setTo(...e)}_setAttribute(e,t){this._selection.setAttribute(e,t)}_removeAttribute(e){this._selection.removeAttribute(e)}_getStoredAttributes(){return this._selection.getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(e){this._selection.restoreGravity(e)}static _getStoreAttributeKey(e){return tR+e}static _isStoreAttributeKey(e){return e.startsWith(tR)}}tx.prototype.is=function(e){return"selection"===e||"model:selection"==e||"documentSelection"==e||"model:documentSelection"==e};class tO extends ty{markers=new r.pM({idProperty:"name"});_model;_document;_attributePriority=new Map;_selectionRestorePosition=null;_hasChangedRange=!1;_overriddenGravityRegister=new Set;_observedMarkers=new Set;constructor(e){super(),this._model=e.model,this._document=e,this.listenTo(this._model,"applyOperation",(e,t)=>{let i=t[0];i.isDocumentOperation&&"marker"!=i.type&&"rename"!=i.type&&"noop"!=i.type&&(0==this._ranges.length&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))},{priority:"lowest"}),this.on("change:range",()=>
1{this._validateSelectionRanges(this.getRanges())}),this.listenTo(this._model.markers,"update",(e,t,i,r)=>{this._updateMarker(t,r)}),this.listenTo(this._document,"change",(e,t)=>{!function(e,t){for(let i of e.document.differ.getChanges()){if("insert"!=i.type)continue;let r=i.position.parent;i.length===r.maxOffset&&e.enqueueChange(t,e=>{for(let t of Array.from(r.getAttributeKeys()).filter(e=>e.startsWith(tR)))e.removeAttribute(t,r)})}}(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<this._ranges.length;e++)this._ranges[e].detach();this.stopListening()}*getRanges(){this._ranges.length?yield*super.getRanges():yield this._document._getDefaultRange()}getFirstRange(){return super.getFirstRange()||this._document._getDefaultRange()}getLastRange(){return super.getLastRange()||this._document._getDefaultRange()}setTo(...e){super.setTo(...e),this._updateAttributes(!0),this.updateMarkers()}setFocus(e,t){super.setFocus(e,t),this._updateAttributes(!0),this.updateMarkers()}setAttribute(e,t){this._setAttribute(e,t)&&this.fire("change:attribute",{attributeKeys:[e],directChange:!0})}removeAttribute(e){this._removeAttribute(e)&&this.fire("change:attribute",{attributeKeys:[e],directChange:!0})}overrideGravity(){let e=(0,r.Ld)();return this._overriddenGravityRegister.add(e),1===this._overriddenGravityRegister.size&&this._updateAttributes(!0),e}restoreGravity(e){if(!this._overriddenGravityRegister.has(e))throw new r.Yb("document-selection-gravity-wrong-restore",this,{uid:e});this._overriddenGravityRegister.delete(e),this.isGravityOverridden||this._updateAttributes(!0)}observeMarkers(e){this._observedMarkers.add(e),this.updateMarkers()}_replaceAllRanges(e){this._validateSelectionRanges(e),super._replaceAllRanges(e)}_popRange(){this._ranges.pop().detach()}_pushRange(e){let t=this._prepareRange(e);t&&this._ranges.push(t)}toJSON(){let e=super.toJSON();return this.markers.length&&(e.markers=this.markers.map(e=>e.toJSON())),e}_validateSelectionRanges(e){for(let t of e)if(!this._document._validateSelectionRange(t))throw new r.Yb("document-selection-wrong-position",this,{range:t})}_prepareRange(e){if(this._checkRange(e),e.root==this._document.graveyard)return;let t=tA.fromRange(e);return t.on("change:range",(e,i,r)=>{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=r.deletionPosition;let e=this._ranges.indexOf(t);this._ranges.splice(e,1),t.detach()}}),t}updateMarkers(){if(!this._observedMarkers.size)return;let e=[],t=!1;for(let t of this._model.markers){let i=t.name.split(":",1)[0];if(!this._observedMarkers.has(i))continue;let r=t.getRange();for(let i of this.getRanges())r.containsRange(i,!i.isCollapsed)&&e.push(t)}let i=Array.from(this.markers);for(let i of e)this.markers.has(i)||(this.markers.add(i),t=!0);for(let i of Array.from(this.markers))e.includes(i)||(this.markers.remove(i),t=!0);t&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateMarker(e,t){let i=e.name.split(":",1)[0];if(!this._observedMarkers.has(i))return;let r=!1,n=Array.from(this.markers),s=this.markers.has(e);if(t){let i=!1;for(let e of this.getRanges())if(t.containsRange(e,!e.isCollapsed)){i=!0;break}i&&!s?(this.markers.add(e),r=!0):!i&&s&&(this.markers.remove(e),r=!0)}else s&&(this.markers.remove(e),r=!0);r&&this.fire("change:marker",{oldMarkers:n,directChange:!1})}_updateAttributes(e){let t=(0,r.av)(this._getSurroundingAttributes()),i=(0,r.av)(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(let[e,t]of this._attributePriority)"low"==t&&(this._attrs.delete(e),this._attributePriority.delete(e));this._setAttributesTo(t);let n=[];for(let[e,t]of this.getAttributes())i.has(e)&&i.get(e)===t||n.push(e);for(let[e]of i)this.hasAttribute(e)||n.push(e);n.length>0&&this.fire("change:attribute",{attributeKeys:n,directChange:!1})}_setAttribute(e,t,i=!0){let r=i?"normal":"low";return("low"!=r||"normal"!=this._attributePriority.get(e))&&super.getAttribute(e)!==t&&(this._attrs.set(e,t),this._attributePriority.set(e,r),!0)}_removeAttribute(e,t=!0){let i=t?"normal":"low";return("low"!=i||"normal"!=this._attributePriority.get(e))&&(this._attributePriority.set(e,i),!!super.hasAttribute(e)&&(this._attrs.delete(e),!0))}_setAttributesTo(e){let t=new Set;for(let[t,i]of this.getAttributes())e.get(t)!==i&&this._removeAttribute(t,!1);for(let[i,r]of e)this._setAttribute(i,r,!1)&&t.add(i);return t}*getStoredAttributes(){let e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty){for(let t of e.getAttributeKeys())if(t.startsWith(tR)){let i=t.substr(tR.length);yield[i,e.getAttribute(t)]}}}_getSurroundingAttributes(){let e=this.getFirstPosition(),t=this._model.schema;if("$graveyard"==e.root.rootName)return null;let i=null;if(this.isCollapsed){let r=e.textNode?e.textNode:e.nodeBefore,n=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(i=tM(r,t)),i||(i=tM(n,t)),!this.isGravityOverridden&&!i){let e=r;
1for(;e&&!i;)i=tM(e=e.previousSibling,t)}if(!i){let e=n;for(;e&&!i;)i=tM(e=e.nextSibling,t)}i||(i=this.getStoredAttributes())}else for(let e of this.getFirstRange()){if(e.item.is("element")&&t.isObject(e.item)){i=tM(e.item,t);break}if("text"==e.type){i=e.item.getAttributes();break}}return i}_fixGraveyardSelection(e){let t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function tM(e,t){if(!e)return null;if(e instanceof tr||e instanceof tE)return e.getAttributes();if(!t.isInline(e))return null;if(!t.isObject(e))return[];let i=[];for(let[r,n]of e.getAttributes())t.checkAttribute("$text",r)&&!1!==t.getAttributeProperties(r).copyFromObject&&i.push([r,n]);return i}class tT{_nodes=[];_offsetToNode=[];constructor(e){e&&this._insertNodes(0,e)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._offsetToNode.length}getNode(e){return this._nodes[e]||null}getNodeAtOffset(e){return this._offsetToNode[e]||null}getNodeIndex(e){return e.index}getNodeStartOffset(e){return e.startOffset}indexToOffset(e){if(e==this._nodes.length)return this.maxOffset;let t=this._nodes[e];if(!t)throw new r.Yb("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){if(e==this._offsetToNode.length)return this._nodes.length;let t=this._offsetToNode[e];if(!t)throw new r.Yb("model-nodelist-offset-out-of-bounds",this,{offset:e,nodeList:this});return this.getNodeIndex(t)}
1_insertNodes(e,t){let i=[];for(let e of t){if(!(e instanceof tb))throw new r.Yb("model-nodelist-insertnodes-not-node",this);i.push(e)}let n=this.indexToOffset(e);(0,r.eL)(this._nodes,i,e),(0,r.eL)(this._offsetToNode,function(e){let t=[],i=0;for(let r of e)for(let e=0;e<r.offsetSize;e++)t[i++]=r;return t}(i),n);for(let t=e;t<this._nodes.length;t++)this._nodes[t]._index=t,this._nodes[t]._startOffset=n,n+=this._nodes[t].offsetSize}_removeNodes(e,t=1){if(0==t)return[];let i=this.indexToOffset(e),r=this._nodes.splice(e,t),n=r[r.length-1],s=n.startOffset+n.offsetSize-i;for(let e of(this._offsetToNode.splice(i,s),r))e._index=null,e._startOffset=null;for(let t=e;t<this._nodes.length;t++)this._nodes[t]._index=t,this._nodes[t]._startOffset=i,i+=this._nodes[t].offsetSize;return r}_removeNodesArray(e){if(0==e.length)return;for(let t of e)t._index=null,t._startOffset=null;this._nodes=this._nodes.filter(e=>null!==e.index),this._offsetToNode=this._offsetToNode.filter(e=>null!==e.index);let t=0;for(let e=0;e<this._nodes.length;e++)this._nodes[e]._index=e,this._nodes[e]._startOffset=t,t+=this._nodes[e].offsetSize}toJSON(){return this._nodes.map(e=>e.toJSON())}}class tN extends tb{name;_children=new tT;constructor(e,t,i){super(t),this.name=e,i&&this._insertChild(0,i)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let t=this;for(let i of e)t=t.getChildAtOffset(i);return t}findAncestor(e,t={}){let i=t.includeSelf?this:this.parent;for(;i;){if(i.name===e)return i;i=i.parent}return null}toJSON(){let e=super.toJSON();if(e.name=this.name,this._children.length>0)for(let t of(e.children=[],this._children))e.children.push(t.toJSON());return e}_clone(e=!1){let t=e?function(e){let t=[];for(let i of e)t.push(i._clone(!0));return t}(this._children):void 0;return new tN(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){let i=function(e){if("string"==typeof e)return[new tE(e)];(0,r.xZ)(e)||(e=[e]);let t=[];for(let i of e)"string"==typeof i?t.push(new tE(i)):i instanceof tr?t.push(new tE(i.data,i.getAttributes())):t.push(i);return t}(t);for(let e of i)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,i)}_removeChildren(e,t=1){let i=this._children._removeNodes(e,t);for(let e of i)e.parent=null;return i}_removeChildrenArray(e){for(let t of(this._children._removeNodesArray(e),e))t.parent=null}static fromJSON(e){let t;if(e.children)for(let i of(t=[],e.children))i.name?t.push(tN.fromJSON(i)):t.push(tE.fromJSON(i));return new tN(e.name,e.attributes,t)}}tN.prototype.is=function(e,t){return t?t===this.name&&("element"===e||"model:element"===e):"element"===e||"model:element"===e||"node"===e||"model:node"===e};class tF{_dispatchers;constructor(e){this._dispatchers=e}add(e){for(let t of this._dispatchers)e(t);return this}}class tI extends tF{elementToElement(e){return this.add(function(e){let t=tU(e.model),i=tK(e.view,"container");return t.attributes.length&&(t.children=!0),r=>{r.on(`insert:${t.name}`,tW(i,tX(t)),{priority:e.converterPriority||"normal"}),(t.children||t.attributes.length)&&r.on("reduceChanges",tQ(t),{priority:"low"})}}(e))}elementToStructure(e){return this.add(function(e){let t=tU(e.model),i=tK(e.view,"container");return t.children=!0,n=>{var s;if(n._conversionApi.schema.checkChild(t.name,"$text"))throw new r.Yb("conversion-element-to-structure-disallowed-text",n,{elementName:t.name});n.on(`insert:${t.name}`,(s=tX(t),(e,t,n)=>{var o,a,l;if(!s(t.item,n.consumable,{preflight:!0}))return;let h=new Map;n.writer._registerSlotFactory((o=t.item,a=h,l=n,(e,t)=>{let i=e.createContainerElement("$slot"),n=null;if("children"===t)n=Array.from(o.getChildren());else if("function"==typeof t)n=Array.from(o.getChildren()).filter(e=>t(e));else throw new r.Yb("conversion-slot-mode-unknown",l.dispatcher,{modeOrFilter:t});return a.set(i,n),i}));let d=i(t.item,n,t);if(n.writer._clearSlotFactory(),!d)return;(function(e,t,i){let n=Array.from(t.values()).flat(),s=new Set(n);if(s.size!=n.length)throw new r.Yb("conversion-slot-filter-overlap",i.dispatcher,{element:e});if(s.size!=e.childCount)throw new r.Yb("conversion-slot-filter-incomplete",i.dispatcher,{element:e})})(t.item,h,n),s(t.item,n.consumable);let u=t.reconversion&&tj(t.item,n)||n.mapper.toViewPosition(t.range.start);n.mapper.bindElements(t.item,d),n.writer.insert(u,d),n.convertAttributes(t.item),function(e,t,i,r){i.mapper.on("modelToViewPosition",o,{priority:"highest"});let n=null,s=null;for([n,s]of t)t0(e,s,i,r),i.writer.setCustomProperty("$structureSlotParent",!0,n.parent),i.writer.move(i.writer.createRangeIn(n),i.writer.createPositionBefore(n)),i.writer.remove(n);function o(e,t){let i=t.modelPosition.nodeAfter,r=s.indexOf(i);r<0||(t.viewPosition=t.mapper.findPositionIn(n,r))}i.mapper.off("modelToViewPosition",o)}(d,h,n,{reconversion:t.reconversion})}),{priority:e.converterPriority||"normal"}),n.on("reduceChanges",tQ(t),{priority:"low"})}}(e))}attributeToElement(e){return this.add(function(e){let t=(e=(0,c.m)(e)).model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;if(t.name&&(i+=":"+t.name),t.values)for(let i of t.values)e.view[i]=tK(e.view[i],"attribute");else e.view=tK(e.view,"attribute");let r=tH(e);return t=>{t.on(i,tq(r),{priority:e.converterPriority||"normal"})}}(e))}attributeToAttribute(e){return this.add(function(e){let t=(e=(0,c.m)(e)).model;"string"==typeof t&&(t={key:t});let i=`attribute:${t.key}`;if(t.name&&(i+=":"+t.name),t.values)for(let i of t.values)e.view[i]=tG(e.view[i]);else e.view=tG(e.view);let n=tH(e);return t=>{t.on(i,(e,t,i)=>{if(!i.consumable.test(t.item,e.name))return;let s=n(t.attributeOldValue,i,t),o=n(t.attributeNewValue,i,t);if(!s&&!o)return;i.consumable.consume(t.item,e.name);let a=i.mapper.toViewElement(t.item),l=i.writer;if(!a)throw new r.Yb("conversion-attribute-to-attribute-on-text",i.dispatcher,t);if(null!==t.attributeOldValue&&s){let e=s.value;"style"==s.key&&(e="string"==typeof s.value?new T(l.document.stylesProcessor).setTo(s.value).getStylesEntries().map(([e])=>e):Object.keys(s.value)),l.removeAttribute(s.key,e,a)}if(null!==t.attributeNewValue&&o){let e=o.value;"style"==o.key&&"string"==typeof o.value&&(e=Object.fromEntries(new T(l.document.stylesProcessor).setTo(o.value).getStylesEntries())),l.setAttribute(o.key,e,!1,a)}},{priority:e.converterPriority||"normal"})}}(e))}markerToElement(e){return this.add(function(e){let t=tK(e.view,"ui");return i=>{i.on(`addMarker:${e.model}`,tY(t),{priority:e.converterPriority||"normal"}),i.on(`removeMarker:${e.model}`,(e,t,i)=>{let r=i.mapper.markerNameToElements(t.markerName);if(r){for(let e of r)i.mapper.unbindElementFromMarkerName(e,t.markerName),i.writer.clear(i.writer.createRangeOn(e),e);i.writer.clearClonedElementsGroup(t.markerName),e.stop()}},{priority:e.converterPriority||"normal"})}}(e))}markerToHighlight(e){var t;return this.add((t=e,e=>{var i,r,n;e.on(`addMarker:${t.model}`,(i=t.view,(e,t,r)=>{if(!t.item||!(t.item instanceof ty||t.item instanceof tx)&&!t.item.is("$textProxy"))return;let n=tZ(i,t,r);if(!n||!r.consumable.consume(t.item,e.name))return;let s=r.writer,o=tV(s,n),a=s.document.selection;if(t.item instanceof ty||t.item instanceof tx)s.wrap(a.getFirstRange(),o);else{let e=r.mapper.toViewRange(t.range);for(let i of s.wrap(e,o).getItems())if(i.is("attributeElement")&&i.isSimilar(o)){r.mapper.bindElementToMarker(i,t.markerName);break}}}),{priority:t.converterPriority||"normal"}),e.on(`addMarker:${t.model}`,(r=t.view,(e,t,i)=>{if(!t.item||!(t.item instanceof tN))return;let n=tZ(r,t,i);if(!n||!i.consumable.test(t.item,e.name))return;let s=i.mapper.toViewElement(t.item);if(s&&s.getCustomProperty("addHighlight")){for(let r of(i.consumable.consume(t.item,e.name),tc._createIn(t.item)))i.consumable.consume(r.item,e.name);s.getCustomProperty("addHighlight")(s,n,i.writer),i.mapper.bindElementToMarker(s,t.markerName)}}),{priority:t.converterPriority||"normal"}),e.on(`removeMarker:${t.model}`,(n=t.view,(e,t,i)=>{if(t.markerRange.isCollapsed)return;let r=tZ(n,t,i);if(!r)return;let s=tV(i.writer,r),o=i.mapper.markerNameToElements(t.markerName);if(o){for(let e of o)i.mapper.unbindElementFromMarkerName(e,t.markerName),e.is("attributeElement")?i.writer.unwrap(i.writer.createRangeOn(e),s):e.getCustomProperty("removeHighlight")(e,r.id,i.writer);i.writer.clearClonedElementsGroup(t.markerName),e.stop()}}),{priority:t.converterPriority||"normal"})}))}markerToData(e){return this.add(function(e){let t=(e=(0,c.m)(e)).model,i=e.view;
1return i||(i=i=>({group:t,name:i.substr(e.model.length+1)})),r=>{var n,s;r.on(`addMarker:${t}`,(n=i,(e,t,i)=>{let r=n(t.markerName,i);if(!r)return;let s=t.markerRange;i.consumable.consume(s,e.name)&&(tz(s,!1,i,t,r),tz(s,!0,i,t,r),e.stop())}),{priority:e.converterPriority||"normal"}),r.on(`removeMarker:${t}`,(s=i,(e,t,i)=>{let r=s(t.markerName,i);if(!r)return;let n=i.mapper.markerNameToElements(t.markerName);if(n){for(let e of n)i.mapper.unbindElementFromMarkerName(e,t.markerName),e.is("containerElement")?(o(`data-${r.group}-start-before`,e),o(`data-${r.group}-start-after`,e),o(`data-${r.group}-end-before`,e),o(`data-${r.group}-end-after`,e)):i.writer.clear(i.writer.createRangeOn(e),e);i.writer.clearClonedElementsGroup(t.markerName),e.stop()}function o(e,t){if(t.hasAttribute(e)){let n=new Set(t.getAttribute(e).split(","));n.delete(r.name),0==n.size?i.writer.removeAttribute(e,t):i.writer.setAttribute(e,Array.from(n).join(","),t)}}}),{priority:e.converterPriority||"normal"})}}(e))}}function tB(){return(e,t,i)=>{if(!i.consumable.consume(t.item,e.name))return;let r=i.writer,n=i.mapper.toViewPosition(t.range.start),s=r.createText(t.item.data);r.insert(n,s)}}function tD(){return(e,t,i)=>{i.convertAttributes(t.item),!t.reconversion&&t.item.is("element")&&!t.item.isEmpty&&i.convertChildren(t.item)}}function tV(e,t){let i=e.createAttributeElement("span",t.attributes);return t.classes&&i._addClass(t.classes),"number"==typeof t.priority&&(i._priority=t.priority),i._id=t.id,i}function t$(){return(e,t,i)=>{let r=t.selection;if(r.isCollapsed||!i.consumable.consume(r,"selection"))return;let n=[];for(let e of r.getRanges())n.push(i.mapper.toViewRange(e));i.writer.setSelection(n,{backward:r.isBackward})}}function tL(){return(e,t,i)=>{let r=t.selection;if(!r.isCollapsed||!i.consumable.consume(r,"selection"))return;let n=i.writer,s=r.getFirstPosition(),o=i.mapper.toViewPosition(s),a=n.breakAttributes(o);n.setSelection(a)}}function tq(e){return(t,i,r)=>{if(!r.consumable.test(i.item,t.name))return;let n=e(i.attributeOldValue,r,i),s=e(i.attributeNewValue,r,i);if(!n&&!s)return;r.consumable.consume(i.item,t.name);let o=r.writer,a=o.document.selection;if(i.item instanceof ty||i.item instanceof tx)o.wrap(a.getFirstRange(),s);else{let e=r.mapper.toViewRange(i.range);null!==i.attributeOldValue&&n&&(e=o.unwrap(e,n)),null!==i.attributeNewValue&&s&&o.wrap(e,s)}}}function tW(e,t=t1){return(i,r,n)=>{if(!t(r.item,n.consumable,{preflight:!0}))return;let s=e(r.item,n,r);if(!s)return;t(r.item,n.consumable);let o=r.reconversion&&tj(r.item,n)||n.mapper.toViewPosition(r.range.start);n.mapper.bindElements(r.item,s),n.writer.insert(o,s),n.convertAttributes(r.item),t0(s,r.item.getChildren(),n,{reconversion:r.reconversion})}}function tY(e){return(t,i,r)=>{i.isOpening=!0;let n=e(i,r);i.isOpening=!1;let s=e(i,r);if(!n||!s)return;let o=i.markerRange;if(o.isCollapsed&&!r.consumable.consume(o,t.name))return;for(let e of o)if(!r.consumable.consume(e.item,t.name))return;let a=r.mapper,l=r.writer;l.insert(a.toViewPosition(o.start),n),r.mapper.bindElementToMarker(n,i.markerName),o.isCollapsed||(l.insert(a.toViewPosition(o.end),s),r.mapper.bindElementToMarker(s,i.markerName)),t.stop()}}function tJ(e,t){let i=t.writer.remove(e);for(let e of t.writer.createRangeIn(i).getItems())t.mapper.unbindViewElement(e,{defer:!0});return e.start}function tj(e,t){let i=t.mapper.toViewElement(e);return i&&tJ(t.writer.createRangeOn(i),t)}function tz(e,t,i,r,n){let s=t?e.start:e.end,o=s.nodeAfter&&s.nodeAfter.is("element")?s.nodeAfter:null,a=s.nodeBefore&&s.nodeBefore.is("element")?s.nodeBefore:null;if(o||a){let e,s;t&&o||!t&&!a?(e=o,s=!0):(e=a,s=!1);let l=i.mapper.toViewElement(e);if(l)return void function(e,t,i,r,n,s){let o=`data-${s.group}-${t?"start":"end"}-${i?"before":"after"}`,a=e.hasAttribute(o)?e.getAttribute(o).split(","):[];a.unshift(s.name),r.writer.setAttribute(o,a.join(","),e),r.mapper.bindElementToMarker(e,n.markerName)}(l,t,s,i,r,n)}!function(e,t,i,r,n){let s=`${n.group}-${t?"start":"end"}`,o=n.name?{name:n.name}:null,a=i.writer.createUIElement(s,o);i.writer.insert(e,a),i.mapper.bindElementToMarker(a,r.markerName)}(i.mapper.toViewPosition(s),t,i,r,n)}function tU(e){return"string"==typeof e&&(e={name:e}),{name:e.name,attributes:e.attributes?(0,r.$r)(e.attributes):[],children:!!e.children}}function tK(e,t){return"function"==typeof e?e:(i,r)=>(function(e,t,i){let r;"string"==typeof e&&(e={name:e});let n=t.writer,s=Object.assign({},e.attributes);if("container"==i)r=n.createContainerElement(e.name,s);else if("attribute"==i){let t={priority:e.priority||el.DEFAULT_PRIORITY};r=n.createAttributeElement(e.name,s,t)}else r=n.createUIElement(e.name,s);if(e.styles)for(let t of Object.keys(e.styles))n.setStyle(t,e.styles[t],r);if(e.classes){let t=e.classes;if("string"==typeof t)n.addClass(t,r);else for(let e of t)n.addClass(e,r)}return r})(e,r,t)}function tH(e){return e.model.values?(t,i,r)=>{let n=e.view[t];return n?n(t,i,r):null}:e.view}function tG(e){return"string"==typeof e?t=>({key:e,value:t}):"object"!=typeof e?e:e.value?()=>e:t=>({key:e.key,value:t})}function tZ(e,t,i){let r="function"==typeof e?e(t,i):{...e};return r?(r.priority||(r.priority=10),r.id||(r.id=t.markerName),r):null}function tQ(e){let t=(t,i)=>{if(!t.is("element",e.name))return!1;if("attribute"==i.type){if(e.attributes.includes(i.attributeKey))return!0}else if(e.children)return!0;return!1};return(e,i)=>{let r=[];for(let e of(i.reconvertedElements||(i.reconvertedElements=new Set),i.changes)){let n="attribute"==e.type?e.range.start.nodeAfter:e.position.parent;
1if(!n||!t(n,e)||"reinsert"==e.type){r.push(e);continue}if("insert"==e.type&&"rename"==e.action&&i.refreshedItems.add(e.position.nodeAfter),!i.reconvertedElements.has(n)){i.reconvertedElements.add(n);let e=to._createBefore(n),t=r.length;for(let i=r.length-1;i>=0;i--){let n=r[i],s=("attribute"==n.type?n.range.start:n.position).compareWith(e);if("before"==s||"remove"==n.type&&"same"==s)break;t=i}r.splice(t,0,{type:"reinsert",name:n.name,position:e,length:1})}}i.changes=r}}function tX(e){return(t,i,r={})=>{let n=["insert"];for(let i of e.attributes)t.hasAttribute(i)&&n.push(`attribute:${i}`);return!!n.every(e=>i.test(t,e))&&(r.preflight||n.forEach(e=>i.consume(t,e)),!0)}}function t0(e,t,i,r){for(let n of t)!function(e,t,i,r){let{writer:n,mapper:s}=i;if(!r.reconversion)return!1;let o=s.toViewElement(t);return!!o&&o.root!=e&&!!i.canReuseView(o)&&(n.move(n.createRangeOn(o),s.toViewPosition(to._createBefore(t))),!0)}(e.root,n,i,r)&&i.convertItem(n)}function t1(e,t,{preflight:i}={}){return i?t.test(e,"insert"):t.consume(e,"insert")}function t9(e){let{schema:t,document:i}=e.model;for(let r of i.getRoots())if(r.isEmpty&&!t.checkChild(r,"$text")&&t.checkChild(r,"paragraph"))return e.insertElement("paragraph",r),!0;return!1}function t2(e,t,i){let r=i.createContext(e);return!!i.checkChild(r,"paragraph")&&!!i.checkChild(r.push("paragraph"),t)}function t3(e,t){let i=t.createElement("paragraph");return t.insert(i,e),t.createPositionAt(i,0)}class t5 extends tF{elementToElement(e){return this.add(t6(e))}elementToAttribute(e){return this.add(function(e){ie(e=(0,c.m)(e));let t=it(e,!1),i=t4(e.view),r=i?`element:${i}`:"element";return i=>{i.on(r,t,{priority:e.converterPriority||"low"})}}(e))}attributeToAttribute(e){return this.add(function(e){e=(0,c.m)(e);let t=null;("string"==typeof e.view||e.view.key)&&(t=function(e){let t;"string"==typeof e.view&&(e.view={key:e.view});let i=e.view.key,r=void 0===e.view.value?/[\s\S]*/:e.view.value;return t="class"==i||"style"==i?{["class"==i?"classes":"styles"]:r}:{attributes:{[i]:r}},e.view.name&&(t.name=e.view.name),e.view=t,i}(e)),ie(e,t);let i=it(e,!0);return t=>{t.on("element",i,{priority:e.converterPriority||"low"})}}(e))}elementToMarker(e){return this.add(function(e){var t;let i=(t=e.model,(e,i)=>{let r="string"==typeof t?t:t(e,i);return i.writer.createElement("$marker",{"data-name":r})});return t6({...e,model:i})}(e))}dataToMarker(e){return this.add(function(e){(e=(0,c.m)(e)).model||(e.model=t=>t?e.view+":"+t:e.view);let t={view:e.view,model:e.model},i=t8(ii(t,"start")),n=t8(ii(t,"end"));return s=>{var o;s.on(`element:${e.view}-start`,i,{priority:e.converterPriority||"normal"}),s.on(`element:${e.view}-end`,n,{priority:e.converterPriority||"normal"});let a=r.vx.low,l=r.vx.highest,h=r.vx.get(e.converterPriority)/l;s.on("element",(o=t,(e,t,i)=>{let r=`data-${o.view}`;function n(e,r){for(let n of r){let r=o.model(n,i),s=i.writer.createElement("$marker",{"data-name":r});i.writer.insert(s,e),t.modelCursor.isEqual(e)?t.modelCursor=t.modelCursor.getShiftedBy(1):t.modelCursor=t.modelCursor._getTransformedByInsertion(e,1),t.modelRange=t.modelRange._getTransformedByInsertion(e,1)[0]}}(i.consumable.test(t.viewItem,{attributes:r+"-end-after"})||i.consumable.test(t.viewItem,{attributes:r+"-start-after"})||i.consumable.test(t.viewItem,{attributes:r+"-end-before"})||i.consumable.test(t.viewItem,{attributes:r+"-start-before"}))&&(t.modelRange||Object.assign(t,i.convertChildren(t.viewItem,t.modelCursor)),i.consumable.consume(t.viewItem,{attributes:r+"-end-after"})&&n(t.modelRange.end,t.viewItem.getAttribute(r+"-end-after").split(",")),i.consumable.consume(t.viewItem,{attributes:r+"-start-after"})&&n(t.modelRange.end,t.viewItem.getAttribute(r+"-start-after").split(",")),i.consumable.consume(t.viewItem,{attributes:r+"-end-before"})&&n(t.modelRange.start,t.viewItem.getAttribute(r+"-end-before").split(",")),i.consumable.consume(t.viewItem,{attributes:r+"-start-before"})&&n(t.modelRange.start,t.viewItem.getAttribute(r+"-start-before").split(",")))}),{priority:a+h})}}(e))}}function t7(){return(e,t,i)=>{if(!t.modelRange&&i.consumable.consume(t.viewItem,{name:!0})){let{modelRange:e,modelCursor:r}=i.convertChildren(t.viewItem,t.modelCursor);t.modelRange=e,t.modelCursor=r}}}function t6(e){let t=t8(e=(0,c.m)(e)),i=t4(e.view),r=i?`element:${i}`:"element";return i=>{i.on(r,t,{priority:e.converterPriority||"normal"})}}function t4(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.name?e.name:null}
1function t8(e){let t=new x(e.view);return(i,r,n)=>{var s,o,a;let l=t.match(r.viewItem);if(!l)return;let h=l.match;if(h.name=!0,!n.consumable.test(r.viewItem,h))return;let d=(s=e.model,o=r.viewItem,a=n,s instanceof Function?s(o,a):a.writer.createElement(s));d&&n.safeInsert(d,r.modelCursor)&&(n.consumable.consume(r.viewItem,h),n.convertChildren(r.viewItem,d),n.updateConversionResult(d,r))}}function ie(e,t=null){let i=null===t||(e=>e.getAttribute(t)),r="object"!=typeof e.model?e.model:e.model.key,n="object"!=typeof e.model||void 0===e.model.value?i:e.model.value;e.model={key:r,value:n}}function it(e,t){let i=new x(e.view);return(r,n,s)=>{if(!n.modelRange&&t)return;let o=i.match(n.viewItem);if(!o||(!function(e,t){let i="function"==typeof e?e(t):e;return("object"!=typeof i||!!t4(i))&&!i.classes&&!i.attributes&&!i.styles}(e.view,n.viewItem)?delete o.match.name:o.match.name=!0,!s.consumable.test(n.viewItem,o.match)))return;let a=e.model.key,l="function"==typeof e.model.value?e.model.value(n.viewItem,s,n):e.model.value;null!=l&&(n.modelRange||Object.assign(n,s.convertChildren(n.viewItem,n.modelCursor)),function(e,t,i,r){let n=!1;for(let s of Array.from(e.getItems({shallow:i})))r.schema.checkAttribute(s,t.key)&&(n=!0,s.hasAttribute(t.key)||r.writer.setAttribute(t.key,t.value,s));return n}(n.modelRange,{key:a,value:l},t,s)&&(s.consumable.test(n.viewItem,{name:!0})&&(o.match.name=!0),s.consumable.consume(n.viewItem,o.match)))}}function ii(e,t){return{view:`${e.view}-${t}`,model:(t,i)=>{let r=t.getAttribute("name"),n=e.model(r,i);return i.writer.createElement("$marker",{"data-name":n})}}}class ir extends(0,r.VM)(){model;view;mapper;downcastDispatcher;constructor(e,t){super(),this.model=e,this.view=new tt(t),this.mapper=new tf,this.downcastDispatcher=new t_({mapper:this.mapper,schema:e.schema});let i=this.model.document,r=i.selection,n=this.model.markers;this.listenTo(this.model,"_beforeChanges",()=>{this.view._disableRendering(!0)},{priority:"highest"}),this.listenTo(this.model,"_afterChanges",()=>{this.view._disableRendering(!1)},{priority:"lowest"}),this.listenTo(i,"change",()=>{this.view.change(e=>{this.downcastDispatcher.convertChanges(i.differ,n,e),this.downcastDispatcher.convertSelection(r,n,e)})},{priority:"low"}),this.listenTo(this.view.document,"selectionChange",function(e,t){return(i,r)=>{let n=r.newSelection,s=[];for(let e of n.getRanges())s.push(t.toModelRange(e));let o=e.createSelection(s,{backward:n.isBackward});o.isEqual(e.document.selection)||e.change(e=>{e.setSelection(o)})}}(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",tB(),{priority:"lowest"}),this.downcastDispatcher.on("insert",tD(),{priority:"lowest"}),this.downcastDispatcher.on("remove",(e,t,i)=>{if(t.reconversion)return;let r=i.mapper.toViewPosition(t.position),n=t.position.getShiftedBy(t.length),s=i.mapper.toViewPosition(n,{isPhantom:!0});tJ(i.writer.createRange(r,s).getTrimmed(),i)},{priority:"low"}),this.downcastDispatcher.on("cleanSelection",(e,t,i)=>{let r=i.writer;for(let e of r.document.selection.getRanges())e.isCollapsed&&e.end.parent.isAttached()&&i.writer.mergeAttributes(e.start);r.setSelection(null)}),this.downcastDispatcher.on("selection",t$(),{priority:"low"}),this.downcastDispatcher.on("selection",tL(),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using(e=>{if("$graveyard"==e.rootName)return null;let t=new J(this.view.document,e.name);return t.rootName=e.rootName,this.mapper.bindElements(e,t),t})}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){let t="string"==typeof e?e:e.name,i=this.model.markers.get(t);if(!i)throw new r.Yb("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change(()=>{this.model.markers._refresh(i)})}reconvertItem(e){this.model.change(()=>{this.model.document.differ._refreshItem(e)})}}class is extends(0,r.VM)(){_sourceDefinitions={};_attributeProperties=Object.create(null);_customChildChecks=new Map;_customAttributeChecks=new Map;_genericCheckSymbol=Symbol("$generic");_compiledDefinitions;constructor(){super(),this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",(e,t)=>{t[0]=new io(t[0])},{priority:"highest"}),this.on("checkChild",(e,t)=>{t[0]=new io(t[0]),t[1]=this.getDefinition(t[1])},{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new r.Yb("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 r.Yb("schema-cannot-extend-missing-item",this,{itemName:e});this._sourceDefinitions[e].push(Object.assign({},t)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(e){let t;return t="string"==typeof e?e:"is"in e&&(e.is("$text")||e.is("$textProxy"))?"$text":e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){let t=this.getDefinition(e);return!!(t&&t.isBlock)}isLimit(e){let t=this.getDefinition(e);return!!t&&!!(t.isLimit||t.isObject)}isObject(e){let t=this.getDefinition(e);return!!t&&!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent)}isInline(e){let t=this.getDefinition(e);return!!(t&&t.isInline)}isSelectable(e){let t=this.getDefinition(e);return!!t&&!!(t.isSelectable||t.isObject)}isContent(e){let t=this.getDefinition(e);return!!t&&!!(t.isContent||t.isObject)}checkChild(e,t){return!!t&&this._checkContextMatch(e,t)}checkAttribute(e,t){let i=this.getDefinition(e.last);if(!i)return!1;let r=this._evaluateAttributeChecks(e,t);return void 0!==r?r:i.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof to){let t=e.nodeBefore,i=e.nodeAfter;if(!(t instanceof tN))throw new r.Yb("schema-check-merge-no-element-before",this);if(!(i instanceof tN))throw new r.Yb("schema-check-merge-no-element-after",this);return this.checkMerge(t,i)}if(this.isLimit(e)||this.isLimit(t))return!1;for(let i of t.getChildren())if(!this.checkChild(e,i))return!1;return!0}addChildCheck(e,t){let i=void 0!==t?t:this._genericCheckSymbol,r=this._customChildChecks.get(i)||[];r.push(e),this._customChildChecks.set(i,r)}addAttributeCheck(e,t){let i=void 0!==t?t:this._genericCheckSymbol,r=this._customAttributeChecks.get(i)||[];r.push(e),this._customAttributeChecks.set(i,r)}setAttributeProperties(e,t){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),t)}getAttributeProperties(e){return this._attributeProperties[e]||Object.create(null)}getLimitElement(e){let t;for(t=e instanceof to?e.parent:(e instanceof tc?[e]:Array.from(e.getRanges())).reduce((e,t)=>
1{let i=t.getCommonAncestor();return e?e.getCommonAncestor(i,{includeSelf:!0}):i},null);!this.isLimit(t);)if(t.parent)t=t.parent;else break;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){let i=[...e.getFirstPosition().getAncestors(),new tE("",e.getAttributes())];return this.checkAttribute(i,t)}for(let i of e.getRanges())for(let e of i)if(this.checkAttribute(e.item,t))return!0;return!1}*getValidRanges(e,t,i={}){for(let r of e=function*(e){for(let t of e)yield*t.getMinimalFlatRanges()}(e))yield*this._getValidRangesForRange(r,t,i)}getNearestSelectionRange(e,t="both"){let i,r;if("$graveyard"==e.root.rootName)return null;if(this.checkChild(e,"$text"))return new tc(e);let n=e.getAncestors().reverse().find(e=>this.isLimit(e))||e.root;for(let s of(("both"==t||"backward"==t)&&(i=new tn({boundaries:tc._createIn(n),startPosition:e,direction:"backward"})),("both"==t||"forward"==t)&&(r=new tn({boundaries:tc._createIn(n),startPosition:e})),function*(e,t){let i=!1;for(;!i;){if(i=!0,e){let t=e.next();t.done||(i=!1,yield{walker:e,value:t.value})}if(t){let e=t.next();e.done||(i=!1,yield{walker:t,value:e.value})}}}(i,r))){let e=s.walker==i?"elementEnd":"elementStart",t=s.value;if(t.type==e&&this.isObject(t.item))return tc._createOn(t.item);if(this.checkChild(t.nextPosition,"$text"))return new tc(t.nextPosition)}return null}findAllowedParent(e,t){let i=e.parent;for(;i;){if(this.checkChild(i,t))return i;if(this.isLimit(i))break;i=i.parent}return null}setAllowedAttributes(e,t,i){let r=i.model;for(let[n,s]of Object.entries(t))r.schema.checkAttribute(e,n)&&i.setAttribute(n,s,e)}removeDisallowedAttributes(e,t){for(let i of e)if(i.is("$text"))ih(this,i,t);else for(let e of tc._createIn(i).getPositions())ih(this,e.nodeBefore||e.parent,t)}getAttributesWithProperty(e,t,i){let r={};for(let[n,s]of e.getAttributes()){let e=this.getAttributeProperties(n);void 0!==e[t]&&(void 0===i||i===e[t])&&(r[n]=s)}return r}createContext(e){return new io(e)}_clearCache(){this._compiledDefinitions=null}_compile(){let e={},t=this._sourceDefinitions;for(let i of Object.keys(t))e[i]=function(e,t){let i={name:t,allowIn:new Set,allowChildren:new Set,disallowIn:new Set,disallowChildren:new Set,allowContentOf:new Set,allowWhere:new Set,allowAttributes:new Set,disallowAttributes:new Set,allowAttributesOf:new Set,inheritTypesFrom:new Set};return function(e,t){for(let i of e)for(let e of Object.keys(i).filter(e=>e.startsWith("is")))t[e]=!!i[e]}(e,i),ia(e,i,"allowIn"),ia(e,i,"allowChildren"),ia(e,i,"disallowIn"),ia(e,i,"disallowChildren"),ia(e,i,"allowContentOf"),ia(e,i,"allowWhere"),ia(e,i,"allowAttributes"),ia(e,i,"disallowAttributes"),ia(e,i,"allowAttributesOf"),ia(e,i,"inheritTypesFrom"),function(e,t){for(let i of e){let e=i.inheritAllFrom;e&&(t.allowContentOf.add(e),t.allowWhere.add(e),t.allowAttributesOf.add(e),t.inheritTypesFrom.add(e))}}(e,i),i}(t[i],i);let i=Object.values(e);for(let t of i)(function(e,t){for(let i of t.allowIn){let r=e[i];r?r.allowChildren.add(t.name):t.allowIn.delete(i)}})(e,t),function(e,t){for(let i of t.allowChildren){let r=e[i];r?r.allowIn.add(t.name):t.allowChildren.delete(i)}}(e,t),function(e,t){for(let i of t.disallowIn){let r=e[i];r?r.disallowChildren.add(t.name):t.disallowIn.delete(i)}}(e,t),function(e,t){for(let i of t.disallowChildren){let r=e[i];r?r.disallowIn.add(t.name):t.disallowChildren.delete(i)}}(e,t);for(let e of i){var r=e;for(let e of r.disallowChildren)r.allowChildren.delete(e);for(let e of r.disallowIn)r.allowIn.delete(e);for(let e of r.disallowAttributes)r.allowAttributes.delete(e)}for(let t of i)!function(e,t){for(let i of t.allowContentOf){let r=e[i];r&&(r.disallowChildren.forEach(i=>{t.allowChildren.has(i)||(t.disallowChildren.add(i),e[i].disallowIn.add(t.name))}),r.allowChildren.forEach(i=>{t.disallowChildren.has(i)||(t.allowChildren.add(i),e[i].allowIn.add(t.name))}))}}(e,t);for(let t of i)!function(e,t){for(let i of t.allowWhere){let r=e[i];r&&(r.disallowIn.forEach(i=>{t.allowIn.has(i)||(t.disallowIn.add(i),e[i].disallowChildren.add(t.name))}),r.allowIn.forEach(i=>{t.disallowIn.has(i)||(t.allowIn.add(i),e[i].allowChildren.add(t.name))}))}}(e,t);for(let t of i)!function(e,t){for(let i of t.allowAttributesOf){let r=e[i];if(!r)return;
1r.allowAttributes.forEach(e=>{t.disallowAttributes.has(e)||t.allowAttributes.add(e)})}}(e,t);for(let t of i){var n=e,s=t;for(let e of s.inheritTypesFrom){let t=n[e];if(t)for(let e of Object.keys(t).filter(e=>e.startsWith("is")))e in s||(s[e]=t[e])}}this._compiledDefinitions=function(e){let t={};for(let i of Object.values(e))t[i.name]={name:i.name,isBlock:!!i.isBlock,isContent:!!i.isContent,isInline:!!i.isInline,isLimit:!!i.isLimit,isObject:!!i.isObject,isSelectable:!!i.isSelectable,allowIn:Array.from(i.allowIn).filter(t=>!!e[t]),allowChildren:Array.from(i.allowChildren).filter(t=>!!e[t]),allowAttributes:Array.from(i.allowAttributes)};return t}(e)}_checkContextMatch(e,t){let i=e.last,r=this._evaluateChildChecks(e,t);if(!(r=void 0!==r?r:t.allowIn.includes(i.name)))return!1;let n=this.getDefinition(i),s=e.trimLast();return!!n&&(0==s.length||this._checkContextMatch(s,n))}_evaluateChildChecks(e,t){for(let i of[...this._customChildChecks.get(this._genericCheckSymbol)||[],...this._customChildChecks.get(t.name)||[]]){let r=i(e,t);if(void 0!==r)return r}}_evaluateAttributeChecks(e,t){for(let i of[...this._customAttributeChecks.get(this._genericCheckSymbol)||[],...this._customAttributeChecks.get(t)||[]]){let r=i(e,t);if(void 0!==r)return r}}*_getValidRangesForRange(e,t,i){let r=e.start,n=e.start;for(let s of e.getItems({shallow:!0})){if(s.is("element"))if(i.includeEmptyRanges&&s.isEmpty){let e=this.createContext(s);this.checkChild(e,"$text")&&this.checkAttribute(e.push("$text"),t)&&(yield tc._createIn(s))}else yield*this._getValidRangesForRange(tc._createIn(s),t,i);this.checkAttribute(s,t)||(r.isEqual(n)||(yield new tc(r,n)),r=to._createAfter(s)),n=to._createAfter(s)}r.isEqual(n)||(yield new tc(r,n))}findOptimalInsertionRange(e,t){let i=e.getSelectedElement();if(i&&this.isObject(i)&&!this.isInline(i))return"before"==t||"after"==t?new tc(to._createAt(i,t)):tc._createOn(i);let n=(0,r.$1)(e.getSelectedBlocks());if(!n)return new tc(e.focus);if(n.isEmpty)return new tc(to._createAt(n,0));let s=to._createAfter(n);return new tc(e.focus.isTouching(s)?s:to._createBefore(n))}}class io{_items;constructor(e){let t;if(e instanceof io)return e;t="string"==typeof e?[e]:Array.isArray(e)?e:e.getAncestors({includeSelf:!0}),this._items=t.map(il)}get length(){return this._items.length}get last(){return this._items[this._items.length-1]}[Symbol.iterator](){return this._items[Symbol.iterator]()}push(e){let t=new io([e]);return t._items=[...this._items,...t._items],t}trimLast(){let e=new io([]);return e._items=this._items.slice(0,-1),e}getItem(e){return this._items[e]}*getNames(){yield*this._items.map(e=>e.name)}endsWith(e){return Array.from(this.getNames()).join(" ").endsWith(e)}startsWith(e){return Array.from(this.getNames()).join(" ").startsWith(e)}}function ia(e,t,i){for(let r of e){let e=r[i];"string"==typeof e&&(e=[e]),Array.isArray(e)&&e.forEach(e=>t[i].add(e))}}function il(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 ih(e,t,i){for(let r of t.getAttributeKeys())e.checkAttribute(t,r)||i.removeAttribute(r,t)}class id extends(0,r.Mm)(){conversionApi;_splitParts=new Map;_cursorParents=new Map;_modelCursor=null;_emptyElementsToKeep=new Set;constructor(e){super(),this.conversionApi={...e,consumable:null,writer:null,store:null,convertItem:(e,t)=>this._convertItem(e,t),convertChildren:(e,t)=>this._convertChildren(e,t),safeInsert:(e,t)=>this._safeInsert(e,t),updateConversionResult:(e,t)=>this._updateConversionResult(e,t),splitToAllowedParent:(e,t)=>this._splitToAllowedParent(e,t),getSplitParts:e=>this._getSplitParts(e),keepEmptyElement:e=>this._keepEmptyElement(e)}}convert(e,t,i=["$root"]){this.fire("viewCleanup",e),this._modelCursor=function(e,t){let i;for(let r of new io(e)){let e={};for(let t of r.getAttributeKeys())e[t]=r.getAttribute(t);let n=t.createElement(r.name,e);i&&t.insert(n,i),i=to._createAt(n,0)}return i}(i,t),this.conversionApi.writer=t,this.conversionApi.consumable=k.createFrom(e),this.conversionApi.store={};let{modelRange:r}=this._convertItem(e,this._modelCursor),n=t.createDocumentFragment();if(r){this._removeEmptyElements();let e=this._modelCursor.parent,i=e._removeChildren(0,e.childCount);n._insertChild(0,i),n.markers=function(e,t){let i=new Set,r=new Map;for(let t of tc._createIn(e).getItems())t.is("element","$marker")&&i.add(t);for(let e of i){let i=e.getAttribute("data-name"),n=t.createPositionBefore(e);r.has(i)?r.get(i).end=n.clone():r.set(i,new tc(n.clone())),t.remove(e)}return r}(n,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,n}_convertItem(e,t){let i={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,i,this.conversionApi):e.is("$text")?this.fire("text",i,this.conversionApi):this.fire("documentFragment",i,this.conversionApi),i.modelRange&&!(i.modelRange instanceof tc))throw new r.Yb("view-conversion-dispatcher-incorrect-result",this);return{modelRange:i.modelRange,modelCursor:i.modelCursor}}_convertChildren(e,t){let i=t.is("position")?t:to._createAt(t,0),r=new tc(i);for(let t of Array.from(e.getChildren())){let e=this._convertItem(t,i);e.modelRange instanceof tc&&(r.end=e.modelRange.end,i=e.modelCursor)}return{modelRange:r,modelCursor:i}}_safeInsert(e,t){let i=this._splitToAllowedParent(e,t);return!!i&&(this.conversionApi.writer.insert(e,i.position),!0)}_updateConversionResult(e,t){let i=this._getSplitParts(e),r=this.conversionApi.writer;t.modelRange||(t.modelRange=r.createRange(r.createPositionBefore(e),r.createPositionAfter(i[i.length-1])));let n=this._cursorParents.get(e);n?t.modelCursor=r.createPositionAt(n,0):t.modelCursor=t.modelRange.end}_splitToAllowedParent(e,t){let{schema:i,writer:r}=this.conversionApi,n=i.findAllowedParent(t,e);if(n){if(n===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(n)&&(n=null)}if(!n)return t2(t,e,i)?{position:t3(t,r)}:null;let s=this.conversionApi.writer.split(t,n),o=[];for(let e of s.range.getWalker())if("elementEnd"==e.type)o.push(e.item);else{let t=o.pop(),i=e.item;this._registerSplitPair(t,i)}let a=s.range.end.parent;return this._cursorParents.set(e,a),{position:s.position,cursorParent:a}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);let i=this._splitParts.get(e);this._splitParts.set(t,i),i.push(t)}_getSplitParts(e){return this._splitParts.has(e)?this._splitParts.get(e):[e]}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){let e=new Map;
1for(let t of this._splitParts.keys())if(t.isEmpty&&!this._emptyElementsToKeep.has(t)){let i=e.get(t.parent)||[];i.push(t),this._splitParts.delete(t),e.set(t.parent,i)}for(let[t,i]of e)t._removeChildrenArray(i);e.size&&this._removeEmptyElements()}}class iu{getHtml(e){let t=r.Sf.document.implementation.createHTMLDocument("").createElement("div");return t.appendChild(e),t.innerHTML}}class ic{domParser;domConverter;htmlWriter;skipComments=!0;constructor(e){this.domParser=new DOMParser,this.domConverter=new eJ(e,{renderingMode:"data"}),this.htmlWriter=new iu}toData(e){let t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){let t=this._toDom(e);return this.domConverter.domToView(t,{skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode="marked"==e?"markedNbsp":"nbsp"}_toDom(e){/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(e.trim().slice(0,1e4))||(e=`<body>${e}</body>`);let t=this.domParser.parseFromString(e,"text/html"),i=t.createDocumentFragment(),r=t.body.childNodes;for(;r.length>0;)i.appendChild(r[0]);return i}}class im extends(0,r.Mm)(){model;mapper;downcastDispatcher;upcastDispatcher;viewDocument;stylesProcessor;htmlProcessor;processor;_viewWriter;constructor(e,t){super(),this.model=e,this.mapper=new tf,this.downcastDispatcher=new t_({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",tB(),{priority:"lowest"}),this.downcastDispatcher.on("insert",tD(),{priority:"lowest"}),this.upcastDispatcher=new id({schema:e.schema}),this.viewDocument=new ea(t),this.stylesProcessor=t,this.htmlProcessor=new ic(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new ew(this.viewDocument),this.upcastDispatcher.on("text",(e,t,{schema:i,consumable:r,writer:n})=>{let s=t.modelCursor;if(!r.test(t.viewItem))return;if(!i.checkChild(s,"$text")){if(!t2(s,"$text",i)||0==t.viewItem.data.trim().length)return;s=t3(s,n)}r.consume(t.viewItem);let o=n.createText(t.viewItem.data);n.insert(o,s),t.modelRange=n.createRange(s,s.getShiftedBy(o.offsetSize)),t.modelCursor=t.modelRange.end},{priority:"lowest"}),this.upcastDispatcher.on("element",t7(),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",t7(),{priority:"lowest"}),(0,r.VM)().prototype.decorate.call(this,"init"),(0,r.VM)().prototype.decorate.call(this,"set"),(0,r.VM)().prototype.decorate.call(this,"get"),(0,r.VM)().prototype.decorate.call(this,"toView"),(0,r.VM)().prototype.decorate.call(this,"toModel"),this.on("init",()=>{this.fire("ready")},{priority:"lowest"}),this.on("ready",()=>{this.model.enqueueChange({isUndoable:!1},t9)},{priority:"lowest"})}get(e={}){let{rootName:t="main",trim:i="empty"}=e;if(!this._checkIfRootsExists([t]))throw new r.Yb("datacontroller-get-non-existent-root",this);let n=this.model.document.getRoot(t);return(n.isAttached()||(0,r.FF)("datacontroller-get-detached-root",this),"empty"!==i||this.model.hasContent(n,{ignoreWhitespaces:!0}))?this.stringify(n,e):""}stringify(e,t={}){let i=this.toView(e,t);return this.processor.toData(i)}toView(e,t={}){let i=this.viewDocument,r=this._viewWriter;this.mapper.clearBindings();let n=tc._createIn(e),s=new e_(i);this.mapper.bindElements(e,s);let o=e.is("documentFragment")?e.markers:function(e){let t=[],i=e.root.document;if(!i)return new Map;let r=tc._createIn(e);for(let e of i.model.markers){let i=e.getRange(),n=i.isCollapsed,s=i.start.isEqual(r.start)||i.end.isEqual(r.end);if(n&&s)t.push([e.name,i]);else{let n=r.getIntersection(i);n&&t.push([e.name,n])}}return t.sort(([e,t],[i,r])=>{if("after"!==t.end.compareWith(r.start))return 1;if("before"!==t.start.compareWith(r.end))return -1;switch(t.start.compareWith(r.start)){case"before":return 1;case"after":return -1;default:switch(t.end.compareWith(r.end)){case"before":return 1;case"after":return -1;default:return i.localeCompare(e)}}}),new Map(t)}(e);return this.downcastDispatcher.convert(n,o,r,t),s}init(e){if(this.model.document.version)throw new r.Yb("datacontroller-init-document-not-empty",this);let t={};if("string"==typeof e?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new r.Yb("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},e=>{for(let i of Object.keys(t)){let r=this.model.document.getRoot(i);e.insert(this.parse(t[i],r),r,0)}}),Promise.resolve()}set(e,t={}){let i={};if("string"==typeof e?i.main=e:i=e,!this._checkIfRootsExists(Object.keys(i)))throw new r.Yb("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},e=>{for(let t of(e.setSelection(null),e.removeSelectionAttribute(this.model.document.selection.getAttributeKeys()),Object.keys(i))){let r=this.model.document.getRoot(t);e.remove(e.createRangeIn(r)),e.insert(this.parse(i[t],r),r,0)}})}parse(e,t="$root"){let i=this.processor.toView(e);return this.toModel(i,t)}toModel(e,t="$root"){return this.model.change(i=>this.upcastDispatcher.convert(e,i,t))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(let t of e)if(!this.model.document.getRoot(t))return!1;return!0}}class ig{_helpers=new Map;_downcast;_upcast;constructor(e,t){this._downcast=(0,r.$r)(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=(0,r.$r)(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){let i=this._downcast.includes(t);if(!this._upcast.includes(t)&&!i)throw new r.Yb("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:i})}for(e){if(!this._helpers.has(e))throw new r.Yb("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){for(let{model:t,view:i}of(this.for("downcast").elementToElement(e),ip(e)))this.for("upcast").elementToElement({model:t,view:i,converterPriority:e.converterPriority})}attributeToElement(e){for(let{model:t,view:i}of(this.for("downcast").attributeToElement(e),ip(e)))this.for("upcast").elementToAttribute({view:i,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){for(let{model:t,view:i}of(this.for("downcast").attributeToAttribute(e),ip(e)))this.for("upcast").attributeToAttribute({view:i,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:i}){if(this._helpers.has(e))throw new r.Yb("conversion-group-exists",this);let n=i?new tI(t):new t5(t);this._helpers.set(e,n)}}function*ip(e){if(e.model.values)for(let t of e.model.values){let i={key:e.model.key,value:t},r=e.view[t],n=e.upcastAlso?e.upcastAlso[t]:void 0;yield*i_(i,r,n)}else yield*i_(e.model,e.view,e.upcastAlso)}function*i_(e,t,i){if(yield{model:e,view:t},i)for(let t of(0,r.$r)(i))yield{model:e,view:t}}class iw{namespaces;domParser;domConverter;htmlWriter;skipComments=!0;constructor(e,t={}){this.namespaces=t.namespaces||[],this.domParser=new DOMParser,this.domConverter=new eJ(e,{renderingMode:"data"}),this.htmlWriter=new iu}toData(e){let t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}
1toView(e){let t=this._toDom(e);return this.domConverter.domToView(t,{keepOriginalCase:!0,skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode="marked"==e?"markedNbsp":"nbsp"}_toDom(e){let t=this.namespaces.map(e=>`xmlns:${e}="nsp"`).join(" ");e=`<xml ${t}>${e}</xml>`;let i=this.domParser.parseFromString(e,"text/xml"),r=i.querySelector("parsererror");if(r)throw Error("Parse error - "+r.textContent);let n=i.createDocumentFragment(),s=i.documentElement.childNodes;for(;s.length>0;)n.appendChild(s[0]);return n}}class ib{baseVersion;isDocumentOperation;batch;constructor(e){this.baseVersion=e,this.isDocumentOperation=null!==this.baseVersion,this.batch=null}_validate(){}toJSON(){let e=Object.assign({},this);return e.__className=this.constructor.className,delete e.batch,delete e.isDocumentOperation,e}static get className(){return"Operation"}static fromJSON(e,t){return new this(e.baseVersion)}}function iy(e,t){let i=iC(t),r=i.reduce((e,t)=>e+t.offsetSize,0),n=e.parent;ik(e);let s=e.index;return n._insertChild(s,i),iA(n,s+i.length),iA(n,s),new tc(e,e.getShiftedBy(r))}function iv(e){if(!e.isFlat)throw new r.Yb("operation-utils-remove-range-not-flat",this);let t=e.start.parent;ik(e.start),ik(e.end);let i=t._removeChildren(e.start.index,e.end.index-e.start.index);return iA(t,e.start.index),i}function iP(e,t){if(!e.isFlat)throw new r.Yb("operation-utils-move-range-not-flat",this);let i=iv(e);return iy(t=t._getTransformedByDeletion(e.start,e.end.offset-e.start.offset),i)}function iC(e){let t=[];!function e(i){if("string"==typeof i)t.push(new tE(i));else if(i instanceof tr)t.push(new tE(i.data,i.getAttributes()));else if(i instanceof tb)t.push(i);else if((0,r.xZ)(i))for(let t of i)e(t)}(e);for(let e=1;e<t.length;e++){let i=t[e],r=t[e-1];i instanceof tE&&r instanceof tE&&iS(i,r)&&(t.splice(e-1,2,new tE(r.data+i.data,r.getAttributes())),e--)}return t}function iA(e,t){let i=e.getChild(t-1),r=e.getChild(t);if(i&&r&&i.is("$text")&&r.is("$text")&&iS(i,r)){let n=new tE(i.data+r.data,i.getAttributes());e._removeChildren(t-1,2),e._insertChild(t-1,n)}}function ik(e){let t=e.textNode,i=e.parent;if(t){let r=e.offset-t.startOffset,n=t.index;i._removeChildren(n,1);let s=new tE(t.data.substr(0,r),t.getAttributes()),o=new tE(t.data.substr(r),t.getAttributes());i._insertChild(n,[s,o])}}function iS(e,t){let i=e.getAttributes(),r=t.getAttributes();for(let e of i){if(e[1]!==t.getAttribute(e[0]))return!1;r.next()}return r.next().done}class iE extends ib{sourcePosition;howMany;targetPosition;constructor(e,t,i,r){super(r),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toNext",this.howMany=t,this.targetPosition=i.clone(),this.targetPosition.stickiness="toNone"}get type(){if(this.targetPosition.root.rootName==this.sourcePosition.root.rootName);else if("$graveyard"==this.targetPosition.root.rootName)return"remove";else if("$graveyard"==this.sourcePosition.root.rootName)return"reinsert";return"move"}get affectedSelectable(){return[tc._createFromPositionAndShift(this.sourcePosition,this.howMany),tc._createFromPositionAndShift(this.targetPosition,0)]}clone(){return new iE(this.sourcePosition,this.howMany,this.targetPosition,this.baseVersion)}getMovedRangeStart(){return this.targetPosition._getTransformedByDeletion(this.sourcePosition,this.howMany)}getReversed(){let e=this.sourcePosition._getTransformedByInsertion(this.targetPosition,this.howMany);return new iE(this.getMovedRangeStart(),this.howMany,e,this.baseVersion+1)}_validate(){let e=this.sourcePosition.parent,t=this.targetPosition.parent,i=this.sourcePosition.offset,n=this.targetPosition.offset;if(i+this.howMany>e.maxOffset)throw new r.Yb("move-operation-nodes-do-not-exist",this);if(e===t&&i<n&&n<i+this.howMany)throw new r.Yb("move-operation-range-into-itself",this);if(this.sourcePosition.root==this.targetPosition.root&&"prefix"==(0,r.ww)(this.sourcePosition.getParentPath(),this.targetPosition.getParentPath())){let e=this.sourcePosition.path.length-1;if(this.targetPosition.path[e]>=i&&this.targetPosition.path[e]<i+this.howMany)throw new r.Yb("move-operation-node-into-itself",this)}}_execute(){iP(tc._createFromPositionAndShift(this.sourcePosition,this.howMany),this.targetPosition)}toJSON(){let e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e.targetPosition=this.targetPosition.toJSON(),e}static get className(){return"MoveOperation"}static fromJSON(e,t){let i=to.fromJSON(e.sourcePosition,t),r=to.fromJSON(e.targetPosition,t);return new this(i,e.howMany,r,e.baseVersion)}}class iR extends ib{position;nodes;shouldReceiveAttributes;constructor(e,t,i){super(i),this.position=e.clone(),this.position.stickiness="toNone",this.nodes=new tT(iC(t)),this.shouldReceiveAttributes=!1}get type(){return"insert"}get howMany(){return this.nodes.maxOffset}get affectedSelectable(){return this.position.clone()}clone(){let e=new tT([...this.nodes].map(e=>e._clone(!0))),t=new iR(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){let e=new to(this.position.root.document.graveyard,[0]);return new iE(this.position,this.nodes.maxOffset,e,this.baseVersion+1)}_validate(){let e=this.position.parent;if(!e||e.maxOffset<this.position.offset)throw new r.Yb("insert-operation-position-invalid",this)}_execute(){let e=this.nodes;this.nodes=new tT([...e].map(e=>e._clone(!0))),iy(this.position,e)}toJSON(){let e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){let i=[];for(let t of e.nodes)t.name?i.push(tN.fromJSON(t)):i.push(tE.fromJSON(t));let r=new iR(to.fromJSON(e.position,t),i,e.baseVersion);return r.shouldReceiveAttributes=e.shouldReceiveAttributes,r}}class ix extends ib{splitPosition;howMany;insertionPosition;graveyardPosition;constructor(e,t,i,r,n){super(n),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=i,this.graveyardPosition=r?r.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){let e=this.insertionPosition.path.slice();return e.push(0),new to(this.insertionPosition.root,e)}get movedRange(){let e=this.splitPosition.getShiftedBy(1/0);return new tc(this.splitPosition,e)}get affectedSelectable(){let e=[tc._createFromPositionAndShift(this.splitPosition,0),tc._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(tc._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new ix(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){let e=new to(this.splitPosition.root.document.graveyard,[0]);return new iO(this.moveTargetPosition,this.howMany,this.splitPosition,e,this.baseVersion+1)}_validate(){let e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset<t)throw new r.Yb("split-operation-position-invalid",this);if(e.parent){if(this.howMany!==-1/0&&this.howMany!=e.maxOffset-this.splitPosition.offset)throw new r.Yb("split-operation-how-many-invalid",this);else if(this.graveyardPosition&&!this.graveyardPosition.nodeAfter)throw new r.Yb("split-operation-graveyard-position-invalid",this)}else throw new r.Yb("split-operation-split-in-root",this);this.howMany=this.splitPosition.parent.maxOffset-this.splitPosition.offset}_execute(){let e=this.splitPosition.parent;if(this.graveyardPosition)iP(tc._createFromPositionAndShift(this.graveyardPosition,1),this.insertionPosition);else{let t=e._clone();iy(this.insertionPosition,t)}iP(new tc(to._createAt(e,this.splitPosition.offset),to._createAt(e,e.maxOffset)),this.moveTargetPosition)}toJSON(){let e=super.toJSON();return e.splitPosition=this.splitPosition.toJSON(),e.insertionPosition=this.insertionPosition.toJSON(),this.graveyardPosition&&(e.graveyardPosition=this.graveyardPosition.toJSON()),e}static get className(){return"SplitOperation"}static getInsertionPosition(e){let t=e.path.slice(0,-1);return t[t.length-1]++,new to(e.root,t,"toPrevious")}static fromJSON(e,t){let i=to.fromJSON(e.splitPosition,t),r=to.fromJSON(e.insertionPosition,t),n=e.graveyardPosition?to.fromJSON(e.graveyardPosition,t):null;return new this(i,e.howMany,r,n,e.baseVersion)}}class iO extends ib{sourcePosition;howMany;targetPosition;graveyardPosition;constructor(e,t,i,r,n){super(n),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=t,this.targetPosition=i.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=r.clone()}get type(){return"merge"}get deletionPosition(){return new to(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){let e=this.sourcePosition.getShiftedBy(1/0);return new tc(this.sourcePosition,e)}get affectedSelectable(){let e=this.sourcePosition.parent;return[tc._createOn(e),tc._createFromPositionAndShift(this.targetPosition,0),tc._createFromPositionAndShift(this.graveyardPosition,0)]}clone(){return new iO(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){let e=this.targetPosition._getTransformedByMergeOperation(this),t=this.sourcePosition.path.slice(0,-1),i=new to(this.sourcePosition.root,t)._getTransformedByMergeOperation(this);return new ix(e,this.howMany,i,this.graveyardPosition,this.baseVersion+1)}_validate(){let e=this.sourcePosition.parent,t=this.targetPosition.parent;if(e.parent)if(t.parent){if(this.howMany!==-1/0&&this.howMany!=e.maxOffset)throw new r.Yb("merge-operation-how-many-invalid",this)}else throw new r.Yb("merge-operation-target-position-invalid",this);else throw new r.Yb("merge-operation-source-position-invalid",this);this.howMany=this.sourcePosition.parent.maxOffset}_execute(){let e=this.sourcePosition.parent;iP(tc._createIn(e),this.targetPosition),iP(tc._createOn(e),this.graveyardPosition)}toJSON(){let 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){let i=to.fromJSON(e.sourcePosition,t),r=to.fromJSON(e.targetPosition,t),n=to.fromJSON(e.graveyardPosition,t);return new this(i,e.howMany,r,n,e.baseVersion)}}class iM extends ib{name;oldRange;newRange;affectsData;_markers;constructor(e,t,i,r,n,s){super(s),this.name=e,this.oldRange=t?t.clone():null,this.newRange=i?i.clone():null,this.affectsData=n,this._markers=r}get type(){return"marker"}get affectedSelectable(){let e=[];return this.oldRange&&e.push(this.oldRange.clone()),this.newRange&&(this.oldRange?e.push(...this.newRange.getDifference(this.oldRange)):e.push(this.newRange.clone())),e}clone(){return new iM(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new iM(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){this.newRange?this._markers._set(this.name,this.newRange,!0,this.affectsData):this._markers._remove(this.name)}toJSON(){let 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 iM(e.name,e.oldRange?tc.fromJSON(e.oldRange,t):null,e.newRange?tc.fromJSON(e.newRange,t):null,t.model.markers,e.affectsData,e.baseVersion)}}class iT extends ib{range;key;oldValue;newValue;constructor(e,t,i,r,n){super(n),this.range=e.clone(),this.key=t,this.oldValue=void 0===i?null:i,this.newValue=void 0===r?null:r}get type(){return null===this.oldValue?"addAttribute":null===this.newValue?"removeAttribute":"changeAttribute"}get affectedSelectable(){return this.range.clone()}clone(){return new iT(this.range,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new iT(this.range,this.key,this.newValue,this.oldValue,this.baseVersion+1)}toJSON(){let e=super.toJSON();return e.range=this.range.toJSON(),e}_validate(){if(!this.range.isFlat)throw new r.Yb("attribute-operation-range-not-flat",this);for(let e of this.range.getItems({shallow:!0})){if(null!==this.oldValue&&!(0,f.n)(e.getAttribute(this.key),this.oldValue))throw new r.Yb("attribute-operation-wrong-old-value",this,{item:e,key:this.key,value:this.oldValue});if(null===this.oldValue&&null!==this.newValue&&e.hasAttribute(this.key))throw new r.Yb("attribute-operation-attribute-exists",this,{node:e,ke
1y:this.key})}}_execute(){(0,f.n)(this.oldValue,this.newValue)||function(e,t,i){for(let r of(ik(e.start),ik(e.end),e.getItems({shallow:!0}))){let e=r.is("$textProxy")?r.textNode:r;null!==i?e._setAttribute(t,i):e._removeAttribute(t),iA(e.parent,e.index)}iA(e.end.parent,e.end.index)}(this.range,this.key,this.newValue)}static get className(){return"AttributeOperation"}static fromJSON(e,t){return new iT(tc.fromJSON(e.range,t),e.key,e.oldValue,e.newValue,e.baseVersion)}}class iN extends ib{get type(){return"noop"}get affectedSelectable(){return null}clone(){return new iN(this.baseVersion)}getReversed(){return new iN(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}class iF extends ib{position;oldName;newName;constructor(e,t,i,r){super(r),this.position=e,this.position.stickiness="toNext",this.oldName=t,this.newName=i}get type(){return"rename"}get affectedSelectable(){return this.position.nodeAfter}clone(){return new iF(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new iF(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){let e=this.position.nodeAfter;if(e instanceof tN){if(""!==this.oldName&&e.name!==this.oldName)throw new r.Yb("rename-operation-wrong-name",this)}else throw new r.Yb("rename-operation-wrong-position",this);this.oldName=e.name}_execute(){this.position.nodeAfter.name=this.newName}toJSON(){let e=super.toJSON();return e.position=this.position.toJSON(),e}static get className(){return"RenameOperation"}static fromJSON(e,t){return new iF(to.fromJSON(e.position,t),e.oldName,e.newName,e.baseVersion)}}class iI extends ib{root;key;oldValue;newValue;constructor(e,t,i,r,n){super(n),this.root=e,this.key=t,this.oldValue=void 0===i?null:i,this.newValue=void 0===r?null:r}get type(){return null===this.oldValue?"addRootAttribute":null===this.newValue?"removeRootAttribute":"changeRootAttribute"}get affectedSelectable(){return this.root}clone(){return new iI(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new iI(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new r.Yb("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 r.Yb("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 r.Yb("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(){let 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 r.Yb("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new iI(t.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}}class iB extends ib{rootName;elementName;isAdd;_document;constructor(e,t,i,r,n){super(n),this.rootName=e,this.elementName=t,this.isAdd=i,this._document=r,this._document.getRoot(this.rootName)||(this._document.createRoot(this.elementName,this.rootName)._isAttached=!1)}get type(){return this.isAdd?"addRoot":"detachRoot"}get affectedSelectable(){return this._document.getRoot(this.rootName)}clone(){return new iB(this.rootName,this.elementName,this.isAdd,this._document,this.baseVersion)}getReversed(){return new iB(this.rootName,this.elementName,!this.isAdd,this._document,this.baseVersion+1)}_execute(){this._document.getRoot(this.rootName)._isAttached=this.isAdd}toJSON(){let e=super.toJSON();return delete e._document,e}static get className(){return"RootOperation"}static fromJSON(e,t){return new iB(e.rootName,e.elementName,e.isAdd,t,e.baseVersion)}}let iD={};iD[iT.className]=iT,iD[iR.className]=iR,iD[iM.className]=iM,iD[iE.className]=iE,iD[iN.className]=iN,iD[ib.className]=ib,iD[iF.className]=iF,iD[iI.className]=iI,iD[iB.className]=iB,iD[ix.className]=ix,iD[iO.className]=iO;class iV{static fromJSON(e,t){return iD[e.__className].fromJSON(e,t)}}let i$=new Map;function iL(e,t,i){let r=i$.get(e);r||(r=new Map,i$.set(e,r)),r.set(t,i)}function iq(e){return[e]}function iW(e,t,i={}){let r=function(e,t){let i=i$.get(e);return i&&i.has(t)?i.get(t):iq}(e.constructor,t.constructor);try{return e=e.clone(),r(e,t,i)}catch(e){throw e}}function iY(e,t,i){e=e.slice(),t=t.slice();let r=new iJ(i.document,i.useRelations,i.forceWeakRemove);r.setOriginalOperations(e),r.setOriginalOperations(t);let n=r.originalOperations;if(0==e.length||0==t.length)return{operationsA:e,operationsB:t,originalOperations:n};let s=new WeakMap;for(let t of e)s.set(t,0);let o={nextBaseVersionA:e[e.length-1].baseVersion+1,nextBaseVersionB:t[t.length-1].baseVersion+1,originalOperationsACount:e.length,originalOperationsBCount:t.length},a=0;for(;a<e.length;){let i=e[a],n=s.get(i);if(n==t.length){a++;continue}let o=t[n],l=iW(i,o,r.getContext(i,o,!0)),h=iW(o,i,r.getContext(o,i,!1));for(let e of(r.updateRelation(i,o),r.setOriginalOperations(l,i),r.setOriginalOperations(h,o),l))s.set(e,n+h.length);e.splice(a,1,...l),t.splice(n,1,...h)}if(iU(e),iU(t),i.padWithNoOps){let i=e.length-o.originalOperationsACount,r=t.length-o.originalOperationsBCount;iz(e,r-i),iz(t,i-r)}return ij(e,o.nextBaseVersionB),ij(t,o.nextBaseVersionA),{operationsA:e,operationsB:t,originalOperations:n}}class iJ{originalOperations;_history;_useRelations;_forceWeakRemove;_relations;constructor(e,t,i=!1){this.originalOperations=new Map,this._history=e.history,this._useRelations=t,this._forceWeakRemove=!!i,this._relations=new Map}setOriginalOperations(e,t=null){let i=t?this.originalOperations.get(t):null;for(let t of e)this.originalOperations.set(t,i||t)}updateRelation(e,t){if(e instanceof iE)t instanceof iO?e.targetPosition.isEqual(t.sourcePosition)||t.movedRange.containsPosition(e.targetPosition)?this._setRelation(e,t,"insertAtSource"):e.targetPosition.isEqual(t.deletionPosition)?this._setRelation(e,t,"insertBetween"):e.targetPosition.isAfter(t.sourcePosition)?this._setRelation(e,t,"moveTargetAfter"):e.howMany>1&&e.sourcePosition.isEqual(t.deletionPosition)?this._setRelation(e,t,"firstToMoveMerged"):e.howMany>1&&e.sourcePosition.getShiftedBy(e.howMany-1).isEqual(t.deletionPosition)&&this._setRelation(e,t,"lastToMoveMerged"):t instanceof iE&&(e.targetPosition.isEqual(t.sourcePosition)||e.targetPosition.isBefore(t.sourcePosition)?this._setRelation(e,t,"insertBefore"):this._setRelation(e,t,"insertAfter"));else if(e instanceof ix){if(t instanceof iO)e.splitPosition.isBefore(t.sourcePosition)&&this._setRelation(e,t,"splitBefore");else if(t instanceof iE)if(e.splitPosition.isEqual(t.sourcePosition)||e.splitPosition.isBefore(t.sourcePosition))this._setRelation(e,t,"splitBefore");else{let i=tc._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&i.containsPosition(e.splitPosition)){let r=i.end.offset-e.splitPosition.offset,n=e.splitPosition.offset-i.start.offset;this._setRelation(e,t,{howMany:r,offset:n})}}}else if(e instanceof iO)t instanceof iO?(e.targetPosition.isEqual(t.sourcePosition)||this._setRelation(e,t,"mergeTargetNotMoved"),e.sourcePosition.isEqual(t.targetPosition)&&this._setRelation(e,t,"mergeSourceNotMoved"),e.sourcePosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeSameElement")):t instanceof ix?e.sourcePosition.isEqual(t.splitPosition)&&this._setRelation(e,t,"splitAtSource"):t instanceof iE&&t.howMany>0&&(e.sourcePosition.isEqual(t.sourcePosition.getShiftedBy(t.howMany))&&this._setRelation(e,t,"mergeSourceAffected"),e.targetPosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeTargetWasBefore"));
1else if(e instanceof iM){let i=e.newRange;if(!i)return;if(t instanceof iO){let r=i.start.isEqual(t.targetPosition),n=i.start.isEqual(t.deletionPosition),s=i.end.isEqual(t.deletionPosition),o=i.end.isEqual(t.sourcePosition);(r||n||s||o)&&this._setRelation(e,t,{wasInLeftElement:r,wasStartBeforeMergedElement:n,wasEndBeforeMergedElement:s,wasInRightElement:o})}}}getContext(e,t,i){return{aIsStrong:i,aWasUndone:this._wasUndone(e),bWasUndone:this._wasUndone(t),abRelation:this._useRelations?this._getRelation(e,t):null,baRelation:this._useRelations?this._getRelation(t,e):null,forceWeakRemove:this._forceWeakRemove}}_wasUndone(e){let t=this.originalOperations.get(e);return t.wasUndone||this._history.isUndoneOperation(t)}_getRelation(e,t){let i=this.originalOperations.get(t),r=this._history.getUndoneOperation(i);if(!r)return null;let n=this.originalOperations.get(e),s=this._relations.get(n);return s&&s.get(r)||null}_setRelation(e,t,i){let r=this.originalOperations.get(e),n=this.originalOperations.get(t),s=this._relations.get(r);s||(s=new Map,this._relations.set(r,s)),s.set(n,i)}}function ij(e,t){for(let i of e)i.baseVersion=t++}function iz(e,t){for(let i=0;i<t;i++)e.push(new iN(0))}function iU(e){let t=new Map;for(let i=0;i<e.length;i++){let r=e[i];if(r instanceof iM)if(-1!==r.baseVersion)t.set(r.name,{op:r,ranges:r.newRange?[r.newRange]:[]});else{if(r.newRange){let e=t.get(r.name).ranges;e[0].containsRange(r.newRange,!0)||e.push(r.newRange)}e.splice(i,1),i--}}for(let{op:e,ranges:i}of t.values())i.length?e.newRange=tc._createFromRanges(i):e.newRange=null}function iK(e,t,i){let r=e.nodes.getNode(0).getAttribute(t);return r==i?null:new iT(new tc(e.position,e.position.getShiftedBy(e.howMany)),t,r,i,0)}function iH(e,t){return null===e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany)}function iG(e,t){let i=[];for(let r=0;r<e.length;r++){let n=e[r],s=new iE(n.start,n.end.offset-n.start.offset,t,0);i.push(s);for(let t=r+1;t<e.length;t++)e[t]=e[t]._getTransformedByMove(s.sourcePosition,s.targetPosition,s.howMany)[0];t=t._getTransformedByMove(s.sourcePosition,s.targetPosition,s.howMany)}return i}iL(iT,iT,(e,t,i)=>{if(!(e.key===t.key&&e.range.start.hasSameParentAs(t.range.start)))return[e];{let r=e.range.getDifference(t.range).map(t=>new iT(t,e.key,e.oldValue,e.newValue,0)),n=e.range.getIntersection(t.range);return(n&&i.aIsStrong&&r.push(new iT(n,t.key,t.newValue,e.newValue,0)),0==r.length)?[new iN(0)]:r}}),iL(iT,iR,(e,t)=>{if(e.range.start.hasSameParentAs(t.position)&&e.range.containsPosition(t.position)){let i=e.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map(t=>new iT(t,e.key,e.oldValue,e.newValue,e.baseVersion));if(t.shouldReceiveAttributes){let r=iK(t,e.key,e.oldValue);r&&i.unshift(r)}return i}return e.range=e.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[e]}),iL(iT,iO,(e,t)=>{let i=[];e.range.start.hasSameParentAs(t.deletionPosition)&&(e.range.containsPosition(t.deletionPosition)||e.range.start.isEqual(t.deletionPosition))&&i.push(tc._createFromPositionAndShift(t.graveyardPosition,1));let r=e.range._getTransformedByMergeOperation(t);return r.isCollapsed||i.push(r),i.map(t=>new iT(t,e.key,e.oldValue,e.newValue,e.baseVersion))}),iL(iT,iE,(e,t)=>(function(e,t){let i=tc._createFromPositionAndShift(t.sourcePosition,t.howMany),r=null,n=[];i.containsRange(e,!0)?r=e:e.start.hasSameParentAs(i.start)?(n=e.getDifference(i),r=e.getIntersection(i)):n=[e];let s=[];for(let e of n){e=e._getTransformedByDeletion(t.sourcePosition,t.howMany);let i=t.getMovedRangeStart(),r=e.start.hasSameParentAs(i),n=e._getTransformedByInsertion(i,t.howMany,r);s.push(...n)}return r&&s.push(r._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]),s})(e.range,t).map(t=>new iT(t,e.key,e.oldValue,e.newValue,e.baseVersion))),iL(iT,ix,(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)){let i=e.clone();return i.range=new tc(t.moveTargetPosition.clone(),e.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),e.range.end=t.splitPosition.clone(),e.range.end.stickiness="toPrevious",[e,i]}return e.range=e.range._getTransformedBySplitOperation(t),[e]}),iL(iR,iT,(e,t)=>{let i=[e];if(e.shouldReceiveAttributes&&e.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(e.position)){let r=iK(e,t.key,t.newValue);r&&i.push(r)}return i}),iL(iR,iR,(e,t,i)=>(e.position.isEqual(t.position)&&i.aIsStrong||(e.position=e.position._getTransformedByInsertOperation(t)),[e])),iL(iR,iE,(e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e])),iL(iR,ix,(e,t)=>(e.position=e.position._getTransformedBySplitOperation(t),[e])),iL(iR,iO,(e,t)=>(e.position=e.position._getTransformedByMergeOperation(t),[e])),iL(iM,iR,(e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByInsertOperation(t)[0]),e.newRange&&(e.newRange=e.newRange._getTransformedByInsertOperation(t)[0]),[e])),iL(iM,iM,(e,t,i)=>{if(e.name==t.name)if(!i.aIsStrong)return[new iN(0)];else e.oldRange=t.newRange?t.newRange.clone():null;return[e]}),iL(iM,iO,(e,t)=>(e.oldRange&&(e.oldRange=e.oldRange._getTransformedByMergeOperation(t)),e.newRange&&(e.newRange=e.newRange._getTransformedByMergeOperation(t)),[e])),iL(iM,iE,(e,t)=>{let i=[e];if(e.oldRange&&(e.oldRange=tc._createFromRanges(e.oldRange._getTransformedByMoveOperation(t))),e.newRange){let r=e.newRange._getTransformedByMoveOperation(t);e.newRange=r[0];for(let t=1;t<r.length;t++){let n=e.clone();n.oldRange=null,n.newRange=r[t],n.baseVersion=-1,i.push(n)}}return i}),iL(iM,ix,(e,t,i)=>{if(e.oldRange&&(e.oldRange=e.oldRange._getTransformedBySplitOperation(t)),e.newRange){if(i.abRelation){let r=e.newRange._getTransformedBySplitOperation(t);return e.newRange.start.isEqual(t.splitPosition)?i.abRelation.wasStartBeforeMergedElement?e.newRange.start=to._createAt(t.insertionPosition):i.abRelation.wasInLeftElement?e.newRange.start=to._createAt(e.newRange.start):e.newRange.start=to._createAt(t.moveTargetPosition):e.newRange.start=r.start,e.newRange.end.isEqual(t.splitPosition)?e.newRange.end.isEqual(t.splitPosition)&&i.abRelation.wasEndBeforeMergedElement?e.newRange.end=to._createAt(t.insertionPosition):i.abRelation.wasInRightElement?e.newRange.end=to._createAt(t.moveTargetPosition):e.newRange.end=to._createAt(e.newRange.end):e.newRange.end=r.end,[e]}e.newRange=e.newRange._getTransformedBySplitOperation(t)}return[e]}),iL(iO,iR,(e,t)=>
1(e.sourcePosition.hasSameParentAs(t.position)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByInsertOperation(t),e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t),[e])),iL(iO,iO,(e,t,i)=>{if(e.sourcePosition.isEqual(t.sourcePosition)&&e.targetPosition.isEqual(t.targetPosition))if(!i.bWasUndone)return[new iN(0)];else{let i=t.graveyardPosition.path.slice();return i.push(0),e.sourcePosition=new to(t.graveyardPosition.root,i),e.howMany=0,[e]}if(e.sourcePosition.isEqual(t.sourcePosition)&&!e.targetPosition.isEqual(t.targetPosition)&&!i.bWasUndone&&"splitAtSource"!=i.abRelation){let r="$graveyard"==e.targetPosition.root.rootName,n="$graveyard"==t.targetPosition.root.rootName;if(!(n&&!r||!(r&&!n)&&i.aIsStrong))return[new iN(0)];{let i=t.targetPosition._getTransformedByMergeOperation(t),r=e.targetPosition._getTransformedByMergeOperation(t);return[new iE(i,e.howMany,r,0)]}}return e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition=e.sourcePosition._getTransformedByMergeOperation(t),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),e.graveyardPosition.isEqual(t.graveyardPosition)&&i.aIsStrong||(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]}),iL(iO,iE,(e,t,i)=>{let r=tc._createFromPositionAndShift(t.sourcePosition,t.howMany);return"remove"==t.type&&!i.bWasUndone&&e.deletionPosition.hasSameParentAs(t.sourcePosition)&&r.containsPosition(e.sourcePosition)?[new iN(0)]:(t.sourcePosition.getShiftedBy(t.howMany).isEqual(e.sourcePosition)?e.sourcePosition.stickiness="toNone":t.targetPosition.isEqual(e.sourcePosition)&&"mergeSourceAffected"==i.abRelation?e.sourcePosition.stickiness="toNext":t.sourcePosition.isEqual(e.targetPosition)?(e.targetPosition.stickiness="toNone",e.howMany-=t.howMany):t.targetPosition.isEqual(e.targetPosition)&&"mergeTargetWasBefore"==i.abRelation?(e.targetPosition.stickiness="toPrevious",e.howMany+=t.howMany):(e.sourcePosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.sourcePosition.hasSameParentAs(t.sourcePosition)&&(e.howMany-=t.howMany)),e.sourcePosition=e.sourcePosition._getTransformedByMoveOperation(t),e.targetPosition=e.targetPosition._getTransformedByMoveOperation(t),e.sourcePosition.stickiness="toPrevious",e.targetPosition.stickiness="toNext",e.graveyardPosition.isEqual(t.targetPosition)||(e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)),[e])}),iL(iO,ix,(e,t,i)=>{if(t.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByDeletion(t.graveyardPosition,1),e.deletionPosition.isEqual(t.graveyardPosition)&&(e.howMany=t.howMany)),e.targetPosition.isEqual(t.splitPosition)&&(t.graveyardPosition&&e.deletionPosition.isEqual(t.graveyardPosition)||"mergeTargetNotMoved"==i.abRelation))return e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),[e];if(e.sourcePosition.isEqual(t.splitPosition)){if("mergeSourceNotMoved"==i.abRelation)return e.howMany=0,e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e];if("mergeSameElement"==i.abRelation||e.sourcePosition.offset>0)return e.sourcePosition=t.moveTargetPosition.clone(),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}return e.sourcePosition.hasSameParentAs(t.splitPosition)&&(e.howMany=t.splitPosition.offset),e.sourcePosition=e.sourcePosition._getTransformedBySplitOperation(t),e.targetPosition=e.targetPosition._getTransformedBySplitOperation(t),[e]}),iL(iE,iR,(e,t)=>{let i=tc._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByInsertOperation(t,!1)[0];return e.sourcePosition=i.start,e.howMany=i.end.offset-i.start.offset,e.targetPosition.isEqual(t.position)||(e.targetPosition=e.targetPosition._getTransformedByInsertOperation(t)),[e]}),iL(iE,iE,(e,t,i)=>{let n,s=tc._createFromPositionAndShift(e.sourcePosition,e.howMany),o=tc._createFromPositionAndShift(t.sourcePosition,t.howMany),a=i.aIsStrong,l=!i.aIsStrong;if("insertBefore"==i.abRelation||"insertAfter"==i.baRelation?l=!0:("insertAfter"==i.abRelation||"insertBefore"==i.baRelation)&&(l=!1),n=e.targetPosition.isEqual(t.targetPosition)&&l?e.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):e.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),iH(e,t)&&iH(t,e))return[t.getReversed()];if(s.containsPosition(t.targetPosition)&&s.containsRange(o,!0))return s.start=s.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),s.end=s.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),iG([s],n);if(o.containsPosition(e.targetPosition)&&o.containsRange(s,!0))return s.start=s.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),s.end=s.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),iG([s],n);let h=(0,r.ww)(e.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if("prefix"==h||"extension"==h)return s.start=s.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),s.end=s.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),iG([s],n);"remove"!=e.type||"remove"==t.type||i.aWasUndone||i.forceWeakRemove?"remove"==e.type||"remove"!=t.type||i.bWasUndone||i.forceWeakRemove||(a=!1):a=!0;let d=[];for(let e of s.getDifference(o)){e.start=e.start._getTransformedByDeletion(t.sourcePosition,t.howMany),e.end=e.end._getTransformedByDeletion(t.sourcePosition,t.howMany);let i="same"==(0,r.ww)(e.start.getParentPath(),t.getMovedRangeStart().getParentPath()),n=e._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,i);d.push(...n)}let u=s.getIntersection(o);return(null!==u&&a&&(u.start=u.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),u.end=u.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),0===d.length?d.push(u):1==d.length?o.start.isBefore(s.start)||o.start.isEqual(s.start)?d.unshift(u):d.push(u):d.splice(1,0,u)),0===d.length)?[new iN(e.baseVersion)]:iG(d,n)}),iL(iE,ix,(e,t,i)=>{let r=e.targetPosition.clone();if(e.targetPosition.isEqual(t.insertionPosition)&&t.graveyardPosition&&"moveTargetAfter"!=i.abRelation||(r=e.targetPosition._getTransformedBySplitOperation(t)),e.sourcePosition.isEqual(t.insertionPosition)&&"firstToMoveMerged"==i.abRelation)return e.howMany++,e.targetPosition=r,[e];let n=tc._createFromPositionAndShift(e.sourcePosition,e.howMany);if(n.end.isEqual(t.insertionPosition))return(!t.graveyardPosition||"lastToMoveMerged"==i.abRelation)&&e.howMany++,e.targetPosition=r,[e];
1if(n.start.hasSameParentAs(t.splitPosition)&&n.containsPosition(t.splitPosition)){let e=new tc(t.splitPosition,n.end);return e=e._getTransformedBySplitOperation(t),iG([new tc(n.start,t.splitPosition),e],r)}e.targetPosition.isEqual(t.splitPosition)&&"insertAtSource"==i.abRelation&&(r=t.moveTargetPosition),e.targetPosition.isEqual(t.insertionPosition)&&"insertBetween"==i.abRelation&&(r=e.targetPosition);let s=[n._getTransformedBySplitOperation(t)];if(t.graveyardPosition){let r=n.start.isEqual(t.graveyardPosition)||n.containsPosition(t.graveyardPosition);e.howMany>1&&r&&!i.aWasUndone&&s.push(tc._createFromPositionAndShift(t.insertionPosition,1))}return iG(s,r)}),iL(iE,iO,(e,t,i)=>{let r=tc._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.deletionPosition.hasSameParentAs(e.sourcePosition)&&r.containsPosition(t.sourcePosition)){if("remove"!=e.type||i.forceWeakRemove){if(1==e.howMany)if(!i.bWasUndone)return[new iN(0)];else return e.sourcePosition=t.graveyardPosition.clone(),e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]}else if(!i.aWasUndone){let i=[],r=t.graveyardPosition.clone(),n=t.targetPosition._getTransformedByMergeOperation(t),s=e.targetPosition.getTransformedByOperation(t);e.howMany>1&&(i.push(new iE(e.sourcePosition,e.howMany-1,s,0)),r=r._getTransformedByMove(e.sourcePosition,s,e.howMany-1),n=n._getTransformedByMove(e.sourcePosition,s,e.howMany-1));let o=t.deletionPosition._getCombined(e.sourcePosition,s),a=new iE(r,1,o,0),l=a.getMovedRangeStart().path.slice();l.push(0);let h=new to(a.targetPosition.root,l),d=new iE(n=n._getTransformedByMove(r,o,1),t.howMany,h,0);return i.push(a),i.push(d),i}}let n=tc._createFromPositionAndShift(e.sourcePosition,e.howMany)._getTransformedByMergeOperation(t);return e.sourcePosition=n.start,e.howMany=n.end.offset-n.start.offset,e.targetPosition=e.targetPosition._getTransformedByMergeOperation(t),[e]}),iL(iF,iR,(e,t)=>(e.position=e.position._getTransformedByInsertOperation(t),[e])),iL(iF,iO,(e,t)=>(e.position.isEqual(t.deletionPosition)?(e.position=t.graveyardPosition.clone(),e.position.stickiness="toNext"):e.position=e.position._getTransformedByMergeOperation(t),[e])),iL(iF,iE,(e,t)=>(e.position=e.position._getTransformedByMoveOperation(t),[e])),iL(iF,iF,(e,t,i)=>{if(e.position.isEqual(t.position))if(!i.aIsStrong)return[new iN(0)];else e.oldName=t.newName;return[e]}),iL(iF,ix,(e,t)=>{let i=e.position.path,n=t.splitPosition.getParentPath();if("same"==(0,r.ww)(i,n)&&!t.graveyardPosition){let t=new iF(e.position.getShiftedBy(1),e.oldName,e.newName,0);return[e,t]}return e.position=e.position._getTransformedBySplitOperation(t),[e]}),iL(iI,iI,(e,t,i)=>{if(e.root===t.root&&e.key===t.key)if(!i.aIsStrong)return[new iN(0)];else e.oldValue=t.newValue;return[e]}),iL(iB,iB,(e,t)=>e.rootName===t.rootName&&e.isAdd===t.isAdd?[new iN(0)]:[e]),iL(ix,iR,(e,t)=>(e.splitPosition.hasSameParentAs(t.position)&&e.splitPosition.offset<t.position.offset&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByInsertOperation(t),e.insertionPosition=e.insertionPosition._getTransformedByInsertOperation(t),[e])),iL(ix,iO,(e,t,i)=>{if(!e.graveyardPosition&&!i.bWasUndone&&e.splitPosition.hasSameParentAs(t.sourcePosition)){let i=t.graveyardPosition.path.slice();i.push(0);let r=new to(t.graveyardPosition.root,i),n=ix.getInsertionPosition(new to(t.graveyardPosition.root,i)),s=new ix(r,0,n,null,0);return e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=ix.getInsertionPosition(e.splitPosition),e.graveyardPosition=s.insertionPosition.clone(),e.graveyardPosition.stickiness="toNext",[s,e]}return e.splitPosition.hasSameParentAs(t.deletionPosition)&&!e.splitPosition.isAfter(t.deletionPosition)&&e.howMany--,e.splitPosition.hasSameParentAs(t.targetPosition)&&(e.howMany+=t.howMany),e.splitPosition=e.splitPosition._getTransformedByMergeOperation(t),e.insertionPosition=ix.getInsertionPosition(e.splitPosition),e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedByMergeOperation(t)),[e]}),iL(ix,iE,(e,t,i)=>{let r=tc._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.graveyardPosition){let n=r.start.isEqual(e.graveyardPosition)||r.containsPosition(e.graveyardPosition);if(!i.bWasUndone&&n){let i=e.splitPosition._getTransformedByMoveOperation(t),r=e.graveyardPosition._getTransformedByMoveOperation(t),n=r.path.slice();n.push(0);let s=new to(r.root,n);return[new iE(i,e.howMany,s,0)]}e.graveyardPosition=e.graveyardPosition._getTransformedByMoveOperation(t)}let n=e.splitPosition.isEqual(t.targetPosition);if(n&&("insertAtSource"==i.baRelation||"splitBefore"==i.abRelation))return e.howMany+=t.howMany,e.splitPosition=e.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),e.insertionPosition=ix.getInsertionPosition(e.splitPosition),[e];if(n&&i.abRelation&&i.abRelation.howMany){let{howMany:t,offset:r}=i.abRelation;return e.howMany+=t,e.splitPosition=e.splitPosition.getShiftedBy(r),[e]}if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&r.containsPosition(e.splitPosition)){let i=t.howMany-(e.splitPosition.offset-t.sourcePosition.offset);return e.howMany-=i,e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset<t.targetPosition.offset&&(e.howMany+=t.howMany),e.splitPosition=t.sourcePosition.clone(),e.
1insertionPosition=ix.getInsertionPosition(e.splitPosition),[e]}return!t.sourcePosition.isEqual(t.targetPosition)&&(e.splitPosition.hasSameParentAs(t.sourcePosition)&&e.splitPosition.offset<=t.sourcePosition.offset&&(e.howMany-=t.howMany),e.splitPosition.hasSameParentAs(t.targetPosition)&&e.splitPosition.offset<t.targetPosition.offset&&(e.howMany+=t.howMany)),e.splitPosition.stickiness="toNone",e.splitPosition=e.splitPosition._getTransformedByMoveOperation(t),e.splitPosition.stickiness="toNext",e.graveyardPosition?e.insertionPosition=e.insertionPosition._getTransformedByMoveOperation(t):e.insertionPosition=ix.getInsertionPosition(e.splitPosition),[e]}),iL(ix,ix,(e,t,i)=>{if(e.splitPosition.isEqual(t.splitPosition)){if(!e.graveyardPosition&&!t.graveyardPosition||e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition))return[new iN(0)];if("splitBefore"==i.abRelation)return e.howMany=0,e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t),[e]}if(e.graveyardPosition&&t.graveyardPosition&&e.graveyardPosition.isEqual(t.graveyardPosition)){let r="$graveyard"==e.splitPosition.root.rootName,n="$graveyard"==t.splitPosition.root.rootName;if(!(n&&!r||!(r&&!n)&&i.aIsStrong))return[new iN(0)];{let i=[];return t.howMany&&i.push(new iE(t.moveTargetPosition,t.howMany,t.splitPosition,0)),e.howMany&&i.push(new iE(e.splitPosition,e.howMany,e.moveTargetPosition,0)),i}}if(e.graveyardPosition&&(e.graveyardPosition=e.graveyardPosition._getTransformedBySplitOperation(t)),e.splitPosition.isEqual(t.insertionPosition)&&"splitBefore"==i.abRelation)return e.howMany++,[e];if(t.splitPosition.isEqual(e.insertionPosition)&&"splitBefore"==i.baRelation){let i=t.insertionPosition.path.slice();i.push(0);let r=new to(t.insertionPosition.root,i),n=new iE(e.insertionPosition,1,r,0);return[e,n]}return e.splitPosition.hasSameParentAs(t.splitPosition)&&e.splitPosition.offset<t.splitPosition.offset&&(e.howMany-=t.howMany),e.splitPosition=e.splitPosition._getTransformedBySplitOperation(t),e.insertionPosition=ix.getInsertionPosition(e.splitPosition),[e]});class iZ extends(0,r.Mm)(to){constructor(e,t,i="toNone"){if(super(e,t,i),!this.root.is("rootElement"))throw new r.Yb("model-liveposition-root-not-rootelement",e);iQ.call(this)}detach(){this.stopListening()}toPosition(){return new to(this.root,this.path.slice(),this.stickiness)}static fromPosition(e,t){return new this(e.root,e.path.slice(),t||e.stickiness)}}function iQ(){this.listenTo(this.root.document.model,"applyOperation",(e,t)=>{let i=t[0];i.isDocumentOperation&&iX.call(this,i)},{priority:"low"})}function iX(e){let t=this.getTransformedByOperation(e);if(!this.isEqual(t)){let e=this.toPosition();this.path=t.path,this.root=t.root,this.fire("change",e)}}iZ.prototype.is=function(e){return"livePosition"===e||"model:livePosition"===e||"position"==e||"model:position"===e};class i0{operations;isUndoable;isLocal;isUndo;isTyping;constructor(e={}){"string"==typeof e&&(e="transparent"===e?{isUndoable:!1}:{},(0,r.FF)("batch-constructor-deprecated-string-type"));let{isUndoable:t=!0,isLocal:i=!0,isUndo:n=!1,isTyping:s=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=i,this.isUndo=n,this.isTyping=s}get baseVersion(){for(let e of this.operations)if(null!==e.baseVersion)return e.baseVersion;return null}addOperation(e){return e.isDocumentOperation&&(e.batch=this,this.operations.push(e)),e}}class i1{static _statesPriority=[void 0,"refresh","rename","move"];_markerCollection;_changesInElement=new Map;_elementsSnapshots=new Map;_elementChildrenSnapshots=new Map;_elementState=new Map;_changedMarkers=new Map;_changedRoots=new Map;_changeCount=0;_cachedChanges=null;_cachedChangesWithGraveyard=null;_refreshedItems=new Set;constructor(e){this._markerCollection=e}get isEmpty(){return 0==this._changesInElement.size&&0==this._changedMarkers.size&&0==this._changedRoots.size}bufferOperation(e){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(let 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;let t=this._isInInsertedElement(e.sourcePosition.parent),i=this._isInInsertedElement(e.targetPosition.parent);for(let r of(t||this._markRemove(e.sourcePosition.parent,e.sourcePosition.offset,e.howMany),i||this._markInsert(e.targetPosition.parent,e.getMovedRangeStart().offset,e.howMany),tc._createFromPositionAndShift(e.sourcePosition,e.howMany).getItems({shallow:!0})))this._setElementState(r,"move");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);let t=tc._createFromPositionAndShift(e.position,1);for(let e of this._markerCollection.getMarkersIntersectingRange(t)){let t=e.getData();this.bufferMarkerChange(e.name,t,t)}this._setElementState(e.position.nodeAfter,"rename");break}case"split":{let t=e.splitPosition.parent;if(!this._isInInsertedElement(t))for(let i of(this._markRemove(t,e.splitPosition.offset,e.howMany),tc._createFromPositionAndShift(e.splitPosition,e.howMany).getItems({shallow:!0})))this._setElementState(i,"move");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),this._setElementState(e.graveyardPosition.nodeAfter,"move"));break}case"merge":{let t=e.sourcePosition.parent;this._isInInsertedElement(t.parent)||this._markRemove(t.parent,t.startOffset,1);let i=e.graveyardPosition.parent;this._markInsert(i,e.graveyardPosition.offset,1),this._setElementState(t,"move");let r=e.targetPosition.parent;if(!this._isInInsertedElement(r))for(let i of(this._markInsert(r,e.targetPosition.offset,t.maxOffset),tc._createFromPositionAndShift(e.sourcePosition,e.howMany).getItems({shallow:!0})))this._setElementState(i,"move");break}case"detachRoot":case"addRoot":{let t=e.affectedSelectable;if(!t._isLoaded||t.isAttached()==e.isAdd)return;this._bufferRootStateChange(e.rootName,e.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!e.root._isLoaded)return;let t=e.root.rootName;this._bufferRootAttributeChange(t,e.key,e.oldValue,e.newValue)}}this._cachedChanges=null}bufferMarkerChange(e,t,i){t.range&&t.range.root.is("rootElement")&&!t.range.root._isLoaded&&(t.range=null),i.range&&i.range.root.is("rootElement")&&!i.range.root._isLoaded&&(i.range=null);let r=this._changedMarkers.get(e);r?r.newMarkerData=i:(r={newMarkerData:i,oldMarkerData:t},this._changedMarkers.set(e,r)),null==r.oldMarkerData.range&&null==i.range&&this._changedMarkers.delete(e)}getMarkersToRemove(){let e=[];for(let[t,i]of this._changedMarkers)null!=i.oldMarkerData.range&&e.push({name:t,range:i.oldMarkerData.range});return e}getMarkersToAdd(){let e=[];for(let[t,i]of this._changedMarkers)null!=i.newMarkerData.range&&e.push({name:t,range:i.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map(([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}}))}
1hasDataChanges(){if(this.getChanges().length||this._changedRoots.size>0)return!0;for(let{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){let i=e.range&&!t.range,r=!e.range&&t.range,n=e.range&&t.range&&!e.range.isEqual(t.range);if(i||r||n)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)if(e.includeChangesInGraveyard)return this._cachedChangesWithGraveyard.slice();else return this._cachedChanges.slice();let t=[];for(let e of this._changesInElement.keys()){let i=this._changesInElement.get(e).sort((e,t)=>e.offset===t.offset?e.type!=t.type?"remove"==e.type?-1:1:0:e.offset<t.offset?-1:1),r=this._elementChildrenSnapshots.get(e),n=i2(e.getChildren()),s=function(e,t){let i=[],r=0,n=0;for(let e of t){if(e.offset>r){for(let t=0;t<e.offset-r;t++)i.push("e");n+=e.offset-r}if("insert"==e.type){for(let t=0;t<e.howMany;t++)i.push("i");r=e.offset+e.howMany}else if("remove"==e.type){for(let t=0;t<e.howMany;t++)i.push("r");r=e.offset,n+=e.howMany}else{if(e.howMany>1500)for(let t=0;t<e.howMany;t++)i.push("a");else i.push(..."a".repeat(e.howMany).split(""));r=e.offset+e.howMany,n+=e.howMany}}if(n<e)for(let t=0;t<e-n-r;t++)i.push("e");return i}(r.length,i),o=0,a=0;for(let i of s)if("i"===i){let i=this._getDiffActionForNode(n[o].node,"insert"),r=this._elementsSnapshots.get(n[o].node),s=this._getInsertDiff(e,o,i,n[o],r);t.push(s),o++}else if("r"===i){let i=this._getDiffActionForNode(r[a].node,"remove"),n=this._getRemoveDiff(e,o,i,r[a]);t.push(n),a++}else if("a"===i){let i,s=r[a].attributes,l=n[o].attributes;if("$text"==n[o].name)i=new tc(to._createAt(e,o),to._createAt(e,o+1));else{let t=e.offsetToIndex(o);i=new tc(to._createAt(e,o),to._createAt(e.getChild(t),0))}let h=this._getAttributesDiff(i,s,l);t.push(...h),o++,a++}else o++,a++}t.sort((e,t)=>e.position.root!=t.position.root?e.position.root.rootName<t.position.root.rootName?-1:1:e.position.isEqual(t.position)?e.changeCount-t.changeCount:e.position.isBefore(t.position)?-1:1);for(let e=1,i=0;e<t.length;e++){let r=t[i],n=t[e],s="remove"==r.type&&"remove"==n.type&&"$text"==r.name&&"$text"==n.name&&r.position.isEqual(n.position),o="insert"==r.type&&"insert"==n.type&&"$text"==r.name&&"$text"==n.name&&r.position.parent==n.position.parent&&r.position.offset+r.length==n.position.offset,a="attribute"==r.type&&"attribute"==n.type&&r.position.parent==n.position.parent&&r.range.isFlat&&n.range.isFlat&&r.position.offset+r.length==n.position.offset&&r.attributeKey==n.attributeKey&&r.attributeOldValue==n.attributeOldValue&&r.attributeNewValue==n.attributeNewValue;s||o||a?(r.length++,a&&(r.range.end=r.range.end.getShiftedBy(1)),t[e]=null):i=e}for(let e of t=t.filter(e=>e))delete e.changeCount,"attribute"==e.type&&(delete e.position,delete e.length);return(this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(i3),e.includeChangesInGraveyard)?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}
1getChangedRoots(){return Array.from(this._changedRoots.values()).map(e=>{let t={...e};return void 0!==t.state&&delete t.attributes,t})}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementChildrenSnapshots.clear(),this._elementsSnapshots.clear(),this._elementState.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems.clear(),this._cachedChanges=null}_refreshItem(e){if(this._isInInsertedElement(e.parent))return;this._markRemove(e.parent,e.startOffset,e.offsetSize),this._markInsert(e.parent,e.startOffset,e.offsetSize),this._refreshedItems.add(e),this._setElementState(e,"refresh");let t=tc._createOn(e);for(let e of this._markerCollection.getMarkersIntersectingRange(t)){let t=e.getData();this.bufferMarkerChange(e.name,t,t)}this._cachedChanges=null}_bufferRootLoad(e){if(e.isAttached()){for(let t of(this._bufferRootStateChange(e.rootName,!0),this._markInsert(e,0,e.maxOffset),e.getAttributeKeys()))this._bufferRootAttributeChange(e.rootName,t,null,e.getAttribute(t));for(let t of this._markerCollection)if(t.getRange().root==e){let e=t.getData();this.bufferMarkerChange(t.name,{...e,range:null},e)}}}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e))return void this._changedRoots.set(e,{name:e,state:t?"attached":"detached"});let i=this._changedRoots.get(e);void 0!==i.state?(delete i.state,void 0===i.attributes&&this._changedRoots.delete(e)):i.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,i,r){let n=this._changedRoots.get(e)||{name:e},s=n.attributes||{};if(s[t]){let e=s[t];r===e.oldValue?delete s[t]:e.newValue=r}else s[t]={oldValue:i,newValue:r};0===Object.entries(s).length?(delete n.attributes,void 0===n.state&&this._changedRoots.delete(e)):(n.attributes=s,this._changedRoots.set(e,n))}_markInsert(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;let r={type:"insert",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,r)}_markRemove(e,t,i){if(e.root.is("rootElement")&&!e.root._isLoaded)return;let r={type:"remove",offset:t,howMany:i,count:this._changeCount++};this._markChange(e,r),this._removeAllNestedChanges(e,t,i)}_markAttribute(e){if(e.root.is("rootElement")&&!e.root._isLoaded)return;let t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshots(e);let i=this._getChangesForElement(e);this._handleChange(t,i),i.push(t);for(let e=0;e<i.length;e++)i[e].howMany<1&&(i.splice(e,1),e--)}_setElementState(e,t){if(!e.is("element"))return;let i=i1._statesPriority.indexOf(this._elementState.get(e));i1._statesPriority.indexOf(t)>i&&this._elementState.set(e,t)}_getDiffActionForNode(e,t){if(!e.is("element")||!this._elementsSnapshots.has(e))return t;let i=this._elementState.get(e);return i&&"move"!=i?i:t}_getChangesForElement(e){let t;return this._changesInElement.has(e)?t=this._changesInElement.get(e):(t=[],this._changesInElement.set(e,t)),t}_makeSnapshots(e){if(this._elementChildrenSnapshots.has(e))return;let t=i2(e.getChildren());for(let i of(this._elementChildrenSnapshots.set(e,t),t))this._elementsSnapshots.set(i.node,i)}_handleChange(e,t){for(let i of(e.nodesToHandle=e.howMany,t)){let r=e.offset+e.howMany,n=i.offset+i.howMany;if("insert"==e.type&&("insert"==i.type&&(e.offset<=i.offset?i.offset+=e.howMany:e.offset<n&&(i.howMany+=e.nodesToHandle,e.nodesToHandle=0)),"remove"==i.type&&e.offset<i.offset&&(i.offset+=e.howMany),"attribute"==i.type)){if(e.offset<=i.offset)i.offset+=e.howMany;else if(e.offset<n){let n=i.howMany;i.howMany=e.offset-i.offset,t.unshift({type:"attribute",offset:r,howMany:n-i.howMany,count:this._changeCount++})}}if("remove"==e.type){if("insert"==i.type){if(r<=i.offset)i.offset-=e.howMany;else if(r<=n)if(e.offset<i.offset){let t=r-i.offset;i.offset=e.offset,i.howMany-=t,e.nodesToHandle-=t}else i.howMany-=e.nodesToHandle,e.nodesToHandle=0;else if(e.offset<=i.offset)e.nodesToHandle-=i.howMany,i.howMany=0;else if(e.offset<n){let t=n-e.offset;i.howMany-=t,e.nodesToHandle-=t}}if("remove"==i.type&&(r<=i.offset?i.offset-=e.howMany:e.offset<i.offset&&(e.nodesToHandle+=i.howMany,i.howMany=0)),"attribute"==i.type){if(r<=i.offset)i.offset-=e.howMany;else if(e.offset<i.offset){let t=r-i.offset;i.offset=e.offset,i.howMany-=t}else if(e.offset<n)if(r<=n){let r=i.howMany;i.howMany=e.offset-i.offset;
1let n=r-i.howMany-e.nodesToHandle;t.unshift({type:"attribute",offset:e.offset,howMany:n,count:this._changeCount++})}else i.howMany-=n-e.offset}}if("attribute"==e.type){if("insert"==i.type)if(e.offset<i.offset&&r>i.offset){if(r>n){let e={type:"attribute",offset:n,howMany:r-n,count:this._changeCount++};this._handleChange(e,t),t.push(e)}e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=i.offset&&e.offset<n&&(r>n?(e.nodesToHandle=r-n,e.offset=n):e.nodesToHandle=0);if("remove"==i.type&&e.offset<i.offset&&r>i.offset){let n={type:"attribute",offset:i.offset,howMany:r-i.offset,count:this._changeCount++};this._handleChange(n,t),t.push(n),e.nodesToHandle=i.offset-e.offset,e.howMany=e.nodesToHandle}"attribute"==i.type&&(e.offset>=i.offset&&r<=n?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=i.offset&&r>=n&&(i.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,i,r,n){let s={type:"insert",position:to._createAt(e,t),name:r.name,attributes:new Map(r.attributes),length:1,changeCount:this._changeCount++,action:i};return"insert"!=i&&n&&(s.before={name:n.name,attributes:new Map(n.attributes)}),s}_getRemoveDiff(e,t,i,r){return{type:"remove",action:i,position:to._createAt(e,t),name:r.name,attributes:new Map(r.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,i){let r=[];for(let[n,s]of(i=new Map(i),t)){let t=i.has(n)?i.get(n):null;t!==s&&r.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:n,attributeOldValue:s,attributeNewValue:t,changeCount:this._changeCount++}),i.delete(n)}for(let[t,n]of i)r.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:t,attributeOldValue:null,attributeNewValue:n,changeCount:this._changeCount++});return r}_isInInsertedElement(e){let t=e.parent;if(!t)return!1;let i=this._changesInElement.get(t),r=e.startOffset;if(i){for(let e of i)if("insert"==e.type&&r>=e.offset&&r<e.offset+e.howMany)return!0}return this._isInInsertedElement(t)}_removeAllNestedChanges(e,t,i){for(let r of new tc(to._createAt(e,t),to._createAt(e,t+i)).getItems({shallow:!0}))r.is("element")&&(this._changesInElement.delete(r),this._removeAllNestedChanges(r,0,r.maxOffset))}}function i9(e){return{node:e,name:e.is("$text")?"$text":e.name,attributes:new Map(e.getAttributes())}}function i2(e){let t=[];for(let i of e)if(i.is("$text"))for(let e=0;e<i.data.length;++e)t.push(i9(i));else t.push(i9(i));return t}function i3(e){let t="position"in e&&"$graveyard"==e.position.root.rootName,i="range"in e&&"$graveyard"==e.range.root.rootName;return!t&&!i}class i5{_operations=[];_undoPairs=new Map;_undoneOperations=new Set;_baseVersionToOperationIndex=new Map;_version=0;_gaps=new Map;get version(){return this._version}set version(e){this._operations.length&&e>this._version+1&&this._gaps.set(this._version,e),this._version=e}get lastOperation(){return this._operations[this._operations.length-1]}addOperation(e){if(e.baseVersion!==this.version)throw new r.Yb("model-document-history-addoperation-incorrect-version",this,{operation:e,historyVersion:this.version});this._operations.push(e),this._version++,this._baseVersionToOperationIndex.set(e.baseVersion,this._operations.length-1)}getOperations(e,t=this.version){if(!this._operations.length)return[];let i=this._operations[0];void 0===e&&(e=i.baseVersion);let r=t-1;for(let[t,i]of this._gaps)e>t&&e<i&&(e=i),r>t&&r<i&&(r=t-1);if(r<i.baseVersion||e>this.lastOperation.baseVersion)return[];let n=this._baseVersionToOperationIndex.get(e);void 0===n&&(n=0);let s=this._baseVersionToOperationIndex.get(r);return void 0===s&&(s=this._operations.length-1),this._operations.slice(n,s+1)}getOperation(e){let t=this._baseVersionToOperationIndex.get(e);if(void 0!==t)return this._operations[t]}setOperationAsUndone(e,t){this._undoPairs.set(t,e),this._undoneOperations.add(e)}isUndoingOperation(e){return this._undoPairs.has(e)}isUndoneOperation(e){return this._undoneOperations.has(e)}getUndoneOperation(e){return this._undoPairs.get(e)}reset(){this._version=0,this._undoPairs=new Map,this._operations=[],this._undoneOperations=new Set,this._gaps=new Map,this._baseVersionToOperationIndex=new Map}}class i7 extends tN{rootName;_document;_isAttached=!0;_isLoaded=!0;constructor(e,t,i="main"){super(t),this._document=e,this.rootName=i}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}i7.prototype.is=function(e,t){return t?t===this.name&&("rootElement"===e||"model:rootElement"===e||"element"===e||"model:element"===e):"rootElement"===e||"model:rootElement"===e||"element"===e||"model:element"===e||"node"===e||"model:node"===e};let i6="$graveyard";class i4 extends(0,r.Mm)(){model;history;selection;roots;differ;isReadOnly;_postFixers;_hasSelectionChangedFromTheLastChangeBlock;constructor(e){super(),this.model=e,this.history=new i5,this.selection=new tx(this),this.roots=new r.pM({idProperty:"rootName"}),this.differ=new i1(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",i6),this.listenTo(e,"applyOperation",(e,t)=>{let i=t[0];i.isDocumentOperation&&this.differ.bufferOperation(i)},{priority:"high"}),this.listenTo(e,"applyOperation",(e,t)=>{let i=t[0];i.isDocumentOperation&&this.history.addOperation(i)},{priority:"low"}),this.listenTo(this.selection,"change",()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0}),this.listenTo(e.markers,"update",(e,t,i,r,n)=>{let s={...t.getData(),range:r};this.differ.bufferMarkerChange(t.name,n,s),null===i&&t.on("change",(e,i)=>{let r=t.getData();this.differ.bufferMarkerChange(t.name,{...r,range:i},r)})}),this.registerPostFixer(e=>{let t=!1;for(let i of this.roots)i.isAttached()||i.isEmpty||(e.remove(e.createRangeIn(i)),t=!0);for(let i of this.model.markers)i.getRange().root.isAttached()||(e.removeMarker(i),t=!0);return t})}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(i6)}
1createRoot(e="$root",t="main"){if(this.roots.get(t))throw new r.Yb("model-document-createroot-name-exists",this,{name:t});let i=new i7(this,e,t);return this.roots.add(i),i}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map(e=>e.rootName)}getRoots(e=!1){return this.roots.filter(t=>t!=this.graveyard&&(e||t.isAttached())&&t._isLoaded)}registerPostFixer(e){this._postFixers.add(e)}toJSON(){let e=(0,m.o)(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(){let e=this.getRoots();return e.length?e[0]:this.graveyard}_getDefaultRange(){let e=this._getDefaultRoot(),t=this.model,i=t.schema,r=t.createPositionFromPath(e,[0]);return i.getNearestSelectionRange(r)||t.createRange(r)}_validateSelectionRange(e){return e.start.isValid()&&e.end.isValid()&&i8(e.start)&&i8(e.end)}_callPostFixers(e){let t=!1;do for(let i of this._postFixers)if(this.selection.refresh(),t=i(e))break;while(t)}}function i8(e){let t=e.textNode;if(t){let i=t.data,n=e.offset-t.startOffset;return!(0,r.P5)(i,n)&&!(0,r.Iw)(i,n)}return!0}class re extends(0,r.Mm)(){_markers=new Map;[Symbol.iterator](){return this._markers.values()}has(e){let t=e instanceof rt?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,i=!1,n=!1){let s=e instanceof rt?e.name:e;if(s.includes(","))throw new r.Yb("markercollection-incorrect-marker-name",this);let o=this._markers.get(s);if(o){let e=o.getData(),r=o.getRange(),a=!1;return r.isEqual(t)||(o._attachLiveRange(tA.fromRange(t)),a=!0),i!=o.managedUsingOperations&&(o._managedUsingOperations=i,a=!0),"boolean"==typeof n&&n!=o.affectsData&&(o._affectsData=n,a=!0),a&&this.fire(`update:${s}`,o,r,t,e),o}let a=new rt(s,tA.fromRange(t),i,n);return this._markers.set(s,a),this.fire(`update:${s}`,a,null,t,{...a.getData(),range:null}),a}_remove(e){let t=e instanceof rt?e.name:e,i=this._markers.get(t);return!!i&&(this._markers.delete(t),this.fire(`update:${t}`,i,i.getRange(),null,i.getData()),this._destroyMarker(i),!0)}_refresh(e){let t=e instanceof rt?e.name:e,i=this._markers.get(t);if(!i)throw new r.Yb("markercollection-refresh-marker-not-exists",this);let n=i.getRange();this.fire(`update:${t}`,i,n,n,i.getData())}*getMarkersAtPosition(e){for(let t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(let t of this)null!==t.getRange().getIntersection(e)&&(yield t)}destroy(){for(let e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(let t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}class rt extends(0,r.Mm)(ti){name;_managedUsingOperations;_affectsData;_liveRange;constructor(e,t,i,r){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=i,this._affectsData=r}get managedUsingOperations(){if(!this._liveRange)throw new r.Yb("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new r.Yb("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new r.Yb("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new r.Yb("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new r.Yb("marker-destroyed",this);return this._liveRange.toRange()}toJSON(){return{name:this.name,range:this._liveRange?.toJSON(),usingOperations:this._managedUsingOperations,affectsData:this._affectsData}}_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}}rt.prototype.is=function(e){return"marker"===e||"model:marker"===e};class ri extends ib{sourcePosition;howMany;constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}get type(){return"detach"}get affectedSelectable(){return null}toJSON(){let e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new r.Yb("detach-operation-on-document-node",this)}_execute(){iv(tc._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class rr extends ti{markers=new Map;_children=new tT;constructor(e){super(),e&&this._insertChild(0,e)}[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return 0===this.childCount}get nextSibling(){return null}get previousSibling(){return null}get root(){return this}get parent(){return null}get document(){return null}isAttached(){return!1}getAncestors(){return[]}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(let i of e)t=t.getChildAtOffset(i);return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){let e=[];for(let t of this._children)e.push(t.toJSON());return e}static fromJSON(e){let t=[];for(let i of e)i.name?t.push(tN.fromJSON(i)):t.push(tE.fromJSON(i));return new rr(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){var i;let n="string"==typeof(i=t)?[new tE(i)]:((0,r.xZ)(i)||(i=[i]),Array.from(i).map(e=>"string"==typeof e?new tE(e):e instanceof tr?new tE(e.data,e.getAttributes()):e));for(let e of n)null!==e.parent&&e._remove(),e.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){let i=this._children._removeNodes(e,t);for(let e of i)e.parent=null;return i}_removeChildrenArray(e){for(let t of(this._children._removeNodesArray(e),e))t.parent=null}}rr.prototype.is=function(e){return"documentFragment"===e||"model:documentFragment"===e};class rn{model;batch;constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new tE(e,t)}createElement(e,t){return new tN(e,t)}createDocumentFragment(){return new rr}
1cloneElement(e,t=!0){return e._clone(t)}insert(e,t,i=0){if(this._assertWriterUsedCorrectly(),e instanceof tE&&""==e.data)return;let n=to._createAt(t,i);if(e.parent)if(rl(e.root,n.root))return void this.move(tc._createOn(e),n);else if(e.root.document)throw new r.Yb("model-writer-insert-forbidden-move",this);else this.remove(e);let s=n.root.document?n.root.document.version:null,o=new iR(n,e instanceof rr?e._removeChildren(0,e.childCount):e,s);if(e instanceof tE&&(o.shouldReceiveAttributes=!0),this.batch.addOperation(o),this.model.applyOperation(o),e instanceof rr)for(let[t,i]of e.markers){let e=to._createAt(i.root,0),r={range:new tc(i.start._getCombined(e,n),i.end._getCombined(e,n)),usingOperation:!0,affectsData:!0};this.model.markers.has(t)?this.updateMarker(t,r):this.addMarker(t,r)}}insertText(e,t,i,r){t instanceof rr||t instanceof tN||t instanceof to?this.insert(this.createText(e),t,i):this.insert(this.createText(e,t),i,r)}insertElement(e,t,i,r){t instanceof rr||t instanceof tN||t instanceof to?this.insert(this.createElement(e),t,i):this.insert(this.createElement(e,t),i,r)}append(e,t){this.insert(e,t,"end")}appendText(e,t,i){t instanceof rr||t instanceof tN?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),i,"end")}appendElement(e,t,i){t instanceof rr||t instanceof tN?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),i,"end")}setAttribute(e,t,i){if(this._assertWriterUsedCorrectly(),i instanceof tc)for(let r of i.getMinimalFlatRanges())rs(this,e,t,r);else ro(this,e,t,i)}setAttributes(e,t){for(let[i,n]of(0,r.av)(e))this.setAttribute(i,n,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof tc)for(let i of t.getMinimalFlatRanges())rs(this,e,null,i);else ro(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();let t=e=>{for(let t of e.getAttributeKeys())this.removeAttribute(t,e)};if(e instanceof tc)for(let i of e.getItems())t(i);else t(e)}move(e,t,i){if(this._assertWriterUsedCorrectly(),!(e instanceof tc))throw new r.Yb("writer-move-invalid-range",this);if(!e.isFlat)throw new r.Yb("writer-move-range-not-flat",this);let n=to._createAt(t,i);if(n.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!rl(e.root,n.root))throw new r.Yb("writer-move-different-document",this);let s=e.root.document?e.root.document.version:null,o=new iE(e.start,e.end.offset-e.start.offset,n,s);this.batch.addOperation(o),this.model.applyOperation(o)}remove(e){for(let t of(this._assertWriterUsedCorrectly(),(e instanceof tc?e:tc._createOn(e)).getMinimalFlatRanges().reverse()))this._addOperationForAffectedMarkers("move",t),function(e,t,i,r){let n;if(e.root.document){let i=r.document;n=new iE(e,t,new to(i.graveyard,[0]),i.version)}else n=new ri(e,t);i.addOperation(n),r.applyOperation(n)}(t.start,t.end.offset-t.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();let t=e.nodeBefore,i=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof tN))throw new r.Yb("writer-merge-no-element-before",this);if(!(i instanceof tN))throw new r.Yb("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,i){return this.model.createPositionFromPath(e,t,i)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(...e){return this.model.createSelection(...e)}_mergeDetached(e){let t=e.nodeBefore,i=e.nodeAfter;this.move(tc._createIn(i),to._createAt(t,"end")),this.remove(i)}_merge(e){let t=to._createAt(e.nodeBefore,"end"),i=to._createAt(e.nodeAfter,0),r=new to(e.root.document.graveyard,[0]),n=e.root.document.version,s=new iO(i,e.nodeAfter.maxOffset,t,r,n);this.batch.addOperation(s),this.model.applyOperation(s)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof tN))throw new r.Yb("writer-rename-not-element-instance",this);let i=e.root.document?e.root.document.version:null,n=new iF(to._createBefore(e),e.name,t,i);this.batch.addOperation(n),this.model.applyOperation(n)}split(e,t){let i,n;this._assertWriterUsedCorrectly();let s=e.parent;if(!s.parent)throw new r.Yb("writer-split-element-no-parent",this);if(t||(t=s.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new r.Yb("writer-split-invalid-limit-element",this);do{let t=s.root.document?s.root.document.version:null,r=s.maxOffset-e.offset,o=ix.getInsertionPosition(e),a=new ix(e,r,o,null,t);this.batch.addOperation(a),this.model.applyOperation(a),i||n||(i=s,n=e.parent.nextSibling),s=(e=this.createPositionAfter(e.parent)).parent}while(s!==t);return{position:e,range:new tc(to._createAt(i,"end"),to._createAt(n,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new r.Yb("writer-wrap-range-not-flat",this);let i=t instanceof tN?t:new tN(t);if(i.childCount>0)throw new r.Yb("writer-wrap-element-not-empty",this);if(null!==i.parent)throw new r.Yb("writer-wrap-element-attached",this);this.insert(i,e.start);let n=new tc(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(n,to._createAt(i,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),null===e.parent)throw new r.Yb("writer-unwrap-element-no-parent",this);this.move(tc._createIn(e),this.createPositionAfter(e)),this.remove(e)}
1addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||"boolean"!=typeof t.usingOperation)throw new r.Yb("writer-addmarker-no-usingoperation",this);let i=t.usingOperation,n=t.range,s=void 0!==t.affectsData&&t.affectsData;if(this.model.markers.has(e))throw new r.Yb("writer-addmarker-marker-exists",this);if(!n)throw new r.Yb("writer-addmarker-no-range",this);return i?(ra(this,e,null,n,s),this.model.markers.get(e)):this.model.markers._set(e,n,i,s)}updateMarker(e,t){this._assertWriterUsedCorrectly();let i="string"==typeof e?e:e.name,n=this.model.markers.get(i);if(!n)throw new r.Yb("writer-updatemarker-marker-not-exists",this);if(!t){(0,r.FF)("writer-updatemarker-reconvert-using-editingcontroller",{markerName:i}),this.model.markers._refresh(n);return}let s="boolean"==typeof t.usingOperation,o="boolean"==typeof t.affectsData,a=o?t.affectsData:n.affectsData;if(!s&&!t.range&&!o)throw new r.Yb("writer-updatemarker-wrong-options",this);let l=n.getRange(),h=t.range?t.range:l;if(s&&t.usingOperation!==n.managedUsingOperations)return void(t.usingOperation?ra(this,i,null,h,a):(ra(this,i,l,null,a),this.model.markers._set(i,h,void 0,a)));n.managedUsingOperations?ra(this,i,l,h,a):this.model.markers._set(i,h,void 0,a)}removeMarker(e){this._assertWriterUsedCorrectly();let t="string"==typeof e?e:e.name;if(!this.model.markers.has(t))throw new r.Yb("writer-removemarker-no-marker",this);let i=this.model.markers.get(t);if(!i.managedUsingOperations)return void this.model.markers._remove(t);ra(this,t,i.getRange(),null,i.affectsData)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();let i=this.model.document.getRoot(e);if(i&&i.isAttached())throw new r.Yb("writer-addroot-root-exists",this);let n=this.model.document,s=new iB(e,t,!0,n,n.version);return this.batch.addOperation(s),this.model.applyOperation(s),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();let t="string"==typeof e?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new r.Yb("writer-detachroot-no-root",this);for(let e of this.model.markers)e.getRange().root===t&&this.removeMarker(e);for(let e of t.getAttributeKeys())this.removeAttribute(e,t);this.remove(this.createRangeIn(t));let i=this.model.document,n=new iB(t.rootName,t.name,!1,i,i.version);this.batch.addOperation(n),this.model.applyOperation(n)}setSelection(...e){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...e)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._setSelectionAttribute(e,t);else for(let[t,i]of(0,r.av)(e))this._setSelectionAttribute(t,i)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),"string"==typeof e)this._removeSelectionAttribute(e);else for(let t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){let i=this.model.document.selection;if(i.isCollapsed&&i.anchor.parent.isEmpty){let r=tx._getStoreAttributeKey(e);this.setAttribute(r,t,i.anchor.parent)}i._setAttribute(e,t)}_removeSelectionAttribute(e){let t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){let i=tx._getStoreAttributeKey(e);this.removeAttribute(i,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new r.Yb("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(let i of this.model.markers){if(!i.managedUsingOperations)continue;let r=i.getRange(),n=!1;if("move"===e)n=t.containsPosition(r.start)||t.start.isEqual(r.start)||t.containsPosition(r.end)||t.end.isEqual(r.end);else{let e=t.nodeBefore,i=t.nodeAfter,s=r.start.parent==e&&r.start.isAtEnd,o=r.end.parent==i&&0==r.end.offset,a=r.end.nodeAfter==i,l=r.start.nodeAfter==i;n=s||o||a||l}n&&this.updateMarker(i.name,{range:r})}}}function rs(e,t,i,r){let n,s,o,a=e.model,l=a.document,h=r.start;for(let e of r.getWalker({shallow:!0}))o=e.item.getAttribute(t),n&&s!=o&&(s!=i&&d(),h=n),n=e.nextPosition,s=o;function d(){let r=new tc(h,n),o=r.root.document?l.version:null,d=new iT(r,t,s,i,o);e.batch.addOperation(d),a.applyOperation(d)}n instanceof to&&n!=h&&s!=i&&d()}function ro(e,t,i,r){let n,s,o=e.model,a=o.document,l=r.getAttribute(t);if(l!=i){if(r.root===r){let e=r.document?a.version:null;s=new iI(r,t,l,i,e)}else{let o=(n=new tc(to._createBefore(r),e.createPositionAfter(r))).root.document?a.version:null;s=new iT(n,t,l,i,o)}e.batch.addOperation(s),o.applyOperation(s)}}function ra(e,t,i,r,n){let s=e.model,o=s.document,a=new iM(t,i,r,s.markers,!!n,o.version);e.batch.addOperation(a),s.applyOperation(a)}function rl(e,t){return e===t||e instanceof i7&&t instanceof i7}function rh(e,t){return e.isCollapsed?function(e,t){let i=e.start,r=t.getNearestSelectionRange(i);if(!r){let e=i.getAncestors().reverse().find(e=>t.isObject(e));return e?tc._createOn(e):null}if(!r.isCollapsed)return r;let n=r.start;return i.isEqual(n)?null:new tc(n)}(e,t):function(e,t){let{start:i,end:r}=e,n=t.checkChild(i,"$text"),s=t.checkChild(r,"$text"),o=t.getLimitElement(i),a=t.getLimitElement(r);if(o===a){if(n&&s)return null;if(function(e,t,i){let r=e.nodeAfter&&!i.isLimit(e.nodeAfter)||i.checkChild(e,"$text"),n=t.nodeBefore&&!i.isLimit(t.nodeBefore)||i.checkChild(t,"$text");return r||n}(i,r,t)){let e=i.nodeAfter&&t.isSelectable(i.nodeAfter)?null:t.getNearestSelectionRange(i,"forward"),n=r.no
1deBefore&&t.isSelectable(r.nodeBefore)?null:t.getNearestSelectionRange(r,"backward");return new tc(e?e.start:i,n?n.end:r)}}let l=o&&!o.is("rootElement"),h=a&&!a.is("rootElement");if(l||h){let e=i.nodeAfter&&r.nodeBefore&&i.nodeAfter.parent===r.nodeBefore.parent,n=l&&(!e||!ru(i.nodeAfter,t)),s=h&&(!e||!ru(r.nodeBefore,t)),d=i,u=r;return n&&(d=to._createBefore(rd(o,t))),s&&(u=to._createAfter(rd(a,t))),new tc(d,u)}return null}(e,t)}function rd(e,t){let i=e,r=i;for(;t.isLimit(r)&&r.parent;)i=r,r=r.parent;return i}function ru(e,t){return e&&t.isSelectable(e)}function rc(e,t,i){let r=t.parent,n=i.parent;return!(r==n||e.isLimit(r)||e.isLimit(n))&&function(e,t,i){for(let r of new tc(e,t).getWalker())if(i.isLimit(r.item))return!1;return!0}(t,i,e)}function rf(e,t,i,r={}){let n=e.createElement("paragraph");e.model.schema.setAllowedAttributes(n,r,e),e.insert(n,t),rm(e,i,e.createPositionAt(n,0))}function rm(e,t,i){t instanceof tx?e.setSelection(i):t.setTo(i)}function rg(e,t){let i=[];Array.from(e.getItems({direction:"backward"})).map(e=>t.createRangeOn(e)).filter(t=>(t.start.isAfter(e.start)||t.start.isEqual(e.start))&&(t.end.isBefore(e.end)||t.end.isEqual(e.end))).forEach(e=>{i.push(e.start.parent),t.remove(e)}),i.forEach(e=>{let i=e;for(;i.parent&&i.isEmpty;){let e=t.createRangeOn(i);i=i.parent,t.remove(e)}})}class rp{model;writer;position;canMergeWith;schema;_documentFragment;_documentFragmentPosition;_firstNode=null;_lastNode=null;_lastAutoParagraph=null;_filterAttributesAndChildrenOf=[];_affectedStart=null;_affectedEnd=null;_nodeToSelect=null;constructor(e,t,i){this.model=e,this.writer=t,this.position=i,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0)}handleNodes(e){for(let t of Array.from(e))t.offsetSize>0&&this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesAndChildrenOf,this.writer),this.model._config?.get("experimentalFlags.modelInsertContentDeepSchemaVerification")&&this._removeDisallowedChildren(this._filterAttributesAndChildrenOf),this._filterAttributesAndChildrenOf=[]}_removeDisallowedChildren(e){let t=Array.from(e);for(let e of t){if(!e.is("element"))continue;let i=[],r=[],n=this.writer.createRangeIn(e).getWalker({ignoreElementEnd:!0});for(let{item:e}of n){let s=e.parent;this.schema.checkChild(s,e)||(e.is("element")&&!this.schema.isObject(e)?(r.push(e),t.push(s)):i.push(e),n.jumpTo(this.writer.createPositionAfter(e)))}for(let e of r)this.writer.unwrap(e);for(let e of i)this.writer.remove(e)}}_updateLastNodeFromAutoParagraph(e){let t=this.writer.createPositionAfter(this._lastNode),i=this.writer.createPositionAfter(e);if(i.isAfter(t)){if(this._lastNode=e,this.position.parent!=e||!this.position.isAtEnd)throw new r.Yb("insertcontent-invalid-insertion-position",this);this.position=i,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?tc._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new tc(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(e){if(!this._checkAndSplitToAllowedPosition(e)){this.schema.isObject(e)||this._handleDisallowedNode(e);return}e=this._appendToFragment(e),this._firstNode||(this._firstNode=e),this._lastNode=e}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;let e=iZ.fromPosition(this.position,"toNext");this._setAffectedBoundaries(this.position),this._documentFragment.getChild(0)==this._firstNode&&(this.writer.insert(this._firstNode,this.position),this._mergeOnLeft(),this.position=e.toPosition()),this._documentFragment.isEmpty||this.writer.insert(this._documentFragment,this.position),this._documentFragmentPosition=this.writer.createPositionAt(this._documentFragment,0),this.position=e.toPosition(),e.detach()}_handleDisallowedNode(e){e.is("element")&&this.handleNodes(e.getChildren())}_appendToFragment(e){if(!this.schema.checkChild(this.position,e))throw new r.Yb("insertcontent-wrong-position",this,{node:e,position:this.position});return this.writer.insert(e,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(e.offsetSize),e.parent||(e=this._documentFragmentPosition.nodeBefore),this.schema.isObject(e)&&!this.schema.checkChild(this.position,"$text")?this._nodeToSelect=e:this._nodeToSelect=null,this._filterAttributesAndChildrenOf.push(e),e}_setAffectedBoundaries(e){this._affectedStart||(this._affectedStart=iZ.fromPosition(e,"toPrevious")),(!this._affectedEnd||this._affectedEnd.isBefore(e))&&(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=iZ.fromPosition(e,"toNext"))}_mergeOnLeft(){let e=this._firstNode;if(!(e instanceof tN)||!this._canMergeLeft(e))return;let t=iZ._createBefore(e);t.stickiness="toNext";let i=iZ.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=iZ._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=iZ._createAt(t.nodeBefore,"end","toNext")),this.position=i.toPosition(),i.detach(),this._filterAttributesAndChildrenOf.push(this.position.parent),t.detach()}_mergeOnRight(){let e=this._lastNode;if(!(e instanceof tN)||!this._canMergeRight(e))return;let t=iZ._createAfter(e);if(t.stickiness="toNext",!this.position.isEqual(t))throw new r.Yb("insertcontent-invalid-insertion-position",this);this.position=to._createAt(t.nodeBefore,"end");let i=iZ.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=iZ._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=iZ._createAt(t.nodeBefore,0,"toPrevious")),this.position=i.toPosition(),i.detach(),this._filterAttributesAndChildrenOf.push(this.position.parent),t.detach()}_canMergeLeft(e){let t=e.previousSibling;return t instanceof tN&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){let t=e.nextSibling;return t instanceof tN&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(e,t)}_insertAutoParagraph(){this._insertPartialFragment();let e=this.writer.createElement("paragraph");this.writer.insert(e,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=e,this.position=this.writer.createPositionAt(e,0)}_checkAndSplitToAllowedPosition(e){let 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){let e=this.position.parent;this.position=this.writer.createPositionBefore(e),e.isEmpty&&e.parent===t&&this.writer.remove(e)}
1else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{let e=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=e,this.canMergeWith.add(this.position.nodeAfter)}return this.schema.checkChild(this.position.parent,e)||this._insertAutoParagraph(),!0}_getAllowedIn(e,t){let i=this.schema.createContext(e);return this.schema.checkChild(i,t)||this.schema.checkChild(i,"paragraph")&&this.schema.checkChild(i.push("paragraph"),t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}}class r_ extends(0,r.VM)(){markers;document;schema;_config;_pendingChanges;_currentWriter;constructor(e){super(),this.markers=new re,this.document=new i4(this),this.schema=new is,this._config=e,this._pendingChanges=[],this._currentWriter=null,["deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach(e=>this.decorate(e)),this.on("applyOperation",(e,t)=>{t[0]._validate()},{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck(()=>!0,"$marker"),function(e){e.document.registerPostFixer(t=>(function(e,t){let i=t.document.selection,r=t.schema,n=[],s=!1;for(let e of i.getRanges()){let t=rh(e,r);t&&!t.isEqual(e)?(n.push(t),s=!0):n.push(e)}return s&&e.setSelection(function(e){let t=[...e],i=new Set,r=1;for(;r<t.length;){let e=t[r];for(let[n,s]of t.slice(0,r).entries())if(!i.has(n)){if(e.isEqual(s))i.add(n);else if(e.isIntersecting(s)){i.add(n),i.add(r);let o=e.getJoined(s);t.push(o)}}r++}return t.filter((e,t)=>!i.has(t))}(n),{backward:i.isBackward}),!1})(t,e))}(this),this.document.registerPostFixer(t9),this.on("insertContent",(e,[t,i])=>{e.return=function(e,t,i){return e.change(r=>{let n,s=i||e.document.selection;s.isCollapsed||e.deleteContent(s,{doNotAutoparagraph:!0});let o=new rp(e,r,s.anchor),a=[];if(t.is("documentFragment")){if(t.markers.size){let e=[];for(let[i,r]of t.markers){let{start:t,end:n}=r,s=t.isEqual(n);e.push({position:t,name:i,isCollapsed:s},{position:n,name:i,isCollapsed:s})}for(let{position:i,name:n,isCollapsed:s}of(e.sort(({position:e},{position:t})=>e.isBefore(t)?1:-1),e)){let e=null,o=null,l=i.parent===t&&i.isAtStart,h=i.parent===t&&i.isAtEnd;l||h?s&&(o=l?"start":"end"):(e=r.createElement("$marker"),r.insert(e,i)),a.push({name:n,element:e,collapsed:o})}}n=t.getChildren()}else n=[t];o.handleNodes(n);let l=o.getSelectionRange();if(t.is("documentFragment")&&a.length){let e=l?tA.fromRange(l):null,t={};for(let e=a.length-1;e>=0;e--){let{name:i,element:n,collapsed:s}=a[e],l=!t[i];if(l&&(t[i]=[]),n){let e=r.createPositionAt(n,"before");t[i].push(e),r.remove(n)}else{let e=o.getAffectedRange();if(!e){s&&t[i].push(o.position);continue}s?t[i].push(e[s]):t[i].push(l?e.start:e.end)}}for(let[e,[i,n]]of Object.entries(t))i&&n&&i.root===n.root&&i.root.document&&!r.model.markers.has(e)&&r.addMarker(e,{usingOperation:!0,affectsData:!0,range:new tc(i,n)});e&&(l=e.toRange(),e.detach())}l&&(s instanceof tx?r.setSelection(l):s.setTo(l));let h=o.getAffectedRange()||e.createRange(s.anchor);return o.destroy(),h})}(this,t,i)}),this.on("insertObject",(e,[t,i,n])=>{e.return=function(e,t,i,n={}){if(!e.schema.isObject(t))throw new r.Yb("insertobject-element-not-an-object",e,{object:t});let s=i||e.document.selection,o=s;n.findOptimalPosition&&e.schema.isBlock(t)&&(o=e.createSelection(e.schema.findOptimalInsertionRange(s,n.findOptimalPosition)));let a=(0,r.$1)(s.getSelectedBlocks()),l={};return a&&Object.assign(l,e.schema.getAttributesWithProperty(a,"copyOnReplace",!0)),e.change(i=>{o.isCollapsed||e.deleteContent(o,{doNotAutoparagraph:!0});let s=t,a=o.anchor.parent,h=e.schema.createContext(a);!e.schema.checkChild(h,t)&&e.schema.checkChild(h,"paragraph")&&e.schema.checkChild(h.push("paragraph"),t)&&(s=i.createElement("paragraph"),i.insert(t,s)),e.schema.setAllowedAttributes(s,l,i);let d=e.insertContent(s,o);return d.isCollapsed||n.setSelection&&function(e,t,i,n){let s=e.model;if("on"==i)return e.setSelection(t,"on");if("after"!=i)throw new r.Yb("insertobject-invalid-place-parameter-value",s);let o=t.nextSibling;if(s.schema.isInline(t))return e.setSelection(t,"after");!(o&&s.schema.checkChild(o,"$text"))&&s.schema.checkChild(t.parent,"paragraph")&&(o=e.createElement("paragraph"),s.schema.setAllowedAttributes(o,n,e),s.insertContent(o,e.createPositionAfter(t))),o&&e.setSelection(o,0)}(i,t,n.setSelection,l),d})}(this,t,i,n)}),this.on("canEditAt",e=>{let t=!this.document.isReadOnly;e.return=t,t||e.stop()})}
1change(e){try{if(0===this._pendingChanges.length)return this._pendingChanges.push({batch:new i0,callback:e}),this._runPendingChanges()[0];return e(this._currentWriter)}catch(e){r.Yb.rethrowUnexpectedError(e,this)}}enqueueChange(e,t){try{e?"function"==typeof e?(t=e,e=new i0):e instanceof i0||(e=new i0(e)):e=new i0,this._pendingChanges.push({batch:e,callback:t}),1==this._pendingChanges.length&&this._runPendingChanges()}catch(e){r.Yb.rethrowUnexpectedError(e,this)}}applyOperation(e){e._execute()}insertContent(e,t,i,...r){let n=rw(t,i);return this.fire("insertContent",[e,n,i,...r])}insertObject(e,t,i,r,...n){let s=rw(t,i);return this.fire("insertObject",[e,s,r,r,...n])}deleteContent(e,t){!function(e,t,i={}){if(t.isCollapsed)return;let r=t.getFirstRange();if("$graveyard"==r.root.rootName)return;let n=e.schema;e.change(e=>{let s,o;if(!i.doNotResetEntireContent&&function(e,t){let i=e.getLimitElement(t);if(!t.containsEntireContent(i))return!1;let r=t.getFirstRange();return r.start.parent!=r.end.parent&&e.checkChild(i,"paragraph")}(n,t))return void function(e,t){let i=e.model.schema.getLimitElement(t);e.remove(e.createRangeIn(i)),rf(e,e.createPositionAt(i,0),t)}(e,t);let a={};if(!i.doNotAutoparagraph){let e=t.getSelectedElement();e&&Object.assign(a,n.getAttributesWithProperty(e,"copyOnReplace",!0))}i.doNotFixSelection?(s=iZ.fromPosition(r.start,"toPrevious"),o=iZ.fromPosition(r.end,"toNext")):[s,o]=function(e){let t=e.root.document.model,i=e.start,r=e.end;if(t.hasContent(e,{ignoreMarkers:!0})){let i=function(e){let t=e.parent,i=t.root.document.model.schema;for(let e of t.getAncestors({parentFirst:!0,includeSelf:!0})){if(i.isLimit(e))return null;if(i.isBlock(e))return e}}(r);if(i&&r.isTouching(t.createPositionAt(i,0))){let i=t.createSelection(e);t.modifySelection(i,{direction:"backward"});let n=i.getLastPosition(),s=t.createRange(n,r);t.hasContent(s,{ignoreMarkers:!0})||(r=n)}}return[iZ.fromPosition(i,"toPrevious"),iZ.fromPosition(r,"toNext")]}(r),s.isTouching(o)||e.remove(e.createRange(s,o)),i.leaveUnmerged||(function(e,t,i){let r=e.model;if(!rc(e.model.schema,t,i))return;let[n,s]=function(e,t){let i=e.getAncestors(),r=t.getAncestors(),n=0;for(;i[n]&&i[n]==r[n];)n++;return[i[n],r[n]]}(t,i);n&&s&&(!r.hasContent(n,{ignoreMarkers:!0})&&r.hasContent(s,{ignoreMarkers:!0})?function e(t,i,r,n){let s=i.parent,o=r.parent;if(s!=n&&o!=n){for(i=t.createPositionAfter(s),(r=t.createPositionBefore(o)).isEqual(i)||t.insert(s,r);i.parent.isEmpty;){let e=i.parent;i=t.createPositionBefore(e),t.remove(e)}r=t.createPositionBefore(o),function(e,t){let i=t.nodeBefore,r=t.nodeAfter;i.name!=r.name&&e.rename(i,r.name),e.clearAttributes(i),e.setAttributes(Object.fromEntries(r.getAttributes()),i),e.merge(t)}(t,r),rc(t.model.schema,i,r)&&e(t,i,r,n)}}(e,t,i,n.parent):function e(t,i,r,n){let s=i.parent,o=r.parent;if(s!=n&&o!=n){for(i=t.createPositionAfter(s),(r=t.createPositionBefore(o)).isEqual(i)||t.insert(o,i),t.merge(i);r.parent.isEmpty;){let e=r.parent;r=t.createPositionBefore(e),t.remove(e)}rc(t.model.schema,i,r)&&e(t,i,r,n)}}(e,t,i,n.parent))}(e,s,o),n.removeDisallowedAttributes(s.parent.getChildren(),e)),rm(e,t,s),!i.doNotAutoparagraph&&function(e,t){let i=e.checkChild(t,"$text"),r=e.checkChild(t,"paragraph");return!i&&r}(n,s)&&rf(e,s,t,a),s.detach(),o.detach()})}(this,e,t)}modifySelection(e,t){!function(e,t,i={}){let n,s=e.schema,o="backward"!=i.direction,a=i.unit?i.unit:"character",l=!!i.treatEmojiAsSingleUnit,h=new tn({boundaries:function(e,t){let i=e.root,r=to._createAt(i,t?"end":0);return t?new tc(e,r):new tc(r,e)}(t.focus,o),singleCharacters:!0,direction:o?"forward":"backward"}),d={walker:h,schema:s,isForward:o,unit:a,treatEmojiAsSingleUnit:l};for(;n=h.next();){if(n.done)return;let i=function(e,t){let{isForward:i,walker:n,unit:s,schema:o,treatEmojiAsSingleUnit:a}=e,{type:l,item:h,nextPosition:d}=t;if("text"==l)return"word"===e.unit?function(e,t){let i=e.position.textNode;for(i||(i=t?e.position.nodeAfter:e.position.nodeBefore);i&&i.is("$text");){var r,n,s,o;let a=e.position.offset-i.startOffset;if(r=i,a===(t?r.offsetSize:0))i=t?e.position.nodeAfter:e.position.nodeBefore;else{if(n=i.data,s=a,o=t,' ,.?!:;"-()'.includes(n.charAt(s+(o?0:-1))))break;else e.next()}}return e.position}(n,i):function(e,t,i){let n=e.position.textNode;if(n){let s=n.data,o=e.position.offset-n.startOffset;for(;(0,r.P5)(s,o)||"character"==t&&(0,r.Iw)(s,o)||i&&(0,r.SQ)(s,o);)e.next(),o=e.position.offset-n.startOffset}return e.position}(n,s,a);if(l==(i?"elementStart":"elementEnd")){if(o.isSelectable(h))return to._createAt(h,i?"after":"before");if(o.checkChild(d,"$text"))return d}else{if(o.isLimit(h))return void n.skip(()=>!0);if(o.checkChild(d,"$text"))return d}}(d,n.value);if(i)return void(t instanceof tx?e.change(e=>{e.setSelectionFocus(i)}):t.setFocus(i))}}(this,e,t)}getSelectedContent(e){return this.change(t=>{let i,r=t.createDocumentFragment(),n=e.getFirstRange();if(!n||n.isCollapsed)return r;let s=n.start.root,o=n.start.getCommonPath(n.end),a=s.getNodeByPath(o),l=(i=n.start.parent==n.end.parent?n:t.createRange(t.createPositionAt(a,n.start.path[o.length]),t.createPositionAt(a,n.end.path[o.length]+1))).end.offset-i.start.offset;for(let e of i.getItems({shallow:!0}))e.is("$textProxy")?t.appendText(e.data,e.getAttributes(),r):t.append(t.cloneElement(e,!0),r);if(i!=n){let e=n._getTransformedByMove(i.start,t.createPositionAt(r,0),l)[0],s=t.createRange(t.createPositionAt(r,0),e.start);rg(t.createRange(e.end,t.createPositionAt(r,"end")),t),rg(s,t)}return r})}
1hasContent(e,t={}){let i=e instanceof tc?e:tc._createIn(e);if(i.isCollapsed)return!1;let{ignoreWhitespaces:r=!1,ignoreMarkers:n=!1}=t;if(!n){for(let e of this.markers.getMarkersIntersectingRange(i))if(e.affectsData)return!0}for(let e of i.getItems())if(this.schema.isContent(e)){if(!e.is("$textProxy"))return!0;else if(!r)return!0;else if(-1!==e.data.search(/\S/))return!0}return!1}canEditAt(e){let t=rw(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,i){return new to(e,t,i)}createPositionAt(e,t){return to._createAt(e,t)}createPositionAfter(e){return to._createAfter(e)}createPositionBefore(e){return to._createBefore(e)}createRange(e,t){return new tc(e,t)}createRangeIn(e){return tc._createIn(e)}createRangeOn(e){return tc._createOn(e)}createSelection(...e){return new ty(...e)}createBatch(e){return new i0(e)}createOperationFromJSON(e){return iV.fromJSON(e,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){let e=[];this.fire("_beforeChanges");try{for(;this._pendingChanges.length;){let t=this._pendingChanges[0].batch;this._currentWriter=new rn(this,t);let i=this._pendingChanges[0].callback(this._currentWriter);e.push(i),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}
1return e}}function rw(e,t){if(e){if(e instanceof ty||e instanceof tx)return e;if(e instanceof tb)if(t||0===t)return new ty(e,t);else if(e.is("rootElement"))return new ty(e,"in");else return new ty(e,"on");return new ty(e)}}class rb extends eQ{domEventType="click";onDomEvent(e){this.fire(e.type,e)}}class ry extends eQ{domEventType=["mousedown","mouseup","mouseover","mouseout"];onDomEvent(e){this.fire(e.type,e)}}class rv extends eQ{domEventType=["touchstart","touchend","touchmove"];onDomEvent(e){this.fire(e.type,e)}}class rP extends eQ{domEventType=["pointerdown","pointerup","pointermove"];onDomEvent(e){this.fire(e.type,e)}}class rC{document;constructor(e){this.document=e}createDocumentFragment(e){return new e_(this.document,e)}createElement(e,t,i){return new D(this.document,e,t,i)}createText(e){return new C(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,i){return i._insertChild(e,t)}removeChildren(e,t,i){return i._removeChildren(e,t)}remove(e){let t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){let i=e.parent;if(i){let r=i.getChildIndex(e);return this.removeChildren(r,1,i),this.insertChild(r,t,i),!0}return!1}unwrapElement(e){let t=e.parent;if(t){let i=t.getChildIndex(e);this.remove(e),this.insertChild(i,e.getChildren(),t)}}rename(e,t){let i=new D(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,i)?i:null}setAttribute(e,t,i){i._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,i){(0,l.Q)(e)&&void 0===i?t._setStyle(e):i._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,i){i._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return z._createAt(e,t)}createPositionAfter(e){return z._createAfter(e)}createPositionBefore(e){return z._createBefore(e)}createRange(e,t){return new U(e,t)}createRangeOn(e){return U._createOn(e)}createRangeIn(e){return U._createIn(e)}createSelection(...e){return new H(...e)}}let rA=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,rk=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,rS=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,rE=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,rR=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,rx=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,rO=new Set(["black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","orange","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","magenta","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","activeborder","activecaption","appworkspace","background","buttonface","buttonhighlight","buttonshadow","buttontext","captiontext","graytext","highlight","highlighttext","inactiveborder","inactivecaption","inactivecaptiontext","infobackground","infotext","menu","menutext","scrollbar","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","window","windowframe","windowtext","rebeccapurple","currentcolor","transparent"]);function rM(e){return e.startsWith("#")?rA.test(e):e.startsWith("rgb")?rk.test(e)||rS.test(e):e.startsWith("hsl")?rE.test(e)||rR.test(e):rO.has(e.toLowerCase())}let rT=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"],rN=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function rF(e){return rN.test(e)}let rI=/^[+-]?[0-9]*([.][0-9]+)?%$/;function rB(e){return rI.test(e)}let rD=["repeat-x","repeat-y","repeat","space","round","no-repeat"],rV=["center","top","bottom","left","right"],r$=["fixed","scroll","local"],rL=/^url\(/;function rq(e=""){if(""===e)return{top:void 0,right:void 0,bottom:void 0,left:void 0};let t=rJ(e),i=t[0],r=t[2]||i,n=t[1]||i,s=t[3]||n;return{top:i,bottom:r,right:n,left:s}}function rW(e){return t=>{let{top:i,right:r,bottom:n,left:s}=t,o=[];return[i,r,s,n].every(e=>!!e)?o.push([e,function({top:e,right:t,bottom:i,left:r}){let n=[];return r!==t?n.push(e,t,i,r):i!==e?n.push(e,t,i):t!==e?n.push(e,t):n.push(e),n.join(" ")}(t)]):(i&&o.push([e+"-top",i]),r&&o.push([e+"-right",r]),n&&o.push([e+"-bottom",n]),s&&o.push([e+"-left",s])),o}}function rY(e){return t=>({path:e,value:rq(t)})}function rJ(e){return Array.from(e.trim().slice(0,1500).matchAll(rx)).map(e=>e[0])}function rj(e){e.setNormalizer("background",e=>{let t={};for(let i of rJ(e))rD.includes(i)?(t.repeat=t.repeat||[],t.repeat.push(i)):rV.includes(i)?(t.position=t.position||[],t.position.push(i)):r$.includes(i)?t.attachment=i:rM(i)?t.color=i:rL.test(i)&&(t.image=i);return{path:"background",value:t}}),e.setNormalizer("background-color",e=>({path:"background.color",value:e})),e.setReducer("background",e=>{let t=[];return t.push(["background-color",e.color]),t}),e.setStyleRelation("background",["background-color"])}function rz(e){e.setNormalizer("border",e=>{let{color:t,style:i,width:r}=rQ(e);return{path:"border",value:{color:rq(t),style:rq(i),width:rq(r)}}}),e.setNormalizer("border-top",rU("top")),e.setNormalizer("border-right",rU("right")),e.setNormalizer("border-bottom",rU("bottom")),e.setNormalizer("border-left",rU("left")),e.setNormalizer("border-color",rK("color")),e.setNormalizer("border-width",rK("width")),e.setNormalizer("border-style",rK("style")),e.setNormalizer("border-top-color",rH("color","top")),e.setNormalizer("border-top-style",rH("style","top")),e.setNormalizer("border-top-width",rH("width","top")),e.setNormalizer("border-right-color",rH("color","right")),e.setNormalizer("border-right-style",rH("style","right")),e.setNormalizer("border-right-width",rH("width","right")),e.setNormalizer("border-bottom-color",rH("color","bottom")),e.setNormalizer("border-bottom-style",rH("style","bottom")),e.setNormalizer("border-bottom-width",rH("width","bottom")),e.setNormalizer("border-left-color",rH("color","left")),e.setNormalizer("border-left-style",rH("style","left")),e.setNormalizer("border-left-width",rH("width","left")),e.setExtractor("border-top",rG("top")),e.setExtractor("border-right",rG("right")),e.setExtractor("border-bottom",rG("bottom")),e.setExtractor("border-left",rG("left")),e.setExtractor("border-top-color","border.color.top"),e.setExtractor("border-right-color","border.color.right"),e.setExtractor("border-bottom-color","border.color.bottom"),e.setExtractor("border-left-color","border.color.left"),e.setExtractor("border-top-width","border.width.top"),e.setExtractor("border-right-width","border.width.right"),e.setExtractor("border-bottom-width","border.width.bottom"),e.setExtractor("border-left-width","border.width.left"),e.setExtractor("border-top-style","border.style.top"),e.setExtractor("border-right-style","border.style.right"),e.setExtractor("border-bottom-style","border.style.bottom"),e.setExtractor("border-left-style","border.style.left"),e.setReducer("border-color",rW("border-color")),e.setReducer("border-style",rW("border-style")),e.setReducer("border-width",rW("border-width")),e.setReducer("border-top",rX("top")),e.setReducer("border-right",rX("right")),e.setReducer("border-bottom",rX("bottom")),e.setReducer("border-left",rX("left")),e.setReducer("border",function(){return t=>{let i=rZ(t,"top"),r=rZ(t,"right"),n=rZ(t,"bottom"),s=rZ(t,"left"),o=[i,r,n,s],a={width:e(o,"width"),style:e(o,"style"),color:e(o,"color")},l=r0(a,"all");return l.length?l:[...Object.entries(a).reduce((e,[t,i])=>(i&&(e.push([`border-${t}
1`,i]),o.forEach(e=>delete e[t])),e),[]),...r0(i,"top"),...r0(r,"right"),...r0(n,"bottom"),...r0(s,"left")]};function e(e,t){return e.map(e=>e[t]).reduce((e,t)=>e==t?e:null)}}()),e.setStyleRelation("border",["border-color","border-style","border-width","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),e.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),e.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),e.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),e.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),e.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),e.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function rU(e){return t=>{let{color:i,style:r,width:n}=rQ(t),s={};return void 0!==i&&(s.color={[e]:i}),void 0!==r&&(s.style={[e]:r}),void 0!==n&&(s.width={[e]:n}),{path:"border",value:s}}}function rK(e){return t=>({path:"border",value:{[e]:rq(t)}})}function rH(e,t){return i=>({path:"border",value:{[e]:{[t]:i}}})}function rG(e){return(t,i)=>{if(i.border)return rZ(i.border,e)}}function rZ(e,t){let i={};return e.width&&e.width[t]&&(i.width=e.width[t]),e.style&&e.style[t]&&(i.style=e.style[t]),e.color&&e.color[t]&&(i.color=e.color[t]),i}function rQ(e){let t={};for(let i of rJ(e))if(rF(i)||/thin|medium|thick/.test(i))t.width=i;else rT.includes(i)?t.style=i:t.color=i;return t}function rX(e){return t=>r0(t,e)}function r0(e,t){let i=[];if(e&&e.width&&i.push("width"),e&&e.style&&i.push("style"),e&&e.color&&i.push("color"),3==i.length){let r=i.map(t=>e[t]).join(" ");return["all"==t?["border",r]:[`border-${t}`,r]]}return"all"==t?[]:i.map(i=>[`border-${t}-${i}`,e[i]])}function r1(e){e.setNormalizer("margin",rY("margin")),e.setNormalizer("margin-top",e=>({path:"margin.top",value:e})),e.setNormalizer("margin-right",e=>({path:"margin.right",value:e})),e.setNormalizer("margin-bottom",e=>({path:"margin.bottom",value:e})),e.setNormalizer("margin-left",e=>({path:"margin.left",value:e})),e.setReducer("margin",rW("margin")),e.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}function r9(e){e.setNormalizer("padding",rY("padding")),e.setNormalizer("padding-top",e=>({path:"padding.top",value:e})),e.setNormalizer("padding-right",e=>({path:"padding.right",value:e})),e.setNormalizer("padding-bottom",e=>({path:"padding.bottom",value:e})),e.setNormalizer("padding-left",e=>({path:"padding.left",value:e})),e.setReducer("padding",rW("padding")),e.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}let r2={container:L,attribute:el,empty:eu,ui:ef,raw:eg},r3={setContentOf:(e,t)=>{e.innerHTML=t}};function r5(e,t={}){if(!(e instanceof tt))throw TypeError("View needs to be an instance of module:engine/view/view~EditingView.");let i=e.document,r=!!t.withoutSelection,n=t.rootName||"main",s=i.getRoot(n),o={showType:t.showType,showPriority:t.showPriority,renderUIElements:t.renderUIElements,renderRawElements:t.renderRawElements,ignoreRoot:!0,domConverter:t.domConverter,skipListItemIds:t.skipListItemIds};return r?r5._stringify(s,null,o):r5._stringify(s,i.selection,o)}function r7(e,t,i={}){if(!(e instanceof tt))throw TypeError("View needs to be an instance of module:engine/view/view~EditingView.");let r=e.document,n=i.rootName||"main",s=r.getRoot(n);e.change(e=>{let i=r7._parse(t,{rootElement:s});i.view&&i.selection&&e.setSelection(i.selection)})}function r6(e,t=null,i={}){return new ne(e,t instanceof z||t instanceof U?new G(t):t,i).stringify()}function r4(e,t={}){let i=new ea(new N);t.order=t.order||[];let r=new r8({sameSelectionCharacters:t.sameSelectionCharacters}),n=new iw(i,{namespaces:Object.keys(r2)});t.inlineObjectElements&&n.domConverter.inlineObjectElements.push(...t.inlineObjectElements);let s=n.toView(e);if(s=function e(t){if(t.is("element")||t.is("documentFragment")){let i=t.is("documentFragment")?new e_(t.document):function(e,t){let i=function(e){var t;let i=e.name.split(":"),r=function(e){let t=parseInt(e,10);return isNaN(t)?null:t}(e.getAttribute("view-priority")),n=e.hasAttribute("view-id")?e.getAttribute("view-id"):null;if(e._removeAttribute("view-priority"),e._removeAttribute("view-id"),1==i.length)return{name:i[0],type:null!==r?"attribute":null,priority:r,id:n};let s=(t=i[0])in r2?t:null;if(s)return{name:i[1],type:s,priority:r,id:n};throw Error(`Parse error - cannot parse element's name: ${e.name}.`)}(t),r=r2[i.type],n=r?new r(e,i.name):new D(e,i.name);for(let e of(n.is("attributeElement")&&(null!==i.priority&&(n._priority=i.priority),null!==i.id&&(n._id=i.id)),t.getAttributeKeys()))n._setAttribute(e,t.getAttribute(e));return n}(t.document,t);for(let r of[...t.getChildren()]){if(i.is("emptyElement"))throw Error("Parse error - cannot parse inside ViewEmptyElement.");if(i.is("uiElement"))throw Error("Parse error - cannot parse inside UIElement.");if(i.is("rawElement"))throw Error("Parse error - cannot parse inside RawElement.");i._appendChild(e(r))}return i}return t}(s),t.rootElement){let e=t.rootElement,i=s._removeChildren(0,s.childCount);e._removeChildren(0,e.childCount),e._appendChild(i),s=e}let o=r._parseView(s,t.order);return(s.is("documentFragment")&&1===s.childCount&&(s=s.getChild(0)),o.length)?{view:s,selection:new G(o,{backward:!!t.lastRangeBackward})}:(s.parent&&s._remove(),s)}r5._stringify=r6,r7._parse=r4;class r8{sameSelectionCharacters;_positions;constructor(e){this.sameSelectionCharacters=!!e.sameSelectionCharacters}_parseView(e,t){this._positions=[],this._getPositions(e);let i=this._createRanges();if(t.length){if(t.length!=i.length)throw Error(`Parse error - there are ${i.length} ranges found, but ranges order array contains ${t.length} elements.`);i=this._sortRanges(i,t)}return i}_getPositions(e){if(e.is("documentFragment")||e.is("element"))for(let t of[...e.getChildren()])this._getPositions(t);if(e.is("$text")){let t,i=RegExp("[{}\\]\\[]","g"),r=e.data,n=0,s=[];for(;t=i.exec(r);){let e=t.index,i=t[0];s.push({bracket:i,textOffset:e-n}),n++}e._data=r=r.replace(i,"");let o=e.index,a=e.parent;for(let t of(r||e._remove(),s))if(r)if(this.sameSelectionCharacters||!this.sameSelectionCharacters&&("{"==t.bracket||"}"==t.bracket))this._positions.push({bracket:t.bracket,position:new z(e,t.textOffset)});else{if(!this.sameSelectionCharacters&&0!==t.textOffset&&t.textOffset!==r.length)throw Error(`Parse error - range delimiter '${t.bracket}' is placed inside text node.`);let e=0===t.textOffset?o:o+1;this._positions.push({bracket:t.bracket,position:new z(a,e)})}else{if(!this.sameSelectionCharacters&&"{"==t.bracket||"}"==t.bracket)throw Error(`Parse error - text range delimiter '${t.bracket}' is placed inside empty text node. `);this._positions.push({bracket:t.bracket,position:new z(a,o)})}}}_sortRanges(e,t){let i=[],r=0;for(let n of t){if(void 0===e[n-1])throw Error("Parse error - provided ranges order is invali
1d.");i[n-1]=e[r],r++}return i}_createRanges(){let e=[],t=null;for(let i of this._positions){if(!t&&("]"==i.bracket||"}"==i.bracket))throw Error(`Parse error - end of range was found '${i.bracket}' but range was not started before.`);if(t&&("["==i.bracket||"{"==i.bracket))throw Error(`Parse error - start of range was found '${i.bracket}' but one range is already started.`);"["==i.bracket||"{"==i.bracket?t=new U(i.position,i.position):(t.end=i.position,e.push(t),t=null)}if(null!==t)throw Error("Parse error - range was started but no end delimiter was found.");return e}}class ne{root;selection;ranges;showType;showPriority;showAttributeElementId;ignoreRoot;sameSelectionCharacters;renderUIElements;renderRawElements;domConverter;skipListItemIds;constructor(e,t,i){this.root=e,this.selection=t,this.ranges=[],t&&(this.ranges=[...t.getRanges()]),this.showType=!!i.showType,this.showPriority=!!i.showPriority,this.showAttributeElementId=!!i.showAttributeElementId,this.ignoreRoot=!!i.ignoreRoot,this.sameSelectionCharacters=!!i.sameSelectionCharacters,this.renderUIElements=!!i.renderUIElements,this.renderRawElements=!!i.renderRawElements,this.domConverter=i.domConverter||r3,this.skipListItemIds=void 0===i.skipListItemIds||!!i.skipListItemIds}stringify(){let e="";return this._walkView(this.root,t=>{e+=t}),this.skipListItemIds&&(e=e.replaceAll(/ data-list-item-id="[^"]+"/g,"")),e}_walkView(e,t){let i=this.ignoreRoot&&this.root===e;if(e.is("element")||e.is("documentFragment")){if(e.is("element")&&!i&&t(this._stringifyElementOpen(e)),this.renderUIElements&&e.is("uiElement"))t(e.render(document,this.domConverter).innerHTML);else if(this.renderRawElements&&e.is("rawElement")){let i=document.createElement("div");e.render(i,this.domConverter),t(i.innerHTML)}else{let i=0;for(let r of(t(this._stringifyElementRanges(e,i)),e.getChildren()))this._walkView(r,t),i++,t(this._stringifyElementRanges(e,i))}e.is("element")&&!i&&t(this._stringifyElementClose(e))}e.is("$text")&&t(this._stringifyTextRanges(e))}_stringifyElementRanges(e,t){let i="",r="",n="";for(let s of this.ranges)s.start.parent==e&&s.start.offset===t&&(s.isCollapsed?n+="[]":i+="["),s.end.parent!==e||s.end.offset!==t||s.isCollapsed||(r+="]");return r+n+i}_stringifyTextRanges(e){let t,i,r=e.data.length,n=e.data.split("");this.sameSelectionCharacters?(t="[",i="]"):(t="{",i="}"),n[r]="";let s=n.map(e=>({letter:e,start:"",end:"",collapsed:""}));for(let n of this.ranges){let o=n.start,a=n.end;o.parent==e&&o.offset>=0&&o.offset<=r&&(n.isCollapsed?s[a.offset].collapsed+=t+i:s[o.offset].start+=t),a.parent==e&&a.offset>=0&&a.offset<=r&&!n.isCollapsed&&(s[a.offset].end+=i)}return s.map(e=>e.end+e.collapsed+e.start+e.letter).join("")}_stringifyElementOpen(e){let t=this._stringifyElementPriority(e),i=this._stringifyElementId(e),r=[this._stringifyElementType(e),e.name].filter(e=>""!==e).join(":"),n=this._stringifyElementAttributes(e);return`<${[r,t,i,n].filter(e=>""!==e).join(" ")}>`}_stringifyElementClose(e){let t=[this._stringifyElementType(e),e.name].filter(e=>""!==e).join(":");return`</${t}>`}_stringifyElementType(e){if(this.showType){for(let t in r2)if(e instanceof r2[t])return t}return""}_stringifyElementPriority(e){return this.showPriority&&e.is("attributeElement")?`view-priority="${e.priority}"`:""}_stringifyElementId(e){return this.showAttributeElementId&&e.is("attributeElement")&&e.id?`view-id="${e.id}"`:""}_stringifyElementAttributes(e){let t=[];for(let i of[...e.getAttributeKeys()].sort()){let r;r="class"===i?[...e.getClassNames()].sort().join(" "):"style"===i?[...e.getStyleNames()].sort().map(t=>`${t}:${e.getStyle(t).replace(/"/g,""")}`).join(";"):e.getAttribute(i),t.push(`${i}="${r}"`)}return t.join(" ")}}function nt(e,t={}){if(!(e instanceof r_))throw TypeError("Model needs to be an instance of module:engine/model/model~Model.");let i=t.rootName||"main",r=e.document.getRoot(i);return nt._stringify(r,t.withoutSelection?null:e.document.selection,t.convertMarkers?e.markers:null)}function ni(e,t,i={}){let r;if(!(e instanceof r_))throw TypeError("Model needs to be an instance of module:engine/model/model~Model.");let n=null,s=e.document.getRoot(i.rootName||"main"),o=ni._parse(t,e.
1schema,{lastRangeBackward:i.lastRangeBackward,selectionAttributes:i.selectionAttributes,context:[s.name],inlineObjectElements:i.inlineObjectElements});function a(t){if(t.remove(t.createRangeIn(s)),t.insert(r,s),t.setSelection(null),t.removeSelectionAttribute(e.document.selection.getAttributeKeys()),n){let e=[];for(let t of n.getRanges()){let i=new to(s,t.start.path),r=new to(s,t.end.path);e.push(new tc(i,r))}t.setSelection(e,{backward:n.isBackward}),i.selectionAttributes&&t.setSelectionAttribute(n.getAttributes())}}"model"in o?(r=o.model,n=o.selection):r=o,void 0!==i.batchType?e.enqueueChange(i.batchType,a):e.change(a)}function nr(){return(e,t,i)=>{let r;if(!i.schema.checkChild(t.modelCursor,"$text"))throw Error("Text was not allowed in given position.");if(t.viewItem.is("element")){let e=no(t.viewItem.getAttributes(),nn),n=t.viewItem.getChild(0);r=i.writer.createText(n.data,e)}else r=i.writer.createText(t.viewItem.data);i.writer.insert(r,t.modelCursor),t.modelRange=tc._createFromPositionAndShift(t.modelCursor,r.offsetSize),t.modelCursor=t.modelRange.end,e.stop()}}function nn(e){try{return JSON.parse(e)}catch{return e}}function ns(e){return(0,l.Q)(e)?JSON.stringify(e):e}function*no(e,t){for(let[i,r]of e)yield[i,t(r)]}nt._stringify=function(e,t=null,i=null){let r,n=new r_,s=new tf,o=null;if(e instanceof i7||e instanceof rr)r=n.createRangeIn(e);else if(e.parent)r=new tc(n.createPositionBefore(e),n.createPositionAfter(e));else{let t=new rr(e);r=n.createRangeIn(t)}t instanceof ty||t instanceof tx?o=t:t instanceof tc?o=new ty(t):t instanceof to&&(o=new ty(t));let a=new tt(new N),l=a.document,h=new J(l,"div");h.rootName="main",l.roots.add(h);let d=new t_({mapper:s,schema:n.schema});s.bindElements(e.root,h),d.on("insert:$text",tB()),d.on("insert",tD(),{priority:"lowest"}),d.on("attribute",(e,t,i)=>{(t.item instanceof ty||t.item instanceof tx||t.item.is("$textProxy"))&&tq((e,{writer:i})=>i.createAttributeElement("model-text-with-attributes",{[t.attributeKey]:ns(e)}))(e,t,i)}),d.on("insert",tW(e=>{let t=no(e.getAttributes(),ns);return new L(l,e.name,t)})),d.on("selection",t$()),d.on("selection",tL()),d.on("addMarker",tY((e,{writer:t})=>{let i=e.markerName+":"+(e.isOpening?"start":"end");return t.createUIElement(i)}));let u=new Map;if(i)for(let e of Array.from(i).sort((e,t)=>e.name<t.name?1:-1))u.set(e.name,e.getRange());let c=a._writer;d.convert(r,u,c),o&&d.convertSelection(o,i||n.markers,c);let f=r6(h,l.selection,{sameSelectionCharacters:!0});return f=f.substr(5,f.length-11),a.destroy(),f.replace(/model-text-with-attributes/g,"$text")},ni._parse=function(e,t,i={}){var n,s;let o,a=new tf,l=r4(e=e.replace(RegExp("\\$text","g"),"model-text-with-attributes"),{sameSelectionCharacters:!0,lastRangeBackward:!!i.lastRangeBackward,inlineObjectElements:i.inlineObjectElements}),h=null,d=null;"view"in l&&"selection"in l?(o=l.view,h=l.selection):o=l;let u=new r_,c=new id({schema:t});c.on("documentFragment",(n=a,(e,t,i)=>{let r=i.convertChildren(t.viewItem,t.modelCursor);n.bindElements(t.modelCursor.parent,t.viewItem),t=Object.assign(t,r),e.stop()})),c.on("element:model-text-with-attributes",nr()),c.on("element",(s=a,(e,t,i)=>{let r=t.viewItem.name;if(!i.schema.checkChild(t.modelCursor,r))throw Error(`Element '${r}' was not allowed in given position.`);let n=no(t.viewItem.getAttributes(),nn),o=i.writer.createElement(t.viewItem.name,n);i.writer.insert(o,t.modelCursor),s.bindElements(o,t.viewItem),i.convertChildren(t.viewItem,o),t.modelRange=tc._createOn(o),t.modelCursor=t.modelRange.end,e.stop()})),c.on("text",nr());let f=u.change(e=>c.convert(o.root,e,i.context||"$root"));if(a.bindElements(f,o.root),1==f.childCount&&(f=f.getChild(0)),h){let e=[];for(let t of h.getRanges())e.push(a.toModelRange(t));for(let[t,n]of(d=new ty(e,{backward:h.isBackward}),(0,r.av)(i.selectionAttributes||[])))d.setAttribute(t,n)}return d?{model:f,selection:d}:f},Symbol("_treeDump")}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.