import{logWarning as G,EmitterMixin as I,CKEditorError as d,compareArrays as $,toArray as ce,toMap as he,isIterable as ue,ObservableMixin as K,count as xr,EventInfo as un,Collection as fn,keyCodes as be,isText as x,env as F,remove as Nr,insertAt as Or,diff as dn,fastDiff as ro,isNode as Rt,isComment as Qe,indexOf as Ee,global as fe,isValidAttributeName as so,first as mn,getAncestors as io,DomEmitterMixin as oo,getCode as ao,isArrowKeyCode as lo,scrollViewportToShowTarget as co,uid as ho,spliceArray as Mr,priorities as gn,isInsideSurrogatePair as Ir,isInsideCombinedSymbol as Fr,isInsideEmojiSequence as uo}from"@ckeditor/ckeditor5-utils";function Dr(r,{insertAt:e}={}){if(!r||typeof document>"u")return;const t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",window.litNonce&&n.setAttribute("nonce",window.litNonce),e==="top"&&t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n),n.styleSheet?n.styleSheet.cssText=r:n.appendChild(document.createTextNode(r))}Dr(".ck .ck-placeholder,.ck.ck-placeholder{position:relative}.ck .ck-placeholder:before,.ck.ck-placeholder:before{content:attr(data-placeholder);left:0;pointer-events:none;position:absolute;right:0}.ck.ck-read-only .ck-placeholder:before{display:none}.ck.ck-reset_all .ck-placeholder{position:relative}@media (forced-colors:active){.ck .ck-placeholder,.ck.ck-placeholder{forced-color-adjust:preserve-parent-color}}.ck .ck-placeholder:before,.ck.ck-placeholder:before{cursor:text}@media (forced-colors:none){.ck .ck-placeholder:before,.ck.ck-placeholder:before{color:var(--ck-color-engine-placeholder-text)}}@media (forced-colors:active){.ck .ck-placeholder:before,.ck.ck-placeholder:before{font-style:italic;margin-left:1px}}");/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const ve=new WeakMap;let Br=!1;function fo({view:r,element:e,text:t,isDirectHost:n=!0,keepOnFocus:s=!1}){const i=r.document;ve.has(i)||(ve.set(i,new Map),i.registerPostFixer(a=>pn(ve.get(i),a)),i.on("change:isComposing",()=>{r.change(a=>pn(ve.get(i),a))},{priority:"high"})),e.is("editableElement")&&e.on("change:placeholder",(a,l,c)=>o(c)),e.placeholder?o(e.placeholder):t&&o(t),t&&_o();function o(a){const l={text:a,isDirectHost:n,keepOnFocus:s,hostElement:n?e:null};ve.get(i).set(e,l),r.change(c=>pn([[e,l]],c))}}function mo(r,e){const t=e.document;ve.has(t)&&r.change(n=>{const s=ve.get(t),i=s.get(e);n.removeAttribute("data-placeholder",i.hostElement),Tt(n,i.hostElement),s.delete(e)})}function Vr(r,e){return e.hasClass("ck-placeholder")?!1:(r.addClass("ck-placeholder",e),!0)}function Tt(r,e){return e.hasClass("ck-placeholder")?(r.removeClass("ck-placeholder",e),!0):!1}function Lr(r,e){if(!r.isAttached()||go(r))return!1;const t=r.document,s=t.selection.anchor;return t.isComposing&&s&&s.parent===r?!1:e||!t.isFocused?!0:!!s&&s.parent!==r}function go(r){for(const e of r.getChildren())if(!e.is("uiElement"))return!0;return!1}function pn(r,e){const t=[];let n=!1;for(const[s,i]of r)i.isDirectHost&&(t.push(s),$r(e,s,i)&&(n=!0));for(const[s,i]of r){if(i.isDirectHost)continue;const o=po(s);o!==i.hostElement&&i.hostElement&&(e.removeAttribute("data-placeholder",i.hostElement),Tt(e,i.hostElement),i.hostElement=null,n=!0),o&&(t.includes(o)||(i.hostElement=o,$r(e,s,i)&&(n=!0)))}return n}function $r(r,e,t){const{text:n,isDirectHost:s,hostElement:i}=t;let o=!1;return i.getAttribute("data-placeholder")!==n&&(r.setAttribute("data-placeholder",n,i),o=!0),(s||e.childCount==1)&&Lr(i,t.keepOnFocus)?Vr(r,i)&&(o=!0):Tt(r,i)&&(o=!0),o}function po(r){if(r.childCount){const e=r.getChild(0);if(e.is("element")&&!e.is("uiElement")&&!e.is("attributeElement"))return e}return null}function _o(){Br||G("enableViewPlaceholder-deprecated-text-option"),Br=!0}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class de{is(){throw new Error("is() method is abstract")}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class me extends I(de){document;parent;constructor(e){super(),this.document=e,this.parent=null}get index(){let e;if(!this.parent)return null;if((e=this.parent.getChildIndex(this))==-1)throw new d("view-node-not-found-in-parent",this);return e}get nextSibling(){const e=this.index;return e!==null&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return e!==null&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.root.is("rootElement")}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.index),t=t.parent;return e}getAncestors(e={}){const t=[];let n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}getCommonAncestor(e,t={}){const n=this.getAncestors(t),s=e.getAncestors(t);let i=0;for(;n[i]==s[i]&&n[i];)i++;return i===0?null:n[i-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;const t=this.getPath(),n=e.getPath(),s=$(t,n);switch(s){case"prefix":return!0;case"extension":return!1;default:return t[s]<n[s]}}isAfter(e){return this==e||this.root!==e.root?!1:!this.isBefore(e)}_remove(){this.parent._removeChildren(this.index)}_fireChange(e,t,n){this.fire(`change:${e}`,t,n),this.parent&&this.parent._fireChange(e,t,n)}toJSON(){const e={path:this.getPath(),type:"Node"};return this!==this.root&&this.root.is("rootElement")&&(e.root=this.root.toJSON()),e}}me.prototype.is=function(r){return r==="node"||r==="view:node"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class T extends me{_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 T?this===e||this.data===e.data:!1}toJSON(){const e=super.toJSON();return e.type="Text",e.data=this.data,e}_clone(){return new T(this.document,this.data)}}T.prototype.is=function(r){return r==="$text"||r==="view:$text"||r==="text"||r==="view:text"||r==="node"||r==="view:node"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ee extends de{textNode;data;offsetInText;constructor(e,t,n){if(super(),this.textNode=e,t<0||t>e.data.length)throw new d("view-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.data.length)throw new d("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+n),this.offsetInText=t}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}getAncestors(e={}){const t=[];let n=e.includeSelf?this.textNode:this.parent;for(;n!==null;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}}ee.prototype.is=function(r){return r==="$textProxy"||r==="view:$textProxy"||r==="textProxy"||r==="view:textProxy"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class hn{_consumables=new Map;add(e,t){let n;if(e.is("$text")||e.is("documentFragment")){this._consumables.set(e,!0);return}this._consumables.has(e)?n=this._consumables.get(e):(n=new Wr(e),this._consumables.set(e,n)),n.add(t?Re(t):e._getConsumables())}test(e,t){const n=this._consumables.get(e);return n===void 0?null:e.is("$text")||e.is("documentFragment")?n:n.test(Re(t))}consume(e,t){if(e.is("$text")||e.is("documentFragment"))return this.test(e,t)?(this._consumables.set(e,!1),!0):!1;const n=this._consumables.get(e);return n===void 0?!1:n.consume(Re(t))}revert(e,t){const n=this._consumables.get(e);n!==void 0&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):n.revert(Re(t)))}static createFrom(e,t){if(t||(t=new hn),e.is("$text"))t.add(e);else if(e.is("element")||e.is("documentFragment")){t.add(e);for(const n of e.getChildren())hn.createFrom(n,t)}return t}}class Wr{element;_canConsumeName=null;_attributes=new Map;constructor(e){this.element=e}add(e){e.name&&(this._canConsumeName=!0);for(const[t,n]of e.attributes)if(n){let s=this._attributes.get(t);(!s||typeof s=="boolean")&&(s=new Map,this._attributes.set(t,s)),s.set(n,!0)}else{if(t=="style"||t=="class")throw new d("viewconsumable-invalid-attribute",this);this._attributes.set(t,!0)}}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const[t,n]of e.attributes){const s=this._attributes.get(t);if(s===void 0)return null;if(s===!1)return!1;if(s!==!0){if(n){const i=s.get(n);if(i===void 0)return null;if(!i)return!1}else for(const i of s.values())if(!i)return!1}}return!0}consume(e){if(!this.test(e))return!1;e.name&&(this._canConsumeName=!1);for(const[t,n]of e.attributes){const s=this._attributes.get(t);if(typeof s=="boolean")for(const[i]of this.element._getConsumables(t,n).attributes)this._attributes.set(i,!1);else if(n)for(const[,i]of this.element._getConsumables(t,n).attributes)s.set(i,!1);else for(const i of s.keys())s.set(i,!1)}return!0}revert(e){e.name&&(this._canConsumeName=!0);for(const[t,n]of e.attributes){const s=this._attributes.get(t);if(s===!1){this._attributes.set(t,!0);continue}if(!(s===void 0||s===!0))if(n)s.get(n)===!1&&s.set(n,!0);else for(const i of s.keys())s.set(i,!0)}}}function Re(r){const e=[];return"attributes"in r&&r.attributes&&_n(e,r.attributes),"classes"in r&&r.classes&&_n(e,r.classes,"class"),"styles"in r&&r.styles&&_n(e,r.styles,"style"),{name:r.name||!1,attributes:e}}function _n(r,e,t){if(typeof e=="string"){r.push(t?[t,e]:[e]);return}for(const n of e)Array.isArray(n)?r.push(n):r.push(t?[t,n]:[n])}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Te{_patterns=[];constructor(...e){this.add(...e)}add(...e){for(let t of e)(typeof t=="string"||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(const t of e)for(const n of this._patterns){const s=this._isElementMatching(t,n);if(s)return{element:t,pattern:n,match:s}}return null}matchAll(...e){const t=[];for(const n of e)for(const s of this._patterns){const i=this._isElementMatching(n,s);i&&t.push({element:n,pattern:s,match:i})}return t.length>0?t:null}getElementName(){if(this._patterns.length!==1)return null;const e=this._patterns[0],t=e.name;return typeof e!="function"&&t&&!(t instanceof RegExp)?t:null}_isElementMatching(e,t){if(typeof t=="function"){const i=t(e);return!i||typeof i!="object"?i:Re(i)}const n={};if(t.name&&(n.name=wo(t.name,e.name),!n.name))return null;const s=[];return t.attributes&&!yo(t.attributes,e,s)||t.classes&&!bo(t.classes,e,s)||t.styles&&!vo(t.styles,e,s)?null:(s.length&&(n.attributes=s),n)}}function Ze(r,e){return r===!0||r===e||r instanceof RegExp&&!!String(e).match(r)}function wo(r,e){return r instanceof RegExp?!!e.match(r):r===e}function wn(r,e){if(Array.isArray(r))return r.map(n=>typeof n!="object"||n instanceof RegExp?e?[e,n,!0]:[n,!0]:((n.key===void 0||n.value===void 0)&&G("matcher-pattern-missing-key-or-value",n),e?[e,n.key,n.value]:[n.key,n.value]));if(typeof r!="object"||r instanceof RegExp)return[e?[e,r,!0]:[r,!0]];const t=[];for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.push(e?[e,n,r[n]]:[n,r[n]]);return t}function yo(r,e,t){let n;return typeof r=="object"&&!(r instanceof RegExp)&&!Array.isArray(r)?(r.style!==void 0&&G("matcher-pattern-deprecated-attributes-style-key",r),r.class!==void 0&&G("matcher-pattern-deprecated-attributes-class-key",r)):n=["class","style"],e._collectAttributesMatch(wn(r),t,n)}function bo(r,e,t){return e._collectAttributesMatch(wn(r,"class"),t)}function vo(r,e,t){return e._collectAttributesMatch(wn(r,"style"),t)}function Po(r){return Number.isSafeInteger(r)&&r>=0}function Co(r){return r!=null&&typeof r!="function"&&Po(r.length)}function et(r){return r==="__proto__"}function So(r){switch(typeof r){case"number":case"symbol":return!1;case"string":return r.includes(".")||r.includes("[")||r.includes("]")}}function qr(r){return typeof r=="string"||typeof r=="symbol"?r:Object.is(r?.valueOf?.(),-0)?"-0":String(r)}function Ur(r){const e=[],t=r.length;if(t===0)return e;let n=0,s="",i="",o=!1;for(r.charCodeAt(0)===46&&(e.push(""),n++);n<t;){const a=r[n];i?a==="\\"&&n+1<t?(n++,s+=r[n]):a===i?i="":s+=a:o?a==='"'||a==="'"?i=a:a==="]"?(o=!1,e.push(s),s=""):s+=a:a==="["?(o=!0,s&&(e.push(s),s="")):a==="."?s&&(e.push(s),s=""):s+=a,n++}return s&&e.push(s),e}function tt(r,e,t){if(r==null)return t;switch(typeof e){case"string":{if(et(e))return t;const n=r[e];return n===void 0?So(e)?tt(r,Ur(e),t):t:n}case"number":case"symbol":{typeof e=="number"&&(e=qr(e));const n=r[e];return n===void 0?t:n}default:{if(Array.isArray(e))return Ao(r,e,t);if(Object.is(e?.valueOf(),-0)?e="-0":e=String(e),et(e))return t;const n=r[e];return n===void 0?t:n}}}function Ao(r,e,t){if(e.length===0)return t;let n=r;for(let s=0;s<e.length;s++){if(n==null||et(e[s]))return t;n=n[e[s]]}return n===void 0?t:n}function xe(r){return r!==null&&(typeof r=="object"||typeof r=="function")}function xt(r){return r==null||typeof r!="object"&&typeof r!="function"}function yn(r,e){return r===e||Number.isNaN(r)&&Number.isNaN(e)}function Nt(r){return Object.getOwnPropertySymbols(r).filter(e=>Object.prototype.propertyIsEnumerable.call(r,e))}function Ne(r){return r==null?r===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(r)}const Ot="[object RegExp]",Oe="[object String]",nt="[object Number]",rt="[object Boolean]",Me="[object Arguments]",Mt="[object Symbol]",It="[object Date]",Ft="[object Map]",Dt="[object Set]",bn="[object Array]",ko="[object Function]",Bt="[object ArrayBuffer]",st="[object Object]",Eo="[object Error]",Vt="[object DataView]",vn="[object Uint8Array]",Pn="[object Uint8ClampedArray]",Cn="[object Uint16Array]",Sn="[object Uint32Array]",Ro="[object BigUint64Array]",An="[object Int8Array]",kn="[object Int16Array]",En="[object Int32Array]",To="[object BigInt64Array]",Rn="[object Float32Array]",Tn="[object Float64Array]";function xn(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function xo(r,e){return Ie(r,void 0,r,new Map,e)}function Ie(r,e,t,n=new Map,s=void 0){const i=s?.(r,e,t,n);if(i!=null)return i;if(xt(r))return r;if(n.has(r))return n.get(r);if(Array.isArray(r)){const o=new Array(r.length);n.set(r,o);for(let a=0;a<r.length;a++)o[a]=Ie(r[a],a,t,n,s);return Object.hasOwn(r,"index")&&(o.index=r.index),Object.hasOwn(r,"input")&&(o.input=r.input),o}if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp){const o=new RegExp(r.source,r.flags);return o.lastIndex=r.lastIndex,o}if(r instanceof Map){const o=new Map;n.set(r,o);for(const[a,l]of r)o.set(a,Ie(l,a,t,n,s));return o}if(r instanceof Set){const o=new Set;n.set(r,o);for(const a of r)o.add(Ie(a,void 0,t,n,s));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(r))return r.subarray();if(xn(r)){const o=new(Object.getPrototypeOf(r)).constructor(r.length);n.set(r,o);for(let a=0;a<r.length;a++)o[a]=Ie(r[a],a,t,n,s);return o}if(r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer)return r.slice(0);if(r instanceof DataView){const o=new DataView(r.buffer.slice(0),r.byteOffset,r.byteLength);return n.set(r,o),Pe(o,r,t,n,s),o}if(typeof File<"u"&&r instanceof File){const o=new File([r],r.name,{type:r.type});return n.set(r,o),Pe(o,r,t,n,s),o}if(r instanceof Blob){const o=new Blob([r],{type:r.type});return n.set(r,o),Pe(o,r,t,n,s),o}if(r instanceof Error){const o=new r.constructor;return n.set(r,o),o.message=r.message,o.name=r.name,o.stack=r.stack,o.cause=r.cause,Pe(o,r,t,n,s),o}if(typeof r=="object"&&No(r)){const o=Object.create(Object.getPrototypeOf(r));return n.set(r,o),Pe(o,r,t,n,s),o}return r}function Pe(r,e,t=r,n,s){const i=[...Object.keys(e),...Nt(e)];for(let o=0;o<i.length;o++){const a=i[o],l=Object.getOwnPropertyDescriptor(r,a);(l==null||l.writable)&&(r[a]=Ie(e[a],a,t,n,s))}}function No(r){switch(Ne(r)){case Me:case bn:case Bt:case Vt:case rt:case It:case Rn:case Tn:case An:case kn:case En:case Ft:case nt:case st:case Ot:case Dt:case Oe:case Mt:case vn:case Pn:case Cn:case Sn:return!0;default:return!1}}function Oo(r,e){return xo(r,(t,n,s,i)=>{if(typeof r=="object")switch(Object.prototype.toString.call(r)){case nt:case Oe:case rt:{const o=new r.constructor(r?.valueOf());return Pe(o,r),o}case Me:{const o={};return Pe(o,r),o.length=r.length,o[Symbol.iterator]=r[Symbol.iterator],o}default:return}})}function te(r){return Oo(r)}const Mo=/^(?:0|[1-9]\d*)$/;function Io(r,e=Number.MAX_SAFE_INTEGER){switch(typeof r){case"number":return Number.isInteger(r)&&r>=0&&r<e;case"symbol":return!1;case"string":return Mo.test(r)}}function zr(r){return r!==null&&typeof r=="object"&&Ne(r)==="[object Arguments]"}function Jr(r){return typeof r=="object"&&r!==null}function jr(r){return typeof r=="symbol"||r instanceof Symbol}function Fo(r){return jr(r)?NaN:Number(r)}function Do(r){return r?(r=Fo(r),r===1/0||r===-1/0?(r<0?-1:1)*Number.MAX_VALUE:r===r?r:0):r===0?r:0}function Bo(r){const e=Do(r),t=e%1;return t?e-t:e}const Vo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Lo=/^\w*$/;function $o(r,e){return Array.isArray(r)?!1:typeof r=="number"||typeof r=="boolean"||r==null||jr(r)?!0:typeof r=="string"&&(Lo.test(r)||!Vo.test(r))||e!=null&&Object.hasOwn(e,r)}function Wo(r){return Array.isArray(r)}const qo=(r,e,t)=>{const n=r[e];(!(Object.hasOwn(r,e)&&yn(n,t))||t===void 0&&!(e in r))&&(r[e]=t)};function Uo(r,e,t,n){if(r==null&&!xe(r))return r;const s=$o(e,r)?[e]:Array.isArray(e)?e:typeof e=="string"?Ur(e):[e];let i=r;for(let o=0;o<s.length&&i!=null;o++){const a=qr(s[o]);if(et(a))continue;let l;if(o===s.length-1)l=t(i[a]);else{const c=i[a],h=n?.(c,a,r);l=h!==void 0?h:xe(c)?c:Io(s[o+1])?[]:{}}qo(i,a,l),i=i[a]}return r}function zo(r,e,t){return Uo(r,e,()=>t,()=>{})}function Jo(r,e,{signal:t,edges:n}={}){let s,i=null;const o=n!=null&&n.includes("leading"),a=n==null||n.includes("trailing"),l=()=>{i!==null&&(r.apply(s,i),s=void 0,i=null)},c=()=>{a&&l(),_()};let h=null;const u=()=>{h!=null&&clearTimeout(h),h=setTimeout(()=>{h=null,c()},e)},g=()=>{h!==null&&(clearTimeout(h),h=null)},_=()=>{g(),s=void 0,i=null},y=()=>{g(),l()},v=function(...R){if(t?.aborted)return;s=this,i=R;const B=h==null;u(),o&&B&&l()};return v.schedule=u,v.cancel=_,v.flush=y,t?.addEventListener("abort",_,{once:!0}),v}function Nn(r,e=0,t={}){typeof t!="object"&&(t={});const{leading:n=!1,trailing:s=!0,maxWait:i}=t,o=Array(2);n&&(o[0]="leading"),s&&(o[1]="trailing");let a,l=null;const c=Jo(function(...g){a=r.apply(this,g),l=null},e,{edges:o}),h=function(...g){return i!=null&&(l===null&&(l=Date.now()),Date.now()-l>=i)?(a=r.apply(this,g),l=Date.now(),c.cancel(),c.schedule(),a):(c.apply(this,g),a)},u=()=>(c.flush(),a);return h.cancel=c.cancel,h.flush=u,h}function Gr(r){if(!r||typeof r!="object")return!1;const e=Object.getPrototypeOf(r);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(r)==="[object Object]":!1}function Kr(r,e,t){return it(r,e,void 0,void 0,void 0,void 0,t)}function it(r,e,t,n,s,i,o){const a=o(r,e,t,n,s,i);if(a!==void 0)return a;if(typeof r==typeof e)switch(typeof r){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return r===e;case"number":return r===e||Object.is(r,e);case"function":return r===e;case"object":return ot(r,e,i,o)}return ot(r,e,i,o)}function ot(r,e,t,n){if(Object.is(r,e))return!0;let s=Ne(r),i=Ne(e);if(s===Me&&(s=st),i===Me&&(i=st),s!==i)return!1;switch(s){case Oe:return r.toString()===e.toString();case nt:{const l=r.valueOf(),c=e.valueOf();return yn(l,c)}case rt:case It:case Mt:return Object.is(r.valueOf(),e.valueOf());case Ot:return r.source===e.source&&r.flags===e.flags;case ko:return r===e}t=t??new Map;const o=t.get(r),a=t.get(e);if(o!=null&&a!=null)return o===e;t.set(r,e),t.set(e,r);try{switch(s){case Ft:{if(r.size!==e.size)return!1;for(const[l,c]of r.entries())if(!e.has(l)||!it(c,e.get(l),l,r,e,t,n))return!1;return!0}case Dt:{if(r.size!==e.size)return!1;const l=Array.from(r.values()),c=Array.from(e.values());for(let h=0;h<l.length;h++){const u=l[h],g=c.findIndex(_=>it(u,_,void 0,r,e,t,n));if(g===-1)return!1;c.splice(g,1)}return!0}case bn:case vn:case Pn:case Cn:case Sn:case Ro:case An:case kn:case En:case To:case Rn:case Tn:{if(typeof Buffer<"u"&&Buffer.isBuffer(r)!==Buffer.isBuffer(e)||r.length!==e.length)return!1;for(let l=0;l<r.length;l++)if(!it(r[l],e[l],l,r,e,t,n))return!1;return!0}case Bt:return r.byteLength!==e.byteLength?!1:ot(new Uint8Array(r),new Uint8Array(e),t,n);case Vt:return r.byteLength!==e.byteLength||r.byteOffset!==e.byteOffset?!1:ot(new Uint8Array(r),new Uint8Array(e),t,n);case Eo:return r.name===e.name&&r.message===e.message;case st:{if(!(ot(r.constructor,e.constructor,t,n)||Gr(r)&&Gr(e)))return!1;const c=[...Object.keys(r),...Nt(r)],h=[...Object.keys(e),...Nt(e)];if(c.length!==h.length)return!1;for(let u=0;u<c.length;u++){const g=c[u],_=r[g];if(!Object.hasOwn(e,g))return!1;const y=e[g];if(!it(_,y,g,r,e,t,n))return!1}return!0}default:return!1}}finally{t.delete(r),t.delete(e)}}function Hr(){}function Xr(r,e){return Kr(r,e,Hr)}function jo(r){return typeof Buffer<"u"&&Buffer.isBuffer(r)}function Go(r){const e=r?.constructor,t=typeof e=="function"?e.prototype:Object.prototype;return r===t}function On(r){return xn(r)}function Ko(r,e){if(r=Bo(r),r<1||!Number.isSafeInteger(r))return[];const t=new Array(r);for(let n=0;n<r;n++)t[n]=typeof e=="function"?e(n):n;return t}function Ho(r){if(r==null)return[];switch(typeof r){case"object":case"function":return Co(r)?Yo(r):Go(r)?Xo(r):Lt(r);default:return Lt(Object(r))}}function Lt(r){const e=[];for(const t in r)e.push(t);return e}function Xo(r){return Lt(r).filter(t=>t!=="constructor")}function Yo(r){const e=Ko(r.length,n=>`${n}`),t=new Set(e);return jo(r)&&(t.add("offset"),t.add("parent")),On(r)&&(t.add("buffer"),t.add("byteLength"),t.add("byteOffset")),[...e,...Lt(r).filter(n=>!t.has(n))]}function Qo(r,...e){for(let t=0;t<e.length;t++)Zo(r,e[t]);return r}function Zo(r,e){const t=Ho(e);for(let n=0;n<t.length;n++){const s=t[n];(!(s in r)||!yn(r[s],e[s]))&&(r[s]=e[s])}}function ea(r){if(xt(r))return r;const e=Ne(r);if(!ta(r))return{};if(Wo(r)){const n=Array.from(r);return r.length>0&&typeof r[0]=="string"&&Object.hasOwn(r,"index")&&(n.index=r.index,n.input=r.input),n}if(On(r)){const n=r,s=n.constructor;return new s(n.buffer,n.byteOffset,n.length)}if(e===Bt)return new ArrayBuffer(r.byteLength);if(e===Vt){const n=r,s=n.buffer,i=n.byteOffset,o=n.byteLength,a=new ArrayBuffer(o),l=new Uint8Array(s,i,o);return new Uint8Array(a).set(l),new DataView(a)}if(e===rt||e===nt||e===Oe){const n=r.constructor,s=new n(r.valueOf());return e===Oe?ra(s,r):Mn(s,r),s}if(e===It)return new Date(Number(r));if(e===Ot){const n=r,s=new RegExp(n.source,n.flags);return s.lastIndex=n.lastIndex,s}if(e===Mt)return Object(Symbol.prototype.valueOf.call(r));if(e===Ft){const n=r,s=new Map;return n.forEach((i,o)=>{s.set(o,i)}),s}if(e===Dt){const n=r,s=new Set;return n.forEach(i=>{s.add(i)}),s}if(e===Me){const n=r,s={};return Mn(s,n),s.length=n.length,s[Symbol.iterator]=n[Symbol.iterator],s}const t={};return sa(t,r),Mn(t,r),na(t,r),t}function ta(r){switch(Ne(r)){case Me:case bn:case Bt:case Vt:case rt:case It:case Rn:case Tn:case An:case kn:case En:case Ft:case nt:case st:case Ot:case Dt:case Oe:case Mt:case vn:case Pn:case Cn:case Sn:return!0;default:return!1}}function Mn(r,e){for(const t in e)Object.hasOwn(e,t)&&(r[t]=e[t])}function na(r,e){const t=Object.getOwnPropertySymbols(e);for(let n=0;n<t.length;n++){const s=t[n];Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}}function ra(r,e){const t=e.valueOf().length;for(const n in e)Object.hasOwn(e,n)&&(Number.isNaN(Number(n))||Number(n)>=t)&&(r[n]=e[n])}function sa(r,e){const t=Object.getPrototypeOf(e);t!==null&&typeof e.constructor=="function"&&Object.setPrototypeOf(r,t)}function at(r){if(typeof r!="object"||r==null)return!1;if(Object.getPrototypeOf(r)===null)return!0;if(Object.prototype.toString.call(r)!=="[object Object]"){const t=r[Symbol.toStringTag];return t==null||!Object.getOwnPropertyDescriptor(r,Symbol.toStringTag)?.writable?!1:r.toString()===`[object ${t}]`}let e=r;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(r)===e}function ia(r){if(xt(r))return r;if(Array.isArray(r)||xn(r)||r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer)return r.slice(0);const e=Object.getPrototypeOf(r),t=e.constructor;if(r instanceof Date||r instanceof Map||r instanceof Set)return new t(r);if(r instanceof RegExp){const n=new t(r);return n.lastIndex=r.lastIndex,n}if(r instanceof DataView)return new t(r.buffer.slice(0));if(r instanceof Error){const n=new t(r.message);return n.stack=r.stack,n.name=r.name,n.cause=r.cause,n}if(typeof File<"u"&&r instanceof File)return new t([r],r.name,{type:r.type,lastModified:r.lastModified});if(typeof r=="object"){const n=Object.create(e);return Object.assign(n,r)}return r}function oa(r,...e){const t=e.slice(0,-1),n=e[e.length-1];let s=r;for(let i=0;i<t.length;i++){const o=t[i];s=$t(s,o,n,new Map)}return s}function $t(r,e,t,n){if(xt(r)&&(r=Object(r)),e==null||typeof e!="object")return r;if(n.has(e))return ia(n.get(e));if(n.set(e,r),Array.isArray(e)){e=e.slice();for(let i=0;i<e.length;i++)e[i]=e[i]??void 0}const s=[...Object.keys(e),...Nt(e)];for(let i=0;i<s.length;i++){const o=s[i];if(et(o))continue;let a=e[o],l=r[o];if(zr(a)&&(a={...a}),zr(l)&&(l={...l}),typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=te(a)),Array.isArray(a))if(typeof l=="object"&&l!=null){const h=[],u=Reflect.ownKeys(l);for(let g=0;g<u.length;g++){const _=u[g];h[_]=l[_]}l=h}else l=[];const c=t(l,a,o,r,e,n);c!=null?r[o]=c:Array.isArray(a)||Jr(l)&&Jr(a)?r[o]=$t(l,a,t,n):l==null&&at(a)?r[o]=$t({},a,t,n):l==null&&On(a)?r[o]=te(a):(l===void 0||a!==void 0)&&(r[o]=a)}return r}function Yr(r,...e){return oa(r,...e,Hr)}function Qr(r,e){if(!Number.isInteger(r)||r<0)throw new Error("n must be a non-negative integer.");let t=0;return(...n)=>{if(++t>=r)return e(...n)}}function In(r,e,t){return typeof t!="function"&&(t=()=>{}),Kr(r,e,(...n)=>{const s=t(...n);if(s!==void 0)return!!s;if(r instanceof Map&&e instanceof Map||r instanceof Set&&e instanceof Set)return In(Array.from(r),Array.from(e),Qr(2,t))})}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Fe{_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){this.clear();const t=aa(e);for(const[n,s]of t)this._styleProcessor.toNormalizedForm(n,s,this._styles);return this}has(e){if(this.isEmpty)return!1;const n=this._styleProcessor.getReducedForm(e,this._styles).find(([s])=>s===e);return Array.isArray(n)}set(e,t){if(this._cachedStyleNames=null,this._cachedExpandedStyleNames=null,xe(e))for(const[n,s]of Object.entries(e))this._styleProcessor.toNormalizedForm(n,s,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){const t={};for(const n of ce(e)){const s=Dn(n),i=tt(this._styles,s);if(i)Wt(t,s,i);else{const o=this.getAsString(n);o!==void 0&&this._styleProcessor.toNormalizedForm(n,o,t)}}Object.keys(t).length&&(Zr(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]&&!xe(this._styles[e]))return this._styles[e];const n=this._styleProcessor.getReducedForm(e,this._styles).find(([s])=>s===e);if(Array.isArray(n))return n[1]}getStyleNames(e=!1){return this.isEmpty?[]:e?(this._cachedExpandedStyleNames||=this._styleProcessor.getStyleNames(this._styles),this._cachedExpandedStyleNames):(this._cachedStyleNames||=this.getStylesEntries().map(([t])=>t),this._cachedStyleNames)}keys(){return this.getStyleNames()}clear(){this._styles={},this._cachedStyleNames=null,this._cachedExpandedStyleNames=null}isSimilar(e){if(this.size!==e.size)return!1;for(const t of this.getStyleNames())if(!e.has(t)||e.getAsString(t)!==this.getAsString(t))return!1;return!0}getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const n of t)e.push(...this._styleProcessor.getReducedForm(n,this._styles));return e}_clone(){const e=new this.constructor(this._styleProcessor);return e.set(this.getNormalized()),e}_getTokensMatch(e,t){const n=[];for(const s of this.getStyleNames(!0))if(Ze(e,s)){if(t===!0){n.push(s);continue}const i=this.getAsString(s);Ze(t,i)&&n.push(s)}return n.length?n:void 0}_getConsumables(e){const t=[];if(e){t.push(e);for(const n of this._styleProcessor.getRelatedStyles(e))t.push(n)}else for(const n of this.getStyleNames()){for(const s of this._styleProcessor.getRelatedStyles(n))t.push(s);t.push(n)}return t}_canMergeFrom(e){for(const t of e.getStyleNames())if(this.has(t)&&this.getAsString(t)!==e.getAsString(t))return!1;return!0}_mergeFrom(e){for(const t of e.getStyleNames())this.has(t)||this.set(t,e.getAsString(t))}_isMatching(e){for(const t of e.getStyleNames())if(!this.has(t)||this.getAsString(t)!==e.getAsString(t))return!1;return!0}}class Fn{_normalizers;_extractors;_reducers;_consumables;constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,n){if(xe(t)){Wt(n,Dn(e),t);return}if(this._normalizers.has(e)){const s=this._normalizers.get(e),{path:i,value:o}=s(t);Wt(n,i,o)}else Wt(n,e,t)}getNormalized(e,t){if(!e)return Yr({},t);if(t[e]!==void 0)return t[e];if(this._extractors.has(e)){const n=this._extractors.get(e);if(typeof n=="string")return tt(t,n);const s=n(e,t);if(s)return s}return tt(t,Dn(e))}getReducedForm(e,t){const n=this.getNormalized(e,t);return n===void 0?[]:this._reducers.has(e)?this._reducers.get(e)(n):[[e,n]]}getStyleNames(e){const t=new Set;for(const n of this._consumables.keys()){const s=this.getNormalized(n,e);s&&(typeof s!="object"||Object.keys(s).length)&&t.add(n)}for(const n of Object.keys(e))t.add(n);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){this._mapStyleNames(e,t);for(const n of t)this._mapStyleNames(n,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function aa(r){let e=null,t=0,n=0,s=null;const i=new Map;if(r==="")return i;r.charAt(r.length-1)!=";"&&(r=r+";");for(let o=0;o<r.length;o++){const a=r.charAt(o);if(e===null)switch(a){case":":s||(s=r.substr(t,o-t),n=o+1);break;case'"':case"'":e=a;break;case";":{const l=r.substr(n,o-n);s&&i.set(s.trim(),l.trim()),s=null,t=o+1;break}}else a===e&&(e=null)}return i}function Dn(r){return r.replace("-",".")}function Wt(r,e,t){let n=t;xe(t)&&(n=Yr({},tt(r,e),t)),zo(r,e,n)}function Zr(r,e){for(const t of Object.keys(e))r[t]!==null&&!Array.isArray(r[t])&&typeof r[t]=="object"&&typeof e[t]=="object"?(Zr(r[t],e[t]),Object.keys(r[t]).length||delete r[t]):delete r[t]}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class qt{_set=new Set;get isEmpty(){return this._set.size==0}get size(){return this._set.size}has(e){return this._set.has(e)}keys(){return Array.from(this._set.keys())}setTo(e){this.clear();for(const t of e.split(/\s+/))t&&this._set.add(t);return this}set(e){for(const t of ce(e))t&&this._set.add(t)}remove(e){for(const t of ce(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(const t of this.keys())if(!e.has(t))return!1;return!0}_clone(){const e=new this.constructor;return e._set=new Set(this._set),e}_getTokensMatch(e){const t=[];if(e===!0){for(const n of this._set.keys())t.push(n);return t}if(typeof e=="string"){for(const n of e.split(/\s+/))if(this._set.has(n))t.push(n);else return;return t}for(const n of this._set.keys())n.match(e)&&t.push(n);return t.length?t:void 0}_getConsumables(e){return e?[e]:this.keys()}_canMergeFrom(){return!0}_mergeFrom(e){for(const t of e._set.keys())this._set.has(t)||this._set.add(t)}_isMatching(e){for(const t of e._set.keys())if(!this._set.has(t))return!1;return!0}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class J extends me{name;_unsafeAttributesToRender=[];_attrs;_children;_customProperties=new Map;get _classes(){return this._attrs.get("class")}get _styles(){return this._attrs.get("style")}constructor(e,t,n,s){super(e),this.name=t,this._attrs=this._parseAttributes(n),this._children=[],s&&this._insertChild(0,s)}get childCount(){return this._children.length}get isEmpty(){return this._children.length===0}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes&&(yield"class"),this._styles&&(yield"style");for(const e of this._attrs.keys())e!="class"&&e!="style"&&(yield e)}*getAttributes(){for(const[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){return this._attrs.has(e)?t!==void 0?De(this.name,e)||lt(this.name,e)?this._attrs.get(e).has(t):this._attrs.get(e)===t:!0:!1}isSimilar(e){if(!(e instanceof J))return!1;if(this===e)return!0;if(this.name!=e.name||this._attrs.size!==e._attrs.size)return!1;for(const[t,n]of this._attrs){const s=e._attrs.get(t);if(s===void 0)return!1;if(typeof n=="string"||typeof s=="string"){if(s!==n)return!1}else if(!n.isSimilar(s))return!1}return!0}hasClass(...e){for(const t of e)if(!this._classes||!this._classes.has(t))return!1;return!0}getClassNames(){const 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(const t of e)if(!this._styles||!this._styles.has(t))return!1;return!0}findAncestor(...e){const t=new Te(...e);let n=this.parent;for(;n&&!n.is("documentFragment");){if(t.match(n))return n;n=n.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=this._classes?this._classes.keys().sort().join(","):"",t=this._styles&&String(this._styles),n=Array.from(this._attrs).filter(([s])=>s!="style"&&s!="class").map(s=>`${s[0]}="${s[1]}"`).sort().join(" ");return this.name+(e==""?"":` class="${e}"`)+(t?` style="${t}"`:"")+(n==""?"":` ${n}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}toJSON(){const e=super.toJSON();if(e.name=this.name,e.type="Element",this._attrs.size&&(e.attributes=Object.fromEntries(this.getAttributes())),this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=[];if(e)for(const s of this.getChildren())t.push(s._clone(e));const n=new this.constructor(this.document,this.name,this._attrs,t);return n._customProperties=new Map(this._customProperties),n.getFillerOffset=this.getFillerOffset,n._unsafeAttributesToRender=this._unsafeAttributesToRender,n}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this,{index:e});let n=0;const s=la(this.document,t);for(const i of s)i.parent!==null&&i._remove(),i.parent=this,i.document=this.document,this._children.splice(e,0,i),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let n=e;n<e+t;n++)this._children[n].parent=null;return this._children.splice(e,t)}_setAttribute(e,t,n=!0){if(this._fireChange("attributes",this),De(this.name,e)||lt(this.name,e)){let s=this._attrs.get(e);s||(s=De(this.name,e)?new Fe(this.document.stylesProcessor):new qt,this._attrs.set(e,s)),n?s.setTo(String(t)):De(this.name,e)?Array.isArray(t)?s.set(t[0],t[1]):s.set(t):s.set(typeof t=="string"?t.split(/\s+/):t)}else this._attrs.set(e,String(t))}_removeAttribute(e,t){if(this._fireChange("attributes",this),t!==void 0&&(De(this.name,e)||lt(this.name,e))){const n=this._attrs.get(e);return n?(lt(this.name,e)&&typeof t=="string"&&(t=t.split(/\s+/)),n.remove(t),n.isEmpty?this._attrs.delete(e):!1):!1}return this._attrs.delete(e)}_addClass(e){this._setAttribute("class",e,!1)}_removeClass(e){this._removeAttribute("class",e)}_setStyle(e,t){typeof e!="string"?this._setAttribute("style",e,!1):this._setAttribute("style",[e,t],!1)}_removeStyle(e){this._removeAttribute("style",e)}_collectAttributesMatch(e,t,n){for(const[s,i,o]of e){let a=!1,l=!1;for(const[c,h]of this._attrs)if(!(n&&n.includes(c)||!Ze(s,c)))if(a=!0,typeof h=="string"){if(Ze(i,h))t.push([c]),l=!0;else if(!(s instanceof RegExp))return!1}else{const u=h._getTokensMatch(i,o||!0);if(u){l=!0;for(const g of u)t.push([c,g])}else if(!(s instanceof RegExp))return!1}if(!a||!l)return!1}return!0}_getConsumables(e,t){const n=[];if(e){const s=this._attrs.get(e);if(s!==void 0)if(typeof s=="string")n.push([e]);else for(const i of s._getConsumables(t))n.push([e,i])}else for(const[s,i]of this._attrs)if(typeof i=="string")n.push([s]);else for(const o of i._getConsumables())n.push([s,o]);return{name:!e,attributes:n}}_canMergeAttributesFrom(e){if(this.name!=e.name)return!1;for(const[t,n]of e._attrs){const s=this._attrs.get(t);if(s!==void 0){if(typeof s=="string"||typeof n=="string"){if(s!==n)return!1}else if(!s._canMergeFrom(n))return!1}}return!0}_mergeAttributesFrom(e){this._fireChange("attributes",this);for(const[t,n]of e._attrs){const s=this._attrs.get(t);s===void 0||typeof s=="string"||typeof n=="string"?this._setAttribute(t,n):s._mergeFrom(n)}}_canSubtractAttributesOf(e){if(this.name!=e.name)return!1;for(const[t,n]of e._attrs){const s=this._attrs.get(t);if(s===void 0)return!1;if(typeof s=="string"||typeof n=="string"){if(s!==n)return!1}else if(!s._isMatching(n))return!1}return!0}_subtractAttributesOf(e){this._fireChange("attributes",this);for(const[t,n]of e._attrs){const s=this._attrs.get(t);typeof s=="string"||typeof n=="string"?this._attrs.delete(t):(s.remove(n.keys()),s.isEmpty&&this._attrs.delete(t))}}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}_parseAttributes(e){const t=he(e);for(const[n,s]of t)if(s===null)t.delete(n);else if(De(this.name,n)){const i=s instanceof Fe?s._clone():new Fe(this.document.stylesProcessor).setTo(String(s));t.set(n,i)}else if(lt(this.name,n)){const i=s instanceof qt?s._clone():new qt().setTo(String(s));t.set(n,i)}else typeof s!="string"&&t.set(n,String(s));return t}}J.prototype.is=function(r,e){return e?e===this.name&&(r==="element"||r==="view:element"):r==="element"||r==="view:element"||r==="node"||r==="view:node"};function la(r,e){if(typeof e=="string")return[new T(r,e)];ue(e)||(e=[e]);const t=[];for(const n of e)typeof n=="string"?t.push(new T(r,n)):n instanceof ee?t.push(new T(r,n.data)):t.push(n);return t}function lt(r,e){return e=="class"||r=="a"&&e=="rel"}function De(r,e){return e=="style"}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ge extends J{constructor(e,t,n,s){super(e,t,n,s),this.getFillerOffset=es}toJSON(){const e=super.toJSON();return e.type="ContainerElement",e}}ge.prototype.is=function(r,e){return e?e===this.name&&(r==="containerElement"||r==="view:containerElement"||r==="element"||r==="view:element"):r==="containerElement"||r==="view:containerElement"||r==="element"||r==="view:element"||r==="node"||r==="view:node"};function es(){const r=[...this.getChildren()],e=r[this.childCount-1];if(e&&e.is("element","br"))return this.childCount;for(const t of r)if(!t.is("uiElement"))return null;return this.childCount}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ct extends K(ge){constructor(e,t,n,s){super(e,t,n,s),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("placeholder",void 0),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",i=>i&&e.selection.editableElement==this),this.listenTo(e.selection,"change",()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this})}destroy(){this.stopListening()}toJSON(){const e=super.toJSON();return e.type="EditableElement",e.isReadOnly=this.isReadOnly,e.isFocused=this.isFocused,e}}ct.prototype.is=function(r,e){return e?e===this.name&&(r==="editableElement"||r==="view:editableElement"||r==="containerElement"||r==="view:containerElement"||r==="element"||r==="view:element"):r==="editableElement"||r==="view:editableElement"||r==="containerElement"||r==="view:containerElement"||r==="element"||r==="view:element"||r==="node"||r==="view:node"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const ts=Symbol("rootName");class Ut extends ct{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(ts)}set rootName(e){this._setCustomProperty(ts,e)}toJSON(){return this.rootName}set _name(e){this.name=e}}Ut.prototype.is=function(r,e){return e?e===this.name&&(r==="rootElement"||r==="view:rootElement"||r==="editableElement"||r==="view:editableElement"||r==="containerElement"||r==="view:containerElement"||r==="element"||r==="view:element"):r==="rootElement"||r==="view:rootElement"||r==="editableElement"||r==="view:editableElement"||r==="containerElement"||r==="view:containerElement"||r==="element"||r==="view:element"||r==="node"||r==="view:node"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class pe{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new d("view-tree-walker-no-start-position",null);if(e.direction&&e.direction!="forward"&&e.direction!="backward")throw new d("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=p._createAt(e.startPosition):this._position=p._createAt(e.boundaries[e.direction=="backward"?"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,n;do n=this.position,t=this.next();while(!t.done&&e(t.value));t.done||(this._position=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()}next(){return this.direction=="forward"?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,n=e.parent;if(n.parent===null&&e.offset===n.childCount)return{done:!0,value:void 0};if(n===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let s;if(n&&n.is("view:$text")){if(e.isAtEnd)return this._position=p._createAfter(n),this._next();s=n.data[e.offset]}else s=n.getChild(e.offset);if(typeof s=="string"){let i;this.singleCharacters?i=1:i=(n===this._boundaryEndParent?this.boundaries.end.offset:n.data.length)-e.offset;const o=new ee(n,e.offset,i);return e.offset+=i,this._position=e,this._formatReturnValue("text",o,t,e,i)}if(s&&s.is("view:element")){if(!this.shallow)e=new p(s,0);else{if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}return this._position=e,this._formatReturnValue("elementStart",s,t,e,1)}if(s&&s.is("view:$text")){if(this.singleCharacters)return e=new p(s,0),this._position=e,this._next();let i=s.data.length,o;return s==this._boundaryEndParent?(i=this.boundaries.end.offset,o=new ee(s,0,i),e=p._createAfter(o)):(o=new ee(s,0,s.data.length),e.offset++),this._position=e,this._formatReturnValue("text",o,t,e,i)}return e=p._createAfter(n),this._position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",n,t,e)}_previous(){let e=this.position.clone();const t=this.position,n=e.parent;if(n.parent===null&&e.offset===0)return{done:!0,value:void 0};if(n==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let s;if(n.is("view:$text")){if(e.isAtStart)return this._position=p._createBefore(n),this._previous();s=n.data[e.offset-1]}else s=n.getChild(e.offset-1);if(typeof s=="string"){let i;if(this.singleCharacters)i=1;else{const a=n===this._boundaryStartParent?this.boundaries.start.offset:0;i=e.offset-a}e.offset-=i;const o=new ee(n,e.offset,i);return this._position=e,this._formatReturnValue("text",o,t,e,i)}if(s&&s.is("view:element"))return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",s,t,e,1)):(e=new p(s,s.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",s,t,e));if(s&&s.is("view:$text")){if(this.singleCharacters)return e=new p(s,s.data.length),this._position=e,this._previous();let i=s.data.length,o;if(s==this._boundaryStartParent){const a=this.boundaries.start.offset;o=new ee(s,a,s.data.length-a),i=o.data.length,e=p._createBefore(o)}else o=new ee(s,0,s.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",o,t,e,i)}return e=p._createBefore(n),this._position=e,this._formatReturnValue("elementStart",n,t,e,1)}_formatReturnValue(e,t,n,s,i){return t.is("view:$textProxy")&&(t.offsetInText+t.data.length==t.textNode.data.length&&(this.direction=="forward"&&!(this.boundaries&&this.boundaries.end.isEqual(this.position))?(s=p._createAfter(t.textNode),this._position=s):n=p._createAfter(t.textNode)),t.offsetInText===0&&(this.direction=="backward"&&!(this.boundaries&&this.boundaries.start.isEqual(this.position))?(s=p._createBefore(t.textNode),this._position=s):n=p._createBefore(t.textNode))),{done:!1,value:{type:e,item:t,previousPosition:n,nextPosition:s,length:i}}}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class p extends de{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 this.offset===0}get isAtEnd(){const e=this.parent.is("$text")?this.parent.data.length:this.parent.childCount;return this.offset===e}get root(){return this.parent.root}get editableElement(){let e=this.parent;for(;!(e instanceof ct);)if(e.parent)e=e.parent;else return null;return e}getShiftedBy(e){const t=p._createAt(this),n=t.offset+e;return t.offset=n<0?0:n,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const n=new pe(t);return n.skip(e),n.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),n=e.getAncestors();let s=0;for(;t[s]==n[s]&&t[s];)s++;return s===0?null:t[s-1]}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return this.compareWith(e)=="before"}isAfter(e){return this.compareWith(e)=="after"}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";const t=this.parent.is("node")?this.parent.getPath():[],n=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),n.push(e.offset);const s=$(t,n);switch(s){case"prefix":return"before";case"extension":return"after";default:return t[s]<n[s]?"before":"after"}}getWalker(e={}){return e.startPosition=this,new pe(e)}clone(){return new p(this.parent,this.offset)}toJSON(){return{parent:this.parent.toJSON(),offset:this.offset}}static _createAt(e,t){if(e instanceof p)return new this(e.parent,e.offset);{const n=e;if(t=="end")t=n.is("$text")?n.data.length:n.childCount;else{if(t=="before")return this._createBefore(n);if(t=="after")return this._createAfter(n);if(t!==0&&!t)throw new d("view-createpositionat-offset-required",n)}return new p(n,t)}}static _createAfter(e){if(e.is("$textProxy"))return new p(e.textNode,e.offsetInText+e.data.length);if(!e.parent)throw new d("view-position-after-root",e,{root:e});return new p(e.parent,e.index+1)}static _createBefore(e){if(e.is("$textProxy"))return new p(e.textNode,e.offsetInText);if(!e.parent)throw new d("view-position-before-root",e,{root:e});return new p(e.parent,e.index)}}p.prototype.is=function(r){return r==="position"||r==="view:position"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class w extends de{start;end;constructor(e,t=null){super(),this.start=e.clone(),this.end=t?t.clone():e.clone()}*[Symbol.iterator](){yield*new pe({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(zt,{direction:"backward"}),t=this.end.getLastMatchingPosition(zt);return e.parent.is("$text")&&e.isAtStart&&(e=p._createBefore(e.parent)),t.parent.is("$text")&&t.isAtEnd&&(t=p._createAfter(t.parent)),new w(e,t)}getTrimmed(){let e=this.start.getLastMatchingPosition(zt);if(e.isAfter(this.end)||e.isEqual(this.end))return new w(e,e);let t=this.end.getLastMatchingPosition(zt,{direction:"backward"});const n=e.nodeAfter,s=t.nodeBefore;return n&&n.is("$text")&&(e=new p(n,0)),s&&s.is("$text")&&(t=new p(s,s.data.length)),new w(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);const n=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),s=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return n&&s}getDifference(e){const t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new w(this.start,e.start)),this.containsPosition(e.end)&&t.push(new w(e.end,this.end))):t.push(this.clone()),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,n=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(n=e.end),new w(t,n)}return null}getWalker(e={}){return e.boundaries=this,new pe(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 w(this.start,this.end)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new pe(e);for(const n of t)yield n.item}*getPositions(e={}){e.boundaries=this;const t=new pe(e);yield t.position;for(const n of t)yield n.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,n,s){return new this(new p(e,t),new p(n,s))}static _createFromPositionAndShift(e,t){const n=e,s=e.getShiftedBy(t);return t>0?new this(n,s):new this(s,n)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(p._createBefore(e),t)}}w.prototype.is=function(r){return r==="range"||r==="view:range"};function zt(r){return!!(r.item.is("attributeElement")||r.item.is("uiElement"))}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Q extends I(de){_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;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return this.rangeCount===1&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(const t of this._ranges)(!e||t.start.isBefore(e.start))&&(e=t);return e?e.clone():null}getLastRange(){let e=null;for(const t of this._ranges)(!e||t.end.isAfter(e.end))&&(e=t);return e?e.clone():null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake||this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel||this.rangeCount!=e.rangeCount)return!1;if(this.rangeCount===0)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let n=!1;for(const s of e._ranges)if(t.isEqual(s)){n=!0;break}if(!n)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=xr(this.getRanges()),n=xr(e.getRanges());if(t!=n)return!1;if(t==0)return!0;for(let s of this.getRanges()){s=s.getTrimmed();let i=!1;for(let o of e.getRanges())if(o=o.getTrimmed(),s.start.isEqual(o.start)&&s.end.isEqual(o.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,n,s]=e;if(typeof n=="object"&&(s=n,n=void 0),t===null)this._setRanges([]),this._setFakeOptions(s);else if(t instanceof Q||t instanceof Be)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof w)this._setRanges([t],s&&s.backward),this._setFakeOptions(s);else if(t instanceof p)this._setRanges([new w(t)]),this._setFakeOptions(s);else if(t instanceof me){const i=!!s&&!!s.backward;let o;if(n===void 0)throw new d("view-selection-setto-required-second-parameter",this);n=="in"?o=w._createIn(t):n=="on"?o=w._createOn(t):o=new w(p._createAt(t,n)),this._setRanges([o],i),this._setFakeOptions(s)}else if(ue(t))this._setRanges(t,s&&s.backward),this._setFakeOptions(s);else throw new d("view-selection-setto-not-selectable",this);this.fire("change")}setFocus(e,t){if(this.anchor===null)throw new d("view-selection-setfocus-no-ranges",this);const n=p._createAt(e,t);if(n.compareWith(this.focus)=="same")return;const s=this.anchor;this._ranges.pop(),n.compareWith(s)=="before"?this._addRange(new w(n,s),!0):this._addRange(new w(s,n)),this.fire("change")}toJSON(){const e={ranges:Array.from(this.getRanges()).map(t=>t.toJSON())};return this.isBackward&&(e.isBackward=!0),this.isFake&&(e.isFake=!0),e}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(const n of e)this._addRange(n);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,t=!1){if(!(e instanceof w))throw new d("view-selection-add-range-not-range",this);this._pushRange(e),this._lastRangeBackward=!!t}_pushRange(e){for(const t of this._ranges)if(e.isIntersecting(t))throw new d("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new w(e.start,e.end))}}Q.prototype.is=function(r){return r==="selection"||r==="view:selection"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Be extends I(de){_selection;constructor(...e){super(),this._selection=new Q,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)}}Be.prototype.is=function(r){return r==="selection"||r=="documentSelection"||r=="view:selection"||r=="view:documentSelection"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Jt extends un{startRange;_eventPhase;_currentTarget;constructor(e,t,n){super(e,t),this.startRange=n,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const Bn=Symbol("bubblingEmitter"),Vn=Symbol("bubblingCallbacks"),Ln=Symbol("bubblingContexts");function ns(r){class e extends r{fire(n,...s){try{const i=n instanceof un?n:new un(this,n),o=$n(this),a=ss(this);if(ht(i,"capturing",this),jt(o,"$capture",i,...s))return i.return;const l=i.startRange||this.selection.getFirstRange(),c=l?l.getContainedElement():null,h=c?ha(a,c):!1;let u=c||ua(l);if(ht(i,"atTarget",u),!h){if(jt(o,"$text",i,...s))return i.return;ht(i,"bubbling",u)}for(;u;){if(u.is("element")&&jt(o,u,i,...s))return i.return;u=u.parent,ht(i,"bubbling",u)}return ht(i,"bubbling",this),jt(o,"$document",i,...s),i.return}catch(i){/* istanbul ignore next -- @preserve */d.rethrowUnexpectedError(i,this)}}_addEventListener(n,s,i){const o=ce(i.context||"$document"),a=$n(this),l=rs(this);for(const h of o)typeof h=="function"&&ss(this).add(h);const c=ca(this,o,s);l.set(s,c),this.listenTo(a,n,c,i)}_removeEventListener(n,s){const i=$n(this),o=rs(this),a=o.get(s);a&&(o.delete(s),this.stopListening(i,n,a))}}return e}function ht(r,e,t){r instanceof Jt&&(r._eventPhase=e,r._currentTarget=t)}function jt(r,e,t,...n){return r.fire(t,{currentTarget:e,eventArgs:n}),!!t.stop.called}function ca(r,e,t){return function(n,s){const{currentTarget:i,eventArgs:o}=s;if(typeof i=="string"){e.includes(i)&&t.call(r,n,...o);return}if(i.is("rootElement")&&e.includes("$root")){t.call(r,n,...o);return}if(e.includes(i.name)){t.call(r,n,...o);return}for(const a of e)if(typeof a=="function"&&a(i)){t.call(r,n,...o);return}}}function $n(r){return r[Bn]||(r[Bn]=new(I())),r[Bn]}function rs(r){return r[Vn]||(r[Vn]=new Map),r[Vn]}function ss(r){return r[Ln]||(r[Ln]=new Set),r[Ln]}function ha(r,e){for(const t of r)if(t(e))return!0;return!1}function ua(r){if(!r)return null;const e=r.start.parent,t=r.end.parent,n=e.getPath(),s=t.getPath();return n.length>s.length?e:t}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Gt extends ns(K()){selection;roots;stylesProcessor;_postFixers=new Set;constructor(e){super(),this.selection=new Be,this.roots=new fn({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.forEach(e=>e.destroy()),this.stopListening()}_callPostFixers(e){let t=!1;do for(const n of this._postFixers)if(t=n(e),t)break;while(t)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const is=10;class _e extends J{static DEFAULT_PRIORITY=is;_priority=is;_id=null;_clonesGroup=null;constructor(e,t,n,s){super(e,t,n,s),this.getFillerOffset=fa}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(this.id===null)throw new d("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}isSimilar(e){return this.id!==null||e.id!==null?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}toJSON(){const e=super.toJSON();return e.type="AttributeElement",e}_clone(e=!1){const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}_canMergeAttributesFrom(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canMergeAttributesFrom(e)}_canSubtractAttributesOf(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canSubtractAttributesOf(e)}}_e.prototype.is=function(r,e){return e?e===this.name&&(r==="attributeElement"||r==="view:attributeElement"||r==="element"||r==="view:element"):r==="attributeElement"||r==="view:attributeElement"||r==="element"||r==="view:element"||r==="node"||r==="view:node"};function fa(){if(Wn(this))return null;let r=this.parent;for(;r&&r.is("attributeElement");){if(Wn(r)>1)return null;r=r.parent}return!r||Wn(r)>1?null:this.childCount}function Wn(r){return Array.from(r.getChildren()).filter(e=>!e.is("uiElement")).length}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ut extends J{constructor(e,t,n,s){super(e,t,n,s),this.getFillerOffset=da}toJSON(){const e=super.toJSON();return e.type="EmptyElement",e}_insertChild(e,t){if(t&&(t instanceof me||Array.from(t).length>0))throw new d("view-emptyelement-cannot-add",[this,t]);return 0}}ut.prototype.is=function(r,e){return e?e===this.name&&(r==="emptyElement"||r==="view:emptyElement"||r==="element"||r==="view:element"):r==="emptyElement"||r==="view:emptyElement"||r==="element"||r==="view:element"||r==="node"||r==="view:node"};function da(){return null}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ve extends J{constructor(e,t,n,s){super(e,t,n,s),this.getFillerOffset=ma}_insertChild(e,t){if(t&&(t instanceof me||Array.from(t).length>0))throw new d("view-uielement-cannot-add",[this,t]);return 0}render(e,t){return this.toDomElement(e)}toDomElement(e){const t=e.createElement(this.name);for(const n of this.getAttributeKeys())t.setAttribute(n,this.getAttribute(n));return t}toJSON(){const e=super.toJSON();return e.type="UIElement",e}}Ve.prototype.is=function(r,e){return e?e===this.name&&(r==="uiElement"||r==="view:uiElement"||r==="element"||r==="view:element"):r==="uiElement"||r==="view:uiElement"||r==="element"||r==="view:element"||r==="node"||r==="view:node"};function os(r){r.document.on("arrowKey",(e,t)=>ga(e,t,r.domConverter),{priority:"low"})}function ma(){return null}function ga(r,e,t){if(e.keyCode==be.arrowright){const n=e.domTarget.ownerDocument.defaultView.getSelection(),s=n.rangeCount==1&&n.getRangeAt(0).collapsed;if(s||e.shiftKey){const i=n.focusNode,o=n.focusOffset,a=t.domPositionToView(i,o);if(a===null)return;let l=!1;const c=a.getLastMatchingPosition(h=>(h.item.is("uiElement")&&(l=!0),!!(h.item.is("uiElement")||h.item.is("attributeElement"))));if(l){const h=t.viewPositionToDom(c);s?n.collapse(h.parent,h.offset):n.extend(h.parent,h.offset)}}}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ft extends J{constructor(e,t,n,s){super(e,t,n,s),this.getFillerOffset=pa}toJSON(){const e=super.toJSON();return e.type="RawElement",e}_insertChild(e,t){if(t&&(t instanceof me||Array.from(t).length>0))throw new d("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}ft.prototype.is=function(r,e){return e?e===this.name&&(r==="rawElement"||r==="view:rawElement"||r==="element"||r==="view:element"):r==="rawElement"||r==="view:rawElement"||r===this.name||r==="view:"+this.name||r==="element"||r==="view:element"||r==="node"||r==="view:node"};function pa(){return null}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class se extends I(de){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 this.childCount===0}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(){const e=[];for(const 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){this._fireChange("children",this,{index:e});let n=0;const s=_a(this.document,t);for(const i of s)i.parent!==null&&i._remove(),i.parent=this,this._children.splice(e,0,i),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let n=e;n<e+t;n++)this._children[n].parent=null;return this._children.splice(e,t)}_fireChange(e,t,n){this.fire(`change:${e}`,t,n)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}}se.prototype.is=function(r){return r==="documentFragment"||r==="view:documentFragment"};function _a(r,e){return typeof e=="string"?[new T(r,e)]:(ue(e)||(e=[e]),Array.from(e).map(t=>typeof t=="string"?new T(r,t):t instanceof ee?new T(r,t.data):t))}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class qn{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 se(this.document,e)}createText(e){return new T(this.document,e)}createAttributeElement(e,t,n={}){const s=new _e(this.document,e,t);return typeof n.priority=="number"&&(s._priority=n.priority),n.id&&(s._id=n.id),n.renderUnsafeAttributes&&s._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),s}createContainerElement(e,t,n={},s={}){let i;va(n)?s=n:i=n;const o=new ge(this.document,e,t,i);return s.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...s.renderUnsafeAttributes),o}createEditableElement(e,t,n={}){const s=new ct(this.document,e,t);return n.renderUnsafeAttributes&&s._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),s}createEmptyElement(e,t,n={}){const s=new ut(this.document,e,t);return n.renderUnsafeAttributes&&s._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),s}createUIElement(e,t,n){const s=new Ve(this.document,e,t);return n&&(s.render=n),s}createRawElement(e,t,n,s={}){const i=new ft(this.document,e,t);return n&&(i.render=n),s.renderUnsafeAttributes&&i._unsafeAttributesToRender.push(...s.renderUnsafeAttributes),i}setAttribute(e,t,n,s){s!==void 0?s._setAttribute(e,t,n):n._setAttribute(e,t)}removeAttribute(e,t,n){n!==void 0?n._removeAttribute(e,t):t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){at(e)&&n===void 0?t._setStyle(e):n._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,n){n._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}breakAttributes(e){return e instanceof p?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){const t=e.parent;if(!t.is("containerElement"))throw new d("view-writer-break-non-container-element",this.document);if(!t.parent)throw new d("view-writer-break-root",this.document);if(e.isAtStart)return p._createBefore(t);if(!e.isAtEnd){const n=t._clone(!1);this.insert(p._createAfter(t),n);const s=new w(e,p._createAt(t,"end")),i=new p(n,0);this.move(s,i)}return p._createAfter(t)}mergeAttributes(e){const t=e.offset,n=e.parent;if(n.is("$text"))return e;if(n.is("attributeElement")&&n.childCount===0){const o=n.parent,a=n.index;return n._remove(),this._removeFromClonedElementsGroup(n),this.mergeAttributes(new p(o,a))}const s=n.getChild(t-1),i=n.getChild(t);if(!s||!i)return e;if(s.is("$text")&&i.is("$text"))return ls(s,i);if(s.is("attributeElement")&&i.is("attributeElement")&&s.isSimilar(i)){const o=s.childCount;return s._appendChild(i.getChildren()),i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new p(s,o))}return e}mergeContainers(e){const t=e.nodeBefore,n=e.nodeAfter;if(!t||!n||!t.is("containerElement")||!n.is("containerElement"))throw new d("view-writer-merge-containers-invalid-position",this.document);const s=t.getChild(t.childCount-1),i=s instanceof T?p._createAt(s,"end"):p._createAt(t,"end");return this.move(w._createIn(n),p._createAt(t,"end")),this.remove(w._createOn(n)),i}insert(e,t){t=ue(t)?[...t]:[t],cs(t,this.document);const n=t.reduce((o,a)=>{const l=o[o.length-1],c=!a.is("uiElement");return!l||l.breakAttributes!=c?o.push({breakAttributes:c,nodes:[a]}):l.nodes.push(a),o},[]);let s=null,i=e;for(const{nodes:o,breakAttributes:a}of n){const l=this._insertNodes(i,o,a);s||(s=l.start),i=l.end}return s?new w(s,i):new w(e)}remove(e){const t=e instanceof w?e:w._createOn(e);if(dt(t,this.document),t.isCollapsed)return new se(this.document);const{start:n,end:s}=this._breakAttributesRange(t,!0),i=n.parent,o=s.offset-n.offset,a=i._removeChildren(n.offset,o);for(const c of a)this._removeFromClonedElementsGroup(c);const l=this.mergeAttributes(n);return t.start=l,t.end=l.clone(),new se(this.document,a)}clear(e,t){dt(e,this.document);const n=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const s of n){const i=s.item;let o;if(i.is("element")&&t.isSimilar(i))o=w._createOn(i);else if(!s.nextPosition.isAfter(e.start)&&i.is("$textProxy")){const a=i.getAncestors().find(l=>l.is("element")&&t.isSimilar(l));a&&(o=w._createIn(a))}o&&(o.end.isAfter(e.end)&&(o.end=e.end),o.start.isBefore(e.start)&&(o.start=e.start),this.remove(o))}}move(e,t){let n;if(t.isAfter(e.end)){t=this._breakAttributes(t,!0);const s=t.parent,i=s.childCount;e=this._breakAttributesRange(e,!0),n=this.remove(e),t.offset+=s.childCount-i}else n=this.remove(e);return this.insert(t,n)}wrap(e,t){if(!(t instanceof _e))throw new d("view-writer-wrap-invalid-attribute",this.document);if(dt(e,this.document),e.isCollapsed){let n=e.start;n.parent.is("element")&&!wa(n.parent)&&(n=n.getLastMatchingPosition(i=>i.item.is("uiElement"))),n=this._wrapPosition(n,t);const s=this.document.selection;return s.isCollapsed&&s.getFirstPosition().isEqual(e.start)&&this.setSelection(n),new w(n)}else return this._wrapRange(e,t)}unwrap(e,t){if(!(t instanceof _e))throw new d("view-writer-unwrap-invalid-attribute",this.document);if(dt(e,this.document),e.isCollapsed)return e;const{start:n,end:s}=this._breakAttributesRange(e,!0),i=n.parent,o=this._unwrapChildren(i,n.offset,s.offset,t),a=this.mergeAttributes(o.start);a.isEqual(o.start)||o.end.offset--;const l=this.mergeAttributes(o.end);return new w(a,l)}rename(e,t){const n=new ge(this.document,e,t.getAttributes());return this.insert(p._createAfter(t),n),this.move(w._createIn(t),p._createAt(n,0)),this.remove(w._createOn(t)),n}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return p._createAt(e,t)}createPositionAfter(e){return p._createAfter(e)}createPositionBefore(e){return p._createBefore(e)}createRange(e,t){return new w(e,t)}createRangeOn(e){return w._createOn(e)}createRangeIn(e){return w._createIn(e)}createSelection(...e){return new Q(...e)}createSlot(e="children"){if(!this._slotFactory)throw new d("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,n){let s;if(n?s=Un(e):s=e.parent.is("$text")?e.parent.parent:e.parent,!s)throw new d("view-writer-invalid-position-container",this.document);let i;n?i=this._breakAttributes(e,!0):i=e.parent.is("$text")?zn(e):e;const o=s._insertChild(i.offset,t);for(const h of t)this._addToClonedElementsGroup(h);const a=i.getShiftedBy(o),l=this.mergeAttributes(i);l.isEqual(i)||a.offset--;const c=this.mergeAttributes(a);return new w(l,c)}_wrapChildren(e,t,n,s){let i=t;const o=[];for(;i<n;){const l=e.getChild(i),c=l.is("$text"),h=l.is("attributeElement");if(h&&l._canMergeAttributesFrom(s))l._mergeAttributesFrom(s),o.push(new p(e,i));else if(c||!h||ya(s,l)){const u=s._clone();l._remove(),u._appendChild(l),e._insertChild(i,u),this._addToClonedElementsGroup(u),o.push(new p(e,i))}else this._wrapChildren(l,0,l.childCount,s);i++}let a=0;for(const l of o){if(l.offset-=a,l.offset==t)continue;this.mergeAttributes(l).isEqual(l)||(a++,n--)}return w._createFromParentsAndOffsets(e,t,e,n)}_unwrapChildren(e,t,n,s){let i=t;const o=[];for(;i<n;){const l=e.getChild(i);if(!l.is("attributeElement")){i++;continue}if(l.isSimilar(s)){const c=l.getChildren(),h=l.childCount;l._remove(),e._insertChild(i,c),this._removeFromClonedElementsGroup(l),o.push(new p(e,i),new p(e,i+h)),i+=h,n+=h-1;continue}if(l._canSubtractAttributesOf(s)){l._subtractAttributesOf(s),o.push(new p(e,i),new p(e,i+1)),i++;continue}this._unwrapChildren(l,0,l.childCount,s),i++}let a=0;for(const l of o){if(l.offset-=a,l.offset==t||l.offset==n)continue;this.mergeAttributes(l).isEqual(l)||(a++,n--)}return w._createFromParentsAndOffsets(e,t,e,n)}_wrapRange(e,t){const{start:n,end:s}=this._breakAttributesRange(e,!0),i=n.parent,o=this._wrapChildren(i,n.offset,s.offset,t),a=this.mergeAttributes(o.start);a.isEqual(o.start)||o.end.offset--;const l=this.mergeAttributes(o.end);return new w(a,l)}_wrapPosition(e,t){if(t.isSimilar(e.parent))return as(e.clone());e.parent.is("$text")&&(e=zn(e));const n=this.createAttributeElement("_wrapPosition-fake-element");n._priority=Number.POSITIVE_INFINITY,n.isSimilar=()=>!1,e.parent._insertChild(e.offset,n);const s=new w(e,e.getShiftedBy(1));this.wrap(s,t);const i=new p(n.parent,n.index);n._remove();const o=i.nodeBefore,a=i.nodeAfter;return o&&o.is("view:$text")&&a&&a.is("view:$text")?ls(o,a):as(i)}_breakAttributesRange(e,t=!1){const n=e.start,s=e.end;if(dt(e,this.document),e.isCollapsed){const l=this._breakAttributes(e.start,t);return new w(l,l)}const i=this._breakAttributes(s,t),o=i.parent.childCount,a=this._breakAttributes(n,t);return i.offset+=i.parent.childCount-o,new w(a,i)}_breakAttributes(e,t=!1){const n=e.offset,s=e.parent;if(e.parent.is("emptyElement"))throw new d("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new d("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new d("view-writer-cannot-break-raw-element",this.document);if(!t&&s.is("$text")&&Jn(s.parent)||Jn(s))return e.clone();if(s.is("$text"))return this._breakAttributes(zn(e),t);const i=s.childCount;if(n==i){const o=new p(s.parent,s.index+1);return this._breakAttributes(o,t)}else if(n===0){const o=new p(s.parent,s.index);return this._breakAttributes(o,t)}else{const o=s.index+1,a=s._clone();s.parent._insertChild(o,a),this._addToClonedElementsGroup(a);const l=s.childCount-n,c=s._removeChildren(n,l);a._appendChild(c);const h=new p(s.parent,o);return this._breakAttributes(h,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const s of e.getChildren())this._addToClonedElementsGroup(s);const t=e.id;if(!t)return;let n=this._cloneGroups.get(t);n||(n=new Set,this._cloneGroups.set(t,n)),n.add(e),e._clonesGroup=n}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const s of e.getChildren())this._removeFromClonedElementsGroup(s);const t=e.id;if(!t)return;const n=this._cloneGroups.get(t);n&&n.delete(e)}}function wa(r){return Array.from(r.getChildren()).some(e=>!e.is("uiElement"))}function Un(r){let e=r.parent;for(;!Jn(e);){if(!e)return;e=e.parent}return e}function ya(r,e){return r.priority<e.priority?!0:r.priority>e.priority?!1:r.getIdentity()<e.getIdentity()}function as(r){const e=r.nodeBefore;if(e&&e.is("$text"))return new p(e,e.data.length);const t=r.nodeAfter;return t&&t.is("$text")?new p(t,0):r}function zn(r){if(r.offset==r.parent.data.length)return new p(r.parent.parent,r.parent.index+1);if(r.offset===0)return new p(r.parent.parent,r.parent.index);const e=r.parent.data.slice(r.offset);return r.parent._data=r.parent.data.slice(0,r.offset),r.parent.parent._insertChild(r.parent.index+1,new T(r.root.document,e)),new p(r.parent.parent,r.parent.index+1)}function ls(r,e){const t=r.data.length;return r._data+=e.data,e._remove(),new p(r,t)}const ba=[T,_e,ge,ut,ft,Ve];function cs(r,e){for(const t of r){if(!ba.some(n=>t instanceof n))throw new d("view-writer-insert-invalid-node-type",e);t.is("$text")||cs(t.getChildren(),e)}}function Jn(r){return r&&(r.is("containerElement")||r.is("documentFragment"))}function dt(r,e){const t=Un(r.start),n=Un(r.end);if(!t||!n||t!==n)throw new d("view-writer-invalid-range-container",e)}function va(r){return at(r)}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const jn=r=>r.createTextNode("\xA0"),Gn=r=>{const e=r.createElement("span");return e.dataset.ckeFiller="true",e.innerText="\xA0",e},Kn=r=>{const e=r.createElement("br");return e.dataset.ckeFiller="true",e},q=7,Le="\u2060".repeat(q);function V(r){return typeof r=="string"?r.substr(0,q)===Le:x(r)&&r.data.substr(0,q)===Le}function Ce(r){return r.data.length==q&&V(r)}function Hn(r){const e=typeof r=="string"?r:r.data;return V(r)?e.slice(q):e}function hs(r){r.document.on("arrowKey",Pa,{priority:"low"})}function Pa(r,e){if(e.keyCode==be.arrowleft){const t=e.domTarget.ownerDocument.defaultView.getSelection();if(t.rangeCount==1&&t.getRangeAt(0).collapsed){const n=t.getRangeAt(0).startContainer,s=t.getRangeAt(0).startOffset;V(n)&&s<=q&&t.collapse(n,0)}}}Dr(".ck.ck-editor__editable span[data-ck-unsafe-element]{display:none}");/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class us extends K(){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),F.isBlink&&!F.isAndroid&&this.on("change:isSelecting",()=>{this.isSelecting||this.render()})}markToSync(e,t){if(e==="text")this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if(e==="attributes")this.markedAttributes.add(t);else if(e==="children")this.markedChildren.add(t);else throw new d("view-renderer-unknown-type",this)}}render(){if(this.isComposing&&!F.isAndroid)return;let e=null;const t=F.isBlink&&!F.isAndroid?!this.isSelecting:!0;for(const n of this.markedChildren)this._updateChildrenMappings(n);t?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?e=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(e=this.selection.getFirstPosition(),this.markedChildren.add(e.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(e=this.domConverter.domPositionToView(this._inlineFiller),e&&e.parent.is("$text")&&(e=p._createBefore(e.parent)));for(const n of this.markedAttributes)this._updateAttrs(n);for(const n of this.markedChildren)this._updateChildren(n,{inlineFillerPosition:e});for(const n of this.markedTexts)!this.markedChildren.has(n.parent)&&this.domConverter.mapViewToDom(n.parent)&&this._updateText(n,{inlineFillerPosition:e});if(t)if(e){const n=this.domConverter.viewPositionToDom(e),s=n.parent.ownerDocument;V(n.parent)?this._inlineFiller=n.parent:this._inlineFiller=fs(s,n.parent,n.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.domConverter._clearTemporaryCustomProperties(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const n=Array.from(t.childNodes),s=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),i=this._diffNodeLists(n,s),o=this._findUpdateActions(i,n,s,Sa);if(o.indexOf("update")!==-1){const a={equal:0,insert:0,delete:0};for(const l of o)if(l==="update"){const c=a.equal+a.insert,h=a.equal+a.delete,u=e.getChild(c);u&&!u.is("uiElement")&&!u.is("rawElement")&&this._updateElementMappings(u,n[h]),Nr(s[c]),a.equal++}else a[l]++}}_updateElementMappings(e,t){this.domConverter.unbindDomElement(t),this.domConverter.bindElements(t,e),this.markedChildren.add(e),this.markedAttributes.add(e)}_getInlineFillerPosition(){const e=this.selection.getFirstPosition();return e.parent.is("$text")?p._createBefore(e.parent):e}_isSelectionInInlineFiller(){if(this.selection.rangeCount!=1||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=this.domConverter.viewPositionToDom(e);return!!(t&&x(t.parent)&&V(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!V(e))throw new d("view-renderer-filler-was-lost",this);Ce(e)?e.remove():e.data=e.data.substr(q),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(this.selection.rangeCount!=1||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,n=e.offset;if(!this.domConverter.mapViewToDom(t.root)||!t.is("element")||!Ca(t))return!1;const s=e.nodeBefore,i=e.nodeAfter;return!(s instanceof T||i instanceof T||n===t.getFillerOffset()&&(!s||!s.is("element","br"))||F.isAndroid&&(s||i))}_updateText(e,t){const n=this.domConverter.findCorrespondingDomText(e);let i=this.domConverter.viewToDom(e).data;const o=t.inlineFillerPosition;o&&o.parent==e.parent&&o.offset==e.index&&(i=Le+i),this._updateTextNode(n,i)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(t){for(const n of Array.from(t.attributes)){const s=n.name;e.hasAttribute(s)||this.domConverter.removeDomElementAttribute(t,s)}for(const n of e.getAttributeKeys())this.domConverter.setDomElementAttribute(t,n,e.getAttribute(n),e)}}_updateChildren(e,t){const n=this.domConverter.mapViewToDom(e);if(!n)return;if(F.isAndroid){let u=null;for(const g of Array.from(n.childNodes)){if(u&&x(u)&&x(g)){n.normalize();break}u=g}}const s=t.inlineFillerPosition,i=n.childNodes,o=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));s&&s.parent===e&&fs(n.ownerDocument,o,s.offset);const a=this._diffNodeLists(i,o),l=this._findUpdateActions(a,i,o,Aa);let c=0;const h=new Set;for(const u of l)u==="delete"?(h.add(i[c]),Nr(i[c])):(u==="equal"||u==="update")&&c++;c=0;for(const u of l)u==="insert"?(Or(n,c,o[c]),c++):u==="update"?(this._updateTextNode(i[c],o[c].data),c++):u==="equal"&&(this._markDescendantTextToSync(this.domConverter.domToView(o[c])),c++);for(const u of h)u.parentNode||this.domConverter.unbindDomElement(u)}_diffNodeLists(e,t){return e=Ra(e,this._fakeSelectionContainer),dn(e,t,ka.bind(null,this.domConverter))}_findUpdateActions(e,t,n,s){if(e.indexOf("insert")===-1||e.indexOf("delete")===-1)return e;let i=[],o=[],a=[];const l={equal:0,insert:0,delete:0};for(const c of e)c==="insert"?a.push(n[l.equal+l.insert]):c==="delete"?o.push(t[l.equal+l.delete]):(i=i.concat(dn(o,a,s).map(h=>h==="equal"?"update":h)),i.push("equal"),o=[],a=[]),l[c]++;return i.concat(dn(o,a,s).map(c=>c==="equal"?"update":c))}_updateTextNode(e,t){const n=e.data;n!=t&&(F.isAndroid&&this.isComposing&&n.replace(/\u00A0/g," ")==t.replace(/\u00A0/g," ")||this._updateTextNodeInternal(e,t))}_updateTextNodeInternal(e,t){const n=ro(e.data,t);for(const s of n)s.type==="insert"?e.insertData(s.index,s.values.join("")):e.deleteData(s.index,s.howMany)}_markDescendantTextToSync(e){if(e){if(e.is("$text"))this.markedTexts.add(e);else if(e.is("element"))for(const t of e.getChildren())this._markDescendantTextToSync(t)}}_updateSelection(){if(F.isBlink&&!F.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(this.selection.rangeCount===0){this._removeDomSelection(),this._removeFakeSelection();return}const 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&&F.isAndroid||this._updateDomSelection(e)}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=Ta(t));const n=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(n,this.selection),!this._fakeSelectionNeedsUpdate(e))return;(!n.parentElement||n.parentElement!=e)&&e.appendChild(n),n.textContent=this.selection.fakeSelectionLabel||"\xA0";const s=t.getSelection(),i=t.createRange();s.removeAllRanges(),i.selectNodeContents(n),s.addRange(i)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const n=this.domConverter.viewPositionToDom(this.selection.anchor),s=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(n.parent,n.offset,s.parent,s.offset),F.isGecko&&Ea(s,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return!(t&&this.selection.isEqual(t)||!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,n=e.ownerDocument.getSelection();return!t||t.parentElement!==e||n.anchorNode!==t&&!t.contains(n.anchorNode)?!0:t.textContent!==this.selection.fakeSelectionLabel}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const n=e.activeElement,s=this.domConverter.mapDomToView(n);n&&s&&t.removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function Ca(r){if(r.getAttribute("contenteditable")=="false")return!1;const e=r.findAncestor(t=>t.hasAttribute("contenteditable"));return!e||e.getAttribute("contenteditable")=="true"}function fs(r,e,t){const n=e instanceof Array?e:e.childNodes,s=n[t];if(x(s))return s.data=Le+s.data,s;{const i=r.createTextNode(Le);return Array.isArray(e)?n.splice(t,0,i):Or(e,t,i),i}}function Sa(r,e){return Rt(r)&&Rt(e)&&!x(r)&&!x(e)&&!Qe(r)&&!Qe(e)&&r.tagName.toLowerCase()===e.tagName.toLowerCase()}function Aa(r,e){return Rt(r)&&Rt(e)&&x(r)&&x(e)}function ka(r,e,t){return e===t?!0:x(e)&&x(t)?e.data===t.data:!!(r.isBlockFiller(e)&&r.isBlockFiller(t))}function Ea(r,e){let t=r.parent,n=r.offset;if(x(t)&&Ce(t)&&(n=Ee(t)+1,t=t.parentNode),t.nodeType!=Node.ELEMENT_NODE||n!=t.childNodes.length-1)return;const s=t.childNodes[n];s&&s.tagName=="BR"&&e.addRange(e.getRangeAt(0))}function Ra(r,e){const t=Array.from(r);return t.length==0||!e||t[t.length-1]==e&&t.pop(),t}function Ta(r){const e=r.createElement("div");return e.className="ck-fake-selection-container",Object.assign(e.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),e.textContent="\xA0",e}/**
 * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
 */const xa=Kn(fe.document),Na=jn(fe.document),Oa=Gn(fe.document),Kt="data-ck-unsafe-attribute-",ds="data-ck-unsafe-element";class Ht{document;renderingMode;blockFillerMode;preElements;blockElements;inlineObjectElements;unsafeElements;_domDocument;_domToViewMapping=new WeakMap;_viewToDomMapping=new WeakMap;_fakeSelectionMapping=new WeakMap;_rawContentElementMatcher=new Te;_inlineObjectElementMatcher=new Te;_elementsWithTemporaryCustomProperties=new Set;constructor(e,{blockFillerMode:t,renderingMode:n="editing"}={}){this.document=e,this.renderingMode=n,this.blockFillerMode=t||(n==="editing"?"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=this.renderingMode==="editing"?fe.document:fe.document.implementation.createHTMLDocument("")}get domDocument(){return this._domDocument}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new Q(t))}fakeSelectionToView(e){return this._fakeSelectionMapping.get(e)}bindElements(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}unbindDomElement(e){const t=this._domToViewMapping.get(e);if(t){this._domToViewMapping.delete(e),this._viewToDomMapping.delete(t);for(const n of e.children)this.unbindDomElement(n)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,n){return this.renderingMode==="data"?!0:(e=e.toLowerCase(),e.startsWith("on")||e==="srcdoc"?!1:n==="img"&&(e==="src"||e==="srcset")||n==="source"&&e==="srcset"?!0:!t.replace(/\s+/g,"").match(/^(javascript:|data:(image\/svg|text\/x?html))/i))}setContentOf(e,t){if(this.renderingMode==="data"){e.innerHTML=t;return}const n=new DOMParser().parseFromString(t,"text/html"),s=n.createDocumentFragment(),i=n.body.childNodes;for(;i.length>0;)s.appendChild(i[0]);const o=n.createTreeWalker(s,NodeFilter.SHOW_ELEMENT),a=[];let l;for(;l=o.nextNode();)a.push(l);for(const c of a){for(const u of c.getAttributeNames())this.setDomElementAttribute(c,u,c.getAttribute(u));const h=c.tagName.toLowerCase();this._shouldRenameElement(h)&&(ws(h),c.replaceWith(this._createReplacementDomElement(h,c)))}for(;e.firstChild;)e.firstChild.remove();e.append(s)}viewToDom(e,t={}){if(e.is("$text")){const n=this._processDataFromViewText(e);return this._domDocument.createTextNode(n)}else{const n=e;if(this.mapViewToDom(n))if(n.getCustomProperty("editingPipeline:doNotReuseOnce"))this._elementsWithTemporaryCustomProperties.add(n);else return this.mapViewToDom(n);let s;if(n.is("documentFragment"))s=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(s,n);else{if(n.is("uiElement"))return n.name==="$comment"?s=this._domDocument.createComment(n.getCustomProperty("$rawContent")):s=n.render(this._domDocument,this),t.bind&&this.bindElements(s,n),s;this._shouldRenameElement(n.name)?(ws(n.name),s=this._createReplacementDomElement(n.name)):n.hasAttribute("xmlns")?s=this._domDocument.createElementNS(n.getAttribute("xmlns"),n.name):s=this._domDocument.createElement(n.name),n.is("rawElement")&&n.render(s,this),t.bind&&this.bindElements(s,n);for(const i of n.getAttributeKeys())this.setDomElementAttribute(s,i,n.getAttribute(i),n)}if(t.withChildren!==!1)for(const i of this.viewChildrenToDom(n,t))s instanceof HTMLTemplateElement?s.content.appendChild(i):s.appendChild(i);return s}}setDomElementAttribute(e,t,n,s){const i=this.shouldRenderAttribute(t,n,e.tagName.toLowerCase())||s&&s.shouldRenderUnsafeAttribute(t);if(i||G("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:n}),!so(t)){G("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:n});return}e.hasAttribute(t)&&!i?e.removeAttribute(t):e.hasAttribute(Kt+t)&&i&&e.removeAttribute(Kt+t),e.setAttribute(i?t:Kt+t,n)}removeDomElementAttribute(e,t){t!=ds&&(e.removeAttribute(t),e.removeAttribute(Kt+t))}*viewChildrenToDom(e,t={}){const n=e.getFillerOffset&&e.getFillerOffset();let s=0;for(const i of e.getChildren()){n===s&&(yield this._getBlockFiller());const o=i.is("element")&&!!i.getCustomProperty("dataPipeline:transparentRendering")&&!mn(i.getAttributes());if(o&&this.renderingMode=="data")if(i.is("rawElement")){const a=this._domDocument.createElement(i.name);i.render(a,this),yield*[...a.childNodes]}else yield*this.viewChildrenToDom(i,t);else o&&G("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:i}),yield this.viewToDom(i,t);s++}n===s&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),n=this.viewPositionToDom(e.end),s=this._domDocument.createRange();return s.setStart(t.parent,t.offset),s.setEnd(n.parent,n.offset),s}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const n=this.findCorrespondingDomText(t);if(!n)return null;let s=e.offset;return V(n)&&(s+=q),n.data&&s>n.data.length&&(s=n.data.length),{parent:n,offset:s}}else{let n,s,i;if(e.offset===0){if(n=this.mapViewToDom(t),!n)return null;i=n.childNodes[0]}else{const a=e.nodeBefore;if(s=a.is("$text")?this.findCorrespondingDomText(a):this.mapViewToDom(a),!s)return null;n=s.parentNode,i=s.nextSibling}if(x(i)&&V(i))return{parent:i,offset:q};const o=s?Ee(s)+1:0;return{parent:n,offset:o}}}domToView(e,t={}){const n=[],s=this._domToView(e,t,n),i=s.next().value;return!i||(s.next(),this._processDomInlineNodes(null,n,t),this.blockFillerMode=="br"&&ps(i))||i.is("$text")&&i.data.length==0?null:i}*domChildrenToView(e,t={},n=[]){let s=[];e instanceof HTMLTemplateElement?s=[...e.content.childNodes]:s=[...e.childNodes];for(let i=0;i<s.length;i++){const o=s[i],a=this._domToView(o,t,n),l=a.next().value;l!==null&&(this._isBlockViewElement(l)&&this._processDomInlineNodes(e,n,t),this.blockFillerMode=="br"&&ps(l)||(yield l),a.next())}this._processDomInlineNodes(e,n,t)}domSelectionToView(e){if(Ba(e))return new Q([]);if(e.rangeCount===1){let s=e.getRangeAt(0).startContainer;x(s)&&(s=s.parentNode);const i=this.fakeSelectionToView(s);if(i)return i}const t=this.isDomSelectionBackward(e),n=[];for(let s=0;s<e.rangeCount;s++){const i=e.getRangeAt(s),o=this.domRangeToView(i);o&&n.push(o)}return new Q(n,{backward:t})}domRangeToView(e){const t=this.domPositionToView(e.startContainer,e.startOffset),n=this.domPositionToView(e.endContainer,e.endOffset);return t&&n?new w(t,n):null}domPositionToView(e,t=0){if(this.isBlockFiller(e))return this.domPositionToView(e.parentNode,Ee(e));const n=this.mapDomToView(e);if(n&&(n.is("uiElement")||n.is("rawElement")))return p._createBefore(n);if(x(e)){if(Ce(e))return this.domPositionToView(e.parentNode,Ee(e));const s=this.findCorrespondingViewText(e);let i=t;return s?(V(e)&&(i-=q,i=i<0?0:i),new p(s,i)):null}else{if(t===0){const s=this.mapDomToView(e);if(s)return new p(s,0)}else{const s=e.childNodes[t-1];if(x(s)&&Ce(s)||s&&this.isBlockFiller(s))return this.domPositionToView(s.parentNode,Ee(s));const i=x(s)?this.findCorrespondingViewText(s):this.mapDomToView(s);if(i&&i.parent)return new p(i.parent,i.index+1)}return null}}mapDomToView(e){return this.getHostViewElement(e)||this._domToViewMapping.get(e)}findCorrespondingViewText(e){if(Ce(e))return null;const t=this.getHostViewElement(e);if(t)return t;const n=e.previousSibling;if(n){if(!this.isElement(n))return null;const s=this.mapDomToView(n);if(s){const i=s.nextSibling;return i instanceof T?i:null}}else{const s=this.mapDomToView(e.parentNode);if(s){const i=s.getChild(0);return i instanceof T?i:null}}return null}mapViewToDom(e){return this._viewToDomMapping.get(e)}findCorrespondingDomText(e){const 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){const t=this.mapViewToDom(e);if(!t||t.ownerDocument.activeElement===t)return;const{scrollX:n,scrollY:s}=fe.window,i=[];ms(t,o=>{const{scrollLeft:a,scrollTop:l}=o;i.push([a,l])}),t.focus({preventScroll:!0}),ms(t,o=>{const[a,l]=i.shift();o.scrollLeft=a,o.scrollTop=l}),fe.window.scrollTo(n,s)}_clearDomSelection(){const e=this.mapViewToDom(this.document.selection.editableElement);if(!e)return;const t=e.ownerDocument.defaultView.getSelection(),n=this.domSelectionToView(t);n&&n.rangeCount>0&&t.removeAllRanges()}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(e){return this.blockFillerMode=="br"?e.isEqualNode(xa):_s(e,this.blockElements)?!0:e.isEqualNode(Oa)||Ia(e,this.blockElements)}isDomSelectionBackward(e){if(e.isCollapsed)return!1;const t=this._domDocument.createRange();try{t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset)}catch{return!1}const n=t.collapsed;return t.detach(),n}getHostViewElement(e){const t=io(e);for(t.pop();t.length;){const n=t.pop(),s=this._domToViewMapping.get(n);if(s&&(s.is("uiElement")||s.is("rawElement")))return s}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}registerInlineObjectMatcher(e){this._inlineObjectElementMatcher.add(e)}_clearTemporaryCustomProperties(){for(const e of this._elementsWithTemporaryCustomProperties)e._removeCustomProperty("editingPipeline:doNotReuseOnce");this._elementsWithTemporaryCustomProperties.clear()}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return jn(this._domDocument);case"markedNbsp":return Gn(this._domDocument);case"br":return Kn(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(x(e)&&V(e)&&t<q||this.isElement(e)&&V(e.childNodes[t]))return!1;const n=this.mapDomToView(e);return!(n&&(n.is("uiElement")||n.is("rawElement")))}*_domToView(e,t,n){if(this.blockFillerMode!="br"&&_s(e,this.blockElements))return null;const s=this.getHostViewElement(e);if(s)return s;if(Qe(e)&&t.skipComments)return null;if(x(e)){if(Ce(e))return null;{const i=e.data;if(i==="")return null;const o=new T(this.document,i);return n.push(o),o}}else{let i=this.mapDomToView(e);if(i)return this._isInlineObjectElement(i)&&n.push(i),i;if(this.isDocumentFragment(e))i=new se(this.document),t.bind&&this.bindDocumentFragments(e,i);else{i=this._createViewElement(e,t),t.bind&&this.bindElements(e,i);const a=e.attributes;if(a)for(let l=a.length,c=0;c<l;c++)i._setAttribute(a[c].name,a[c].value);if(this._isViewElementWithRawContent(i,t))return i._setCustomProperty("$rawContent",e.innerHTML),this._isBlockViewElement(i)||n.push(i),i;if(Qe(e))return i._setCustomProperty("$rawContent",e.data),i}yield i;const o=[];if(t.withChildren!==!1)for(const a of this.domChildrenToView(e,t,o))i._appendChild(a);if(this._isInlineObjectElement(i))n.push(i),this._processDomInlineNodes(null,o,t);else for(const a of o)n.push(a)}}_processDomInlineNodes(e,t,n){if(!t.length||e&&!this.isDocumentFragment(e)&&!this._isBlockDomElement(e))return;let s=!1;for(let i=0;i<t.length;i++){const o=t[i];if(!o.is("$text")){s=!1;continue}let a,l=!1;if(this._isPreFormatted(o))a=Hn(o.data);else{a=o.data.replace(/[ \n\t\r]{1,}/g," "),l=/[^\S\u00A0]/.test(a.charAt(a.length-1));const c=i>0?t[i-1]:null,h=i+1<t.length?t[i+1]:null,u=!c||c.is("element")&&c.name=="br"||s,g=h?!1:!V(o.data);n.withChildren!==!1&&(u&&(a=a.replace(/^ /,"")),g&&(a=a.replace(/ $/,""))),a=Hn(a),this.blockFillerMode!="br"&&o.parent&&(Da(o.parent,a)?(a="",o.parent.parent&&(o.parent.parent._setCustomProperty("$hasBlockFiller",!0),o.parent._remove())):Fa(o.parent,a,this.blockElements)&&(a="",o.parent._setCustomProperty("$hasBlockFiller",!0))),a=a.replace(/ \u00A0/g,"  ");const _=h&&h.is("element")&&h.name!="br",y=h&&h.is("$text")&&h.data.charAt(0)==" ";(/[ \u00A0]\u00A0$/.test(a)||!h||_||y)&&(a=a.replace(/\u00A0$/," ")),(u||c&&c.is("element")&&c.name!="br")&&(a=a.replace(/^\u00A0/," "))}a.length==0&&o.parent?(o._remove(),t.splice(i,1),i--):(o._data=a,s=l)}t.length=0}_processDataFromViewText(e){let t=e.data;if(this._isPreFormatted(e))return t;if(t.charAt(0)==" "){const n=this._getTouchingInlineViewNode(e,!1);(n&&n.is("$textProxy")&&this._nodeEndsWithSpace(n)||!n)&&(t="\xA0"+t.substr(1))}if(t.charAt(t.length-1)==" "){const n=this._getTouchingInlineViewNode(e,!0),s=n&&n.is("$textProxy")&&n.data.charAt(0)==" ";(t.charAt(t.length-2)==" "||!n||s)&&(t=t.substr(0,t.length-1)+"\xA0")}return t.replace(/ {2}/g," \xA0")}_nodeEndsWithSpace(e){if(this._isPreFormatted(e))return!1;const t=this._processDataFromViewText(e);return t.charAt(t.length-1)==" "}_isPreFormatted(e){if(Ma(e,this.preElements))return!0;for(const t of e.getAncestors({parentFirst:!0}))if(!(!t.is("element")||!t.hasStyle("white-space")||t.getStyle("white-space")==="inherit"))return["pre","pre-wrap","break-spaces"].includes(t.getStyle("white-space"));return!1}_getTouchingInlineViewNode(e,t){const n=new pe({startPosition:t?p._createAfter(e):p._createBefore(e),direction:t?"forward":"backward"});for(const{item:s}of n){if(s.is("$textProxy"))return s;if(s.is("element")&&s.getCustomProperty("dataPipeline:transparentRendering"))continue;if(s.is("element","br"))return null;if(this._isInlineObjectElement(s))return s;if(s.is("containerElement")||this._isBlockViewElement(s))return null}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")?e.name=="br"||this.inlineObjectElements.includes(e.name)||!!this._inlineObjectElementMatcher.match(e):!1}_createViewElement(e,t){if(Qe(e))return new Ve(this.document,"$comment");const n=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new J(this.document,n)}_isViewElementWithRawContent(e,t){return t.withChildren!==!1&&e.is("element")&&!!this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return this.renderingMode==="editing"&&this.unsafeElements.includes(t)}_createReplacementDomElement(e,t){const n=this._domDocument.createElement("span");if(n.setAttribute(ds,e),t){for(;t.firstChild;)n.appendChild(t.firstChild);for(const s of t.getAttributeNames())n.setAttribute(s,t.getAttribute(s))}return n}}function Ma(r,e){return r.getAncestors().some(t=>t.is("element")&&e.includes(t.name))}function ms(r,e){let t=r;for(;t;)e(t),t=t.parentElement}function Ia(r,e){return r.isEqualNode(Na)&&gs(r,e)&&r.parentNode.childNodes.length===1}function gs(r,e){const t=r.parentNode;return!!t&&!!t.tagName&&e.includes(t.tagName.toLowerCase())}function Fa(r,e,t){return e=="\xA0"&&r&&r.is("element")&&r.childCount==1&&t.includes(r.name)}function Da(r,e){return e=="\xA0"&&r&&r.is("element","span")&&r.childCount==1&&r.hasAttribute("data-cke-filler")}function ps(r){return r.is("element","br")&&r.hasAttribute("data-cke-filler")}function _s(r,e){return r.tagName==="BR"&&gs(r,e)&&r.parentNode.childNodes.length===1}function ws(r){r==="script"&&G("domconverter-unsafe-script-element-detected"),r==="style"&&G("domconverter-unsafe-style-element-detected")}function Ba(r){if(!F.isGecko||!r.rangeCount)return!1;const e=r.getRangeAt(0).startContainer;try{Object.prototype.toString.call(e)}catch{return!0}return!1}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Se extends oo(){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()}checkShouldIgnoreEventFromTarget(e){return e&&e.nodeType===3&&(e=e.parentNode),!e||e.nodeType!==1?!1:e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ys{view;document;domEvent;domTarget;constructor(e,t,n){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,Qo(this,n)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ie extends Se{useCapture=!1;usePassive=!1;observe(e){(typeof this.domEventType=="string"?[this.domEventType]:this.domEventType).forEach(n=>{this.listenTo(e,n,(s,i)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(i.target)&&this.onDomEvent(i)},{useCapture:this.useCapture,usePassive:this.usePassive})})}stopObserving(e){this.stopListening(e)}fire(e,t,n){this.isEnabled&&this.document.fire(e,new ys(this.view,t,n))}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class bs extends ie{domEventType=["keydown","keyup"];onDomEvent(e){const t={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return ao(this)}};this.fire(e.type,e,t)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class vs extends Se{_fireSelectionChangeDoneDebounced;constructor(e){super(e),this._fireSelectionChangeDoneDebounced=Nn(t=>{this.document.fire("selectionChangeDone",t)},200)}observe(){const e=this.document;e.on("arrowKey",(t,n)=>{e.selection.isFake&&this.isEnabled&&n.preventDefault()},{context:"$capture"}),e.on("arrowKey",(t,n)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(n.keyCode)},{priority:"lowest"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,n=new Q(t.getRanges(),{backward:t.isBackward,fake:!1});(e==be.arrowleft||e==be.arrowup)&&n.setTo(n.getFirstPosition()),(e==be.arrowright||e==be.arrowdown)&&n.setTo(n.getLastPosition());const s={oldSelection:t,newSelection:n,domSelection:null};this.document.fire("selectionChange",s),this._fireSelectionChangeDoneDebounced(s)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Xn extends Se{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){this._mutationObserver.disconnect();for(const t of this._domElements)this._mutationObserver.observe(t,this._config)}}enable(){super.enable();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}disable(){super.disable(),this._mutationObserver.disconnect()}destroy(){super.destroy(),this._mutationObserver.disconnect()}_onMutations(e){if(e.length===0)return;const t=this.domConverter,n=new Set,s=new Set;for(const o of e){const a=t.mapDomToView(o.target);a&&(a.is("uiElement")||a.is("rawElement")||o.type==="childList"&&!this._isBogusBrMutation(o)&&s.add(a))}for(const o of e){const a=t.mapDomToView(o.target);if(!(a&&(a.is("uiElement")||a.is("rawElement")))&&o.type==="characterData"){const l=t.findCorrespondingViewText(o.target);l&&!s.has(l.parent)?n.add(l):!l&&V(o.target)&&s.add(t.mapDomToView(o.target.parentNode))}}const i=[];for(const o of n)i.push({type:"text",node:o});for(const o of s){const a=t.mapViewToDom(o),l=Array.from(o.getChildren()),c=Array.from(t.domChildrenToView(a,{withChildren:!1}));In(l,c,Va)||i.push({type:"children",node:o})}i.length&&this.document.fire("mutations",{mutations:i})}_isBogusBrMutation(e){let t=null;return e.nextSibling===null&&e.removedNodes.length===0&&e.addedNodes.length==1&&(t=this.domConverter.domToView(e.addedNodes[0],{withChildren:!1})),t&&t.is("element","br")}}function Va(r,e){if(!Array.isArray(r))return r===e?!0:r.is("$text")&&e.is("$text")?r.data===e.data:!1}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Xt extends ie{_renderTimeoutId=null;_isFocusChanging=!1;domEventType=["focus","blur"];constructor(e){super(e),this.useCapture=!0;const t=this.document;t.on("focus",()=>this._handleFocus()),t.on("blur",(n,s)=>this._handleBlur(s)),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){const t=this.document.selection.editableElement;(t===null||t===e.target)&&(this.document.isFocused=!1,this._isFocusChanging=!1,this.view.change(()=>{}))}_clearTimeout(){this._renderTimeoutId&&(clearTimeout(this._renderTimeoutId),this._renderTimeoutId=null)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ps extends Se{mutationObserver;focusObserver;selection;domConverter;_documents=new WeakSet;_fireSelectionChangeDoneDebounced;_clearInfiniteLoopInterval;_documentIsSelectingInactivityTimeoutDebounced;_loopbackCounter=0;_pendingSelectionChange=new Set;constructor(e){super(e),this.mutationObserver=e.getObserver(Xn),this.focusObserver=e.getObserver(Xt),this.selection=this.document.selection,this.domConverter=e.domConverter,this._fireSelectionChangeDoneDebounced=Nn(t=>{this.document.fire("selectionChangeDone",t)},200),this._clearInfiniteLoopInterval=setInterval(()=>this._clearInfiniteLoop(),1e3),this._documentIsSelectingInactivityTimeoutDebounced=Nn(()=>this.document.isSelecting=!1,5e3),this.view.document.on("change:isFocused",(t,n,s)=>{if(s&&this._pendingSelectionChange.size){for(const i of Array.from(this._pendingSelectionChange))this._handleSelectionChange(i);this._pendingSelectionChange.clear()}})}observe(e){const t=e.ownerDocument,n=()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()},s=()=>{this.document.isSelecting&&(this._handleSelectionChange(t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",n,{priority:"highest"}),this.listenTo(e,"keydown",s,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",s,{priority:"highest",useCapture:!0}),!this._documents.has(t)&&(this.listenTo(t,"mouseup",s,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",()=>{this.document.isComposing&&!F.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;const t=e.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(t.anchorNode))return;this.mutationObserver.flush();const n=this.domConverter.domSelectionToView(t);if(n.rangeCount==0){this.view.hasDomSelection=!1;return}if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.view.document.isFocused&&!this.view.document.isReadOnly){this._pendingSelectionChange.add(e);return}if(this._pendingSelectionChange.delete(e),!(this.selection.isEqual(n)&&this.domConverter.isDomSelectionCorrect(t))){if(++this._loopbackCounter>60){this._reportInfiniteLoop();return}if(!La(n))this.view.forceRender();else if(this.selection.isSimilar(n))this.view.forceRender();else{const s={oldSelection:this.selection,newSelection:n,domSelection:t};this.document.fire("selectionChange",s),this._fireSelectionChangeDoneDebounced(s)}}}_clearInfiniteLoop(){this._loopbackCounter=0}}function La(r){return Array.from(r.getRanges()).flatMap(e=>[e.start.root,e.end.root]).every(e=>e&&e.is("rootElement"))}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Cs extends ie{domEventType=["compositionstart","compositionupdate","compositionend"];constructor(e){super(e);const 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})}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ss{_files;_native;constructor(e,t={}){this._files=t.cacheFiles?As(e):null,this._native=e}get files(){return this._files||(this._files=As(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,n){this._native.setDragImage(e,t,n)}get isCanceled(){return this._native.dropEffect=="none"||!!this._native.mozUserCancelled}}function As(r){const e=Array.from(r.files||[]),t=Array.from(r.items||[]);return e.length?e:t.filter(n=>n.kind==="file").map(n=>n.getAsFile())}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ks extends ie{domEventType="beforeinput";onDomEvent(e){const t=e.getTargetRanges(),n=this.view,s=n.document;let i=null,o=null,a=[];if(e.dataTransfer&&(i=new Ss(e.dataTransfer)),e.data!==null?o=e.data:i&&(o=i.getData("text/plain")),s.selection.isFake)a=Array.from(s.selection.getRanges()),e.preventDefault();else if(t.length)a=t.map(l=>{let c=n.domConverter.domPositionToView(l.startContainer,l.startOffset);const h=n.domConverter.domPositionToView(l.endContainer,l.endOffset);if(c&&V(l.startContainer)&&l.startOffset<q){e.preventDefault();let u=q-l.startOffset;c=c.getLastMatchingPosition(g=>!!(g.item.is("attributeElement")||g.item.is("uiElement")||g.item.is("$textProxy")&&u--),{direction:"backward",singleCharacters:!0})}if($a(l.endContainer,l.endOffset)&&e.preventDefault(),c)return n.createRange(c,h);if(h)return n.createRange(h)}).filter(l=>!!l);else if(F.isAndroid){const l=e.target.ownerDocument.defaultView.getSelection();a=Array.from(n.domConverter.domSelectionToView(l).getRanges())}if(F.isAndroid&&e.inputType=="insertCompositionText"&&o&&o.endsWith(`
`)){this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[n.createRange(a[0].end)]});return}if(["insertText","insertReplacementText"].includes(e.inputType)&&o&&o.includes(`
`)){const l=o.split(/\n{1,2}/g);let c=a;e.preventDefault();for(let h=0;h<l.length;h++){const u=l[h];u!=""&&(this.fire(e.type,e,{data:u,dataTransfer:i,targetRanges:c,inputType:e.inputType,isComposing:e.isComposing}),c=[s.selection.getFirstRange()]),h+1<l.length&&(this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:c}),c=[s.selection.getFirstRange()])}return}this.fire(e.type,e,{data:o,dataTransfer:i,targetRanges:a,inputType:e.inputType,isComposing:e.isComposing})}}function $a(r,e){for(;r.parentNode;){if(x(r)){if(e!=r.data.length)return!1}else if(e!=r.childNodes.length)return!1;if(e=Ee(r)+1,r=r.parentNode,e<r.childNodes.length&&V(r.childNodes[e]))return!0}return!1}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Wa extends Se{constructor(e){super(e),this.document.on("keydown",(t,n)=>{if(this.isEnabled&&lo(n.keyCode)){const s=new Jt(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(s,n),s.stop.called&&t.stop()}})}observe(){}stopObserving(){}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Es extends Se{constructor(e){super(e);const t=this.document;t.on("keydown",(n,s)=>{if(!this.isEnabled||s.keyCode!=be.tab||s.ctrlKey)return;const i=new Jt(t,"tab",t.selection.getFirstRange());t.fire(i,s),i.stop.called&&n.stop()})}observe(){}stopObserving(){}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class mt extends K(){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 Gt(e),this.domConverter=new Ht(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new us(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new qn(this.document),this.addObserver(Xn),this.addObserver(Xt),this.addObserver(Ps),this.addObserver(bs),this.addObserver(vs),this.addObserver(Cs),this.addObserver(Wa),this.addObserver(ks),this.addObserver(Es),hs(this),os(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}),F.isiOS&&this.listenTo(this.document,"blur",(t,n)=>{this.domConverter.mapDomToView(n.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}),this.listenTo(this.document,"mutations",(t,{mutations:n})=>{n.forEach(s=>this._renderer.markToSync(s.type,s.node))},{priority:"low"}),this.listenTo(this.document,"mutations",()=>{this.forceRender()},{priority:"lowest"})}attachDomRoot(e,t="main"){const n=this.document.getRoot(t);n._name=e.tagName.toLowerCase();const s={};for(const{name:o,value:a}of Array.from(e.attributes))s[o]=a,o==="class"?this._writer.addClass(a.split(" "),n):n.hasAttribute(o)||this._writer.setAttribute(o,a,n);this._initialDomRootAttributes.set(e,s);const i=()=>{this._writer.setAttribute("contenteditable",(!n.isReadOnly).toString(),n),n.isReadOnly?this._writer.addClass("ck-read-only",n):this._writer.removeClass("ck-read-only",n)};i(),this.domRoots.set(t,e),this.domConverter.bindElements(e,n),this._renderer.markToSync("children",n),this._renderer.markToSync("attributes",n),this._renderer.domDocuments.add(e.ownerDocument),n.on("change:children",(o,a)=>this._renderer.markToSync("children",a)),n.on("change:attributes",(o,a)=>this._renderer.markToSync("attributes",a)),n.on("change:text",(o,a)=>this._renderer.markToSync("text",a)),n.on("change:isReadOnly",()=>this.change(i)),n.on("change",()=>{this._hasChangedSinceTheLastRendering=!0});for(const o of this._observers.values())o.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach(({name:s})=>t.removeAttribute(s));const n=this._initialDomRootAttributes.get(t);for(const s in n)t.setAttribute(s,n[s]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t);for(const s of this._observers.values())s.stopObserving(t)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;t=new e(this),this._observers.set(e,t);for(const[n,s]of this.domRoots)t.observe(s,n);return t.enable(),t}getObserver(e){return this._observers.get(e)}disableObservers(){for(const e of this._observers.values())e.disable()}enableObservers(){for(const e of this._observers.values())e.enable()}scrollToTheSelection({alignToTop:e,forceScroll:t,viewportOffset:n=20,ancestorOffset:s=20}={}){const i=this.document.selection.getFirstRange();if(!i)return;const o=te({alignToTop:e,forceScroll:t,viewportOffset:n,ancestorOffset:s});typeof n=="number"&&(n={top:n,bottom:n,left:n,right:n});const a={target:this.domConverter.viewRangeToDom(i),viewportOffset:n,ancestorOffset:s,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",a,o),co(a)}focus(){if(!this.document.isFocused){const e=this.document.selection.editableElement;e&&(this.domConverter.focus(e),this.forceRender())}}change(e){if(this.isRenderingInProgress||this._postFixersInProgress)throw new d("cannot-change-view-tree",this);try{if(this._ongoingChange)return e(this._writer);this._ongoingChange=!0;const t=e(this._writer);return this._ongoingChange=!1,!this._renderingDisabled&&this._hasChangedSinceTheLastRendering&&(this._postFixersInProgress=!0,this.document._callPostFixers(this._writer),this._postFixersInProgress=!1,this.fire("render")),t}catch(t){/* istanbul ignore next -- @preserve */d.rethrowUnexpectedError(t,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Xt).flush(),this.change(()=>{})}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return p._createAt(e,t)}createPositionAfter(e){return p._createAfter(e)}createPositionBefore(e){return p._createBefore(e)}createRange(e,t){return new w(e,t)}createRangeOn(e){return w._createOn(e)}createRangeIn(e){return w._createIn(e)}createSelection(...e){return new Q(...e)}_disableRendering(e){this._renderingDisabled=e,e==!1&&this.change(()=>{})}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class oe{is(){throw new Error("is() method is abstract")}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class H extends oe{textNode;data;offsetInText;constructor(e,t,n){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new d("model-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.offsetSize)throw new d("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+n),this.offsetInText=t}get startOffset(){return this.textNode.startOffset!==null?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return this.startOffset!==null?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}getPath(){const e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={}){const t=[];let n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}H.prototype.is=function(r){return r==="$textProxy"||r==="model:$textProxy"||r==="textProxy"||r==="model:textProxy"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ae{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;_visitedParent;constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new d("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if(t!="forward"&&t!="backward")throw new d("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=m._createAt(this.boundaries[this.direction=="backward"?"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,n,s,i;do s=this.position,i=this._visitedParent,{done:t,value:n}=this.next();while(!t&&e(n));t||(this._position=s,this._visitedParent=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(),this._visitedParent=e.parent}next(){return this.direction=="forward"?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),n=this._visitedParent;if(n.parent===null&&t.offset===n.maxOffset)return{done:!0,value:void 0};if(n===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const s=$e(t,n),i=s||Yn(t,n,s);if(i&&i.is("model:element")){if(!this.shallow)t.path.push(0),this._visitedParent=i;else{if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}return this._position=t,Ae("elementStart",i,e,t,1)}if(i&&i.is("model:$text")){let o;if(this.singleCharacters)o=1;else{let c=i.endOffset;this._boundaryEndParent==n&&this.boundaries.end.offset<c&&(c=this.boundaries.end.offset),o=c-t.offset}const a=t.offset-i.startOffset,l=new H(i,a,o);return t.offset+=o,this._position=t,Ae("text",l,e,t,o)}return t.path.pop(),t.offset++,this._position=t,this._visitedParent=n.parent,this.ignoreElementEnd?this._next():Ae("elementEnd",n,e,t)}_previous(){const e=this.position,t=this.position.clone(),n=this._visitedParent;if(n.parent===null&&t.offset===0)return{done:!0,value:void 0};if(n==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0,value:void 0};const s=t.parent,i=$e(t,s),o=i||Qn(t,s,i);if(o&&o.is("model:element"))return t.offset--,this.shallow?(this._position=t,Ae("elementStart",o,e,t,1)):(t.path.push(o.maxOffset),this._position=t,this._visitedParent=o,this.ignoreElementEnd?this._previous():Ae("elementEnd",o,e,t));if(o&&o.is("model:$text")){let a;if(this.singleCharacters)a=1;else{let h=o.startOffset;this._boundaryStartParent==n&&this.boundaries.start.offset>h&&(h=this.boundaries.start.offset),a=t.offset-h}const l=t.offset-o.startOffset,c=new H(o,l-a,a);return t.offset-=a,this._position=t,Ae("text",c,e,t,a)}return t.path.pop(),this._position=t,this._visitedParent=n.parent,Ae("elementStart",n,e,t,1)}}function Ae(r,e,t,n,s){return{done:!1,value:{type:r,item:e,previousPosition:t,nextPosition:n,length:s}}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class m extends oe{root;path;stickiness;constructor(e,t,n="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new d("model-position-root-invalid",e);if(!Array.isArray(t)||t.length===0)throw new d("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=n}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;t<this.path.length-1;t++)if(e=e.getChildAtOffset(this.path[t]),!e)throw new d("model-position-path-incorrect",this,{position:this});if(e.is("$text"))throw new d("model-position-path-incorrect",this,{position:this});return e}get index(){return this.parent.offsetToIndex(this.offset)}get textNode(){return $e(this,this.parent)}get nodeAfter(){const e=this.parent;return Yn(this,e,$e(this,e))}get nodeBefore(){const e=this.parent;return Qn(this,e,$e(this,e))}get isAtStart(){return this.offset===0}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]),!e)return!1;return this.offset<=e.maxOffset}compareWith(e){if(this.root!=e.root)return"different";const t=$(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"}}getLastMatchingPosition(e,t={}){t.startPosition=this;const n=new ae(t);return n.skip(e),n.position}getParentPath(){return this.path.slice(0,-1)}getAncestors(){const e=this.parent;return e.is("documentFragment")?[e]:e.getAncestors({includeSelf:!0})}findAncestor(e){const t=this.parent;return t.is("element")?t.findAncestor(e,{includeSelf:!0}):null}getCommonPath(e){if(this.root!=e.root)return[];const t=$(this.path,e.path),n=typeof t=="string"?Math.min(this.path.length,e.path.length):t;return this.path.slice(0,n)}getCommonAncestor(e){const t=this.getAncestors(),n=e.getAncestors();let s=0;for(;t[s]==n[s]&&t[s];)s++;return s===0?null:t[s-1]}getShiftedBy(e){const t=this.clone(),n=t.offset+e;return t.offset=n<0?0:n,t}isAfter(e){return this.compareWith(e)=="after"}isBefore(e){return this.compareWith(e)=="before"}isEqual(e){return this.compareWith(e)=="same"}isTouching(e){if(this.root!==e.root)return!1;const t=Math.min(this.path.length,e.path.length);for(let n=0;n<t;n++){const s=this.path[n]-e.path[n];if(s<-1||s>1)return!1;if(s===1)return Rs(e,this,n);if(s===-1)return Rs(this,e,n)}return this.path.length===e.path.length?!0:this.path.length>e.path.length?Zn(this.path,t):Zn(e.path,t)}hasSameParentAs(e){if(this.root!==e.root)return!1;const t=this.getParentPath(),n=e.getParentPath();return $(t,n)=="same"}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=m._createAt(this);break}return t}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){const t=e.movedRange;return t.containsPosition(this)||t.start.isEqual(this)&&this.stickiness=="toNext"?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(e){const t=e.movedRange,n=t.containsPosition(this)||t.start.isEqual(this);let s;return n?(s=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(s=s._getTransformedByDeletion(e.deletionPosition,1))):this.isEqual(e.deletionPosition)?s=m._createAt(e.deletionPosition):s=this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),s}_getTransformedByDeletion(e,t){const n=m._createAt(this);if(this.root!=e.root)return n;if($(e.getParentPath(),this.getParentPath())=="same"){if(e.offset<this.offset){if(e.offset+t>this.offset)return null;n.offset-=t}}else if($(e.getParentPath(),this.getParentPath())=="prefix"){const s=e.path.length-1;if(e.offset<=this.path[s]){if(e.offset+t>this.path[s])return null;n.path[s]-=t}}return n}_getTransformedByInsertion(e,t){const n=m._createAt(this);if(this.root!=e.root)return n;if($(e.getParentPath(),this.getParentPath())=="same")(e.offset<this.offset||e.offset==this.offset&&this.stickiness!="toPrevious")&&(n.offset+=t);else if($(e.getParentPath(),this.getParentPath())=="prefix"){const s=e.path.length-1;e.offset<=this.path[s]&&(n.path[s]+=t)}return n}_getTransformedByMove(e,t,n){if(t=t._getTransformedByDeletion(e,n),e.isEqual(t))return m._createAt(this);const s=this._getTransformedByDeletion(e,n);return s===null||e.isEqual(this)&&this.stickiness=="toNext"||e.getShiftedBy(n).isEqual(this)&&this.stickiness=="toPrevious"?this._getCombined(e,t):s._getTransformedByInsertion(t,n)}_getCombined(e,t){const n=e.path.length-1,s=m._createAt(t);return s.stickiness=this.stickiness,s.offset=s.offset+this.path[n]-e.offset,s.path=[...s.path,...this.path.slice(n+1)],s}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,n="toNone"){if(e.is("model:position"))return new m(e.root,e.path,e.stickiness);{const s=e;if(t=="end")t=s.maxOffset;else{if(t=="before")return this._createBefore(s,n);if(t=="after")return this._createAfter(s,n);if(t!==0&&!t)throw new d("model-createpositionat-offset-required",[this,e])}if(!s.is("element")&&!s.is("documentFragment"))throw new d("model-position-parent-incorrect",[this,e]);const i=s.getPath();return i.push(t),new this(s.root,i,n)}}static _createAfter(e,t){if(!e.parent)throw new d("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 d("model-position-before-root",e,{root:e});return this._createAt(e.parent,e.startOffset,t)}static fromJSON(e,t){if(e.root==="$graveyard"){const n=new m(t.graveyard,e.path);return n.stickiness=e.stickiness,n}if(!t.getRoot(e.root))throw new d("model-position-fromjson-no-root",t,{rootName:e.root});return new m(t.getRoot(e.root),e.path,e.stickiness)}}m.prototype.is=function(r){return r==="position"||r==="model:position"};function $e(r,e){const t=e.getChildAtOffset(r.offset);return t&&t.is("$text")&&t.startOffset<r.offset?t:null}function Yn(r,e,t){return t!==null?null:e.getChildAtOffset(r.offset)}function Qn(r,e,t){return t!==null?null:e.getChild(e.offsetToIndex(r.offset)-1)}function Rs(r,e,t){return!(t+1===r.path.length||!Zn(e.path,t+1)||!qa(r,t+1))}function Zn(r,e){for(;e<r.length;){if(r[e]!==0)return!1;e++}return!0}function qa(r,e){let t=r.parent,n=r.path.length-1,s=0;for(;n>=e;){if(r.path[n]+s!==t.maxOffset)return!1;s=1,n--,t=t.parent}return!0}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class f extends oe{start;end;constructor(e,t){super(),this.start=m._createAt(e),this.end=t?m._createAt(t):m._createAt(e),this.start.stickiness=this.isCollapsed?"toNone":"toNext",this.end.stickiness=this.isCollapsed?"toNone":"toPrevious"}*[Symbol.iterator](){yield*new ae({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){const e=this.start.getParentPath(),t=this.end.getParentPath();return $(e,t)=="same"}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);const n=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),s=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return n&&s}containsItem(e){const t=m._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){const t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new f(this.start,e.start)),this.containsPosition(e.end)&&t.push(new f(e.end,this.end))):t.push(new f(this.start,this.end)),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,n=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(n=e.end),new f(t,n)}return null}getJoined(e,t=!1){let n=this.isIntersecting(e);if(n||(this.start.isBefore(e.start)?n=t?this.end.isTouching(e.start):this.end.isEqual(e.start):n=t?e.end.isTouching(this.start):e.end.isEqual(this.start)),!n)return null;let s=this.start,i=this.end;return e.start.isBefore(s)&&(s=e.start),e.end.isAfter(i)&&(i=e.end),new f(s,i)}getMinimalFlatRanges(){const e=[],t=this.start.getCommonPath(this.end).length,n=m._createAt(this.start);let s=n.parent;for(;n.path.length>t+1;){const i=s.maxOffset-n.offset;i!==0&&e.push(new f(n,n.getShiftedBy(i))),n.path=n.path.slice(0,-1),n.offset++,s=s.parent}for(;n.path.length<=this.end.path.length;){const i=this.end.path[n.path.length-1],o=i-n.offset;o!==0&&e.push(new f(n,n.getShiftedBy(o))),n.offset=i,n.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new ae(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new ae(e);for(const n of t)yield n.item}*getPositions(e={}){e.boundaries=this;const t=new ae(e);yield t.position;for(const n of t)yield n.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 f(this.start,this.end)]}getTransformedByOperations(e){const t=[new f(this.start,this.end)];for(const n of e)for(let s=0;s<t.length;s++){const i=t[s].getTransformedByOperation(n);t.splice(s,1,...i),s+=i.length-1}for(let n=0;n<t.length;n++){const s=t[n];for(let i=n+1;i<t.length;i++){const o=t[i];(s.containsRange(o)||o.containsRange(s)||s.isEqual(o))&&t.splice(i,1)}}return t}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;const 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){const n=e.sourcePosition,s=e.howMany,i=e.targetPosition;return this._getTransformedByMove(n,i,s,t)}_getTransformedBySplitOperation(e){const t=this.start._getTransformedBySplitOperation(e);let n=this.end._getTransformedBySplitOperation(e);return this.end.isEqual(e.insertionPosition)&&(n=this.end.getShiftedBy(1)),t.root!=n.root&&(n=this.end.getShiftedBy(-1)),new f(t,n)}_getTransformedByMergeOperation(e){if(this.start.isEqual(e.targetPosition)&&this.end.isEqual(e.deletionPosition))return new f(this.start);let t=this.start._getTransformedByMergeOperation(e),n=this.end._getTransformedByMergeOperation(e);return t.root!=n.root&&(n=this.end.getShiftedBy(-1)),t.isAfter(n)?(e.sourcePosition.isBefore(e.targetPosition)?(t=m._createAt(n),t.offset=0):(e.deletionPosition.isEqual(t)||(n=e.deletionPosition),t=e.targetPosition),new f(t,n)):new f(t,n)}_getTransformedByInsertion(e,t,n=!1){if(n&&this.containsPosition(e))return[new f(this.start,e),new f(e.getShiftedBy(t),this.end._getTransformedByInsertion(e,t))];{const s=new f(this.start,this.end);return s.start=s.start._getTransformedByInsertion(e,t),s.end=s.end._getTransformedByInsertion(e,t),[s]}}_getTransformedByMove(e,t,n,s=!1){if(this.isCollapsed){const u=this.start._getTransformedByMove(e,t,n);return[new f(u)]}const i=f._createFromPositionAndShift(e,n),o=t._getTransformedByDeletion(e,n);if(this.containsPosition(t)&&!s&&(i.containsPosition(this.start)||i.containsPosition(this.end))){const u=this.start._getTransformedByMove(e,t,n),g=this.end._getTransformedByMove(e,t,n);return[new f(u,g)]}let a;const l=this.getDifference(i);let c=null;const h=this.getIntersection(i);if(l.length==1?c=new f(l[0].start._getTransformedByDeletion(e,n),l[0].end._getTransformedByDeletion(e,n)):l.length==2&&(c=new f(this.start,this.end._getTransformedByDeletion(e,n))),c?a=c._getTransformedByInsertion(o,n,h!==null||s):a=[],h){const u=new f(h.start._getCombined(i.start,o),h.end._getCombined(i.start,o));a.length==2?a.splice(1,0,u):a.push(u)}return a}_getTransformedByDeletion(e,t){let n=this.start._getTransformedByDeletion(e,t),s=this.end._getTransformedByDeletion(e,t);return n==null&&s==null?null:(n==null&&(n=e),s==null&&(s=e),new f(n,s))}static _createFromPositionAndShift(e,t){const n=e,s=e.getShiftedBy(t);return t>0?new this(n,s):new this(s,n)}static _createIn(e){return new this(m._createAt(e,0),m._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(m._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(e.length===0)throw new d("range-create-from-ranges-empty-array",null);if(e.length==1)return e[0].clone();const t=e[0];e.sort((i,o)=>i.start.isAfter(o.start)?1:-1);const n=e.indexOf(t),s=new this(t.start,t.end);for(let i=n-1;i>=0&&e[i].end.isEqual(s.start);i--)s.start=m._createAt(e[i].start);for(let i=n+1;i<e.length&&e[i].start.isEqual(s.end);i++)s.end=m._createAt(e[i].end);return s}static fromJSON(e,t){return new this(m.fromJSON(e.start,t),m.fromJSON(e.end,t))}}f.prototype.is=function(r){return r==="range"||r==="model:range"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class gt extends I(){_modelToViewMapping=new WeakMap;_viewToModelMapping=new WeakMap;_viewToModelLengthCallbacks=new Map;_markerNameToElements=new Map;_elementToMarkerNames=new Map;_deferredBindingRemovals=new Map;_unboundMarkerNames=new Set;_cache=new Ts;constructor(){super(),this.on("modelToViewPosition",(e,t)=>{if(t.viewPosition)return;const n=this._modelToViewMapping.get(t.modelPosition.parent);if(!n)throw new d("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(n,t.modelPosition.offset)},{priority:"low"}),this.on("viewToModelPosition",(e,t)=>{if(t.modelPosition)return;const n=this.findMappedViewAncestor(t.viewPosition),s=this._viewToModelMapping.get(n),i=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,n);t.modelPosition=m._createAt(s,i)},{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const n=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const s of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(s);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e)&&this._cache.stopTracking(e),this._modelToViewMapping.get(n)==e&&this._modelToViewMapping.delete(n))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)&&this._cache.stopTracking(t)}bindElementToMarker(e,t){const n=this._markerNameToElements.get(t)||new Set;n.add(e);const s=this._elementToMarkerNames.get(e)||new Set;s.add(t),this._markerNameToElements.set(t,n),this._elementToMarkerNames.set(e,s)}unbindElementFromMarkerName(e,t){const n=this._markerNameToElements.get(t);n&&(n.delete(e),n.size==0&&this._markerNameToElements.delete(t));const s=this._elementToMarkerNames.get(e);s&&(s.delete(t),s.size==0&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){const e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(const[e,t]of this._deferredBindingRemovals)e.root==t&&this.unbindViewElement(e);this._deferredBindingRemovals=new Map}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this._deferredBindingRemovals=new Map}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new f(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new w(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){const t={viewPosition:e,mapper:this};return this.fire("viewToModelPosition",t),t.modelPosition}toViewPosition(e,t={}){const n={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",n),n.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const n=new Set;for(const s of t)if(s.is("attributeElement"))for(const i of s.getElementsWithSameId())n.add(i);else n.add(s);return n}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,n){if(n!=e){const i=this._toModelOffset(e.parent,e.index,n),o=this._toModelOffset(e,t,e);return i+o}if(e.is("$text"))return t;let s=0;for(let i=0;i<t;i++)s+=this.getModelLength(e.getChild(i));return s}getModelLength(e){const t=[e];let n=0;for(;t.length>0;){const s=t.pop(),i=s.name&&this._viewToModelLengthCallbacks.size>0&&this._viewToModelLengthCallbacks.get(s.name);if(i)n+=i(s);else if(this._viewToModelMapping.has(s))n+=1;else if(s.is("$text"))n+=s.data.length;else{if(s.is("uiElement"))continue;for(const o of s.getChildren())t.push(o)}}return n}findPositionIn(e,t){if(t===0)return this._moveViewPositionToTextNode(new p(e,0));if(this._viewToModelLengthCallbacks.size==0&&this._viewToModelMapping.has(e)){const s=this._cache.getClosest(e,t);return this._findPositionStartingFrom(s.viewPosition,s.modelOffset,t,e,!0)}else return this._findPositionStartingFrom(new p(e,0),0,t,e,!1)}_findPositionStartingFrom(e,t,n,s,i){let o=e.parent,a=e.offset;if(o.is("$text"))return new p(o,n-t);let l,c=t,h=0;for(;c<n;){if(l=o.getChild(a),!l){if(o==s)throw new d("mapping-model-offset-not-found",this,{modelOffset:n,viewContainer:s});a=o.parent.getChildIndex(o)+1,o=o.parent,i&&this._cache.save(o,a,s,c);continue}i?h=this._getModelLengthAndCache(l,s,c):h=this.getModelLength(l),c+=h,a++}let u=new p(o,a);if(i)for(;u.isAtEnd&&u.parent!==s&&u.parent.parent;){const g=u.parent.parent,_=g.getChildIndex(u.parent)+1;this._cache.save(g,_,s,c),u=new p(g,_)}return c==n?this._moveViewPositionToTextNode(u):this._findPositionStartingFrom(new p(l,0),c-h,n,s,i)}_getModelLengthAndCache(e,t,n){let s=0;if(this._viewToModelMapping.has(e))s=1;else if(e.is("$text"))s=e.data.length;else if(!e.is("uiElement"))for(const i of e.getChildren())s+=this._getModelLengthAndCache(i,t,n+s);return this._cache.save(e.parent,e.index+1,t,n+s),s}_moveViewPositionToTextNode(e){const t=e.nodeBefore,n=e.nodeAfter;return t&&t.is("view:$text")?new p(t,t.data.length):n&&n.is("view:$text")?new p(n,0):e}}class Ts extends I(){_cachedMapping=new WeakMap;_nodeToCacheListIndex=new WeakMap;_invalidateOnChildrenChangeCallback=(e,t,n)=>{this._clearCacheInsideParent(t,n.index)};_invalidateOnTextChangeCallback=(e,t)=>{this._clearCacheAfter(t)};save(e,t,n,s){const i=this._cachedMapping.get(n),o=i.cacheMap.get(s);if(o){const h=e.getChild(t-1),u=o.viewPosition.nodeBefore?this._nodeToCacheListIndex.get(o.viewPosition.nodeBefore):0;this._nodeToCacheListIndex.set(h,u);return}const l={viewPosition:new p(e,t),modelOffset:s};i.maxModelOffset=s>i.maxModelOffset?s:i.maxModelOffset,i.cacheMap.set(s,l);let c=i.cacheList.length-1;for(;c>=0&&i.cacheList[c].modelOffset>s;)c--;if(i.cacheList.splice(c+1,0,l),t>0){const h=e.getChild(t-1);this._nodeToCacheListIndex.set(h,c+1)}}getClosest(e,t){const n=this._cachedMapping.get(e);let s;if(n)if(t>n.maxModelOffset)s=n.cacheList[n.cacheList.length-1];else{const i=n.cacheMap.get(t);i?s=i:s=this._findInCacheList(n.cacheList,t)}else s=this.startTracking(e);return{modelOffset:s.modelOffset,viewPosition:s.viewPosition.clone()}}startTracking(e){const n={viewPosition:new p(e,0),modelOffset:0},s={maxModelOffset:0,cacheList:[n],cacheMap:new Map([[0,n]])};return this._cachedMapping.set(e,s),e.on("change:children",this._invalidateOnChildrenChangeCallback),e.on("change:text",this._invalidateOnTextChangeCallback),n}stopTracking(e){e.off("change:children",this._invalidateOnChildrenChangeCallback),e.off("change:text",this._invalidateOnTextChangeCallback),this._cachedMapping.delete(e)}_clearCacheInsideParent(e,t){if(t==0)this._cachedMapping.has(e)?this._clearCacheAll(e):this._clearCacheInsideParent(e.parent,e.index);else{const n=e.getChild(t-1);this._clearCacheAfter(n)}}_clearCacheAll(e){const 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){const t=this._nodeToCacheListIndex.get(e);if(t===void 0){const s=e.parent;this._cachedMapping.has(s)||this._clearCacheInsideParent(s.parent,s.index);return}let n=e.parent;for(;!this._cachedMapping.has(n);)n=n.parent;this._clearCacheFromCacheIndex(n,t)}_clearCacheFromCacheIndex(e,t){t===0&&(t=1);const n=this._cachedMapping.get(e),s=n.cacheList[t-1];if(!s)return;n.maxModelOffset=s.modelOffset;const i=n.cacheList.splice(t);for(const o of i){n.cacheMap.delete(o.modelOffset);const a=o.viewPosition.nodeBefore;this._nodeToCacheListIndex.delete(a)}}_findInCacheList(e,t){let n=0,s=e.length-1,i=s-n>>1,o=e[i];for(;n<s;)o.modelOffset<t?n=i+1:s=i-1,i=n+(s-n>>1),o=e[i];return o.modelOffset<=t?o:e[i-1]}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ua{_consumable=new Map;_textProxyRegistry=new Map;add(e,t){t=Yt(t),e instanceof H&&(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=Yt(t),e instanceof H&&(e=this._getSymbolForTextProxy(e)),this.test(e,t)?(this._consumable.get(e).set(t,!1),!0):!1}test(e,t){t=Yt(t),e instanceof H&&(e=this._getSymbolForTextProxy(e));const n=this._consumable.get(e);if(n===void 0)return null;const s=n.get(t);return s===void 0?null:s}revert(e,t){t=Yt(t),e instanceof H&&(e=this._getSymbolForTextProxy(e));const n=this.test(e,t);return n===!1?(this._consumable.get(e).set(t,!0),!0):n===!0?!1:null}verifyAllConsumed(e){const t=[];for(const[n,s]of this._consumable)for(const[i,o]of s){const a=i.split(":")[0];o&&e==a&&t.push({event:i,item:n.name||n.description})}if(t.length)throw new d("conversion-model-consumable-not-consumed",null,{items:t})}_getSymbolForTextProxy(e){let t=null;const n=this._textProxyRegistry.get(e.startOffset);if(n){const s=n.get(e.endOffset);s&&(t=s.get(e.parent))}return t||(t=this._addSymbolForTextProxy(e)),t}_addSymbolForTextProxy(e){const t=e.startOffset,n=e.endOffset,s=e.parent,i=Symbol("$textProxy:"+e.data);let o,a;return o=this._textProxyRegistry.get(t),o||(o=new Map,this._textProxyRegistry.set(t,o)),a=o.get(n),a||(a=new Map,o.set(n,a)),a.set(s,i),i}}function Yt(r){const e=r.split(":");return e[0]=="insert"?e[0]:e[0]=="addMarker"||e[0]=="removeMarker"?r:e.length>1?e[0]+":"+e[1]:e[0]}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class er extends I(){_conversionApi;_firedEventsMap;constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,n){const s=e.getRefreshedItems(),i=this._createConversionApi(n,s);for(const a of e.getMarkersToRemove())this._convertMarkerRemove(a.name,a.range,i);const o=this._reduceChanges(e.getChanges(),s);for(const a of o)a.type==="insert"?this._convertInsert(f._createFromPositionAndShift(a.position,a.length),i):a.type==="reinsert"?this._convertReinsert(f._createFromPositionAndShift(a.position,a.length),i):a.type==="remove"?this._convertRemove(a.position,a.length,a.name,i):this._convertAttribute(a.range,a.attributeKey,a.attributeOldValue,a.attributeNewValue,i);i.mapper.flushDeferredBindings();for(const a of i.mapper.flushUnboundMarkerNames()){const l=t.get(a).getRange();this._convertMarkerRemove(a,l,i),this._convertMarkerAdd(a,l,i)}for(const a of e.getMarkersToAdd())this._convertMarkerAdd(a.name,a.range,i);i.consumable.verifyAllConsumed("insert")}convert(e,t,n,s={}){const i=this._createConversionApi(n,void 0,s);this._convertInsert(e,i);for(const[o,a]of t)this._convertMarkerAdd(o,a,i);i.consumable.verifyAllConsumed("insert")}convertSelection(e,t,n){const s=this._createConversionApi(n);this.fire("cleanSelection",{selection:e},s);const i=e.getFirstPosition().root;if(!s.mapper.toViewElement(i))return;const o=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(s.consumable,e,o),this.fire("selection",{selection:e},s),!!e.isCollapsed){for(const a of o)if(s.consumable.test(e,"addMarker:"+a.name)){const l=a.getRange();if(!za(e.getFirstPosition(),a,s.mapper))continue;const c={item:e,markerName:a.name,markerRange:l};this.fire(`addMarker:${a.name}`,c,s)}for(const a of e.getAttributeKeys())if(s.consumable.test(e,"attribute:"+a)){const l={item:e,range:e.getFirstRange(),attributeKey:a,attributeOldValue:null,attributeNewValue:e.getAttribute(a)};this.fire(`attribute:${a}:$text`,l,s)}}}_convertInsert(e,t,n={}){n.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,e);for(const s of e.getWalker({shallow:!0}))this._testAndFire("insert",xs(s),t)}_convertRemove(e,t,n,s){this.fire(`remove:${n}`,{position:e,length:t},s)}_convertAttribute(e,t,n,s,i){this._addConsumablesForRange(i.consumable,e,`attribute:${t}`);for(const o of e){const a={item:o.item,range:f._createFromPositionAndShift(o.previousPosition,o.length),attributeKey:t,attributeOldValue:n,attributeNewValue:s};this._testAndFire(`attribute:${t}`,a,i)}}_convertReinsert(e,t){const n=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,n);for(const s of n.map(xs))this.fire(`remove:${s.item.is("element")?s.item.name:"$text"}`,{position:s.range.start,length:s.item.offsetSize,reconversion:!0},t),this._testAndFire("insert",{...s,reconversion:!0},t)}_convertMarkerAdd(e,t,n){if(t.root.rootName=="$graveyard")return;const s=`addMarker:${e}`;if(n.consumable.add(t,s),this.fire(s,{markerName:e,markerRange:t},n),!!n.consumable.consume(t,s)){this._addConsumablesForRange(n.consumable,t,s);for(const i of t.getItems()){if(!n.consumable.test(i,s))continue;const o={item:i,range:f._createOn(i),markerName:e,markerRange:t};this.fire(s,o,n)}}}_convertMarkerRemove(e,t,n){t.root.rootName!="$graveyard"&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},n)}_reduceChanges(e,t){const n={changes:e,refreshedItems:t};return this.fire("reduceChanges",n),n.changes}_addConsumablesForInsert(e,t){for(const n of t){const s=n.item;if(e.test(s,"insert")===null){e.add(s,"insert");for(const i of s.getAttributeKeys())e.add(s,"attribute:"+i)}}return e}_addConsumablesForRange(e,t,n){for(const s of t.getItems())e.add(s,n);return e}_addConsumablesForSelection(e,t,n){e.add(t,"selection");for(const s of n)e.add(t,"addMarker:"+s.name);for(const s of t.getAttributeKeys())e.add(t,"attribute:"+s);return e}_testAndFire(e,t,n){const s=Ja(e,t),i=t.item.is("$textProxy")?n.consumable._getSymbolForTextProxy(t.item):t.item,o=this._firedEventsMap.get(n),a=o.get(i);if(!a)o.set(i,new Set([s]));else if(!a.has(s))a.add(s);else return;this.fire(s,t,n)}_testAndFireAddAttributes(e,t){const n={item:e,range:f._createOn(e)};for(const s of n.item.getAttributeKeys())n.attributeKey=s,n.attributeOldValue=null,n.attributeNewValue=n.item.getAttribute(s),this._testAndFire(`attribute:${s}`,n,t)}_createConversionApi(e,t=new Set,n={}){const s={...this._conversionApi,consumable:new Ua,writer:e,options:n,convertItem:i=>this._convertInsert(f._createOn(i),s),convertChildren:i=>this._convertInsert(f._createIn(i),s,{doNotAddConsumables:!0}),convertAttributes:i=>this._testAndFireAddAttributes(i,s),canReuseView:i=>!t.has(s.mapper.toModelElement(i))};return this._firedEventsMap.set(s,new Map),s}}function za(r,e,t){const n=e.getRange(),s=Array.from(r.getAncestors());return s.shift(),s.reverse(),!s.some(o=>{if(n.containsItem(o))return!!t.toViewElement(o).getCustomProperty("addHighlight")})}function Ja(r,e){const t=e.item.is("element")?e.item.name:"$text";return`${r}:${t}`}function xs(r){return{item:r.item,range:f._createFromPositionAndShift(r.previousPosition,r.length)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class we extends oe{parent=null;_attrs;_index=null;_startOffset=null;constructor(e){super(),this._attrs=he(e)}get document(){return null}get index(){return this._index}get startOffset(){return this._startOffset}get offsetSize(){return 1}get endOffset(){return this.startOffset===null?null:this.startOffset+this.offsetSize}get nextSibling(){const e=this.index;return e!==null&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return e!==null&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.parent===null?!1:this.root.isAttached()}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={}){const t=[];let n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}getCommonAncestor(e,t={}){const n=this.getAncestors(t),s=e.getAncestors(t);let i=0;for(;n[i]==s[i]&&n[i];)i++;return i===0?null:n[i-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;const t=this.getPath(),n=e.getPath(),s=$(t,n);switch(s){case"prefix":return!0;case"extension":return!1;default:return t[s]<n[s]}}isAfter(e){return this==e||this.root!==e.root?!1:!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(){const e={};return this._attrs.size&&(e.attributes=Array.from(this._attrs).reduce((t,n)=>(t[n[0]]=n[1],t),{})),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=he(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}}we.prototype.is=function(r){return r==="node"||r==="model:node"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class O extends I(oe){_lastRangeBackward=!1;_attrs=new Map;_ranges=[];constructor(...e){super(),e.length&&this.setTo(...e)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return this._ranges.length===1?this._ranges[0].isCollapsed:!1}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(this.rangeCount===0)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let n=!1;for(const s of e._ranges)if(t.isEqual(s)){n=!0;break}if(!n)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new f(e.start,e.end)}getFirstRange(){let e=null;for(const t of this._ranges)(!e||t.start.isBefore(e.start))&&(e=t);return e?new f(e.start,e.end):null}getLastRange(){let e=null;for(const t of this._ranges)(!e||t.end.isAfter(e.end))&&(e=t);return e?new f(e.start,e.end):null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}setTo(...e){let[t,n,s]=e;if(typeof n=="object"&&(s=n,n=void 0),t===null)this._setRanges([]);else if(t instanceof O)this._setRanges(t.getRanges(),t.isBackward);else if(t&&typeof t.getRanges=="function")this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof f)this._setRanges([t],!!s&&!!s.backward);else if(t instanceof m)this._setRanges([new f(t)]);else if(t instanceof we){const i=!!s&&!!s.backward;let o;if(n=="in")o=f._createIn(t);else if(n=="on")o=f._createOn(t);else if(n!==void 0)o=new f(m._createAt(t,n));else throw new d("model-selection-setto-required-second-parameter",[this,t]);this._setRanges([o],i)}else if(ue(t))this._setRanges(t,s&&!!s.backward);else throw new d("model-selection-setto-not-selectable",[this,t])}_setRanges(e,t=!1){const n=Array.from(e),s=n.some(i=>{if(!(i instanceof f))throw new d("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every(o=>!o.isEqual(i))});n.length===this._ranges.length&&!s||(this._replaceAllRanges(n),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(this.anchor===null)throw new d("model-selection-setfocus-no-ranges",[this,e]);const n=m._createAt(e,t);if(n.compareWith(this.focus)=="same")return;const s=this.anchor;this._ranges.length&&this._popRange(),n.compareWith(s)=="before"?(this._pushRange(new f(n,s)),this._lastRangeBackward=!0):(this._pushRange(new f(s,n)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const n=Os(t.start,e);Ga(n,t)&&(yield n);const s=t.getWalker();for(const o of s){const a=o.item;o.type=="elementEnd"&&ja(a,e,t)?yield a:o.type=="elementStart"&&a.is("model:element")&&a.root.document.model.schema.isBlock(a)&&s.jumpTo(m._createAt(a,"end"))}const i=Os(t.end,e);Ka(i,t)&&(yield i)}}containsEntireContent(e=this.anchor.root){const t=m._createAt(e,0),n=m._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&n.isTouching(this.getLastPosition())}toJSON(){const e={ranges:Array.from(this.getRanges()).map(n=>n.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 f(e.start,e.end))}_checkRange(e){for(let t=0;t<this._ranges.length;t++)if(e.isIntersecting(this._ranges[t]))throw new d("model-selection-range-intersects",[this,e],{addedRange:e,intersectingRange:this._ranges[t]})}_replaceAllRanges(e){this._removeAllRanges();for(const t of e)this._pushRange(t)}_removeAllRanges(){for(;this._ranges.length>0;)this._popRange()}_popRange(){this._ranges.pop()}}O.prototype.is=function(r){return r==="selection"||r==="model:selection"};function Ns(r,e){return e.has(r)?!1:(e.add(r),r.root.document.model.schema.isBlock(r)&&!!r.parent)}function ja(r,e,t){return Ns(r,e)&&tr(r,t)}function Os(r,e){const n=r.parent.root.document.model.schema,s=r.parent.getAncestors({parentFirst:!0,includeSelf:!0});let i=!1;const o=s.find(a=>i?!1:(i=n.isLimit(a),!i&&Ns(a,e)));return s.forEach(a=>e.add(a)),o}function tr(r,e){const t=Ha(r);return t?!e.containsRange(f._createOn(t),!0):!0}function Ga(r,e){return r?e.isCollapsed||r.isEmpty?!0:e.start.isTouching(m._createAt(r,r.maxOffset))?!1:tr(r,e):!1}function Ka(r,e){return r?e.isCollapsed||r.isEmpty?!0:e.end.isTouching(m._createAt(r,0))?!1:tr(r,e):!1}function Ha(r){const e=r.root.document.model.schema;let t=r.parent;for(;t;){if(e.isBlock(t))return t;t=t.parent}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ye extends I(f){constructor(e,t){super(e,t),Xa.call(this)}detach(){this.stopListening()}toRange(){return new f(this.start,this.end)}static fromRange(e){return new ye(e.start,e.end)}}ye.prototype.is=function(r){return r==="liveRange"||r==="model:liveRange"||r=="range"||r==="model:range"};function Xa(){this.listenTo(this.root.document.model,"applyOperation",(r,e)=>{const t=e[0];t.isDocumentOperation&&Ya.call(this,t)},{priority:"low"})}function Ya(r){const e=this.getTransformedByOperation(r),t=f._createFromRanges(e),n=!t.isEqual(this),s=Qa(this,r);let i=null;if(n){t.root.rootName=="$graveyard"&&(r.type=="remove"?i=r.sourcePosition:i=r.deletionPosition);const o=this.toRange();this.start=t.start,this.end=t.end,this.fire("change:range",o,{deletionPosition:i})}else s&&this.fire("change:content",this.toRange(),{deletionPosition:i})}function Qa(r,e){switch(e.type){case"insert":return r.containsPosition(e.position);case"move":case"remove":case"reinsert":case"merge":return r.containsPosition(e.sourcePosition)||r.start.isEqual(e.sourcePosition)||r.containsPosition(e.targetPosition);case"split":return r.containsPosition(e.splitPosition)||r.containsPosition(e.insertionPosition)}return!1}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class S extends we{_data;constructor(e,t){super(t),this._data=e||""}get offsetSize(){return this.data.length}get data(){return this._data}toJSON(){const e=super.toJSON();return e.data=this.data,e}_clone(){return new S(this.data,this.getAttributes())}static fromJSON(e){return new S(e.data,e.attributes)}}S.prototype.is=function(r){return r==="$text"||r==="model:$text"||r==="text"||r==="model:text"||r==="node"||r==="model:node"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const pt="selection:";class U extends I(oe){_selection;constructor(e){super(),this._selection=new Za(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 pt+e}static _isStoreAttributeKey(e){return e.startsWith(pt)}}U.prototype.is=function(r){return r==="selection"||r=="model:selection"||r=="documentSelection"||r=="model:documentSelection"};class Za extends O{markers=new fn({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",(t,n)=>{const s=n[0];!s.isDocumentOperation||s.type=="marker"||s.type=="rename"||s.type=="noop"||(this._ranges.length==0&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))},{priority:"lowest"}),this.on("change:range",()=>{this._validateSelectionRanges(this.getRanges())}),this.listenTo(this._model.markers,"update",(t,n,s,i)=>{this._updateMarker(n,i)}),this.listenTo(this._document,"change",(t,n)=>{el(this._model,n)})}get isCollapsed(){return this._ranges.length===0?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){if(this._setAttribute(e,t)){const n=[e];this.fire("change:attribute",{attributeKeys:n,directChange:!0})}}removeAttribute(e){if(this._removeAttribute(e)){const t=[e];this.fire("change:attribute",{attributeKeys:t,directChange:!0})}}overrideGravity(){const e=ho();return this._overriddenGravityRegister.add(e),this._overriddenGravityRegister.size===1&&this._updateAttributes(!0),e}restoreGravity(e){if(!this._overriddenGravityRegister.has(e))throw new d("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){const t=this._prepareRange(e);t&&this._ranges.push(t)}toJSON(){const e=super.toJSON();return this.markers.length&&(e.markers=this.markers.map(t=>t.toJSON())),e}_validateSelectionRanges(e){for(const t of e)if(!this._document._validateSelectionRange(t))throw new d("document-selection-wrong-position",this,{range:t})}_prepareRange(e){if(this._checkRange(e),e.root==this._document.graveyard)return;const t=ye.fromRange(e);return t.on("change:range",(n,s,i)=>{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=i.deletionPosition;const o=this._ranges.indexOf(t);this._ranges.splice(o,1),t.detach()}}),t}updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const s of this._model.markers){const i=s.name.split(":",1)[0];if(!this._observedMarkers.has(i))continue;const o=s.getRange();for(const a of this.getRanges())o.containsRange(a,!a.isCollapsed)&&e.push(s)}const n=Array.from(this.markers);for(const s of e)this.markers.has(s)||(this.markers.add(s),t=!0);for(const s of Array.from(this.markers))e.includes(s)||(this.markers.remove(s),t=!0);t&&this.fire("change:marker",{oldMarkers:n,directChange:!1})}_updateMarker(e,t){const n=e.name.split(":",1)[0];if(!this._observedMarkers.has(n))return;let s=!1;const i=Array.from(this.markers),o=this.markers.has(e);if(!t)o&&(this.markers.remove(e),s=!0);else{let a=!1;for(const l of this.getRanges())if(t.containsRange(l,!l.isCollapsed)){a=!0;break}a&&!o?(this.markers.add(e),s=!0):!a&&o&&(this.markers.remove(e),s=!0)}s&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateAttributes(e){const t=he(this._getSurroundingAttributes()),n=he(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[i,o]of this._attributePriority)o=="low"&&(this._attrs.delete(i),this._attributePriority.delete(i));this._setAttributesTo(t);const s=[];for(const[i,o]of this.getAttributes())(!n.has(i)||n.get(i)!==o)&&s.push(i);for(const[i]of n)this.hasAttribute(i)||s.push(i);s.length>0&&this.fire("change:attribute",{attributeKeys:s,directChange:!1})}_setAttribute(e,t,n=!0){const s=n?"normal":"low";return s=="low"&&this._attributePriority.get(e)=="normal"||super.getAttribute(e)===t?!1:(this._attrs.set(e,t),this._attributePriority.set(e,s),!0)}_removeAttribute(e,t=!0){const n=t?"normal":"low";return n=="low"&&this._attributePriority.get(e)=="normal"||(this._attributePriority.set(e,n),!super.hasAttribute(e))?!1:(this._attrs.delete(e),!0)}_setAttributesTo(e){const t=new Set;for(const[n,s]of this.getAttributes())e.get(n)!==s&&this._removeAttribute(n,!1);for(const[n,s]of e)this._setAttribute(n,s,!1)&&t.add(n);return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())t.startsWith(pt)&&(yield[t.substr(pt.length),e.getAttribute(t)])}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;if(e.root.rootName=="$graveyard")return null;let n=null;if(this.isCollapsed){const s=e.textNode?e.textNode:e.nodeBefore,i=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(n=_t(s,t)),n||(n=_t(i,t)),!this.isGravityOverridden&&!n){let o=s;for(;o&&!n;)o=o.previousSibling,n=_t(o,t)}if(!n){let o=i;for(;o&&!n;)o=o.nextSibling,n=_t(o,t)}n||(n=this.getStoredAttributes())}else{const s=this.getFirstRange();for(const i of s){if(i.item.is("element")&&t.isObject(i.item)){n=_t(i.item,t);break}if(i.type=="text"){n=i.item.getAttributes();break}}}return n}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function _t(r,e){if(!r)return null;if(r instanceof H||r instanceof S)return r.getAttributes();if(!e.isInline(r))return null;if(!e.isObject(r))return[];const t=[];for(const[n,s]of r.getAttributes())e.checkAttribute("$text",n)&&e.getAttributeProperties(n).copyFromObject!==!1&&t.push([n,s]);return t}function el(r,e){const t=r.document.differ;for(const n of t.getChanges()){if(n.type!="insert")continue;const s=n.position.parent;n.length===s.maxOffset&&r.enqueueChange(e,o=>{const a=Array.from(s.getAttributeKeys()).filter(l=>l.startsWith(pt));for(const l of a)o.removeAttribute(l,s)})}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class We{_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;const t=this._nodes[e];if(!t)throw new d("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){if(e==this._offsetToNode.length)return this._nodes.length;const t=this._offsetToNode[e];if(!t)throw new d("model-nodelist-offset-out-of-bounds",this,{offset:e,nodeList:this});return this.getNodeIndex(t)}_insertNodes(e,t){const n=[];for(const i of t){if(!(i instanceof we))throw new d("model-nodelist-insertnodes-not-node",this);n.push(i)}let s=this.indexToOffset(e);Mr(this._nodes,n,e),Mr(this._offsetToNode,tl(n),s);for(let i=e;i<this._nodes.length;i++)this._nodes[i]._index=i,this._nodes[i]._startOffset=s,s+=this._nodes[i].offsetSize}_removeNodes(e,t=1){if(t==0)return[];let n=this.indexToOffset(e);const s=this._nodes.splice(e,t),i=s[s.length-1],o=i.startOffset+i.offsetSize-n;this._offsetToNode.splice(n,o);for(const a of s)a._index=null,a._startOffset=null;for(let a=e;a<this._nodes.length;a++)this._nodes[a]._index=a,this._nodes[a]._startOffset=n,n+=this._nodes[a].offsetSize;return s}_removeNodesArray(e){if(e.length==0)return;for(const n of e)n._index=null,n._startOffset=null;this._nodes=this._nodes.filter(n=>n.index!==null),this._offsetToNode=this._offsetToNode.filter(n=>n.index!==null);let t=0;for(let n=0;n<this._nodes.length;n++)this._nodes[n]._index=n,this._nodes[n]._startOffset=t,t+=this._nodes[n].offsetSize}toJSON(){return this._nodes.map(e=>e.toJSON())}}function tl(r){const e=[];let t=0;for(const n of r)for(let s=0;s<n.offsetSize;s++)e[t++]=n;return e}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class A extends we{name;_children=new We;constructor(e,t,n){super(t),this.name=e,n&&this._insertChild(0,n)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return this.childCount===0}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(const n of e)t=t.getChildAtOffset(n);return t}findAncestor(e,t={}){let n=t.includeSelf?this:this.parent;for(;n;){if(n.name===e)return n;n=n.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?rl(this._children):void 0;return new A(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const n=nl(t);for(const s of n)s.parent!==null&&s._remove(),s.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const s of n)s.parent=null;return n}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}static fromJSON(e){let t;if(e.children){t=[];for(const n of e.children)n.name?t.push(A.fromJSON(n)):t.push(S.fromJSON(n))}return new A(e.name,e.attributes,t)}}A.prototype.is=function(r,e){return e?e===this.name&&(r==="element"||r==="model:element"):r==="element"||r==="model:element"||r==="node"||r==="model:node"};function nl(r){if(typeof r=="string")return[new S(r)];ue(r)||(r=[r]);const e=[];for(const t of r)typeof t=="string"?e.push(new S(t)):t instanceof H?e.push(new S(t.data,t.getAttributes())):e.push(t);return e}function rl(r){const e=[];for(const t of r)e.push(t._clone(!0));return e}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class nr{_dispatchers;constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Ms extends nr{elementToElement(e){return this.add(dl(e))}elementToStructure(e){return this.add(ml(e))}attributeToElement(e){return this.add(gl(e))}attributeToAttribute(e){return this.add(pl(e))}markerToElement(e){return this.add(_l(e))}markerToHighlight(e){return this.add(yl(e))}markerToData(e){return this.add(wl(e))}}function Qt(){return(r,e,t)=>{if(!t.consumable.consume(e.item,r.name))return;const n=t.writer,s=t.mapper.toViewPosition(e.range.start),i=n.createText(e.item.data);n.insert(s,i)}}function Zt(){return(r,e,t)=>{t.convertAttributes(e.item),!e.reconversion&&e.item.is("element")&&!e.item.isEmpty&&t.convertChildren(e.item)}}function Is(){return(r,e,t)=>{if(e.reconversion)return;const n=t.mapper.toViewPosition(e.position),s=e.position.getShiftedBy(e.length),i=t.mapper.toViewPosition(s,{isPhantom:!0}),o=t.writer.createRange(n,i);Bs(o.getTrimmed(),t)}}function rr(r,e){const t=r.createAttributeElement("span",e.attributes);return e.classes&&t._addClass(e.classes),typeof e.priority=="number"&&(t._priority=e.priority),t._id=e.id,t}function sr(){return(r,e,t)=>{const n=e.selection;if(n.isCollapsed||!t.consumable.consume(n,"selection"))return;const s=[];for(const i of n.getRanges())s.push(t.mapper.toViewRange(i));t.writer.setSelection(s,{backward:n.isBackward})}}function ir(){return(r,e,t)=>{const n=e.selection;if(!n.isCollapsed||!t.consumable.consume(n,"selection"))return;const s=t.writer,i=n.getFirstPosition(),o=t.mapper.toViewPosition(i),a=s.breakAttributes(o);s.setSelection(a)}}function Fs(){return(r,e,t)=>{const n=t.writer,s=n.document.selection;for(const i of s.getRanges())i.isCollapsed&&i.end.parent.isAttached()&&t.writer.mergeAttributes(i.start);n.setSelection(null)}}function or(r){return(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;const s=r(t.attributeOldValue,n,t),i=r(t.attributeNewValue,n,t);if(!s&&!i)return;n.consumable.consume(t.item,e.name);const o=n.writer,a=o.document.selection;if(t.item instanceof O||t.item instanceof U)o.wrap(a.getFirstRange(),i);else{let l=n.mapper.toViewRange(t.range);t.attributeOldValue!==null&&s&&(l=o.unwrap(l,s)),t.attributeNewValue!==null&&i&&o.wrap(l,i)}}}function ar(r,e=kl){return(t,n,s)=>{if(!e(n.item,s.consumable,{preflight:!0}))return;const i=r(n.item,s,n);if(!i)return;e(n.item,s.consumable);const o=n.reconversion&&Vs(n.item,s)||s.mapper.toViewPosition(n.range.start);s.mapper.bindElements(n.item,i),s.writer.insert(o,i),s.convertAttributes(n.item),Js(i,n.item.getChildren(),s,{reconversion:n.reconversion})}}function Ds(r,e){return(t,n,s)=>{if(!e(n.item,s.consumable,{preflight:!0}))return;const i=new Map;s.writer._registerSlotFactory(Pl(n.item,i,s));const o=r(n.item,s,n);if(s.writer._clearSlotFactory(),!o)return;Cl(n.item,i,s),e(n.item,s.consumable);const a=n.reconversion&&Vs(n.item,s)||s.mapper.toViewPosition(n.range.start);s.mapper.bindElements(n.item,o),s.writer.insert(a,o),s.convertAttributes(n.item),Sl(o,i,s,{reconversion:n.reconversion})}}function lr(r){return(e,t,n)=>{t.isOpening=!0;const s=r(t,n);t.isOpening=!1;const i=r(t,n);if(!s||!i)return;const o=t.markerRange;if(o.isCollapsed&&!n.consumable.consume(o,e.name))return;for(const c of o)if(!n.consumable.consume(c.item,e.name))return;const a=n.mapper,l=n.writer;l.insert(a.toViewPosition(o.start),s),n.mapper.bindElementToMarker(s,t.markerName),o.isCollapsed||(l.insert(a.toViewPosition(o.end),i),n.mapper.bindElementToMarker(i,t.markerName)),e.stop()}}function Bs(r,e){const t=e.writer.remove(r);for(const n of e.writer.createRangeIn(t).getItems())e.mapper.unbindViewElement(n,{defer:!0});return r.start}function Vs(r,e){const t=e.mapper.toViewElement(r);return t&&Bs(e.writer.createRangeOn(t),e)}function sl(){return(r,e,t)=>{const n=t.mapper.markerNameToElements(e.markerName);if(n){for(const s of n)t.mapper.unbindElementFromMarkerName(s,e.markerName),t.writer.clear(t.writer.createRangeOn(s),s);t.writer.clearClonedElementsGroup(e.markerName),r.stop()}}}function il(r){return(e,t,n)=>{const s=r(t.markerName,n);if(!s)return;const i=t.markerRange;n.consumable.consume(i,e.name)&&(Ls(i,!1,n,t,s),Ls(i,!0,n,t,s),e.stop())}}function Ls(r,e,t,n,s){const i=e?r.start:r.end,o=i.nodeAfter&&i.nodeAfter.is("element")?i.nodeAfter:null,a=i.nodeBefore&&i.nodeBefore.is("element")?i.nodeBefore:null;if(o||a){let c,h;e&&o||!e&&!a?(c=o,h=!0):(c=a,h=!1);const u=t.mapper.toViewElement(c);if(u){ol(u,e,h,t,n,s);return}}const l=t.mapper.toViewPosition(i);al(l,e,t,n,s)}function ol(r,e,t,n,s,i){const o=`data-${i.group}-${e?"start":"end"}-${t?"before":"after"}`,a=r.hasAttribute(o)?r.getAttribute(o).split(","):[];a.unshift(i.name),n.writer.setAttribute(o,a.join(","),r),n.mapper.bindElementToMarker(r,s.markerName)}function al(r,e,t,n,s){const i=`${s.group}-${e?"start":"end"}`,o=s.name?{name:s.name}:null,a=t.writer.createUIElement(i,o);t.writer.insert(r,a),t.mapper.bindElementToMarker(a,n.markerName)}function ll(r){return(e,t,n)=>{const s=r(t.markerName,n);if(!s)return;const i=n.mapper.markerNameToElements(t.markerName);if(!i)return;for(const a of i)n.mapper.unbindElementFromMarkerName(a,t.markerName),a.is("containerElement")?(o(`data-${s.group}-start-before`,a),o(`data-${s.group}-start-after`,a),o(`data-${s.group}-end-before`,a),o(`data-${s.group}-end-after`,a)):n.writer.clear(n.writer.createRangeOn(a),a);n.writer.clearClonedElementsGroup(t.markerName),e.stop();function o(a,l){if(l.hasAttribute(a)){const c=new Set(l.getAttribute(a).split(","));c.delete(s.name),c.size==0?n.writer.removeAttribute(a,l):n.writer.setAttribute(a,Array.from(c).join(","),l)}}}}function cl(r){return(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;const s=r(t.attributeOldValue,n,t),i=r(t.attributeNewValue,n,t);if(!s&&!i)return;n.consumable.consume(t.item,e.name);const o=n.mapper.toViewElement(t.item),a=n.writer;if(!o)throw new d("conversion-attribute-to-attribute-on-text",n.dispatcher,t);if(t.attributeOldValue!==null&&s){let l=s.value;s.key=="style"&&(typeof s.value=="string"?l=new Fe(a.document.stylesProcessor).setTo(s.value).getStylesEntries().map(([c])=>c):l=Object.keys(s.value)),a.removeAttribute(s.key,l,o)}if(t.attributeNewValue!==null&&i){let l=i.value;i.key=="style"&&typeof i.value=="string"&&(l=Object.fromEntries(new Fe(a.document.stylesProcessor).setTo(i.value).getStylesEntries())),a.setAttribute(i.key,l,!1,o)}}}function hl(r){return(e,t,n)=>{if(!t.item||!(t.item instanceof O||t.item instanceof U)&&!t.item.is("$textProxy"))return;const s=cr(r,t,n);if(!s||!n.consumable.consume(t.item,e.name))return;const i=n.writer,o=rr(i,s),a=i.document.selection;if(t.item instanceof O||t.item instanceof U)i.wrap(a.getFirstRange(),o);else{const l=n.mapper.toViewRange(t.range),c=i.wrap(l,o);for(const h of c.getItems())if(h.is("attributeElement")&&h.isSimilar(o)){n.mapper.bindElementToMarker(h,t.markerName);break}}}}function ul(r){return(e,t,n)=>{if(!t.item||!(t.item instanceof A))return;const s=cr(r,t,n);if(!s||!n.consumable.test(t.item,e.name))return;const i=n.mapper.toViewElement(t.item);if(i&&i.getCustomProperty("addHighlight")){n.consumable.consume(t.item,e.name);for(const a of f._createIn(t.item))n.consumable.consume(a.item,e.name);i.getCustomProperty("addHighlight")(i,s,n.writer),n.mapper.bindElementToMarker(i,t.markerName)}}}function fl(r){return(e,t,n)=>{if(t.markerRange.isCollapsed)return;const s=cr(r,t,n);if(!s)return;const i=rr(n.writer,s),o=n.mapper.markerNameToElements(t.markerName);if(o){for(const a of o)n.mapper.unbindElementFromMarkerName(a,t.markerName),a.is("attributeElement")?n.writer.unwrap(n.writer.createRangeOn(a),i):a.getCustomProperty("removeHighlight")(a,s.id,n.writer);n.writer.clearClonedElementsGroup(t.markerName),e.stop()}}}function dl(r){const e=$s(r.model),t=wt(r.view,"container");return e.attributes.length&&(e.children=!0),n=>{n.on(`insert:${e.name}`,ar(t,zs(e)),{priority:r.converterPriority||"normal"}),(e.children||e.attributes.length)&&n.on("reduceChanges",Us(e),{priority:"low"})}}function ml(r){const e=$s(r.model),t=wt(r.view,"container");return e.children=!0,n=>{if(n._conversionApi.schema.checkChild(e.name,"$text"))throw new d("conversion-element-to-structure-disallowed-text",n,{elementName:e.name});n.on(`insert:${e.name}`,Ds(t,zs(e)),{priority:r.converterPriority||"normal"}),n.on("reduceChanges",Us(e),{priority:"low"})}}function gl(r){r=te(r);let e=r.model;typeof e=="string"&&(e={key:e});let t=`attribute:${e.key}`;if(e.name&&(t+=":"+e.name),e.values)for(const s of e.values)r.view[s]=wt(r.view[s],"attribute");else r.view=wt(r.view,"attribute");const n=Ws(r);return s=>{s.on(t,or(n),{priority:r.converterPriority||"normal"})}}function pl(r){r=te(r);let e=r.model;typeof e=="string"&&(e={key:e});let t=`attribute:${e.key}`;if(e.name&&(t+=":"+e.name),e.values)for(const s of e.values)r.view[s]=qs(r.view[s]);else r.view=qs(r.view);const n=Ws(r);return s=>{s.on(t,cl(n),{priority:r.converterPriority||"normal"})}}function _l(r){const e=wt(r.view,"ui");return t=>{t.on(`addMarker:${r.model}`,lr(e),{priority:r.converterPriority||"normal"}),t.on(`removeMarker:${r.model}`,sl(),{priority:r.converterPriority||"normal"})}}function wl(r){r=te(r);const e=r.model;let t=r.view;return t||(t=n=>({group:e,name:n.substr(r.model.length+1)})),n=>{n.on(`addMarker:${e}`,il(t),{priority:r.converterPriority||"normal"}),n.on(`removeMarker:${e}`,ll(t),{priority:r.converterPriority||"normal"})}}function yl(r){return e=>{e.on(`addMarker:${r.model}`,hl(r.view),{priority:r.converterPriority||"normal"}),e.on(`addMarker:${r.model}`,ul(r.view),{priority:r.converterPriority||"normal"}),e.on(`removeMarker:${r.model}`,fl(r.view),{priority:r.converterPriority||"normal"})}}function $s(r){return typeof r=="string"&&(r={name:r}),{name:r.name,attributes:r.attributes?ce(r.attributes):[],children:!!r.children}}function wt(r,e){return typeof r=="function"?r:(t,n)=>bl(r,n,e)}function bl(r,e,t){typeof r=="string"&&(r={name:r});let n;const s=e.writer,i=Object.assign({},r.attributes);if(t=="container")n=s.createContainerElement(r.name,i);else if(t=="attribute"){const o={priority:r.priority||_e.DEFAULT_PRIORITY};n=s.createAttributeElement(r.name,i,o)}else n=s.createUIElement(r.name,i);if(r.styles){const o=Object.keys(r.styles);for(const a of o)s.setStyle(a,r.styles[a],n)}if(r.classes){const o=r.classes;if(typeof o=="string")s.addClass(o,n);else for(const a of o)s.addClass(a,n)}return n}function Ws(r){return r.model.values?(e,t,n)=>{const s=r.view[e];return s?s(e,t,n):null}:r.view}function qs(r){return typeof r=="string"?e=>({key:r,value:e}):typeof r=="object"?r.value?()=>r:e=>({key:r.key,value:e}):r}function cr(r,e,t){const n=typeof r=="function"?r(e,t):{...r};return n?(n.priority||(n.priority=10),n.id||(n.id=e.markerName),n):null}function vl(r){return(e,t)=>{if(!e.is("element",r.name))return!1;if(t.type=="attribute"){if(r.attributes.includes(t.attributeKey))return!0}else{/* istanbul ignore else: This is always true because otherwise it would not register a reducer callback. -- @preserve */if(r.children)return!0}return!1}}function Us(r){const e=vl(r);return(t,n)=>{const s=[];n.reconvertedElements||(n.reconvertedElements=new Set);for(const i of n.changes){const o=i.type=="attribute"?i.range.start.nodeAfter:i.position.parent;if(!o||!e(o,i)||i.type=="reinsert"){s.push(i);continue}if(i.type=="insert"&&i.action=="rename"&&n.refreshedItems.add(i.position.nodeAfter),!n.reconvertedElements.has(o)){n.reconvertedElements.add(o);const a=m._createBefore(o);let l=s.length;for(let c=s.length-1;c>=0;c--){const h=s[c],g=(h.type=="attribute"?h.range.start:h.position).compareWith(a);if(g=="before"||h.type=="remove"&&g=="same")break;l=c}s.splice(l,0,{type:"reinsert",name:o.name,position:a,length:1})}}n.changes=s}}function zs(r){return(e,t,n={})=>{const s=["insert"];for(const i of r.attributes)e.hasAttribute(i)&&s.push(`attribute:${i}`);return s.every(i=>t.test(e,i))?(n.preflight||s.forEach(i=>t.consume(e,i)),!0):!1}}function Pl(r,e,t){return(n,s)=>{const i=n.createContainerElement("$slot");let o=null;if(s==="children")o=Array.from(r.getChildren());else if(typeof s=="function")o=Array.from(r.getChildren()).filter(a=>s(a));else throw new d("conversion-slot-mode-unknown",t.dispatcher,{modeOrFilter:s});return e.set(i,o),i}}function Cl(r,e,t){const n=Array.from(e.values()).flat(),s=new Set(n);if(s.size!=n.length)throw new d("conversion-slot-filter-overlap",t.dispatcher,{element:r});if(s.size!=r.childCount)throw new d("conversion-slot-filter-incomplete",t.dispatcher,{element:r})}function Sl(r,e,t,n){t.mapper.on("modelToViewPosition",o,{priority:"highest"});let s=null,i=null;for([s,i]of e)Js(r,i,t,n),t.writer.setCustomProperty("$structureSlotParent",!0,s.parent),t.writer.move(t.writer.createRangeIn(s),t.writer.createPositionBefore(s)),t.writer.remove(s);t.mapper.off("modelToViewPosition",o);function o(a,l){const c=l.modelPosition.nodeAfter,h=i.indexOf(c);h<0||(l.viewPosition=l.mapper.findPositionIn(s,h))}}function Js(r,e,t,n){for(const s of e)Al(r.root,s,t,n)||t.convertItem(s)}function Al(r,e,t,n){const{writer:s,mapper:i}=t;if(!n.reconversion)return!1;const o=i.toViewElement(e);return!o||o.root==r||!t.canReuseView(o)?!1:(s.move(s.createRangeOn(o),i.toViewPosition(m._createBefore(e))),!0)}function kl(r,e,{preflight:t}={}){return t?e.test(r,"insert"):e.consume(r,"insert")}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function en(r){const{schema:e,document:t}=r.model;for(const n of t.getRoots())if(n.isEmpty&&!e.checkChild(n,"$text")&&e.checkChild(n,"paragraph"))return r.insertElement("paragraph",n),!0;return!1}function tn(r,e,t){const n=t.createContext(r);return!(!t.checkChild(n,"paragraph")||!t.checkChild(n.push("paragraph"),e))}function nn(r,e){const t=e.createElement("paragraph");return e.insert(t,r),e.createPositionAt(t,0)}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class js extends nr{elementToElement(e){return this.add(Hs(e))}elementToAttribute(e){return this.add(El(e))}attributeToAttribute(e){return this.add(Rl(e))}elementToMarker(e){return this.add(Tl(e))}dataToMarker(e){return this.add(xl(e))}}function hr(){return(r,e,t)=>{if(!e.modelRange&&t.consumable.consume(e.viewItem,{name:!0})){const{modelRange:n,modelCursor:s}=t.convertChildren(e.viewItem,e.modelCursor);e.modelRange=n,e.modelCursor=s}}}function Gs(){return(r,e,{schema:t,consumable:n,writer:s})=>{let i=e.modelCursor;if(!n.test(e.viewItem))return;if(!t.checkChild(i,"$text")){if(!tn(i,"$text",t)||e.viewItem.data.trim().length==0)return;i=nn(i,s)}n.consume(e.viewItem);const o=s.createText(e.viewItem.data);s.insert(o,i),e.modelRange=s.createRange(i,i.getShiftedBy(o.offsetSize)),e.modelCursor=e.modelRange.end}}function Ks(r,e){return(t,n)=>{const s=n.newSelection,i=[];for(const a of s.getRanges())i.push(e.toModelRange(a));const o=r.createSelection(i,{backward:s.isBackward});o.isEqual(r.document.selection)||r.change(a=>{a.setSelection(o)})}}function Hs(r){r=te(r);const e=fr(r),t=ur(r.view),n=t?`element:${t}`:"element";return s=>{s.on(n,e,{priority:r.converterPriority||"normal"})}}function El(r){r=te(r),Xs(r);const e=Ys(r,!1),t=ur(r.view),n=t?`element:${t}`:"element";return s=>{s.on(n,e,{priority:r.converterPriority||"low"})}}function Rl(r){r=te(r);let e=null;(typeof r.view=="string"||r.view.key)&&(e=Ml(r)),Xs(r,e);const t=Ys(r,!0);return n=>{n.on("element",t,{priority:r.converterPriority||"low"})}}function Tl(r){const e=Dl(r.model);return Hs({...r,model:e})}function xl(r){r=te(r),r.model||(r.model=s=>s?r.view+":"+s:r.view);const e={view:r.view,model:r.model},t=fr(Qs(e,"start")),n=fr(Qs(e,"end"));return s=>{s.on(`element:${r.view}-start`,t,{priority:r.converterPriority||"normal"}),s.on(`element:${r.view}-end`,n,{priority:r.converterPriority||"normal"});const i=gn.low,o=gn.highest,a=gn.get(r.converterPriority)/o;s.on("element",Nl(e),{priority:i+a})}}function Nl(r){return(e,t,n)=>{const s=`data-${r.view}`;if(!n.consumable.test(t.viewItem,{attributes:s+"-end-after"})&&!n.consumable.test(t.viewItem,{attributes:s+"-start-after"})&&!n.consumable.test(t.viewItem,{attributes:s+"-end-before"})&&!n.consumable.test(t.viewItem,{attributes:s+"-start-before"}))return;t.modelRange||Object.assign(t,n.convertChildren(t.viewItem,t.modelCursor)),n.consumable.consume(t.viewItem,{attributes:s+"-end-after"})&&i(t.modelRange.end,t.viewItem.getAttribute(s+"-end-after").split(",")),n.consumable.consume(t.viewItem,{attributes:s+"-start-after"})&&i(t.modelRange.end,t.viewItem.getAttribute(s+"-start-after").split(",")),n.consumable.consume(t.viewItem,{attributes:s+"-end-before"})&&i(t.modelRange.start,t.viewItem.getAttribute(s+"-end-before").split(",")),n.consumable.consume(t.viewItem,{attributes:s+"-start-before"})&&i(t.modelRange.start,t.viewItem.getAttribute(s+"-start-before").split(","));function i(o,a){for(const l of a){const c=r.model(l,n),h=n.writer.createElement("$marker",{"data-name":c});n.writer.insert(h,o),t.modelCursor.isEqual(o)?t.modelCursor=t.modelCursor.getShiftedBy(1):t.modelCursor=t.modelCursor._getTransformedByInsertion(o,1),t.modelRange=t.modelRange._getTransformedByInsertion(o,1)[0]}}}}function ur(r){return typeof r=="string"?r:typeof r=="object"&&typeof r.name=="string"?r.name:null}function fr(r){const e=new Te(r.view);return(t,n,s)=>{const i=e.match(n.viewItem);if(!i)return;const o=i.match;if(o.name=!0,!s.consumable.test(n.viewItem,o))return;const a=Ol(r.model,n.viewItem,s);a&&s.safeInsert(a,n.modelCursor)&&(s.consumable.consume(n.viewItem,o),s.convertChildren(n.viewItem,a),s.updateConversionResult(a,n))}}function Ol(r,e,t){return r instanceof Function?r(e,t):t.writer.createElement(r)}function Ml(r){typeof r.view=="string"&&(r.view={key:r.view});const e=r.view.key,t=typeof r.view.value>"u"?/[\s\S]*/:r.view.value;let n;return e=="class"||e=="style"?n={[e=="class"?"classes":"styles"]:t}:n={attributes:{[e]:t}},r.view.name&&(n.name=r.view.name),r.view=n,e}function Xs(r,e=null){const t=e===null?!0:i=>i.getAttribute(e),n=typeof r.model!="object"?r.model:r.model.key,s=typeof r.model!="object"||typeof r.model.value>"u"?t:r.model.value;r.model={key:n,value:s}}function Ys(r,e){const t=new Te(r.view);return(n,s,i)=>{if(!s.modelRange&&e)return;const o=t.match(s.viewItem);if(!o||(Il(r.view,s.viewItem)?o.match.name=!0:delete o.match.name,!i.consumable.test(s.viewItem,o.match)))return;const a=r.model.key,l=typeof r.model.value=="function"?r.model.value(s.viewItem,i,s):r.model.value;if(l==null)return;s.modelRange||Object.assign(s,i.convertChildren(s.viewItem,s.modelCursor)),Fl(s.modelRange,{key:a,value:l},e,i)&&(i.consumable.test(s.viewItem,{name:!0})&&(o.match.name=!0),i.consumable.consume(s.viewItem,o.match))}}function Il(r,e){const t=typeof r=="function"?r(e):r;return typeof t=="object"&&!ur(t)?!1:!t.classes&&!t.attributes&&!t.styles}function Fl(r,e,t,n){let s=!1;for(const i of Array.from(r.getItems({shallow:t})))n.schema.checkAttribute(i,e.key)&&(s=!0,!i.hasAttribute(e.key)&&n.writer.setAttribute(e.key,e.value,i));return s}function Dl(r){return(e,t)=>{const n=typeof r=="string"?r:r(e,t);return t.writer.createElement("$marker",{"data-name":n})}}function Qs(r,e){const t=(n,s)=>{const i=n.getAttribute("name"),o=r.model(i,s);return s.writer.createElement("$marker",{"data-name":o})};return{view:`${r.view}-${e}`,model:t}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Bl extends K(){model;view;mapper;downcastDispatcher;constructor(e,t){super(),this.model=e,this.view=new mt(t),this.mapper=new gt,this.downcastDispatcher=new er({mapper:this.mapper,schema:e.schema});const n=this.model.document,s=n.selection,i=this.model.markers;this.listenTo(this.model,"_beforeChanges",()=>{this.view._disableRendering(!0)},{priority:"highest"}),this.listenTo(this.model,"_afterChanges",()=>{this.view._disableRendering(!1)},{priority:"lowest"}),this.listenTo(n,"change",()=>{this.view.change(o=>{this.downcastDispatcher.convertChanges(n.differ,i,o),this.downcastDispatcher.convertSelection(s,i,o)})},{priority:"low"}),this.listenTo(this.view.document,"selectionChange",Ks(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",Qt(),{priority:"lowest"}),this.downcastDispatcher.on("insert",Zt(),{priority:"lowest"}),this.downcastDispatcher.on("remove",Is(),{priority:"low"}),this.downcastDispatcher.on("cleanSelection",Fs()),this.downcastDispatcher.on("selection",sr(),{priority:"low"}),this.downcastDispatcher.on("selection",ir(),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using(o=>{if(o.rootName=="$graveyard")return null;const a=new Ut(this.view.document,o.name);return a.rootName=o.rootName,this.mapper.bindElements(o,a),a})}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const t=typeof e=="string"?e:e.name,n=this.model.markers.get(t);if(!n)throw new d("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change(()=>{this.model.markers._refresh(n)})}reconvertItem(e){this.model.change(()=>{this.model.document.differ._refreshItem(e)})}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Zs extends K(){_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 le(t[0])},{priority:"highest"}),this.on("checkChild",(e,t)=>{t[0]=new le(t[0]),t[1]=this.getDefinition(t[1])},{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new d("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 d("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 typeof e=="string"?t=e:"is"in e&&(e.is("$text")||e.is("$textProxy"))?t="$text":t=e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const t=this.getDefinition(e);return!!(t&&t.isBlock)}isLimit(e){const t=this.getDefinition(e);return t?!!(t.isLimit||t.isObject):!1}isObject(e){const t=this.getDefinition(e);return t?!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent):!1}isInline(e){const t=this.getDefinition(e);return!!(t&&t.isInline)}isSelectable(e){const t=this.getDefinition(e);return t?!!(t.isSelectable||t.isObject):!1}isContent(e){const t=this.getDefinition(e);return t?!!(t.isContent||t.isObject):!1}checkChild(e,t){return t?this._checkContextMatch(e,t):!1}checkAttribute(e,t){const n=this.getDefinition(e.last);if(!n)return!1;const s=this._evaluateAttributeChecks(e,t);return s!==void 0?s:n.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof m){const n=e.nodeBefore,s=e.nodeAfter;if(!(n instanceof A))throw new d("schema-check-merge-no-element-before",this);if(!(s instanceof A))throw new d("schema-check-merge-no-element-after",this);return this.checkMerge(n,s)}if(this.isLimit(e)||this.isLimit(t))return!1;for(const n of t.getChildren())if(!this.checkChild(e,n))return!1;return!0}addChildCheck(e,t){const n=t!==void 0?t:this._genericCheckSymbol,s=this._customChildChecks.get(n)||[];s.push(e),this._customChildChecks.set(n,s)}addAttributeCheck(e,t){const n=t!==void 0?t:this._genericCheckSymbol,s=this._customAttributeChecks.get(n)||[];s.push(e),this._customAttributeChecks.set(n,s)}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(e instanceof m?t=e.parent:t=(e instanceof f?[e]:Array.from(e.getRanges())).reduce((s,i)=>{const o=i.getCommonAncestor();return s?s.getCommonAncestor(o,{includeSelf:!0}):o},null);!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const s=[...e.getFirstPosition().getAncestors(),new S("",e.getAttributes())];return this.checkAttribute(s,t)}else{const n=e.getRanges();for(const s of n)for(const i of s)if(this.checkAttribute(i.item,t))return!0}return!1}*getValidRanges(e,t,n={}){e=Zl(e);for(const s of e)yield*this._getValidRangesForRange(s,t,n)}getNearestSelectionRange(e,t="both"){if(e.root.rootName=="$graveyard")return null;if(this.checkChild(e,"$text"))return new f(e);let n,s;const i=e.getAncestors().reverse().find(o=>this.isLimit(o))||e.root;(t=="both"||t=="backward")&&(n=new ae({boundaries:f._createIn(i),startPosition:e,direction:"backward"})),(t=="both"||t=="forward")&&(s=new ae({boundaries:f._createIn(i),startPosition:e}));for(const o of Ql(n,s)){const a=o.walker==n?"elementEnd":"elementStart",l=o.value;if(l.type==a&&this.isObject(l.item))return f._createOn(l.item);if(this.checkChild(l.nextPosition,"$text"))return new f(l.nextPosition)}return null}findAllowedParent(e,t){let n=e.parent;for(;n;){if(this.checkChild(n,t))return n;if(this.isLimit(n))return null;n=n.parent}return null}setAllowedAttributes(e,t,n){const s=n.model;for(const[i,o]of Object.entries(t))s.schema.checkAttribute(e,i)&&n.setAttribute(i,o,e)}removeDisallowedAttributes(e,t){for(const n of e)if(n.is("$text"))ei(this,n,t);else{const i=f._createIn(n).getPositions();for(const o of i){const a=o.nodeBefore||o.parent;ei(this,a,t)}}}getAttributesWithProperty(e,t,n){const s={};for(const[i,o]of e.getAttributes()){const a=this.getAttributeProperties(i);a[t]!==void 0&&(n===void 0||n===a[t])&&(s[i]=o)}return s}createContext(e){return new le(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,n=Object.keys(t);for(const i of n)e[i]=Vl(t[i],i);const s=Object.values(e);for(const i of s)Ll(e,i),$l(e,i),Wl(e,i),ql(e,i);for(const i of s)Ul(e,i);for(const i of s)zl(e,i);for(const i of s)Jl(e,i);for(const i of s)Gl(e,i);for(const i of s)Kl(e,i);this._compiledDefinitions=jl(e)}_checkContextMatch(e,t){const n=e.last;let s=this._evaluateChildChecks(e,t);if(s=s!==void 0?s:t.allowIn.includes(n.name),!s)return!1;const i=this.getDefinition(n),o=e.trimLast();return i?o.length==0?!0:this._checkContextMatch(o,i):!1}_evaluateChildChecks(e,t){const n=this._customChildChecks.get(this._genericCheckSymbol)||[],s=this._customChildChecks.get(t.name)||[];for(const i of[...n,...s]){const o=i(e,t);if(o!==void 0)return o}}_evaluateAttributeChecks(e,t){const n=this._customAttributeChecks.get(this._genericCheckSymbol)||[],s=this._customAttributeChecks.get(t)||[];for(const i of[...n,...s]){const o=i(e,t);if(o!==void 0)return o}}*_getValidRangesForRange(e,t,n){let s=e.start,i=e.start;for(const o of e.getItems({shallow:!0})){if(o.is("element"))if(n.includeEmptyRanges&&o.isEmpty){const a=this.createContext(o);this.checkChild(a,"$text")&&this.checkAttribute(a.push("$text"),t)&&(yield f._createIn(o))}else yield*this._getValidRangesForRange(f._createIn(o),t,n);this.checkAttribute(o,t)||(s.isEqual(i)||(yield new f(s,i)),s=m._createAfter(o)),i=m._createAfter(o)}s.isEqual(i)||(yield new f(s,i))}findOptimalInsertionRange(e,t){const n=e.getSelectedElement();if(n&&this.isObject(n)&&!this.isInline(n))return t=="before"||t=="after"?new f(m._createAt(n,t)):f._createOn(n);const s=mn(e.getSelectedBlocks());if(!s)return new f(e.focus);if(s.isEmpty)return new f(m._createAt(s,0));const i=m._createAfter(s);return e.focus.isTouching(i)?new f(i):new f(m._createBefore(s))}}class le{_items;constructor(e){if(e instanceof le)return e;let t;typeof e=="string"?t=[e]:Array.isArray(e)?t=e:t=e.getAncestors({includeSelf:!0}),this._items=t.map(Yl)}get length(){return this._items.length}get last(){return this._items[this._items.length-1]}[Symbol.iterator](){return this._items[Symbol.iterator]()}push(e){const t=new le([e]);return t._items=[...this._items,...t._items],t}trimLast(){const e=new le([]);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 Vl(r,e){const t={name:e,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 Hl(r,t),ne(r,t,"allowIn"),ne(r,t,"allowChildren"),ne(r,t,"disallowIn"),ne(r,t,"disallowChildren"),ne(r,t,"allowContentOf"),ne(r,t,"allowWhere"),ne(r,t,"allowAttributes"),ne(r,t,"disallowAttributes"),ne(r,t,"allowAttributesOf"),ne(r,t,"inheritTypesFrom"),Xl(r,t),t}function Ll(r,e){for(const t of e.allowIn){const n=r[t];n?n.allowChildren.add(e.name):e.allowIn.delete(t)}}function $l(r,e){for(const t of e.allowChildren){const n=r[t];n?n.allowIn.add(e.name):e.allowChildren.delete(t)}}function Wl(r,e){for(const t of e.disallowIn){const n=r[t];n?n.disallowChildren.add(e.name):e.disallowIn.delete(t)}}function ql(r,e){for(const t of e.disallowChildren){const n=r[t];n?n.disallowIn.add(e.name):e.disallowChildren.delete(t)}}function Ul(r,e){for(const t of e.disallowChildren)e.allowChildren.delete(t);for(const t of e.disallowIn)e.allowIn.delete(t);for(const t of e.disallowAttributes)e.allowAttributes.delete(t)}function zl(r,e){for(const t of e.allowContentOf){const n=r[t];n&&(n.disallowChildren.forEach(s=>{e.allowChildren.has(s)||(e.disallowChildren.add(s),r[s].disallowIn.add(e.name))}),n.allowChildren.forEach(s=>{e.disallowChildren.has(s)||(e.allowChildren.add(s),r[s].allowIn.add(e.name))}))}}function Jl(r,e){for(const t of e.allowWhere){const n=r[t];n&&(n.disallowIn.forEach(s=>{e.allowIn.has(s)||(e.disallowIn.add(s),r[s].disallowChildren.add(e.name))}),n.allowIn.forEach(s=>{e.disallowIn.has(s)||(e.allowIn.add(s),r[s].allowChildren.add(e.name))}))}}function jl(r){const e={};for(const t of Object.values(r))e[t.name]={name:t.name,isBlock:!!t.isBlock,isContent:!!t.isContent,isInline:!!t.isInline,isLimit:!!t.isLimit,isObject:!!t.isObject,isSelectable:!!t.isSelectable,allowIn:Array.from(t.allowIn).filter(n=>!!r[n]),allowChildren:Array.from(t.allowChildren).filter(n=>!!r[n]),allowAttributes:Array.from(t.allowAttributes)};return e}function Gl(r,e){for(const t of e.allowAttributesOf){const n=r[t];if(!n)return;n.allowAttributes.forEach(s=>{e.disallowAttributes.has(s)||e.allowAttributes.add(s)})}}function Kl(r,e){for(const t of e.inheritTypesFrom){const n=r[t];if(n){const s=Object.keys(n).filter(i=>i.startsWith("is"));for(const i of s)i in e||(e[i]=n[i])}}}function Hl(r,e){for(const t of r){const n=Object.keys(t).filter(s=>s.startsWith("is"));for(const s of n)e[s]=!!t[s]}}function ne(r,e,t){for(const n of r){let s=n[t];typeof s=="string"&&(s=[s]),Array.isArray(s)&&s.forEach(i=>e[t].add(i))}}function Xl(r,e){for(const t of r){const n=t.inheritAllFrom;n&&(e.allowContentOf.add(n),e.allowWhere.add(n),e.allowAttributesOf.add(n),e.inheritTypesFrom.add(n))}}function Yl(r){return typeof r=="string"||r.is("documentFragment")?{name:typeof r=="string"?r:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:r.is("element")?r.name:"$text",*getAttributeKeys(){yield*r.getAttributeKeys()},getAttribute(e){return r.getAttribute(e)}}}function*Ql(r,e){let t=!1;for(;!t;){if(t=!0,r){const n=r.next();n.done||(t=!1,yield{walker:r,value:n.value})}if(e){const n=e.next();n.done||(t=!1,yield{walker:e,value:n.value})}}}function*Zl(r){for(const e of r)yield*e.getMinimalFlatRanges()}function ei(r,e,t){for(const n of e.getAttributeKeys())r.checkAttribute(e,n)||t.removeAttribute(n,e)}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ti extends I(){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:(t,n)=>this._convertItem(t,n),convertChildren:(t,n)=>this._convertChildren(t,n),safeInsert:(t,n)=>this._safeInsert(t,n),updateConversionResult:(t,n)=>this._updateConversionResult(t,n),splitToAllowedParent:(t,n)=>this._splitToAllowedParent(t,n),getSplitParts:t=>this._getSplitParts(t),keepEmptyElement:t=>this._keepEmptyElement(t)}}convert(e,t,n=["$root"]){this.fire("viewCleanup",e),this._modelCursor=tc(n,t),this.conversionApi.writer=t,this.conversionApi.consumable=hn.createFrom(e),this.conversionApi.store={};const{modelRange:s}=this._convertItem(e,this._modelCursor),i=t.createDocumentFragment();if(s){this._removeEmptyElements();const o=this._modelCursor.parent,a=o._removeChildren(0,o.childCount);i._insertChild(0,a),i.markers=ec(i,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,i}_convertItem(e,t){const n={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,n,this.conversionApi):e.is("$text")?this.fire("text",n,this.conversionApi):this.fire("documentFragment",n,this.conversionApi),n.modelRange&&!(n.modelRange instanceof f))throw new d("view-conversion-dispatcher-incorrect-result",this);return{modelRange:n.modelRange,modelCursor:n.modelCursor}}_convertChildren(e,t){let n=t.is("position")?t:m._createAt(t,0);const s=new f(n);for(const i of Array.from(e.getChildren())){const o=this._convertItem(i,n);o.modelRange instanceof f&&(s.end=o.modelRange.end,n=o.modelCursor)}return{modelRange:s,modelCursor:n}}_safeInsert(e,t){const n=this._splitToAllowedParent(e,t);return n?(this.conversionApi.writer.insert(e,n.position),!0):!1}_updateConversionResult(e,t){const n=this._getSplitParts(e),s=this.conversionApi.writer;t.modelRange||(t.modelRange=s.createRange(s.createPositionBefore(e),s.createPositionAfter(n[n.length-1])));const i=this._cursorParents.get(e);i?t.modelCursor=s.createPositionAt(i,0):t.modelCursor=t.modelRange.end}_splitToAllowedParent(e,t){const{schema:n,writer:s}=this.conversionApi;let i=n.findAllowedParent(t,e);if(i){if(i===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(i)&&(i=null)}if(!i)return tn(t,e,n)?{position:nn(t,s)}:null;const o=this.conversionApi.writer.split(t,i),a=[];for(const c of o.range.getWalker())if(c.type=="elementEnd")a.push(c.item);else{const h=a.pop(),u=c.item;this._registerSplitPair(h,u)}const l=o.range.end.parent;return this._cursorParents.set(e,l),{position:o.position,cursorParent:l}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);const n=this._splitParts.get(e);this._splitParts.set(t,n),n.push(t)}_getSplitParts(e){let t;return this._splitParts.has(e)?t=this._splitParts.get(e):t=[e],t}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){const e=new Map;for(const t of this._splitParts.keys())if(t.isEmpty&&!this._emptyElementsToKeep.has(t)){const n=e.get(t.parent)||[];n.push(t),this._splitParts.delete(t),e.set(t.parent,n)}for(const[t,n]of e)t._removeChildrenArray(n);e.size&&this._removeEmptyElements()}}function ec(r,e){const t=new Set,n=new Map,s=f._createIn(r).getItems();for(const i of s)i.is("element","$marker")&&t.add(i);for(const i of t){const o=i.getAttribute("data-name"),a=e.createPositionBefore(i);n.has(o)?n.get(o).end=a.clone():n.set(o,new f(a.clone())),e.remove(i)}return n}function tc(r,e){let t;for(const n of new le(r)){const s={};for(const o of n.getAttributeKeys())s[o]=n.getAttribute(o);const i=e.createElement(n.name,s);t&&e.insert(i,t),t=m._createAt(i,0)}return t}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class dr{getHtml(e){const n=fe.document.implementation.createHTMLDocument("").createElement("div");return n.appendChild(e),n.innerHTML}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ni{domParser;domConverter;htmlWriter;skipComments=!0;constructor(e){this.domParser=new DOMParser,this.domConverter=new Ht(e,{renderingMode:"data"}),this.htmlWriter=new dr}toData(e){const t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this.domConverter.domToView(t,{skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode=e=="marked"?"markedNbsp":"nbsp"}_toDom(e){/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(e.trim().slice(0,1e4))||(e=`<body>${e}</body>`);const t=this.domParser.parseFromString(e,"text/html"),n=t.createDocumentFragment(),s=t.body.childNodes;for(;s.length>0;)n.appendChild(s[0]);return n}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class nc extends I(){model;mapper;downcastDispatcher;upcastDispatcher;viewDocument;stylesProcessor;htmlProcessor;processor;_viewWriter;constructor(e,t){super(),this.model=e,this.mapper=new gt,this.downcastDispatcher=new er({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",Qt(),{priority:"lowest"}),this.downcastDispatcher.on("insert",Zt(),{priority:"lowest"}),this.upcastDispatcher=new ti({schema:e.schema}),this.viewDocument=new Gt(t),this.stylesProcessor=t,this.htmlProcessor=new ni(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new qn(this.viewDocument),this.upcastDispatcher.on("text",Gs(),{priority:"lowest"}),this.upcastDispatcher.on("element",hr(),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",hr(),{priority:"lowest"}),K().prototype.decorate.call(this,"init"),K().prototype.decorate.call(this,"set"),K().prototype.decorate.call(this,"get"),K().prototype.decorate.call(this,"toView"),K().prototype.decorate.call(this,"toModel"),this.on("init",()=>{this.fire("ready")},{priority:"lowest"}),this.on("ready",()=>{this.model.enqueueChange({isUndoable:!1},en)},{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:n="empty"}=e;if(!this._checkIfRootsExists([t]))throw new d("datacontroller-get-non-existent-root",this);const s=this.model.document.getRoot(t);return s.isAttached()||G("datacontroller-get-detached-root",this),n==="empty"&&!this.model.hasContent(s,{ignoreWhitespaces:!0})?"":this.stringify(s,e)}stringify(e,t={}){const n=this.toView(e,t);return this.processor.toData(n)}toView(e,t={}){const n=this.viewDocument,s=this._viewWriter;this.mapper.clearBindings();const i=f._createIn(e),o=new se(n);this.mapper.bindElements(e,o);const a=e.is("documentFragment")?e.markers:rc(e);return this.downcastDispatcher.convert(i,a,s,t),o}init(e){if(this.model.document.version)throw new d("datacontroller-init-document-not-empty",this);let t={};if(typeof e=="string"?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new d("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},n=>{for(const s of Object.keys(t)){const i=this.model.document.getRoot(s);n.insert(this.parse(t[s],i),i,0)}}),Promise.resolve()}set(e,t={}){let n={};if(typeof e=="string"?n.main=e:n=e,!this._checkIfRootsExists(Object.keys(n)))throw new d("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},s=>{s.setSelection(null),s.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const i of Object.keys(n)){const o=this.model.document.getRoot(i);s.remove(s.createRangeIn(o)),s.insert(this.parse(n[i],o),o,0)}})}parse(e,t="$root"){const n=this.processor.toView(e);return this.toModel(n,t)}toModel(e,t="$root"){return this.model.change(n=>this.upcastDispatcher.convert(e,n,t))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const t of e)if(!this.model.document.getRoot(t))return!1;return!0}}function rc(r){const e=[],t=r.root.document;if(!t)return new Map;const n=f._createIn(r);for(const s of t.model.markers){const i=s.getRange(),o=i.isCollapsed,a=i.start.isEqual(n.start)||i.end.isEqual(n.end);if(o&&a)e.push([s.name,i]);else{const l=n.getIntersection(i);l&&e.push([s.name,l])}}return e.sort(([s,i],[o,a])=>{if(i.end.compareWith(a.start)!=="after")return 1;if(i.start.compareWith(a.end)!=="before")return-1;switch(i.start.compareWith(a.start)){case"before":return 1;case"after":return-1;default:switch(i.end.compareWith(a.end)){case"before":return 1;case"after":return-1;default:return o.localeCompare(s)}}}),new Map(e)}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class sc{_helpers=new Map;_downcast;_upcast;constructor(e,t){this._downcast=ce(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=ce(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const n=this._downcast.includes(t);if(!this._upcast.includes(t)&&!n)throw new d("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:n})}for(e){if(!this._helpers.has(e))throw new d("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:n}of mr(e))this.for("upcast").elementToElement({model:t,view:n,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:n}of mr(e))this.for("upcast").elementToAttribute({view:n,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:n}of mr(e))this.for("upcast").attributeToAttribute({view:n,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:n}){if(this._helpers.has(e))throw new d("conversion-group-exists",this);const s=n?new Ms(t):new js(t);this._helpers.set(e,s)}}function*mr(r){if(r.model.values)for(const e of r.model.values){const t={key:r.model.key,value:e},n=r.view[e],s=r.upcastAlso?r.upcastAlso[e]:void 0;yield*ri(t,n,s)}else yield*ri(r.model,r.view,r.upcastAlso)}function*ri(r,e,t){if(yield{model:r,view:e},t)for(const n of ce(t))yield{model:r,view:n}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class si{namespaces;domParser;domConverter;htmlWriter;skipComments=!0;constructor(e,t={}){this.namespaces=t.namespaces||[],this.domParser=new DOMParser,this.domConverter=new Ht(e,{renderingMode:"data"}),this.htmlWriter=new dr}toData(e){const t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this.domConverter.domToView(t,{keepOriginalCase:!0,skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode=e=="marked"?"markedNbsp":"nbsp"}_toDom(e){e=`<xml ${this.namespaces.map(a=>`xmlns:${a}="nsp"`).join(" ")}>${e}</xml>`;const n=this.domParser.parseFromString(e,"text/xml"),s=n.querySelector("parsererror");if(s)throw new Error("Parse error - "+s.textContent);const i=n.createDocumentFragment(),o=n.documentElement.childNodes;for(;o.length>0;)i.appendChild(o[0]);return i}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class z{baseVersion;isDocumentOperation;batch;constructor(e){this.baseVersion=e,this.isDocumentOperation=this.baseVersion!==null,this.batch=null}_validate(){}toJSON(){const e=Object.assign({},this);return e.__className=this.constructor.className,delete e.batch,delete e.isDocumentOperation,e}static get className(){return"Operation"}static fromJSON(e,t){return new this(e.baseVersion)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function rn(r,e){const t=pr(e),n=t.reduce((o,a)=>o+a.offsetSize,0),s=r.parent;bt(r);const i=r.index;return s._insertChild(i,t),yt(s,i+t.length),yt(s,i),new f(r,r.getShiftedBy(n))}function gr(r){if(!r.isFlat)throw new d("operation-utils-remove-range-not-flat",this);const e=r.start.parent;bt(r.start),bt(r.end);const t=e._removeChildren(r.start.index,r.end.index-r.start.index);return yt(e,r.start.index),t}function qe(r,e){if(!r.isFlat)throw new d("operation-utils-move-range-not-flat",this);const t=gr(r);return e=e._getTransformedByDeletion(r.start,r.end.offset-r.start.offset),rn(e,t)}function ii(r,e,t){bt(r.start),bt(r.end);for(const n of r.getItems({shallow:!0})){const s=n.is("$textProxy")?n.textNode:n;t!==null?s._setAttribute(e,t):s._removeAttribute(e),yt(s.parent,s.index)}yt(r.end.parent,r.end.index)}function pr(r){const e=[];function t(n){if(typeof n=="string")e.push(new S(n));else if(n instanceof H)e.push(new S(n.data,n.getAttributes()));else if(n instanceof we)e.push(n);else if(ue(n))for(const s of n)t(s)}t(r);for(let n=1;n<e.length;n++){const s=e[n],i=e[n-1];s instanceof S&&i instanceof S&&oi(s,i)&&(e.splice(n-1,2,new S(i.data+s.data,i.getAttributes())),n--)}return e}function yt(r,e){const t=r.getChild(e-1),n=r.getChild(e);if(t&&n&&t.is("$text")&&n.is("$text")&&oi(t,n)){const s=new S(t.data+n.data,t.getAttributes());r._removeChildren(e-1,2),r._insertChild(e-1,s)}}function bt(r){const e=r.textNode,t=r.parent;if(e){const n=r.offset-e.startOffset,s=e.index;t._removeChildren(s,1);const i=new S(e.data.substr(0,n),e.getAttributes()),o=new S(e.data.substr(n),e.getAttributes());t._insertChild(s,[i,o])}}function oi(r,e){const t=r.getAttributes(),n=e.getAttributes();for(const s of t){if(s[1]!==e.getAttribute(s[0]))return!1;n.next()}return n.next().done}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class P extends z{sourcePosition;howMany;targetPosition;constructor(e,t,n,s){super(s),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toNext",this.howMany=t,this.targetPosition=n.clone(),this.targetPosition.stickiness="toNone"}get type(){return this.targetPosition.root.rootName==this.sourcePosition.root.rootName?"move":this.targetPosition.root.rootName=="$graveyard"?"remove":this.sourcePosition.root.rootName=="$graveyard"?"reinsert":"move"}get affectedSelectable(){return[f._createFromPositionAndShift(this.sourcePosition,this.howMany),f._createFromPositionAndShift(this.targetPosition,0)]}clone(){return new P(this.sourcePosition,this.howMany,this.targetPosition,this.baseVersion)}getMovedRangeStart(){return this.targetPosition._getTransformedByDeletion(this.sourcePosition,this.howMany)}getReversed(){const e=this.sourcePosition._getTransformedByInsertion(this.targetPosition,this.howMany);return new P(this.getMovedRangeStart(),this.howMany,e,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent,n=this.sourcePosition.offset,s=this.targetPosition.offset;if(n+this.howMany>e.maxOffset)throw new d("move-operation-nodes-do-not-exist",this);if(e===t&&n<s&&s<n+this.howMany)throw new d("move-operation-range-into-itself",this);if(this.sourcePosition.root==this.targetPosition.root&&$(this.sourcePosition.getParentPath(),this.targetPosition.getParentPath())=="prefix"){const i=this.sourcePosition.path.length-1;if(this.targetPosition.path[i]>=n&&this.targetPosition.path[i]<n+this.howMany)throw new d("move-operation-node-into-itself",this)}}_execute(){qe(f._createFromPositionAndShift(this.sourcePosition,this.howMany),this.targetPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e.targetPosition=this.targetPosition.toJSON(),e}static get className(){return"MoveOperation"}static fromJSON(e,t){const n=m.fromJSON(e.sourcePosition,t),s=m.fromJSON(e.targetPosition,t);return new this(n,e.howMany,s,e.baseVersion)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class M extends z{position;nodes;shouldReceiveAttributes;constructor(e,t,n){super(n),this.position=e.clone(),this.position.stickiness="toNone",this.nodes=new We(pr(t)),this.shouldReceiveAttributes=!1}get type(){return"insert"}get howMany(){return this.nodes.maxOffset}get affectedSelectable(){return this.position.clone()}clone(){const e=new We([...this.nodes].map(n=>n._clone(!0))),t=new M(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new m(e,[0]);return new P(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffset<this.position.offset)throw new d("insert-operation-position-invalid",this)}_execute(){const e=this.nodes;this.nodes=new We([...e].map(t=>t._clone(!0))),rn(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){const n=[];for(const i of e.nodes)i.name?n.push(A.fromJSON(i)):n.push(S.fromJSON(i));const s=new M(m.fromJSON(e.position,t),n,e.baseVersion);return s.shouldReceiveAttributes=e.shouldReceiveAttributes,s}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class C extends z{splitPosition;howMany;insertionPosition;graveyardPosition;constructor(e,t,n,s,i){super(i),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=n,this.graveyardPosition=s?s.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new m(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new f(this.splitPosition,e)}get affectedSelectable(){const e=[f._createFromPositionAndShift(this.splitPosition,0),f._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(f._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new C(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new m(e,[0]);return new k(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset<t)throw new d("split-operation-position-invalid",this);if(e.parent){if(this.howMany!==Number.NEGATIVE_INFINITY&&this.howMany!=e.maxOffset-this.splitPosition.offset)throw new d("split-operation-how-many-invalid",this);if(this.graveyardPosition&&!this.graveyardPosition.nodeAfter)throw new d("split-operation-graveyard-position-invalid",this)}else throw new d("split-operation-split-in-root",this);this.howMany=this.splitPosition.parent.maxOffset-this.splitPosition.offset}_execute(){const e=this.splitPosition.parent;if(this.graveyardPosition)qe(f._createFromPositionAndShift(this.graveyardPosition,1),this.insertionPosition);else{const n=e._clone();rn(this.insertionPosition,n)}const t=new f(m._createAt(e,this.splitPosition.offset),m._createAt(e,e.maxOffset));qe(t,this.moveTargetPosition)}toJSON(){const 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){const t=e.path.slice(0,-1);return t[t.length-1]++,new m(e.root,t,"toPrevious")}static fromJSON(e,t){const n=m.fromJSON(e.splitPosition,t),s=m.fromJSON(e.insertionPosition,t),i=e.graveyardPosition?m.fromJSON(e.graveyardPosition,t):null;return new this(n,e.howMany,s,i,e.baseVersion)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class k extends z{sourcePosition;howMany;targetPosition;graveyardPosition;constructor(e,t,n,s,i){super(i),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=t,this.targetPosition=n.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=s.clone()}get type(){return"merge"}get deletionPosition(){return new m(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const e=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new f(this.sourcePosition,e)}get affectedSelectable(){const e=this.sourcePosition.parent;return[f._createOn(e),f._createFromPositionAndShift(this.targetPosition,0),f._createFromPositionAndShift(this.graveyardPosition,0)]}clone(){return new k(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.targetPosition._getTransformedByMergeOperation(this),t=this.sourcePosition.path.slice(0,-1),n=new m(this.sourcePosition.root,t)._getTransformedByMergeOperation(this);return new C(e,this.howMany,n,this.graveyardPosition,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent;if(e.parent)if(t.parent){if(this.howMany!==Number.NEGATIVE_INFINITY&&this.howMany!=e.maxOffset)throw new d("merge-operation-how-many-invalid",this)}else throw new d("merge-operation-target-position-invalid",this);else throw new d("merge-operation-source-position-invalid",this);this.howMany=this.sourcePosition.parent.maxOffset}_execute(){const e=this.sourcePosition.parent,t=f._createIn(e);qe(t,this.targetPosition),qe(f._createOn(e),this.graveyardPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=e.sourcePosition.toJSON(),e.targetPosition=e.targetPosition.toJSON(),e.graveyardPosition=e.graveyardPosition.toJSON(),e}static get className(){return"MergeOperation"}static fromJSON(e,t){const n=m.fromJSON(e.sourcePosition,t),s=m.fromJSON(e.targetPosition,t),i=m.fromJSON(e.graveyardPosition,t);return new this(n,e.howMany,s,i,e.baseVersion)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class L extends z{name;oldRange;newRange;affectsData;_markers;constructor(e,t,n,s,i,o){super(o),this.name=e,this.oldRange=t?t.clone():null,this.newRange=n?n.clone():null,this.affectsData=i,this._markers=s}get type(){return"marker"}get affectedSelectable(){const 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 L(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new L(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){this.newRange?this._markers._set(this.name,this.newRange,!0,this.affectsData):this._markers._remove(this.name)}toJSON(){const e=super.toJSON();return this.oldRange&&(e.oldRange=this.oldRange.toJSON()),this.newRange&&(e.newRange=this.newRange.toJSON()),delete e._markers,e}static get className(){return"MarkerOperation"}static fromJSON(e,t){return new L(e.name,e.oldRange?f.fromJSON(e.oldRange,t):null,e.newRange?f.fromJSON(e.newRange,t):null,t.model.markers,e.affectsData,e.baseVersion)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class E extends z{range;key;oldValue;newValue;constructor(e,t,n,s,i){super(i),this.range=e.clone(),this.key=t,this.oldValue=n===void 0?null:n,this.newValue=s===void 0?null:s}get type(){return this.oldValue===null?"addAttribute":this.newValue===null?"removeAttribute":"changeAttribute"}get affectedSelectable(){return this.range.clone()}clone(){return new E(this.range,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new E(this.range,this.key,this.newValue,this.oldValue,this.baseVersion+1)}toJSON(){const e=super.toJSON();return e.range=this.range.toJSON(),e}_validate(){if(!this.range.isFlat)throw new d("attribute-operation-range-not-flat",this);for(const e of this.range.getItems({shallow:!0})){if(this.oldValue!==null&&!Xr(e.getAttribute(this.key),this.oldValue))throw new d("attribute-operation-wrong-old-value",this,{item:e,key:this.key,value:this.oldValue});if(this.oldValue===null&&this.newValue!==null&&e.hasAttribute(this.key))throw new d("attribute-operation-attribute-exists",this,{node:e,key:this.key})}}_execute(){Xr(this.oldValue,this.newValue)||ii(this.range,this.key,this.newValue)}static get className(){return"AttributeOperation"}static fromJSON(e,t){return new E(f.fromJSON(e.range,t),e.key,e.oldValue,e.newValue,e.baseVersion)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class N extends z{get type(){return"noop"}get affectedSelectable(){return null}clone(){return new N(this.baseVersion)}getReversed(){return new N(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class W extends z{position;oldName;newName;constructor(e,t,n,s){super(s),this.position=e,this.position.stickiness="toNext",this.oldName=t,this.newName=n}get type(){return"rename"}get affectedSelectable(){return this.position.nodeAfter}clone(){return new W(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new W(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const e=this.position.nodeAfter;if(e instanceof A){if(this.oldName!==""&&e.name!==this.oldName)throw new d("rename-operation-wrong-name",this)}else throw new d("rename-operation-wrong-position",this);this.oldName=e.name}_execute(){const e=this.position.nodeAfter;e.name=this.newName}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e}static get className(){return"RenameOperation"}static fromJSON(e,t){return new W(m.fromJSON(e.position,t),e.oldName,e.newName,e.baseVersion)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class re extends z{root;key;oldValue;newValue;constructor(e,t,n,s,i){super(i),this.root=e,this.key=t,this.oldValue=n===void 0?null:n,this.newValue=s===void 0?null:s}get type(){return this.oldValue===null?"addRootAttribute":this.newValue===null?"removeRootAttribute":"changeRootAttribute"}get affectedSelectable(){return this.root}clone(){return new re(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new re(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new d("rootattribute-operation-not-a-root",this,{root:this.root,key:this.key});if(this.oldValue!==null&&this.root.getAttribute(this.key)!==this.oldValue)throw new d("rootattribute-operation-wrong-old-value",this,{root:this.root,key:this.key});if(this.oldValue===null&&this.newValue!==null&&this.root.hasAttribute(this.key))throw new d("rootattribute-operation-attribute-exists",this,{root:this.root,key:this.key})}_execute(){this.newValue!==null?this.root._setAttribute(this.key,this.newValue):this.root._removeAttribute(this.key)}toJSON(){const e=super.toJSON();return e.root=this.root.toJSON(),e}static get className(){return"RootAttributeOperation"}static fromJSON(e,t){if(!t.getRoot(e.root))throw new d("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new re(t.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Z extends z{rootName;elementName;isAdd;_document;constructor(e,t,n,s,i){if(super(i),this.rootName=e,this.elementName=t,this.isAdd=n,this._document=s,!this._document.getRoot(this.rootName)){const o=this._document.createRoot(this.elementName,this.rootName);o._isAttached=!1}}get type(){return this.isAdd?"addRoot":"detachRoot"}get affectedSelectable(){return this._document.getRoot(this.rootName)}clone(){return new Z(this.rootName,this.elementName,this.isAdd,this._document,this.baseVersion)}getReversed(){return new Z(this.rootName,this.elementName,!this.isAdd,this._document,this.baseVersion+1)}_execute(){this._document.getRoot(this.rootName)._isAttached=this.isAdd}toJSON(){const e=super.toJSON();return delete e._document,e}static get className(){return"RootOperation"}static fromJSON(e,t){return new Z(e.rootName,e.elementName,e.isAdd,t,e.baseVersion)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const X={};X[E.className]=E,X[M.className]=M,X[L.className]=L,X[P.className]=P,X[N.className]=N,X[z.className]=z,X[W.className]=W,X[re.className]=re,X[Z.className]=Z,X[C.className]=C,X[k.className]=k;class _r{static fromJSON(e,t){return X[e.__className].fromJSON(e,t)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const wr=new Map;function b(r,e,t){let n=wr.get(r);n||(n=new Map,wr.set(r,n)),n.set(e,t)}function ic(r,e){const t=wr.get(r);return t&&t.has(e)?t.get(e):oc}function oc(r){return[r]}function yr(r,e,t={}){const n=ic(r.constructor,e.constructor);try{return r=r.clone(),n(r,e,t)}catch(s){throw s}}function ac(r,e,t){r=r.slice(),e=e.slice();const n=new lc(t.document,t.useRelations,t.forceWeakRemove);n.setOriginalOperations(r),n.setOriginalOperations(e);const s=n.originalOperations;if(r.length==0||e.length==0)return{operationsA:r,operationsB:e,originalOperations:s};const i=new WeakMap;for(const l of r)i.set(l,0);const o={nextBaseVersionA:r[r.length-1].baseVersion+1,nextBaseVersionB:e[e.length-1].baseVersion+1,originalOperationsACount:r.length,originalOperationsBCount:e.length};let a=0;for(;a<r.length;){const l=r[a],c=i.get(l);if(c==e.length){a++;continue}const h=e[c],u=yr(l,h,n.getContext(l,h,!0)),g=yr(h,l,n.getContext(h,l,!1));n.updateRelation(l,h),n.setOriginalOperations(u,l),n.setOriginalOperations(g,h);for(const _ of u)i.set(_,c+g.length);r.splice(a,1,...u),e.splice(c,1,...g)}if(ci(r),ci(e),t.padWithNoOps){const l=r.length-o.originalOperationsACount,c=e.length-o.originalOperationsBCount;li(r,c-l),li(e,l-c)}return ai(r,o.nextBaseVersionB),ai(e,o.nextBaseVersionA),{operationsA:r,operationsB:e,originalOperations:s}}class lc{originalOperations;_history;_useRelations;_forceWeakRemove;_relations;constructor(e,t,n=!1){this.originalOperations=new Map,this._history=e.history,this._useRelations=t,this._forceWeakRemove=!!n,this._relations=new Map}setOriginalOperations(e,t=null){const n=t?this.originalOperations.get(t):null;for(const s of e)this.originalOperations.set(s,n||s)}updateRelation(e,t){if(e instanceof P)t instanceof k?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 P&&(e.targetPosition.isEqual(t.sourcePosition)||e.targetPosition.isBefore(t.sourcePosition)?this._setRelation(e,t,"insertBefore"):this._setRelation(e,t,"insertAfter"));else if(e instanceof C){if(t instanceof k)e.splitPosition.isBefore(t.sourcePosition)&&this._setRelation(e,t,"splitBefore");else if(t instanceof P)if(e.splitPosition.isEqual(t.sourcePosition)||e.splitPosition.isBefore(t.sourcePosition))this._setRelation(e,t,"splitBefore");else{const n=f._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.splitPosition)){const s=n.end.offset-e.splitPosition.offset,i=e.splitPosition.offset-n.start.offset;this._setRelation(e,t,{howMany:s,offset:i})}}}else if(e instanceof k)t instanceof k?(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 C?e.sourcePosition.isEqual(t.splitPosition)&&this._setRelation(e,t,"splitAtSource"):t instanceof P&&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"));else if(e instanceof L){const n=e.newRange;if(!n)return;if(t instanceof k){const s=n.start.isEqual(t.targetPosition),i=n.start.isEqual(t.deletionPosition),o=n.end.isEqual(t.deletionPosition),a=n.end.isEqual(t.sourcePosition);(s||i||o||a)&&this._setRelation(e,t,{wasInLeftElement:s,wasStartBeforeMergedElement:i,wasEndBeforeMergedElement:o,wasInRightElement:a})}}}getContext(e,t,n){return{aIsStrong:n,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){const t=this.originalOperations.get(e);return t.wasUndone||this._history.isUndoneOperation(t)}_getRelation(e,t){const n=this.originalOperations.get(t),s=this._history.getUndoneOperation(n);if(!s)return null;const i=this.originalOperations.get(e),o=this._relations.get(i);return o&&o.get(s)||null}_setRelation(e,t,n){const s=this.originalOperations.get(e),i=this.originalOperations.get(t);let o=this._relations.get(s);o||(o=new Map,this._relations.set(s,o)),o.set(i,n)}}function ai(r,e){for(const t of r)t.baseVersion=e++}function li(r,e){for(let t=0;t<e;t++)r.push(new N(0))}function ci(r){const e=new Map;for(let t=0;t<r.length;t++){const n=r[t];n instanceof L&&(n.baseVersion!==-1?e.set(n.name,{op:n,ranges:n.newRange?[n.newRange]:[]}):(n.newRange&&e.get(n.name).ranges.push(n.newRange),r.splice(t,1),t--))}for(const{op:t,ranges:n}of e.values())n.length?t.newRange=f._createFromRanges(n):t.newRange=null}b(E,E,(r,e,t)=>{if(r.key===e.key&&r.range.start.hasSameParentAs(e.range.start)){const n=r.range.getDifference(e.range).map(i=>new E(i,r.key,r.oldValue,r.newValue,0)),s=r.range.getIntersection(e.range);return s&&t.aIsStrong&&n.push(new E(s,e.key,e.newValue,r.newValue,0)),n.length==0?[new N(0)]:n}else return[r]}),b(E,M,(r,e)=>{if(r.range.start.hasSameParentAs(e.position)&&r.range.containsPosition(e.position)){const n=r.range._getTransformedByInsertion(e.position,e.howMany,!e.shouldReceiveAttributes).map(s=>new E(s,r.key,r.oldValue,r.newValue,r.baseVersion));if(e.shouldReceiveAttributes){const s=hi(e,r.key,r.oldValue);s&&n.unshift(s)}return n}return r.range=r.range._getTransformedByInsertion(e.position,e.howMany,!1)[0],[r]});function hi(r,e,t){const s=r.nodes.getNode(0).getAttribute(e);if(s==t)return null;const i=new f(r.position,r.position.getShiftedBy(r.howMany));return new E(i,e,s,t,0)}b(E,k,(r,e)=>{const t=[];r.range.start.hasSameParentAs(e.deletionPosition)&&(r.range.containsPosition(e.deletionPosition)||r.range.start.isEqual(e.deletionPosition))&&t.push(f._createFromPositionAndShift(e.graveyardPosition,1));const n=r.range._getTransformedByMergeOperation(e);return n.isCollapsed||t.push(n),t.map(s=>new E(s,r.key,r.oldValue,r.newValue,r.baseVersion))}),b(E,P,(r,e)=>cc(r.range,e).map(n=>new E(n,r.key,r.oldValue,r.newValue,r.baseVersion)));function cc(r,e){const t=f._createFromPositionAndShift(e.sourcePosition,e.howMany);let n=null,s=[];t.containsRange(r,!0)?n=r:r.start.hasSameParentAs(t.start)?(s=r.getDifference(t),n=r.getIntersection(t)):s=[r];const i=[];for(let o of s){o=o._getTransformedByDeletion(e.sourcePosition,e.howMany);const a=e.getMovedRangeStart(),l=o.start.hasSameParentAs(a),c=o._getTransformedByInsertion(a,e.howMany,l);i.push(...c)}return n&&i.push(n._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany,!1)[0]),i}b(E,C,(r,e)=>{if(r.range.end.isEqual(e.insertionPosition))return e.graveyardPosition||r.range.end.offset++,[r];if(r.range.start.hasSameParentAs(e.splitPosition)&&r.range.containsPosition(e.splitPosition)){const t=r.clone();return t.range=new f(e.moveTargetPosition.clone(),r.range.end._getCombined(e.splitPosition,e.moveTargetPosition)),r.range.end=e.splitPosition.clone(),r.range.end.stickiness="toPrevious",[r,t]}return r.range=r.range._getTransformedBySplitOperation(e),[r]}),b(M,E,(r,e)=>{const t=[r];if(r.shouldReceiveAttributes&&r.position.hasSameParentAs(e.range.start)&&e.range.containsPosition(r.position)){const n=hi(r,e.key,e.newValue);n&&t.push(n)}return t}),b(M,M,(r,e,t)=>r.position.isEqual(e.position)&&t.aIsStrong?[r]:(r.position=r.position._getTransformedByInsertOperation(e),[r])),b(M,P,(r,e)=>(r.position=r.position._getTransformedByMoveOperation(e),[r])),b(M,C,(r,e)=>(r.position=r.position._getTransformedBySplitOperation(e),[r])),b(M,k,(r,e)=>(r.position=r.position._getTransformedByMergeOperation(e),[r])),b(L,M,(r,e)=>(r.oldRange&&(r.oldRange=r.oldRange._getTransformedByInsertOperation(e)[0]),r.newRange&&(r.newRange=r.newRange._getTransformedByInsertOperation(e)[0]),[r])),b(L,L,(r,e,t)=>{if(r.name==e.name)if(t.aIsStrong)r.oldRange=e.newRange?e.newRange.clone():null;else return[new N(0)];return[r]}),b(L,k,(r,e)=>(r.oldRange&&(r.oldRange=r.oldRange._getTransformedByMergeOperation(e)),r.newRange&&(r.newRange=r.newRange._getTransformedByMergeOperation(e)),[r])),b(L,P,(r,e)=>{const t=[r];if(r.oldRange&&(r.oldRange=f._createFromRanges(r.oldRange._getTransformedByMoveOperation(e))),r.newRange){const n=r.newRange._getTransformedByMoveOperation(e);r.newRange=n[0];for(let s=1;s<n.length;s++){const i=r.clone();i.oldRange=null,i.newRange=n[s],i.baseVersion=-1,t.push(i)}}return t}),b(L,C,(r,e,t)=>{if(r.oldRange&&(r.oldRange=r.oldRange._getTransformedBySplitOperation(e)),r.newRange){if(t.abRelation){const n=r.newRange._getTransformedBySplitOperation(e);return r.newRange.start.isEqual(e.splitPosition)?t.abRelation.wasStartBeforeMergedElement?r.newRange.start=m._createAt(e.insertionPosition):t.abRelation.wasInLeftElement?r.newRange.start=m._createAt(r.newRange.start):r.newRange.start=m._createAt(e.moveTargetPosition):r.newRange.start=n.start,r.newRange.end.isEqual(e.splitPosition)?r.newRange.end.isEqual(e.splitPosition)&&t.abRelation.wasEndBeforeMergedElement?r.newRange.end=m._createAt(e.insertionPosition):t.abRelation.wasInRightElement?r.newRange.end=m._createAt(e.moveTargetPosition):r.newRange.end=m._createAt(r.newRange.end):r.newRange.end=n.end,[r]}r.newRange=r.newRange._getTransformedBySplitOperation(e)}return[r]}),b(k,M,(r,e)=>(r.sourcePosition.hasSameParentAs(e.position)&&(r.howMany+=e.howMany),r.sourcePosition=r.sourcePosition._getTransformedByInsertOperation(e),r.targetPosition=r.targetPosition._getTransformedByInsertOperation(e),[r])),b(k,k,(r,e,t)=>{if(r.sourcePosition.isEqual(e.sourcePosition)&&r.targetPosition.isEqual(e.targetPosition))if(t.bWasUndone){const n=e.graveyardPosition.path.slice();return n.push(0),r.sourcePosition=new m(e.graveyardPosition.root,n),r.howMany=0,[r]}else return[new N(0)];if(r.sourcePosition.isEqual(e.sourcePosition)&&!r.targetPosition.isEqual(e.targetPosition)&&!t.bWasUndone&&t.abRelation!="splitAtSource"){const n=r.targetPosition.root.rootName=="$graveyard",s=e.targetPosition.root.rootName=="$graveyard";if(s&&!n||!(n&&!s)&&t.aIsStrong){const l=e.targetPosition._getTransformedByMergeOperation(e),c=r.targetPosition._getTransformedByMergeOperation(e);return[new P(l,r.howMany,c,0)]}else return[new N(0)]}return r.sourcePosition.hasSameParentAs(e.targetPosition)&&(r.howMany+=e.howMany),r.sourcePosition=r.sourcePosition._getTransformedByMergeOperation(e),r.targetPosition=r.targetPosition._getTransformedByMergeOperation(e),(!r.graveyardPosition.isEqual(e.graveyardPosition)||!t.aIsStrong)&&(r.graveyardPosition=r.graveyardPosition._getTransformedByMergeOperation(e)),[r]}),b(k,P,(r,e,t)=>{const n=f._createFromPositionAndShift(e.sourcePosition,e.howMany);return e.type=="remove"&&!t.bWasUndone&&r.deletionPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(r.sourcePosition)?[new N(0)]:(e.sourcePosition.getShiftedBy(e.howMany).isEqual(r.sourcePosition)?r.sourcePosition.stickiness="toNone":e.targetPosition.isEqual(r.sourcePosition)&&t.abRelation=="mergeSourceAffected"?r.sourcePosition.stickiness="toNext":e.sourcePosition.isEqual(r.targetPosition)?(r.targetPosition.stickiness="toNone",r.howMany-=e.howMany):e.targetPosition.isEqual(r.targetPosition)&&t.abRelation=="mergeTargetWasBefore"?(r.targetPosition.stickiness="toPrevious",r.howMany+=e.howMany):(r.sourcePosition.hasSameParentAs(e.targetPosition)&&(r.howMany+=e.howMany),r.sourcePosition.hasSameParentAs(e.sourcePosition)&&(r.howMany-=e.howMany)),r.sourcePosition=r.sourcePosition._getTransformedByMoveOperation(e),r.targetPosition=r.targetPosition._getTransformedByMoveOperation(e),r.sourcePosition.stickiness="toPrevious",r.targetPosition.stickiness="toNext",r.graveyardPosition.isEqual(e.targetPosition)||(r.graveyardPosition=r.graveyardPosition._getTransformedByMoveOperation(e)),[r])}),b(k,C,(r,e,t)=>{if(e.graveyardPosition&&(r.graveyardPosition=r.graveyardPosition._getTransformedByDeletion(e.graveyardPosition,1),r.deletionPosition.isEqual(e.graveyardPosition)&&(r.howMany=e.howMany)),r.targetPosition.isEqual(e.splitPosition)&&(e.graveyardPosition&&r.deletionPosition.isEqual(e.graveyardPosition)||t.abRelation=="mergeTargetNotMoved"))return r.sourcePosition=r.sourcePosition._getTransformedBySplitOperation(e),[r];if(r.sourcePosition.isEqual(e.splitPosition)){if(t.abRelation=="mergeSourceNotMoved")return r.howMany=0,r.targetPosition=r.targetPosition._getTransformedBySplitOperation(e),[r];if(t.abRelation=="mergeSameElement"||r.sourcePosition.offset>0)return r.sourcePosition=e.moveTargetPosition.clone(),r.targetPosition=r.targetPosition._getTransformedBySplitOperation(e),[r]}return r.sourcePosition.hasSameParentAs(e.splitPosition)&&(r.howMany=e.splitPosition.offset),r.sourcePosition=r.sourcePosition._getTransformedBySplitOperation(e),r.targetPosition=r.targetPosition._getTransformedBySplitOperation(e),[r]}),b(P,M,(r,e)=>{const n=f._createFromPositionAndShift(r.sourcePosition,r.howMany)._getTransformedByInsertOperation(e,!1)[0];return r.sourcePosition=n.start,r.howMany=n.end.offset-n.start.offset,r.targetPosition.isEqual(e.position)||(r.targetPosition=r.targetPosition._getTransformedByInsertOperation(e)),[r]}),b(P,P,(r,e,t)=>{const n=f._createFromPositionAndShift(r.sourcePosition,r.howMany),s=f._createFromPositionAndShift(e.sourcePosition,e.howMany);let i=t.aIsStrong,o=!t.aIsStrong;t.abRelation=="insertBefore"||t.baRelation=="insertAfter"?o=!0:(t.abRelation=="insertAfter"||t.baRelation=="insertBefore")&&(o=!1);let a;if(r.targetPosition.isEqual(e.targetPosition)&&o?a=r.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany):a=r.targetPosition._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),ui(r,e)&&ui(e,r))return[e.getReversed()];if(n.containsPosition(e.targetPosition)&&n.containsRange(s,!0))return n.start=n.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),n.end=n.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Ue([n],a);if(s.containsPosition(r.targetPosition)&&s.containsRange(n,!0))return n.start=n.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),n.end=n.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),Ue([n],a);const h=$(r.sourcePosition.getParentPath(),e.sourcePosition.getParentPath());if(h=="prefix"||h=="extension")return n.start=n.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),n.end=n.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Ue([n],a);r.type=="remove"&&e.type!="remove"&&!t.aWasUndone&&!t.forceWeakRemove?i=!0:r.type!="remove"&&e.type=="remove"&&!t.bWasUndone&&!t.forceWeakRemove&&(i=!1);const u=[],g=n.getDifference(s);for(const y of g){y.start=y.start._getTransformedByDeletion(e.sourcePosition,e.howMany),y.end=y.end._getTransformedByDeletion(e.sourcePosition,e.howMany);const v=$(y.start.getParentPath(),e.getMovedRangeStart().getParentPath())=="same",R=y._getTransformedByInsertion(e.getMovedRangeStart(),e.howMany,v);u.push(...R)}const _=n.getIntersection(s);return _!==null&&i&&(_.start=_.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),_.end=_.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),u.length===0?u.push(_):u.length==1?s.start.isBefore(n.start)||s.start.isEqual(n.start)?u.unshift(_):u.push(_):u.splice(1,0,_)),u.length===0?[new N(r.baseVersion)]:Ue(u,a)}),b(P,C,(r,e,t)=>{let n=r.targetPosition.clone();if((!r.targetPosition.isEqual(e.insertionPosition)||!e.graveyardPosition||t.abRelation=="moveTargetAfter")&&(n=r.targetPosition._getTransformedBySplitOperation(e)),r.sourcePosition.isEqual(e.insertionPosition)&&t.abRelation=="firstToMoveMerged")return r.howMany++,r.targetPosition=n,[r];const s=f._createFromPositionAndShift(r.sourcePosition,r.howMany);if(s.end.isEqual(e.insertionPosition))return(!e.graveyardPosition||t.abRelation=="lastToMoveMerged")&&r.howMany++,r.targetPosition=n,[r];if(s.start.hasSameParentAs(e.splitPosition)&&s.containsPosition(e.splitPosition)){let a=new f(e.splitPosition,s.end);a=a._getTransformedBySplitOperation(e);const l=[new f(s.start,e.splitPosition),a];return Ue(l,n)}r.targetPosition.isEqual(e.splitPosition)&&t.abRelation=="insertAtSource"&&(n=e.moveTargetPosition),r.targetPosition.isEqual(e.insertionPosition)&&t.abRelation=="insertBetween"&&(n=r.targetPosition);const o=[s._getTransformedBySplitOperation(e)];if(e.graveyardPosition){const a=s.start.isEqual(e.graveyardPosition)||s.containsPosition(e.graveyardPosition);r.howMany>1&&a&&!t.aWasUndone&&o.push(f._createFromPositionAndShift(e.insertionPosition,1))}return Ue(o,n)}),b(P,k,(r,e,t)=>{const n=f._createFromPositionAndShift(r.sourcePosition,r.howMany);if(e.deletionPosition.hasSameParentAs(r.sourcePosition)&&n.containsPosition(e.sourcePosition)){if(r.type=="remove"&&!t.forceWeakRemove){if(!t.aWasUndone){const o=[];let a=e.graveyardPosition.clone(),l=e.targetPosition._getTransformedByMergeOperation(e);const c=r.targetPosition.getTransformedByOperation(e);r.howMany>1&&(o.push(new P(r.sourcePosition,r.howMany-1,c,0)),a=a._getTransformedByMove(r.sourcePosition,c,r.howMany-1),l=l._getTransformedByMove(r.sourcePosition,c,r.howMany-1));const h=e.deletionPosition._getCombined(r.sourcePosition,c),u=new P(a,1,h,0),g=u.getMovedRangeStart().path.slice();g.push(0);const _=new m(u.targetPosition.root,g);l=l._getTransformedByMove(a,h,1);const y=new P(l,e.howMany,_,0);return o.push(u),o.push(y),o}}else if(r.howMany==1)return t.bWasUndone?(r.sourcePosition=e.graveyardPosition.clone(),r.targetPosition=r.targetPosition._getTransformedByMergeOperation(e),[r]):[new N(0)]}const i=f._createFromPositionAndShift(r.sourcePosition,r.howMany)._getTransformedByMergeOperation(e);return r.sourcePosition=i.start,r.howMany=i.end.offset-i.start.offset,r.targetPosition=r.targetPosition._getTransformedByMergeOperation(e),[r]}),b(W,M,(r,e)=>(r.position=r.position._getTransformedByInsertOperation(e),[r])),b(W,k,(r,e)=>r.position.isEqual(e.deletionPosition)?(r.position=e.graveyardPosition.clone(),r.position.stickiness="toNext",[r]):(r.position=r.position._getTransformedByMergeOperation(e),[r])),b(W,P,(r,e)=>(r.position=r.position._getTransformedByMoveOperation(e),[r])),b(W,W,(r,e,t)=>{if(r.position.isEqual(e.position))if(t.aIsStrong)r.oldName=e.newName;else return[new N(0)];return[r]}),b(W,C,(r,e)=>{const t=r.position.path,n=e.splitPosition.getParentPath();if($(t,n)=="same"&&!e.graveyardPosition){const s=new W(r.position.getShiftedBy(1),r.oldName,r.newName,0);return[r,s]}return r.position=r.position._getTransformedBySplitOperation(e),[r]}),b(re,re,(r,e,t)=>{if(r.root===e.root&&r.key===e.key)if(t.aIsStrong)r.oldValue=e.newValue;else return[new N(0)];return[r]}),b(Z,Z,(r,e)=>r.rootName===e.rootName&&r.isAdd===e.isAdd?[new N(0)]:[r]),b(C,M,(r,e)=>(r.splitPosition.hasSameParentAs(e.position)&&r.splitPosition.offset<e.position.offset&&(r.howMany+=e.howMany),r.splitPosition=r.splitPosition._getTransformedByInsertOperation(e),r.insertionPosition=r.insertionPosition._getTransformedByInsertOperation(e),[r])),b(C,k,(r,e,t)=>{if(!r.graveyardPosition&&!t.bWasUndone&&r.splitPosition.hasSameParentAs(e.sourcePosition)){const n=e.graveyardPosition.path.slice();n.push(0);const s=new m(e.graveyardPosition.root,n),i=C.getInsertionPosition(new m(e.graveyardPosition.root,n)),o=new C(s,0,i,null,0);return r.splitPosition=r.splitPosition._getTransformedByMergeOperation(e),r.insertionPosition=C.getInsertionPosition(r.splitPosition),r.graveyardPosition=o.insertionPosition.clone(),r.graveyardPosition.stickiness="toNext",[o,r]}return r.splitPosition.hasSameParentAs(e.deletionPosition)&&!r.splitPosition.isAfter(e.deletionPosition)&&r.howMany--,r.splitPosition.hasSameParentAs(e.targetPosition)&&(r.howMany+=e.howMany),r.splitPosition=r.splitPosition._getTransformedByMergeOperation(e),r.insertionPosition=C.getInsertionPosition(r.splitPosition),r.graveyardPosition&&(r.graveyardPosition=r.graveyardPosition._getTransformedByMergeOperation(e)),[r]}),b(C,P,(r,e,t)=>{const n=f._createFromPositionAndShift(e.sourcePosition,e.howMany);if(r.graveyardPosition){const i=n.start.isEqual(r.graveyardPosition)||n.containsPosition(r.graveyardPosition);if(!t.bWasUndone&&i){const o=r.splitPosition._getTransformedByMoveOperation(e),a=r.graveyardPosition._getTransformedByMoveOperation(e),l=a.path.slice();l.push(0);const c=new m(a.root,l);return[new P(o,r.howMany,c,0)]}r.graveyardPosition=r.graveyardPosition._getTransformedByMoveOperation(e)}const s=r.splitPosition.isEqual(e.targetPosition);if(s&&(t.baRelation=="insertAtSource"||t.abRelation=="splitBefore"))return r.howMany+=e.howMany,r.splitPosition=r.splitPosition._getTransformedByDeletion(e.sourcePosition,e.howMany),r.insertionPosition=C.getInsertionPosition(r.splitPosition),[r];if(s&&t.abRelation&&t.abRelation.howMany){const{howMany:i,offset:o}=t.abRelation;return r.howMany+=i,r.splitPosition=r.splitPosition.getShiftedBy(o),[r]}if(r.splitPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(r.splitPosition)){const i=e.howMany-(r.splitPosition.offset-e.sourcePosition.offset);return r.howMany-=i,r.splitPosition.hasSameParentAs(e.targetPosition)&&r.splitPosition.offset<e.targetPosition.offset&&(r.howMany+=e.howMany),r.splitPosition=e.sourcePosition.clone(),r.insertionPosition=C.getInsertionPosition(r.splitPosition),[r]}return e.sourcePosition.isEqual(e.targetPosition)||(r.splitPosition.hasSameParentAs(e.sourcePosition)&&r.splitPosition.offset<=e.sourcePosition.offset&&(r.howMany-=e.howMany),r.splitPosition.hasSameParentAs(e.targetPosition)&&r.splitPosition.offset<e.targetPosition.offset&&(r.howMany+=e.howMany)),r.splitPosition.stickiness="toNone",r.splitPosition=r.splitPosition._getTransformedByMoveOperation(e),r.splitPosition.stickiness="toNext",r.graveyardPosition?r.insertionPosition=r.insertionPosition._getTransformedByMoveOperation(e):r.insertionPosition=C.getInsertionPosition(r.splitPosition),[r]}),b(C,C,(r,e,t)=>{if(r.splitPosition.isEqual(e.splitPosition)){if(!r.graveyardPosition&&!e.graveyardPosition)return[new N(0)];if(r.graveyardPosition&&e.graveyardPosition&&r.graveyardPosition.isEqual(e.graveyardPosition))return[new N(0)];if(t.abRelation=="splitBefore")return r.howMany=0,r.graveyardPosition=r.graveyardPosition._getTransformedBySplitOperation(e),[r]}if(r.graveyardPosition&&e.graveyardPosition&&r.graveyardPosition.isEqual(e.graveyardPosition)){const n=r.splitPosition.root.rootName=="$graveyard",s=e.splitPosition.root.rootName=="$graveyard";if(s&&!n||!(n&&!s)&&t.aIsStrong){const l=[];return e.howMany&&l.push(new P(e.moveTargetPosition,e.howMany,e.splitPosition,0)),r.howMany&&l.push(new P(r.splitPosition,r.howMany,r.moveTargetPosition,0)),l}else return[new N(0)]}if(r.graveyardPosition&&(r.graveyardPosition=r.graveyardPosition._getTransformedBySplitOperation(e)),r.splitPosition.isEqual(e.insertionPosition)&&t.abRelation=="splitBefore")return r.howMany++,[r];if(e.splitPosition.isEqual(r.insertionPosition)&&t.baRelation=="splitBefore"){const n=e.insertionPosition.path.slice();n.push(0);const s=new m(e.insertionPosition.root,n),i=new P(r.insertionPosition,1,s,0);return[r,i]}return r.splitPosition.hasSameParentAs(e.splitPosition)&&r.splitPosition.offset<e.splitPosition.offset&&(r.howMany-=e.howMany),r.splitPosition=r.splitPosition._getTransformedBySplitOperation(e),r.insertionPosition=C.getInsertionPosition(r.splitPosition),[r]});function ui(r,e){return r.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany)===null}function Ue(r,e){const t=[];for(let n=0;n<r.length;n++){const s=r[n],i=new P(s.start,s.end.offset-s.start.offset,e,0);t.push(i);for(let o=n+1;o<r.length;o++)r[o]=r[o]._getTransformedByMove(i.sourcePosition,i.targetPosition,i.howMany)[0];e=e._getTransformedByMove(i.sourcePosition,i.targetPosition,i.howMany)}return t}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class D extends I(m){constructor(e,t,n="toNone"){if(super(e,t,n),!this.root.is("rootElement"))throw new d("model-liveposition-root-not-rootelement",e);hc.call(this)}detach(){this.stopListening()}toPosition(){return new m(this.root,this.path.slice(),this.stickiness)}static fromPosition(e,t){return new this(e.root,e.path.slice(),t||e.stickiness)}}D.prototype.is=function(r){return r==="livePosition"||r==="model:livePosition"||r=="position"||r==="model:position"};function hc(){this.listenTo(this.root.document.model,"applyOperation",(r,e)=>{const t=e[0];t.isDocumentOperation&&uc.call(this,t)},{priority:"low"})}function uc(r){const e=this.getTransformedByOperation(r);if(!this.isEqual(e)){const t=this.toPosition();this.path=e.path,this.root=e.root,this.fire("change",t)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ke{operations;isUndoable;isLocal;isUndo;isTyping;constructor(e={}){typeof e=="string"&&(e=e==="transparent"?{isUndoable:!1}:{},G("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:n=!0,isUndo:s=!1,isTyping:i=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=n,this.isUndo=s,this.isTyping=i}get baseVersion(){for(const e of this.operations)if(e.baseVersion!==null)return e.baseVersion;return null}addOperation(e){return e.isDocumentOperation&&(e.batch=this,this.operations.push(e)),e}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Et{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 this._changesInElement.size==0&&this._changedMarkers.size==0&&this._changedRoots.size==0}bufferOperation(e){const t=e;switch(t.type){case"insert":{if(this._isInInsertedElement(t.position.parent))return;this._markInsert(t.position.parent,t.position.offset,t.nodes.maxOffset);break}case"addAttribute":case"removeAttribute":case"changeAttribute":{for(const n of t.range.getItems({shallow:!0}))this._isInInsertedElement(n.parent)||this._markAttribute(n);break}case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const n=this._isInInsertedElement(t.sourcePosition.parent),s=this._isInInsertedElement(t.targetPosition.parent);n||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),s||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);const i=f._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const o of i.getItems({shallow:!0}))this._setElementState(o,"move");break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const n=f._createFromPositionAndShift(t.position,1);for(const s of this._markerCollection.getMarkersIntersectingRange(n)){const i=s.getData();this.bufferMarkerChange(s.name,i,i)}this._setElementState(t.position.nodeAfter,"rename");break}case"split":{const n=t.splitPosition.parent;if(!this._isInInsertedElement(n)){this._markRemove(n,t.splitPosition.offset,t.howMany);const s=f._createFromPositionAndShift(t.splitPosition,t.howMany);for(const i of s.getItems({shallow:!0}))this._setElementState(i,"move")}this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&(this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1),this._setElementState(t.graveyardPosition.nodeAfter,"move"));break}case"merge":{const n=t.sourcePosition.parent;this._isInInsertedElement(n.parent)||this._markRemove(n.parent,n.startOffset,1);const s=t.graveyardPosition.parent;this._markInsert(s,t.graveyardPosition.offset,1),this._setElementState(n,"move");const i=t.targetPosition.parent;if(!this._isInInsertedElement(i)){this._markInsert(i,t.targetPosition.offset,n.maxOffset);const o=f._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const a of o.getItems({shallow:!0}))this._setElementState(a,"move")}break}case"detachRoot":case"addRoot":{const n=t.affectedSelectable;if(!n._isLoaded||n.isAttached()==t.isAdd)return;this._bufferRootStateChange(t.rootName,t.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!t.root._isLoaded)return;const n=t.root.rootName;this._bufferRootAttributeChange(n,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,n){t.range&&t.range.root.is("rootElement")&&!t.range.root._isLoaded&&(t.range=null),n.range&&n.range.root.is("rootElement")&&!n.range.root._isLoaded&&(n.range=null);let s=this._changedMarkers.get(e);s?s.newMarkerData=n:(s={newMarkerData:n,oldMarkerData:t},this._changedMarkers.set(e,s)),s.oldMarkerData.range==null&&n.range==null&&this._changedMarkers.delete(e)}getMarkersToRemove(){const e=[];for(const[t,n]of this._changedMarkers)n.oldMarkerData.range!=null&&e.push({name:t,range:n.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,n]of this._changedMarkers)n.newMarkerData.range!=null&&e.push({name:t,range:n.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map(([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}}))}hasDataChanges(){if(this.getChanges().length||this._changedRoots.size>0)return!0;for(const{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){const n=e.range&&!t.range,s=!e.range&&t.range,i=e.range&&t.range&&!e.range.isEqual(t.range);if(n||s||i)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const n of this._changesInElement.keys()){const s=this._changesInElement.get(n).sort((h,u)=>h.offset===u.offset?h.type!=u.type?h.type=="remove"?-1:1:0:h.offset<u.offset?-1:1),i=this._elementChildrenSnapshots.get(n),o=di(n.getChildren()),a=fc(i.length,s);let l=0,c=0;for(const h of a)if(h==="i"){const u=this._getDiffActionForNode(o[l].node,"insert"),g=this._elementsSnapshots.get(o[l].node),_=this._getInsertDiff(n,l,u,o[l],g);t.push(_),l++}else if(h==="r"){const u=this._getDiffActionForNode(i[c].node,"remove"),g=this._getRemoveDiff(n,l,u,i[c]);t.push(g),c++}else if(h==="a"){const u=i[c].attributes,g=o[l].attributes;let _;if(o[l].name=="$text")_=new f(m._createAt(n,l),m._createAt(n,l+1));else{const v=n.offsetToIndex(l);_=new f(m._createAt(n,l),m._createAt(n.getChild(v),0))}const y=this._getAttributesDiff(_,u,g);t.push(...y),l++,c++}else l++,c++}t.sort((n,s)=>n.position.root!=s.position.root?n.position.root.rootName<s.position.root.rootName?-1:1:n.position.isEqual(s.position)?n.changeCount-s.changeCount:n.position.isBefore(s.position)?-1:1);for(let n=1,s=0;n<t.length;n++){const i=t[s],o=t[n],a=i.type=="remove"&&o.type=="remove"&&i.name=="$text"&&o.name=="$text"&&i.position.isEqual(o.position),l=i.type=="insert"&&o.type=="insert"&&i.name=="$text"&&o.name=="$text"&&i.position.parent==o.position.parent&&i.position.offset+i.length==o.position.offset,c=i.type=="attribute"&&o.type=="attribute"&&i.position.parent==o.position.parent&&i.range.isFlat&&o.range.isFlat&&i.position.offset+i.length==o.position.offset&&i.attributeKey==o.attributeKey&&i.attributeOldValue==o.attributeOldValue&&i.attributeNewValue==o.attributeNewValue;a||l||c?(i.length++,c&&(i.range.end=i.range.end.getShiftedBy(1)),t[n]=null):s=n}t=t.filter(n=>n);for(const n of t)delete n.changeCount,n.type=="attribute"&&(delete n.position,delete n.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(dc),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getChangedRoots(){return Array.from(this._changedRoots.values()).map(e=>{const t={...e};return t.state!==void 0&&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");const t=f._createOn(e);for(const n of this._markerCollection.getMarkersIntersectingRange(t)){const s=n.getData();this.bufferMarkerChange(n.name,s,s)}this._cachedChanges=null}_bufferRootLoad(e){if(e.isAttached()){this._bufferRootStateChange(e.rootName,!0),this._markInsert(e,0,e.maxOffset);for(const t of e.getAttributeKeys())this._bufferRootAttributeChange(e.rootName,t,null,e.getAttribute(t));for(const t of this._markerCollection)if(t.getRange().root==e){const n=t.getData();this.bufferMarkerChange(t.name,{...n,range:null},n)}}}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e)){this._changedRoots.set(e,{name:e,state:t?"attached":"detached"});return}const n=this._changedRoots.get(e);n.state!==void 0?(delete n.state,n.attributes===void 0&&this._changedRoots.delete(e)):n.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,n,s){const i=this._changedRoots.get(e)||{name:e},o=i.attributes||{};if(o[t]){const a=o[t];s===a.oldValue?delete o[t]:a.newValue=s}else o[t]={oldValue:n,newValue:s};Object.entries(o).length===0?(delete i.attributes,i.state===void 0&&this._changedRoots.delete(e)):(i.attributes=o,this._changedRoots.set(e,i))}_markInsert(e,t,n){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const s={type:"insert",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,s)}_markRemove(e,t,n){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const s={type:"remove",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,s),this._removeAllNestedChanges(e,t,n)}_markAttribute(e){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshots(e);const n=this._getChangesForElement(e);this._handleChange(t,n),n.push(t);for(let s=0;s<n.length;s++)n[s].howMany<1&&(n.splice(s,1),s--)}_setElementState(e,t){if(!e.is("element"))return;const n=Et._statesPriority.indexOf(this._elementState.get(e));Et._statesPriority.indexOf(t)>n&&this._elementState.set(e,t)}_getDiffActionForNode(e,t){if(!e.is("element")||!this._elementsSnapshots.has(e))return t;const n=this._elementState.get(e);return!n||n=="move"?t:n}_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;const t=di(e.getChildren());this._elementChildrenSnapshots.set(e,t);for(const n of t)this._elementsSnapshots.set(n.node,n)}_handleChange(e,t){e.nodesToHandle=e.howMany;for(const n of t){const s=e.offset+e.howMany,i=n.offset+n.howMany;if(e.type=="insert"&&(n.type=="insert"&&(e.offset<=n.offset?n.offset+=e.howMany:e.offset<i&&(n.howMany+=e.nodesToHandle,e.nodesToHandle=0)),n.type=="remove"&&e.offset<n.offset&&(n.offset+=e.howMany),n.type=="attribute")){if(e.offset<=n.offset)n.offset+=e.howMany;else if(e.offset<i){const o=n.howMany;n.howMany=e.offset-n.offset,t.unshift({type:"attribute",offset:s,howMany:o-n.howMany,count:this._changeCount++})}}if(e.type=="remove"){if(n.type=="insert"){if(s<=n.offset)n.offset-=e.howMany;else if(s<=i)if(e.offset<n.offset){const o=s-n.offset;n.offset=e.offset,n.howMany-=o,e.nodesToHandle-=o}else n.howMany-=e.nodesToHandle,e.nodesToHandle=0;else if(e.offset<=n.offset)e.nodesToHandle-=n.howMany,n.howMany=0;else if(e.offset<i){const o=i-e.offset;n.howMany-=o,e.nodesToHandle-=o}}if(n.type=="remove"&&(s<=n.offset?n.offset-=e.howMany:e.offset<n.offset&&(e.nodesToHandle+=n.howMany,n.howMany=0)),n.type=="attribute"){if(s<=n.offset)n.offset-=e.howMany;else if(e.offset<n.offset){const o=s-n.offset;n.offset=e.offset,n.howMany-=o}else if(e.offset<i)if(s<=i){const o=n.howMany;n.howMany=e.offset-n.offset;const a=o-n.howMany-e.nodesToHandle;t.unshift({type:"attribute",offset:e.offset,howMany:a,count:this._changeCount++})}else n.howMany-=i-e.offset}}if(e.type=="attribute"){if(n.type=="insert")if(e.offset<n.offset&&s>n.offset){if(s>i){const o={type:"attribute",offset:i,howMany:s-i,count:this._changeCount++};this._handleChange(o,t),t.push(o)}e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=n.offset&&e.offset<i&&(s>i?(e.nodesToHandle=s-i,e.offset=i):e.nodesToHandle=0);if(n.type=="remove"&&e.offset<n.offset&&s>n.offset){const o={type:"attribute",offset:n.offset,howMany:s-n.offset,count:this._changeCount++};this._handleChange(o,t),t.push(o),e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}n.type=="attribute"&&(e.offset>=n.offset&&s<=i?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=n.offset&&s>=i&&(n.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,n,s,i){const o={type:"insert",position:m._createAt(e,t),name:s.name,attributes:new Map(s.attributes),length:1,changeCount:this._changeCount++,action:n};return n!="insert"&&i&&(o.before={name:i.name,attributes:new Map(i.attributes)}),o}_getRemoveDiff(e,t,n,s){return{type:"remove",action:n,position:m._createAt(e,t),name:s.name,attributes:new Map(s.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,n){const s=[];n=new Map(n);for(const[i,o]of t){const a=n.has(i)?n.get(i):null;a!==o&&s.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:i,attributeOldValue:o,attributeNewValue:a,changeCount:this._changeCount++}),n.delete(i)}for(const[i,o]of n)s.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:i,attributeOldValue:null,attributeNewValue:o,changeCount:this._changeCount++});return s}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const n=this._changesInElement.get(t),s=e.startOffset;if(n){for(const i of n)if(i.type=="insert"&&s>=i.offset&&s<i.offset+i.howMany)return!0}return this._isInInsertedElement(t)}_removeAllNestedChanges(e,t,n){const s=new f(m._createAt(e,t),m._createAt(e,t+n));for(const i of s.getItems({shallow:!0}))i.is("element")&&(this._changesInElement.delete(i),this._removeAllNestedChanges(i,0,i.maxOffset))}}function fi(r){return{node:r,name:r.is("$text")?"$text":r.name,attributes:new Map(r.getAttributes())}}function di(r){const e=[];for(const t of r)if(t.is("$text"))for(let n=0;n<t.data.length;++n)e.push(fi(t));else e.push(fi(t));return e}function fc(r,e){const t=[];let n=0,s=0;for(const i of e){if(i.offset>n){for(let o=0;o<i.offset-n;o++)t.push("e");s+=i.offset-n}if(i.type=="insert"){for(let o=0;o<i.howMany;o++)t.push("i");n=i.offset+i.howMany}else if(i.type=="remove"){for(let o=0;o<i.howMany;o++)t.push("r");n=i.offset,s+=i.howMany}else{if(i.howMany>1500)for(let o=0;o<i.howMany;o++)t.push("a");else t.push(..."a".repeat(i.howMany).split(""));n=i.offset+i.howMany,s+=i.howMany}}if(s<r)for(let i=0;i<r-s-n;i++)t.push("e");return t}function dc(r){const e="position"in r&&r.position.root.rootName=="$graveyard",t="range"in r&&r.range.root.rootName=="$graveyard";return!e&&!t}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class mi{_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 d("model-document-history-addoperation-incorrect-version",this,{operation:e,historyVersion:this.version});this._operations.push(e),this._version++,this._baseVersionToOperationIndex.set(e.baseVersion,this._operations.length-1)}getOperations(e,t=this.version){if(!this._operations.length)return[];const n=this._operations[0];e===void 0&&(e=n.baseVersion);let s=t-1;for(const[a,l]of this._gaps)e>a&&e<l&&(e=l),s>a&&s<l&&(s=a-1);if(s<n.baseVersion||e>this.lastOperation.baseVersion)return[];let i=this._baseVersionToOperationIndex.get(e);i===void 0&&(i=0);let o=this._baseVersionToOperationIndex.get(s);return o===void 0&&(o=this._operations.length-1),this._operations.slice(i,o+1)}getOperation(e){const t=this._baseVersionToOperationIndex.get(e);if(t!==void 0)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}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class ze extends A{rootName;_document;_isAttached=!0;_isLoaded=!0;constructor(e,t,n="main"){super(t),this._document=e,this.rootName=n}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}ze.prototype.is=function(r,e){return e?e===this.name&&(r==="rootElement"||r==="model:rootElement"||r==="element"||r==="model:element"):r==="rootElement"||r==="model:rootElement"||r==="element"||r==="model:element"||r==="node"||r==="model:node"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const gi="$graveyard";class pi extends I(){model;history;selection;roots;differ;isReadOnly;_postFixers;_hasSelectionChangedFromTheLastChangeBlock;constructor(e){super(),this.model=e,this.history=new mi,this.selection=new U(this),this.roots=new fn({idProperty:"rootName"}),this.differ=new Et(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",gi),this.listenTo(e,"applyOperation",(t,n)=>{const s=n[0];s.isDocumentOperation&&this.differ.bufferOperation(s)},{priority:"high"}),this.listenTo(e,"applyOperation",(t,n)=>{const s=n[0];s.isDocumentOperation&&this.history.addOperation(s)},{priority:"low"}),this.listenTo(this.selection,"change",()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0}),this.listenTo(e.markers,"update",(t,n,s,i,o)=>{const a={...n.getData(),range:i};this.differ.bufferMarkerChange(n.name,o,a),s===null&&n.on("change",(l,c)=>{const h=n.getData();this.differ.bufferMarkerChange(n.name,{...h,range:c},h)})}),this.registerPostFixer(t=>{let n=!1;for(const s of this.roots)!s.isAttached()&&!s.isEmpty&&(t.remove(t.createRangeIn(s)),n=!0);for(const s of this.model.markers)s.getRange().root.isAttached()||(t.removeMarker(s),n=!0);return n})}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(gi)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new d("model-document-createroot-name-exists",this,{name:t});const n=new ze(this,e,t);return this.roots.add(n),n}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map(t=>t.rootName)}getRoots(e=!1){return this.roots.filter(t=>t!=this.graveyard&&(e||t.isAttached())&&t._isLoaded)}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=ea(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){const e=this.getRoots();return e.length?e[0]:this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,n=t.schema,s=t.createPositionFromPath(e,[0]);return n.getNearestSelectionRange(s)||t.createRange(s)}_validateSelectionRange(e){return e.start.isValid()&&e.end.isValid()&&_i(e.start)&&_i(e.end)}_callPostFixers(e){let t=!1;do for(const n of this._postFixers)if(this.selection.refresh(),t=n(e),t)break;while(t)}}function _i(r){const e=r.textNode;if(e){const t=e.data,n=r.offset-e.startOffset;return!Ir(t,n)&&!Fr(t,n)}return!0}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class wi extends I(){_markers=new Map;[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof Je?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,n=!1,s=!1){const i=e instanceof Je?e.name:e;if(i.includes(","))throw new d("markercollection-incorrect-marker-name",this);const o=this._markers.get(i);if(o){const c=o.getData(),h=o.getRange();let u=!1;return h.isEqual(t)||(o._attachLiveRange(ye.fromRange(t)),u=!0),n!=o.managedUsingOperations&&(o._managedUsingOperations=n,u=!0),typeof s=="boolean"&&s!=o.affectsData&&(o._affectsData=s,u=!0),u&&this.fire(`update:${i}`,o,h,t,c),o}const a=ye.fromRange(t),l=new Je(i,a,n,s);return this._markers.set(i,l),this.fire(`update:${i}`,l,null,t,{...l.getData(),range:null}),l}_remove(e){const t=e instanceof Je?e.name:e,n=this._markers.get(t);return n?(this._markers.delete(t),this.fire(`update:${t}`,n,n.getRange(),null,n.getData()),this._destroyMarker(n),!0):!1}_refresh(e){const t=e instanceof Je?e.name:e,n=this._markers.get(t);if(!n)throw new d("markercollection-refresh-marker-not-exists",this);const s=n.getRange();this.fire(`update:${t}`,n,s,s,n.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)t.getRange().getIntersection(e)!==null&&(yield t)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}class Je extends I(oe){name;_managedUsingOperations;_affectsData;_liveRange;constructor(e,t,n,s){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=n,this._affectsData=s}get managedUsingOperations(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new d("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}}Je.prototype.is=function(r){return r==="marker"||r==="model:marker"};/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class yi extends z{sourcePosition;howMany;constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}get type(){return"detach"}get affectedSelectable(){return null}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new d("detach-operation-on-document-node",this)}_execute(){gr(f._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class j extends oe{markers=new Map;_children=new We;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 this.childCount===0}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(const n of e)t=t.getChildAtOffset(n);return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const n of e)n.name?t.push(A.fromJSON(n)):t.push(S.fromJSON(n));return new j(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const n=mc(t);for(const s of n)s.parent!==null&&s._remove(),s.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const s of n)s.parent=null;return n}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}}j.prototype.is=function(r){return r==="documentFragment"||r==="model:documentFragment"};function mc(r){return typeof r=="string"?[new S(r)]:(ue(r)||(r=[r]),Array.from(r).map(e=>typeof e=="string"?new S(e):e instanceof H?new S(e.data,e.getAttributes()):e))}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class bi{model;batch;constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new S(e,t)}createElement(e,t){return new A(e,t)}createDocumentFragment(){return new j}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,n=0){if(this._assertWriterUsedCorrectly(),e instanceof S&&e.data=="")return;const s=m._createAt(t,n);if(e.parent)if(Ci(e.root,s.root)){this.move(f._createOn(e),s);return}else{if(e.root.document)throw new d("model-writer-insert-forbidden-move",this);this.remove(e)}const i=s.root.document?s.root.document.version:null,o=e instanceof j?e._removeChildren(0,e.childCount):e,a=new M(s,o,i);if(e instanceof S&&(a.shouldReceiveAttributes=!0),this.batch.addOperation(a),this.model.applyOperation(a),e instanceof j)for(const[l,c]of e.markers){const h=m._createAt(c.root,0),g={range:new f(c.start._getCombined(h,s),c.end._getCombined(h,s)),usingOperation:!0,affectsData:!0};this.model.markers.has(l)?this.updateMarker(l,g):this.addMarker(l,g)}}insertText(e,t,n,s){t instanceof j||t instanceof A||t instanceof m?this.insert(this.createText(e),t,n):this.insert(this.createText(e,t),n,s)}insertElement(e,t,n,s){t instanceof j||t instanceof A||t instanceof m?this.insert(this.createElement(e),t,n):this.insert(this.createElement(e,t),n,s)}append(e,t){this.insert(e,t,"end")}appendText(e,t,n){t instanceof j||t instanceof A?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),n,"end")}appendElement(e,t,n){t instanceof j||t instanceof A?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),n,"end")}setAttribute(e,t,n){if(this._assertWriterUsedCorrectly(),n instanceof f){const s=n.getMinimalFlatRanges();for(const i of s)vi(this,e,t,i)}else Pi(this,e,t,n)}setAttributes(e,t){for(const[n,s]of he(e))this.setAttribute(n,s,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof f){const n=t.getMinimalFlatRanges();for(const s of n)vi(this,e,null,s)}else Pi(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=n=>{for(const s of n.getAttributeKeys())this.removeAttribute(s,n)};if(!(e instanceof f))t(e);else for(const n of e.getItems())t(n)}move(e,t,n){if(this._assertWriterUsedCorrectly(),!(e instanceof f))throw new d("writer-move-invalid-range",this);if(!e.isFlat)throw new d("writer-move-range-not-flat",this);const s=m._createAt(t,n);if(s.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!Ci(e.root,s.root))throw new d("writer-move-different-document",this);const i=e.root.document?e.root.document.version:null,o=new P(e.start,e.end.offset-e.start.offset,s,i);this.batch.addOperation(o),this.model.applyOperation(o)}remove(e){this._assertWriterUsedCorrectly();const n=(e instanceof f?e:f._createOn(e)).getMinimalFlatRanges().reverse();for(const s of n)this._addOperationForAffectedMarkers("move",s),gc(s.start,s.end.offset-s.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,n=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof A))throw new d("writer-merge-no-element-before",this);if(!(n instanceof A))throw new d("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,n){return this.model.createPositionFromPath(e,t,n)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(...e){return this.model.createSelection(...e)}_mergeDetached(e){const t=e.nodeBefore,n=e.nodeAfter;this.move(f._createIn(n),m._createAt(t,"end")),this.remove(n)}_merge(e){const t=m._createAt(e.nodeBefore,"end"),n=m._createAt(e.nodeAfter,0),s=e.root.document.graveyard,i=new m(s,[0]),o=e.root.document.version,a=new k(n,e.nodeAfter.maxOffset,t,i,o);this.batch.addOperation(a),this.model.applyOperation(a)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof A))throw new d("writer-rename-not-element-instance",this);const n=e.root.document?e.root.document.version:null,s=new W(m._createBefore(e),e.name,t,n);this.batch.addOperation(s),this.model.applyOperation(s)}split(e,t){this._assertWriterUsedCorrectly();let n=e.parent;if(!n.parent)throw new d("writer-split-element-no-parent",this);if(t||(t=n.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new d("writer-split-invalid-limit-element",this);let s,i;do{const o=n.root.document?n.root.document.version:null,a=n.maxOffset-e.offset,l=C.getInsertionPosition(e),c=new C(e,a,l,null,o);this.batch.addOperation(c),this.model.applyOperation(c),!s&&!i&&(s=n,i=e.parent.nextSibling),e=this.createPositionAfter(e.parent),n=e.parent}while(n!==t);return{position:e,range:new f(m._createAt(s,"end"),m._createAt(i,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new d("writer-wrap-range-not-flat",this);const n=t instanceof A?t:new A(t);if(n.childCount>0)throw new d("writer-wrap-element-not-empty",this);if(n.parent!==null)throw new d("writer-wrap-element-attached",this);this.insert(n,e.start);const s=new f(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(s,m._createAt(n,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),e.parent===null)throw new d("writer-unwrap-element-no-parent",this);this.move(f._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||typeof t.usingOperation!="boolean")throw new d("writer-addmarker-no-usingoperation",this);const n=t.usingOperation,s=t.range,i=t.affectsData===void 0?!1:t.affectsData;if(this.model.markers.has(e))throw new d("writer-addmarker-marker-exists",this);if(!s)throw new d("writer-addmarker-no-range",this);return n?(vt(this,e,null,s,i),this.model.markers.get(e)):this.model.markers._set(e,s,n,i)}updateMarker(e,t){this._assertWriterUsedCorrectly();const n=typeof e=="string"?e:e.name,s=this.model.markers.get(n);if(!s)throw new d("writer-updatemarker-marker-not-exists",this);if(!t){G("writer-updatemarker-reconvert-using-editingcontroller",{markerName:n}),this.model.markers._refresh(s);return}const i=typeof t.usingOperation=="boolean",o=typeof t.affectsData=="boolean",a=o?t.affectsData:s.affectsData;if(!i&&!t.range&&!o)throw new d("writer-updatemarker-wrong-options",this);const l=s.getRange(),c=t.range?t.range:l;if(i&&t.usingOperation!==s.managedUsingOperations){t.usingOperation?vt(this,n,null,c,a):(vt(this,n,l,null,a),this.model.markers._set(n,c,void 0,a));return}s.managedUsingOperations?vt(this,n,l,c,a):this.model.markers._set(n,c,void 0,a)}removeMarker(e){this._assertWriterUsedCorrectly();const t=typeof e=="string"?e:e.name;if(!this.model.markers.has(t))throw new d("writer-removemarker-no-marker",this);const n=this.model.markers.get(t);if(!n.managedUsingOperations){this.model.markers._remove(t);return}const s=n.getRange();vt(this,t,s,null,n.affectsData)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const n=this.model.document.getRoot(e);if(n&&n.isAttached())throw new d("writer-addroot-root-exists",this);const s=this.model.document,i=new Z(e,t,!0,s,s.version);return this.batch.addOperation(i),this.model.applyOperation(i),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();const t=typeof e=="string"?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new d("writer-detachroot-no-root",this);for(const i of this.model.markers)i.getRange().root===t&&this.removeMarker(i);for(const i of t.getAttributeKeys())this.removeAttribute(i,t);this.remove(this.createRangeIn(t));const n=this.model.document,s=new Z(t.rootName,t.name,!1,n,n.version);this.batch.addOperation(s),this.model.applyOperation(s)}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(),typeof e=="string")this._setSelectionAttribute(e,t);else for(const[n,s]of he(e))this._setSelectionAttribute(n,s)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),typeof e=="string")this._removeSelectionAttribute(e);else for(const t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){const n=this.model.document.selection;if(n.isCollapsed&&n.anchor.parent.isEmpty){const s=U._getStoreAttributeKey(e);this.setAttribute(s,t,n.anchor.parent)}n._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const n=U._getStoreAttributeKey(e);this.removeAttribute(n,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new d("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const n of this.model.markers){if(!n.managedUsingOperations)continue;const s=n.getRange();let i=!1;if(e==="move"){const o=t;i=o.containsPosition(s.start)||o.start.isEqual(s.start)||o.containsPosition(s.end)||o.end.isEqual(s.end)}else{const o=t,a=o.nodeBefore,l=o.nodeAfter,c=s.start.parent==a&&s.start.isAtEnd,h=s.end.parent==l&&s.end.offset==0,u=s.end.nodeAfter==l,g=s.start.nodeAfter==l;i=c||h||u||g}i&&this.updateMarker(n.name,{range:s})}}}function vi(r,e,t,n){const s=r.model,i=s.document;let o=n.start,a,l,c;for(const u of n.getWalker({shallow:!0}))c=u.item.getAttribute(e),a&&l!=c&&(l!=t&&h(),o=a),a=u.nextPosition,l=c;a instanceof m&&a!=o&&l!=t&&h();function h(){const u=new f(o,a),g=u.root.document?i.version:null,_=new E(u,e,l,t,g);r.batch.addOperation(_),s.applyOperation(_)}}function Pi(r,e,t,n){const s=r.model,i=s.document,o=n.getAttribute(e);let a,l;if(o!=t){if(n.root===n){const h=n.document?i.version:null;l=new re(n,e,o,t,h)}else{a=new f(m._createBefore(n),r.createPositionAfter(n));const h=a.root.document?i.version:null;l=new E(a,e,o,t,h)}r.batch.addOperation(l),s.applyOperation(l)}}function vt(r,e,t,n,s){const i=r.model,o=i.document,a=new L(e,t,n,i.markers,!!s,o.version);r.batch.addOperation(a),i.applyOperation(a)}function gc(r,e,t,n){let s;if(r.root.document){const i=n.document,o=new m(i.graveyard,[0]);s=new P(r,e,o,i.version)}else s=new yi(r,e);t.addOperation(s),n.applyOperation(s)}function Ci(r,e){return r===e||r instanceof ze&&e instanceof ze}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Si(r){r.document.registerPostFixer(e=>pc(e,r))}function pc(r,e){const t=e.document.selection,n=e.schema,s=[];let i=!1;for(const o of t.getRanges()){const a=Ai(o,n);a&&!a.isEqual(o)?(s.push(a),i=!0):s.push(o)}return i&&r.setSelection(Ei(s),{backward:t.isBackward}),!1}function Ai(r,e){return r.isCollapsed?_c(r,e):wc(r,e)}function _c(r,e){const t=r.start,n=e.getNearestSelectionRange(t);if(!n){const i=t.getAncestors().reverse().find(o=>e.isObject(o));return i?f._createOn(i):null}if(!n.isCollapsed)return n;const s=n.start;return t.isEqual(s)?null:new f(s)}function wc(r,e){const{start:t,end:n}=r,s=e.checkChild(t,"$text"),i=e.checkChild(n,"$text"),o=e.getLimitElement(t),a=e.getLimitElement(n);if(o===a){if(s&&i)return null;if(yc(t,n,e)){const u=t.nodeAfter&&e.isSelectable(t.nodeAfter)?null:e.getNearestSelectionRange(t,"forward"),_=n.nodeBefore&&e.isSelectable(n.nodeBefore)?null:e.getNearestSelectionRange(n,"backward"),y=u?u.start:t,v=_?_.end:n;return new f(y,v)}}const l=o&&!o.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const h=t.nodeAfter&&n.nodeBefore&&t.nodeAfter.parent===n.nodeBefore.parent,u=l&&(!h||!Ri(t.nodeAfter,e)),g=c&&(!h||!Ri(n.nodeBefore,e));let _=t,y=n;return u&&(_=m._createBefore(ki(o,e))),g&&(y=m._createAfter(ki(a,e))),new f(_,y)}return null}function ki(r,e){let t=r,n=t;for(;e.isLimit(n)&&n.parent;)t=n,n=n.parent;return t}function yc(r,e,t){const n=r.nodeAfter&&!t.isLimit(r.nodeAfter)||t.checkChild(r,"$text"),s=e.nodeBefore&&!t.isLimit(e.nodeBefore)||t.checkChild(e,"$text");return n||s}function Ei(r){const e=[...r],t=new Set;let n=1;for(;n<e.length;){const i=e[n],o=e.slice(0,n);for(const[a,l]of o.entries())if(!t.has(a)){if(i.isEqual(l))t.add(a);else if(i.isIntersecting(l)){t.add(a),t.add(n);const c=i.getJoined(l);e.push(c)}}n++}return e.filter((i,o)=>!t.has(o))}function Ri(r,e){return r&&e.isSelectable(r)}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ti(r,e,t={}){if(e.isCollapsed)return;const n=e.getFirstRange();if(n.root.rootName=="$graveyard")return;const s=r.schema;r.change(i=>{if(!t.doNotResetEntireContent&&Rc(s,e)){Ec(i,e);return}const o={};if(!t.doNotAutoparagraph){const c=e.getSelectedElement();c&&Object.assign(o,s.getAttributesWithProperty(c,"copyOnReplace",!0))}let a,l;t.doNotFixSelection?(a=D.fromPosition(n.start,"toPrevious"),l=D.fromPosition(n.end,"toNext")):[a,l]=bc(n),a.isTouching(l)||i.remove(i.createRange(a,l)),t.leaveUnmerged||(Pc(i,a,l),s.removeDisallowedAttributes(a.parent.getChildren(),i)),Mi(i,e,a),!t.doNotAutoparagraph&&Ac(s,a)&&Oi(i,a,e,o),a.detach(),l.detach()})}function bc(r){const e=r.root.document.model,t=r.start;let n=r.end;if(e.hasContent(r,{ignoreMarkers:!0})){const s=vc(n);if(s&&n.isTouching(e.createPositionAt(s,0))){const i=e.createSelection(r);e.modifySelection(i,{direction:"backward"});const o=i.getLastPosition(),a=e.createRange(o,n);e.hasContent(a,{ignoreMarkers:!0})||(n=o)}}return[D.fromPosition(t,"toPrevious"),D.fromPosition(n,"toNext")]}function vc(r){const e=r.parent,t=e.root.document.model.schema,n=e.getAncestors({parentFirst:!0,includeSelf:!0});for(const s of n){if(t.isLimit(s))return null;if(t.isBlock(s))return s}}function Pc(r,e,t){const n=r.model;if(!br(r.model.schema,e,t))return;const[s,i]=Sc(e,t);!s||!i||(!n.hasContent(s,{ignoreMarkers:!0})&&n.hasContent(i,{ignoreMarkers:!0})?Ni(r,e,t,s.parent):xi(r,e,t,s.parent))}function xi(r,e,t,n){const s=e.parent,i=t.parent;if(!(s==n||i==n)){for(e=r.createPositionAfter(s),t=r.createPositionBefore(i),t.isEqual(e)||r.insert(i,e),r.merge(e);t.parent.isEmpty;){const o=t.parent;t=r.createPositionBefore(o),r.remove(o)}br(r.model.schema,e,t)&&xi(r,e,t,n)}}function Ni(r,e,t,n){const s=e.parent,i=t.parent;if(!(s==n||i==n)){for(e=r.createPositionAfter(s),t=r.createPositionBefore(i),t.isEqual(e)||r.insert(s,t);e.parent.isEmpty;){const o=e.parent;e=r.createPositionBefore(o),r.remove(o)}t=r.createPositionBefore(i),Cc(r,t),br(r.model.schema,e,t)&&Ni(r,e,t,n)}}function Cc(r,e){const t=e.nodeBefore,n=e.nodeAfter;t.name!=n.name&&r.rename(t,n.name),r.clearAttributes(t),r.setAttributes(Object.fromEntries(n.getAttributes()),t),r.merge(e)}function br(r,e,t){const n=e.parent,s=t.parent;return n==s||r.isLimit(n)||r.isLimit(s)?!1:kc(e,t,r)}function Sc(r,e){const t=r.getAncestors(),n=e.getAncestors();let s=0;for(;t[s]&&t[s]==n[s];)s++;return[t[s],n[s]]}function Ac(r,e){const t=r.checkChild(e,"$text"),n=r.checkChild(e,"paragraph");return!t&&n}function kc(r,e,t){const n=new f(r,e);for(const s of n.getWalker())if(t.isLimit(s.item))return!1;return!0}function Oi(r,e,t,n={}){const s=r.createElement("paragraph");r.model.schema.setAllowedAttributes(s,n,r),r.insert(s,e),Mi(r,t,r.createPositionAt(s,0))}function Ec(r,e){const t=r.model.schema.getLimitElement(e);r.remove(r.createRangeIn(t)),Oi(r,r.createPositionAt(t,0),e)}function Rc(r,e){const t=r.getLimitElement(e);if(!e.containsEntireContent(t))return!1;const n=e.getFirstRange();return n.start.parent==n.end.parent?!1:r.checkChild(t,"paragraph")}function Mi(r,e,t){e instanceof U?r.setSelection(t):e.setTo(t)}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ii(r,e){return r.change(t=>{const n=t.createDocumentFragment(),s=e.getFirstRange();if(!s||s.isCollapsed)return n;const i=s.start.root,o=s.start.getCommonPath(s.end),a=i.getNodeByPath(o);let l;s.start.parent==s.end.parent?l=s:l=t.createRange(t.createPositionAt(a,s.start.path[o.length]),t.createPositionAt(a,s.end.path[o.length]+1));const c=l.end.offset-l.start.offset;for(const h of l.getItems({shallow:!0}))h.is("$textProxy")?t.appendText(h.data,h.getAttributes(),n):t.append(t.cloneElement(h,!0),n);if(l!=s){const h=s._getTransformedByMove(l.start,t.createPositionAt(n,0),c)[0],u=t.createRange(t.createPositionAt(n,0),h.start),g=t.createRange(h.end,t.createPositionAt(n,"end"));Fi(g,t),Fi(u,t)}return n})}function Fi(r,e){const t=[];Array.from(r.getItems({direction:"backward"})).map(n=>e.createRangeOn(n)).filter(n=>(n.start.isAfter(r.start)||n.start.isEqual(r.start))&&(n.end.isBefore(r.end)||n.end.isEqual(r.end))).forEach(n=>{t.push(n.start.parent),e.remove(n)}),t.forEach(n=>{let s=n;for(;s.parent&&s.isEmpty;){const i=e.createRangeOn(s);s=s.parent,e.remove(i)}})}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Di(r,e,t){return r.change(n=>{const s=t||r.document.selection;s.isCollapsed||r.deleteContent(s,{doNotAutoparagraph:!0});const i=new Tc(r,n,s.anchor),o=[];let a;if(e.is("documentFragment")){if(e.markers.size){const h=[];for(const[u,g]of e.markers){const{start:_,end:y}=g,v=_.isEqual(y);h.push({position:_,name:u,isCollapsed:v},{position:y,name:u,isCollapsed:v})}h.sort(({position:u},{position:g})=>u.isBefore(g)?1:-1);for(const{position:u,name:g,isCollapsed:_}of h){let y=null,v=null;const R=u.parent===e&&u.isAtStart,B=u.parent===e&&u.isAtEnd;!R&&!B?(y=n.createElement("$marker"),n.insert(y,u)):_&&(v=R?"start":"end"),o.push({name:g,element:y,collapsed:v})}}a=e.getChildren()}else a=[e];i.handleNodes(a);let l=i.getSelectionRange();if(e.is("documentFragment")&&o.length){const h=l?ye.fromRange(l):null,u={};for(let g=o.length-1;g>=0;g--){const{name:_,element:y,collapsed:v}=o[g],R=!u[_];if(R&&(u[_]=[]),y){const B=n.createPositionAt(y,"before");u[_].push(B),n.remove(y)}else{const B=i.getAffectedRange();if(!B){v&&u[_].push(i.position);continue}v?u[_].push(B[v]):u[_].push(R?B.start:B.end)}}for(const[g,[_,y]]of Object.entries(u))_&&y&&_.root===y.root&&_.root.document&&!n.model.markers.has(g)&&n.addMarker(g,{usingOperation:!0,affectsData:!0,range:new f(_,y)});h&&(l=h.toRange(),h.detach())}/* istanbul ignore else -- @preserve */l&&(s instanceof U?n.setSelection(l):s.setTo(l));const c=i.getAffectedRange()||r.createRange(s.anchor);return i.destroy(),c})}class Tc{model;writer;position;canMergeWith;schema;_documentFragment;_documentFragmentPosition;_firstNode=null;_lastNode=null;_lastAutoParagraph=null;_filterAttributesAndChildrenOf=[];_affectedStart=null;_affectedEnd=null;_nodeToSelect=null;constructor(e,t,n){this.model=e,this.writer=t,this.position=n,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0)}handleNodes(e){for(const 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){const t=Array.from(e);for(const n of t){if(!n.is("element"))continue;const s=[],i=[],o=this.writer.createRangeIn(n).getWalker({ignoreElementEnd:!0});for(const{item:a}of o){const l=a.parent;this.schema.checkChild(l,a)||(a.is("element")&&!this.schema.isObject(a)?(i.push(a),t.push(l)):s.push(a),o.jumpTo(this.writer.createPositionAfter(a)))}for(const a of i)this.writer.unwrap(a);for(const a of s)this.writer.remove(a)}}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),n=this.writer.createPositionAfter(e);if(n.isAfter(t)){this._lastNode=e;/* istanbul ignore if -- @preserve */if(this.position.parent!=e||!this.position.isAtEnd)throw new d("insertcontent-invalid-insertion-position",this);this.position=n,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?f._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new f(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;const e=D.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){/* istanbul ignore if -- @preserve */if(!this.schema.checkChild(this.position,e))throw new d("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=D.fromPosition(e,"toPrevious")),(!this._affectedEnd||this._affectedEnd.isBefore(e))&&(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=D.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof A)||!this._canMergeLeft(e))return;const t=D._createBefore(e);t.stickiness="toNext";const n=D.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=D._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=D._createAt(t.nodeBefore,"end","toNext")),this.position=n.toPosition(),n.detach(),this._filterAttributesAndChildrenOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof A)||!this._canMergeRight(e))return;const t=D._createAfter(e);t.stickiness="toNext";/* istanbul ignore if -- @preserve */if(!this.position.isEqual(t))throw new d("insertcontent-invalid-insertion-position",this);this.position=m._createAt(t.nodeBefore,"end");const n=D.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=D._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=D._createAt(t.nodeBefore,0,"toPrevious")),this.position=n.toPosition(),n.detach(),this._filterAttributesAndChildrenOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof A&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof A&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(e,t)}_insertAutoParagraph(){this._insertPartialFragment();const 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){const t=this._getAllowedIn(this.position.parent,e);if(!t)return!1;for(t!=this.position.parent&&this._insertPartialFragment();t!=this.position.parent;)if(this.position.isAtStart){const n=this.position.parent;this.position=this.writer.createPositionBefore(n),n.isEmpty&&n.parent===t&&this.writer.remove(n)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const n=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=n,this.canMergeWith.add(this.position.nodeAfter)}return this.schema.checkChild(this.position.parent,e)||this._insertAutoParagraph(),!0}_getAllowedIn(e,t){const n=this.schema.createContext(e);return this.schema.checkChild(n,t)||this.schema.checkChild(n,"paragraph")&&this.schema.checkChild(n.push("paragraph"),t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Bi(r,e,t,n={}){if(!r.schema.isObject(e))throw new d("insertobject-element-not-an-object",r,{object:e});const s=t||r.document.selection;let i=s;n.findOptimalPosition&&r.schema.isBlock(e)&&(i=r.createSelection(r.schema.findOptimalInsertionRange(s,n.findOptimalPosition)));const o=mn(s.getSelectedBlocks()),a={};return o&&Object.assign(a,r.schema.getAttributesWithProperty(o,"copyOnReplace",!0)),r.change(l=>{i.isCollapsed||r.deleteContent(i,{doNotAutoparagraph:!0});let c=e;const h=i.anchor.parent,u=r.schema.createContext(h);!r.schema.checkChild(u,e)&&r.schema.checkChild(u,"paragraph")&&r.schema.checkChild(u.push("paragraph"),e)&&(c=l.createElement("paragraph"),l.insert(e,c)),r.schema.setAllowedAttributes(c,a,l);const g=r.insertContent(c,i);return g.isCollapsed||n.setSelection&&xc(l,e,n.setSelection,a),g})}function xc(r,e,t,n){const s=r.model;if(t=="on"){r.setSelection(e,"on");return}if(t!="after")throw new d("insertobject-invalid-place-parameter-value",s);let i=e.nextSibling;if(s.schema.isInline(e)){r.setSelection(e,"after");return}!(i&&s.schema.checkChild(i,"$text"))&&s.schema.checkChild(e.parent,"paragraph")&&(i=r.createElement("paragraph"),s.schema.setAllowedAttributes(i,n,r),s.insertContent(i,r.createPositionAfter(e))),i&&r.setSelection(i,0)}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const Nc=' ,.?!:;"-()';function Vi(r,e,t={}){const n=r.schema,s=t.direction!="backward",i=t.unit?t.unit:"character",o=!!t.treatEmojiAsSingleUnit,a=e.focus,l=new ae({boundaries:Fc(a,s),singleCharacters:!0,direction:s?"forward":"backward"}),c={walker:l,schema:n,isForward:s,unit:i,treatEmojiAsSingleUnit:o};let h;for(;h=l.next();){if(h.done)return;const u=Oc(c,h.value);if(u){e instanceof U?r.change(g=>{g.setSelectionFocus(u)}):e.setFocus(u);return}}}function Oc(r,e){const{isForward:t,walker:n,unit:s,schema:i,treatEmojiAsSingleUnit:o}=r,{type:a,item:l,nextPosition:c}=e;if(a=="text")return r.unit==="word"?Ic(n,t):Mc(n,s,o);if(a==(t?"elementStart":"elementEnd")){if(i.isSelectable(l))return m._createAt(l,t?"after":"before");if(i.checkChild(c,"$text"))return c}else{if(i.isLimit(l)){n.skip(()=>!0);return}if(i.checkChild(c,"$text"))return c}}function Mc(r,e,t){const n=r.position.textNode;if(n){const s=n.data;let i=r.position.offset-n.startOffset;for(;Ir(s,i)||e=="character"&&Fr(s,i)||t&&uo(s,i);)r.next(),i=r.position.offset-n.startOffset}return r.position}function Ic(r,e){let t=r.position.textNode;for(t||(t=e?r.position.nodeAfter:r.position.nodeBefore);t&&t.is("$text");){const n=r.position.offset-t.startOffset;if(Bc(t,n,e))t=e?r.position.nodeAfter:r.position.nodeBefore;else{if(Dc(t.data,n,e))break;r.next()}}return r.position}function Fc(r,e){const t=r.root,n=m._createAt(t,e?"end":0);return e?new f(r,n):new f(n,r)}function Dc(r,e,t){const n=e+(t?0:-1);return Nc.includes(r.charAt(n))}function Bc(r,e,t){return e===(t?r.offsetSize:0)}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Pt extends K(){markers;document;schema;_config;_pendingChanges;_currentWriter;constructor(e){super(),this.markers=new wi,this.document=new pi(this),this.schema=new Zs,this._config=e,this._pendingChanges=[],this._currentWriter=null,["deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach(t=>this.decorate(t)),this.on("applyOperation",(t,n)=>{n[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"),Si(this),this.document.registerPostFixer(en),this.on("insertContent",(t,[n,s])=>{t.return=Di(this,n,s)}),this.on("insertObject",(t,[n,s,i])=>{t.return=Bi(this,n,s,i)}),this.on("canEditAt",t=>{const n=!this.document.isReadOnly;t.return=n,n||t.stop()})}change(e){try{return this._pendingChanges.length===0?(this._pendingChanges.push({batch:new ke,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(t){/* istanbul ignore next -- @preserve */d.rethrowUnexpectedError(t,this)}}enqueueChange(e,t){try{e?typeof e=="function"?(t=e,e=new ke):e instanceof ke||(e=new ke(e)):e=new ke,this._pendingChanges.push({batch:e,callback:t}),this._pendingChanges.length==1&&this._runPendingChanges()}catch(n){/* istanbul ignore next -- @preserve */d.rethrowUnexpectedError(n,this)}}applyOperation(e){e._execute()}insertContent(e,t,n,...s){const i=vr(t,n);return this.fire("insertContent",[e,i,n,...s])}insertObject(e,t,n,s,...i){const o=vr(t,n);return this.fire("insertObject",[e,o,s,s,...i])}deleteContent(e,t){Ti(this,e,t)}modifySelection(e,t){Vi(this,e,t)}getSelectedContent(e){return Ii(this,e)}hasContent(e,t={}){const n=e instanceof f?e:f._createIn(e);if(n.isCollapsed)return!1;const{ignoreWhitespaces:s=!1,ignoreMarkers:i=!1}=t;if(!i){for(const o of this.markers.getMarkersIntersectingRange(n))if(o.affectsData)return!0}for(const o of n.getItems())if(this.schema.isContent(o))if(o.is("$textProxy"))if(s){if(o.data.search(/\S/)!==-1)return!0}else return!0;else return!0;return!1}canEditAt(e){const t=vr(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,n){return new m(e,t,n)}createPositionAt(e,t){return m._createAt(e,t)}createPositionAfter(e){return m._createAfter(e)}createPositionBefore(e){return m._createBefore(e)}createRange(e,t){return new f(e,t)}createRangeIn(e){return f._createIn(e)}createRangeOn(e){return f._createOn(e)}createSelection(...e){return new O(...e)}createBatch(e){return new ke(e)}createOperationFromJSON(e){return _r.fromJSON(e,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const e=[];this.fire("_beforeChanges");try{for(;this._pendingChanges.length;){const t=this._pendingChanges[0].batch;this._currentWriter=new bi(this,t);const n=this._pendingChanges[0].callback(this._currentWriter);e.push(n),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}return e}}function vr(r,e){if(r)return r instanceof O||r instanceof U?r:r instanceof we?e||e===0?new O(r,e):r.is("rootElement")?new O(r,"in"):new O(r,"on"):new O(r)}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Vc extends ie{domEventType="click";onDomEvent(e){this.fire(e.type,e)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Lc extends ie{domEventType=["mousedown","mouseup","mouseover","mouseout"];onDomEvent(e){this.fire(e.type,e)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class $c extends ie{domEventType=["touchstart","touchend","touchmove"];onDomEvent(e){this.fire(e.type,e)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Wc extends ie{domEventType=["pointerdown","pointerup","pointermove"];onDomEvent(e){this.fire(e.type,e)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/class Li{document;constructor(e){this.document=e}createDocumentFragment(e){return new se(this.document,e)}createElement(e,t,n){return new J(this.document,e,t,n)}createText(e){return new T(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,n){return n._insertChild(e,t)}removeChildren(e,t,n){return n._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const n=e.parent;if(n){const s=n.getChildIndex(e);return this.removeChildren(s,1,n),this.insertChild(s,t,n),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const n=t.getChildIndex(e);this.remove(e),this.insertChild(n,e.getChildren(),t)}}rename(e,t){const n=new J(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,n)?n:null}setAttribute(e,t,n){n._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){at(e)&&n===void 0?t._setStyle(e):n._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,n){n._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return p._createAt(e,t)}createPositionAfter(e){return p._createAfter(e)}createPositionBefore(e){return p._createBefore(e)}createRange(e,t){return new w(e,t)}createRangeOn(e){return w._createOn(e)}createRangeIn(e){return w._createIn(e)}createSelection(...e){return new Q(...e)}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const qc=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Uc=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,zc=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Jc=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,jc=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Gc=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,Kc=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 $i(r){return r.startsWith("#")?qc.test(r):r.startsWith("rgb")?Uc.test(r)||zc.test(r):r.startsWith("hsl")?Jc.test(r)||jc.test(r):Kc.has(r.toLowerCase())}const Hc=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];function Wi(r){return Hc.includes(r)}const Xc=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function qi(r){return Xc.test(r)}const Yc=/^[+-]?[0-9]*([.][0-9]+)?%$/;function Qc(r){return Yc.test(r)}const Zc=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function Ui(r){return Zc.includes(r)}const eh=["center","top","bottom","left","right"];function zi(r){return eh.includes(r)}const th=["fixed","scroll","local"];function Ji(r){return th.includes(r)}const nh=/^url\(/;function ji(r){return nh.test(r)}function je(r=""){if(r==="")return{top:void 0,right:void 0,bottom:void 0,left:void 0};const e=sn(r),t=e[0],n=e[2]||t,s=e[1]||t,i=e[3]||s;return{top:t,bottom:n,right:s,left:i}}function Ge(r){return e=>{const{top:t,right:n,bottom:s,left:i}=e,o=[];return[t,n,i,s].every(a=>!!a)?o.push([r,Gi(e)]):(t&&o.push([r+"-top",t]),n&&o.push([r+"-right",n]),s&&o.push([r+"-bottom",s]),i&&o.push([r+"-left",i])),o}}function Gi({top:r,right:e,bottom:t,left:n}){const s=[];return n!==e?s.push(r,e,t,n):t!==r?s.push(r,e,t):e!==r?s.push(r,e):s.push(r),s.join(" ")}function Pr(r){return e=>({path:r,value:je(e)})}function sn(r){const e=r.trim().slice(0,1500).matchAll(Gc);return Array.from(e).map(t=>t[0])}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function rh(r){r.setNormalizer("background",sh()),r.setNormalizer("background-color",ih()),r.setReducer("background",oh()),r.setStyleRelation("background",["background-color"])}function sh(){return r=>{const e={},t=sn(r);for(const n of t)Ui(n)?(e.repeat=e.repeat||[],e.repeat.push(n)):zi(n)?(e.position=e.position||[],e.position.push(n)):Ji(n)?e.attachment=n:$i(n)?e.color=n:ji(n)&&(e.image=n);return{path:"background",value:e}}}function ih(){return r=>({path:"background.color",value:r})}function oh(){return r=>{const e=[];return e.push(["background-color",r.color]),e}}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function ah(r){r.setNormalizer("border",lh()),r.setNormalizer("border-top",on("top")),r.setNormalizer("border-right",on("right")),r.setNormalizer("border-bottom",on("bottom")),r.setNormalizer("border-left",on("left")),r.setNormalizer("border-color",Cr("color")),r.setNormalizer("border-width",Cr("width")),r.setNormalizer("border-style",Cr("style")),r.setNormalizer("border-top-color",Y("color","top")),r.setNormalizer("border-top-style",Y("style","top")),r.setNormalizer("border-top-width",Y("width","top")),r.setNormalizer("border-right-color",Y("color","right")),r.setNormalizer("border-right-style",Y("style","right")),r.setNormalizer("border-right-width",Y("width","right")),r.setNormalizer("border-bottom-color",Y("color","bottom")),r.setNormalizer("border-bottom-style",Y("style","bottom")),r.setNormalizer("border-bottom-width",Y("width","bottom")),r.setNormalizer("border-left-color",Y("color","left")),r.setNormalizer("border-left-style",Y("style","left")),r.setNormalizer("border-left-width",Y("width","left")),r.setExtractor("border-top",an("top")),r.setExtractor("border-right",an("right")),r.setExtractor("border-bottom",an("bottom")),r.setExtractor("border-left",an("left")),r.setExtractor("border-top-color","border.color.top"),r.setExtractor("border-right-color","border.color.right"),r.setExtractor("border-bottom-color","border.color.bottom"),r.setExtractor("border-left-color","border.color.left"),r.setExtractor("border-top-width","border.width.top"),r.setExtractor("border-right-width","border.width.right"),r.setExtractor("border-bottom-width","border.width.bottom"),r.setExtractor("border-left-width","border.width.left"),r.setExtractor("border-top-style","border.style.top"),r.setExtractor("border-right-style","border.style.right"),r.setExtractor("border-bottom-style","border.style.bottom"),r.setExtractor("border-left-style","border.style.left"),r.setReducer("border-color",Ge("border-color")),r.setReducer("border-style",Ge("border-style")),r.setReducer("border-width",Ge("border-width")),r.setReducer("border-top",ln("top")),r.setReducer("border-right",ln("right")),r.setReducer("border-bottom",ln("bottom")),r.setReducer("border-left",ln("left")),r.setReducer("border",hh()),r.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"]),r.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),r.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),r.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),r.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),r.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),r.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),r.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function lh(){return r=>{const{color:e,style:t,width:n}=Ki(r);return{path:"border",value:{color:je(e),style:je(t),width:je(n)}}}}function on(r){return e=>{const{color:t,style:n,width:s}=Ki(e),i={};return t!==void 0&&(i.color={[r]:t}),n!==void 0&&(i.style={[r]:n}),s!==void 0&&(i.width={[r]:s}),{path:"border",value:i}}}function Cr(r){return e=>({path:"border",value:ch(e,r)})}function ch(r,e){return{[e]:je(r)}}function Y(r,e){return t=>({path:"border",value:{[r]:{[e]:t}}})}function an(r){return(e,t)=>{if(t.border)return Ct(t.border,r)}}function Ct(r,e){const t={};return r.width&&r.width[e]&&(t.width=r.width[e]),r.style&&r.style[e]&&(t.style=r.style[e]),r.color&&r.color[e]&&(t.color=r.color[e]),t}function Ki(r){const e={},t=sn(r);for(const n of t)qi(n)||/thin|medium|thick/.test(n)?e.width=n:Wi(n)?e.style=n:e.color=n;return e}function hh(){return e=>{const t=Ct(e,"top"),n=Ct(e,"right"),s=Ct(e,"bottom"),i=Ct(e,"left"),o=[t,n,s,i],a={width:r(o,"width"),style:r(o,"style"),color:r(o,"color")},l=Ke(a,"all");return l.length?l:[...Object.entries(a).reduce((h,[u,g])=>(g&&(h.push([`border-${u}`,g]),o.forEach(_=>delete _[u])),h),[]),...Ke(t,"top"),...Ke(n,"right"),...Ke(s,"bottom"),...Ke(i,"left")]};function r(e,t){return e.map(n=>n[t]).reduce((n,s)=>n==s?n:null)}}function ln(r){return e=>Ke(e,r)}function Ke(r,e){const t=[];if(r&&r.width&&t.push("width"),r&&r.style&&t.push("style"),r&&r.color&&t.push("color"),t.length==3){const n=t.map(s=>r[s]).join(" ");return[e=="all"?["border",n]:[`border-${e}`,n]]}return e=="all"?[]:t.map(n=>[`border-${e}-${n}`,r[n]])}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function uh(r){r.setNormalizer("margin",Pr("margin")),r.setNormalizer("margin-top",e=>({path:"margin.top",value:e})),r.setNormalizer("margin-right",e=>({path:"margin.right",value:e})),r.setNormalizer("margin-bottom",e=>({path:"margin.bottom",value:e})),r.setNormalizer("margin-left",e=>({path:"margin.left",value:e})),r.setReducer("margin",Ge("margin")),r.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function fh(r){r.setNormalizer("padding",Pr("padding")),r.setNormalizer("padding-top",e=>({path:"padding.top",value:e})),r.setNormalizer("padding-right",e=>({path:"padding.right",value:e})),r.setNormalizer("padding-bottom",e=>({path:"padding.bottom",value:e})),r.setNormalizer("padding-left",e=>({path:"padding.left",value:e})),r.setReducer("padding",Ge("padding")),r.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/const He="[",St="]",Xe="{",At="}",kt={container:ge,attribute:_e,empty:ut,ui:Ve,raw:ft},dh={setContentOf:(r,e)=>{r.innerHTML=e}};function cn(r,e={}){if(!(r instanceof mt))throw new TypeError("View needs to be an instance of module:engine/view/view~EditingView.");const t=r.document,n=!!e.withoutSelection,s=e.rootName||"main",i=t.getRoot(s),o={showType:e.showType,showPriority:e.showPriority,renderUIElements:e.renderUIElements,renderRawElements:e.renderRawElements,ignoreRoot:!0,domConverter:e.domConverter,skipListItemIds:e.skipListItemIds};return n?cn._stringify(i,null,o):cn._stringify(i,t.selection,o)}cn._stringify=Ar;function Sr(r,e,t={}){if(!(r instanceof mt))throw new TypeError("View needs to be an instance of module:engine/view/view~EditingView.");const n=r.document,s=t.rootName||"main",i=n.getRoot(s);r.change(o=>{const a=Sr._parse(e,{rootElement:i});a.view&&a.selection&&o.setSelection(a.selection)})}Sr._parse=kr;function Ar(r,e=null,t={}){let n;return e instanceof p||e instanceof w?n=new Be(e):n=e,new gh(r,n,t).stringify()}function kr(r,e={}){const t=new Gt(new Fn);e.order=e.order||[];const n=new mh({sameSelectionCharacters:e.sameSelectionCharacters}),s=new si(t,{namespaces:Object.keys(kt)});e.inlineObjectElements&&s.domConverter.inlineObjectElements.push(...e.inlineObjectElements);let i=s.toView(r);if(i=Hi(i),e.rootElement){const a=e.rootElement,l=i._removeChildren(0,i.childCount);a._removeChildren(0,a.childCount),a._appendChild(l),i=a}const o=n._parseView(i,e.order);if(i.is("documentFragment")&&i.childCount===1&&(i=i.getChild(0)),o.length){const a=new Be(o,{backward:!!e.lastRangeBackward});return{view:i,selection:a}}return i.parent&&i._remove(),i}class mh{sameSelectionCharacters;_positions;constructor(e){this.sameSelectionCharacters=!!e.sameSelectionCharacters}_parseView(e,t){this._positions=[],this._getPositions(e);let n=this._createRanges();if(t.length){if(t.length!=n.length)throw new Error(`Parse error - there are ${n.length} ranges found, but ranges order array contains ${t.length} elements.`);n=this._sortRanges(n,t)}return n}_getPositions(e){if(e.is("documentFragment")||e.is("element")){const t=[...e.getChildren()];for(const n of t)this._getPositions(n)}if(e.is("$text")){const t=new RegExp(`[${Xe}${At}\\${St}\\${He}]`,"g");let n=e.data,s,i=0;const o=[];for(;s=t.exec(n);){const c=s.index,h=s[0];o.push({bracket:h,textOffset:c-i}),i++}n=n.replace(t,""),e._data=n;const a=e.index,l=e.parent;n||e._remove();for(const c of o)if(n)if(this.sameSelectionCharacters||!this.sameSelectionCharacters&&(c.bracket==Xe||c.bracket==At))this._positions.push({bracket:c.bracket,position:new p(e,c.textOffset)});else{if(!this.sameSelectionCharacters&&c.textOffset!==0&&c.textOffset!==n.length)throw new Error(`Parse error - range delimiter '${c.bracket}' is placed inside text node.`);const h=c.textOffset===0?a:a+1;this._positions.push({bracket:c.bracket,position:new p(l,h)})}else{if(!this.sameSelectionCharacters&&c.bracket==Xe||c.bracket==At)throw new Error(`Parse error - text range delimiter '${c.bracket}' is placed inside empty text node. `);this._positions.push({bracket:c.bracket,position:new p(l,a)})}}}_sortRanges(e,t){const n=[];let s=0;for(const i of t){if(e[i-1]===void 0)throw new Error("Parse error - provided ranges order is invalid.");n[i-1]=e[s],s++}return n}_createRanges(){const e=[];let t=null;for(const n of this._positions){if(!t&&(n.bracket==St||n.bracket==At))throw new Error(`Parse error - end of range was found '${n.bracket}' but range was not started before.`);if(t&&(n.bracket==He||n.bracket==Xe))throw new Error(`Parse error - start of range was found '${n.bracket}' but one range is already started.`);n.bracket==He||n.bracket==Xe?t=new w(n.position,n.position):(t.end=n.position,e.push(t),t=null)}if(t!==null)throw new Error("Parse error - range was started but no end delimiter was found.");return e}}class gh{root;selection;ranges;showType;showPriority;showAttributeElementId;ignoreRoot;sameSelectionCharacters;renderUIElements;renderRawElements;domConverter;skipListItemIds;constructor(e,t,n){this.root=e,this.selection=t,this.ranges=[],t&&(this.ranges=[...t.getRanges()]),this.showType=!!n.showType,this.showPriority=!!n.showPriority,this.showAttributeElementId=!!n.showAttributeElementId,this.ignoreRoot=!!n.ignoreRoot,this.sameSelectionCharacters=!!n.sameSelectionCharacters,this.renderUIElements=!!n.renderUIElements,this.renderRawElements=!!n.renderRawElements,this.domConverter=n.domConverter||dh,this.skipListItemIds=n.skipListItemIds!==void 0?!!n.skipListItemIds:!0}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){const n=this.ignoreRoot&&this.root===e;if(e.is("element")||e.is("documentFragment")){if(e.is("element")&&!n&&t(this._stringifyElementOpen(e)),this.renderUIElements&&e.is("uiElement"))t(e.render(document,this.domConverter).innerHTML);else if(this.renderRawElements&&e.is("rawElement")){const s=document.createElement("div");e.render(s,this.domConverter),t(s.innerHTML)}else{let s=0;t(this._stringifyElementRanges(e,s));for(const i of e.getChildren())this._walkView(i,t),s++,t(this._stringifyElementRanges(e,s))}e.is("element")&&!n&&t(this._stringifyElementClose(e))}e.is("$text")&&t(this._stringifyTextRanges(e))}_stringifyElementRanges(e,t){let n="",s="",i="";for(const o of this.ranges)o.start.parent==e&&o.start.offset===t&&(o.isCollapsed?i+=He+St:n+=He),o.end.parent===e&&o.end.offset===t&&!o.isCollapsed&&(s+=St);return s+i+n}_stringifyTextRanges(e){const t=e.data.length,n=e.data.split("");let s,i;this.sameSelectionCharacters?(s=He,i=St):(s=Xe,i=At),n[t]="";const o=n.map(a=>({letter:a,start:"",end:"",collapsed:""}));for(const a of this.ranges){const l=a.start,c=a.end;l.parent==e&&l.offset>=0&&l.offset<=t&&(a.isCollapsed?o[c.offset].collapsed+=s+i:o[l.offset].start+=s),c.parent==e&&c.offset>=0&&c.offset<=t&&!a.isCollapsed&&(o[c.offset].end+=i)}return o.map(a=>a.end+a.collapsed+a.start+a.letter).join("")}_stringifyElementOpen(e){const t=this._stringifyElementPriority(e),n=this._stringifyElementId(e),i=[this._stringifyElementType(e),e.name].filter(l=>l!=="").join(":"),o=this._stringifyElementAttributes(e);return`<${[i,t,n,o].filter(l=>l!=="").join(" ")}>`}_stringifyElementClose(e){return`</${[this._stringifyElementType(e),e.name].filter(s=>s!=="").join(":")}>`}_stringifyElementType(e){if(this.showType){for(const t in kt)if(e instanceof kt[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){const t=[],n=[...e.getAttributeKeys()].sort();for(const s of n){let i;s==="class"?i=[...e.getClassNames()].sort().join(" "):s==="style"?i=[...e.getStyleNames()].sort().map(o=>`${o}:${e.getStyle(o).replace(/"/g,"&quot;")}`).join(";"):i=e.getAttribute(s),t.push(`${s}="${i}"`)}return t.join(" ")}}function Hi(r){if(r.is("element")||r.is("documentFragment")){const e=r.is("documentFragment")?new se(r.document):ph(r.document,r);for(const t of[...r.getChildren()]){if(e.is("emptyElement"))throw new Error("Parse error - cannot parse inside ViewEmptyElement.");if(e.is("uiElement"))throw new Error("Parse error - cannot parse inside UIElement.");if(e.is("rawElement"))throw new Error("Parse error - cannot parse inside RawElement.");e._appendChild(Hi(t))}return e}return r}function ph(r,e){const t=_h(e),n=kt[t.type],s=n?new n(r,t.name):new J(r,t.name);s.is("attributeElement")&&(t.priority!==null&&(s._priority=t.priority),t.id!==null&&(s._id=t.id));for(const i of e.getAttributeKeys())s._setAttribute(i,e.getAttribute(i));return s}function _h(r){const e=r.name.split(":"),t=yh(r.getAttribute("view-priority")),n=r.hasAttribute("view-id")?r.getAttribute("view-id"):null;if(r._removeAttribute("view-priority"),r._removeAttribute("view-id"),e.length==1)return{name:e[0],type:t!==null?"attribute":null,priority:t,id:n};const s=wh(e[0]);if(s)return{name:e[1],type:s,priority:t,id:n};throw new Error(`Parse error - cannot parse element's name: ${r.name}.`)}function wh(r){return r in kt?r:null}function yh(r){const e=parseInt(r,10);return isNaN(e)?null:e}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Er(r,e={}){if(!(r instanceof Pt))throw new TypeError("Model needs to be an instance of module:engine/model/model~Model.");const t=e.rootName||"main",n=r.document.getRoot(t);return Er._stringify(n,e.withoutSelection?null:r.document.selection,e.convertMarkers?r.markers:null)}Er._stringify=Xi;function Rr(r,e,t={}){if(!(r instanceof Pt))throw new TypeError("Model needs to be an instance of module:engine/model/model~Model.");let n,s=null;const i=r.document.getRoot(t.rootName||"main"),o=Rr._parse(e,r.schema,{lastRangeBackward:t.lastRangeBackward,selectionAttributes:t.selectionAttributes,context:[i.name],inlineObjectElements:t.inlineObjectElements});"model"in o?(n=o.model,s=o.selection):n=o,t.batchType!==void 0?r.enqueueChange(t.batchType,a):r.change(a);function a(l){if(l.remove(l.createRangeIn(i)),l.insert(n,i),l.setSelection(null),l.removeSelectionAttribute(r.document.selection.getAttributeKeys()),s){const c=[];for(const h of s.getRanges()){const u=new m(i,h.start.path),g=new m(i,h.end.path);c.push(new f(u,g))}l.setSelection(c,{backward:s.isBackward}),t.selectionAttributes&&l.setSelectionAttribute(s.getAttributes())}}}Rr._parse=Yi;function Xi(r,e=null,t=null){const n=new Pt,s=new gt;let i=null,o;if(r instanceof ze||r instanceof j)o=n.createRangeIn(r);else if(r.parent)o=new f(n.createPositionBefore(r),n.createPositionAfter(r));else{const v=new j(r);o=n.createRangeIn(v)}e instanceof O||e instanceof U?i=e:e instanceof f?i=new O(e):e instanceof m&&(i=new O(e));const a=new Fn,l=new mt(a),c=l.document,h=new Ut(c,"div");h.rootName="main",c.roots.add(h);const u=new er({mapper:s,schema:n.schema});s.bindElements(r.root,h),u.on("insert:$text",Qt()),u.on("insert",Zt(),{priority:"lowest"}),u.on("attribute",(v,R,B)=>{(R.item instanceof O||R.item instanceof U||R.item.is("$textProxy"))&&or((to,{writer:no})=>no.createAttributeElement("model-text-with-attributes",{[R.attributeKey]:eo(to)}))(v,R,B)}),u.on("insert",ar(v=>{const R=Tr(v.getAttributes(),eo);return new ge(c,v.name,R)})),u.on("selection",sr()),u.on("selection",ir()),u.on("addMarker",lr((v,{writer:R})=>{const B=v.markerName+":"+(v.isOpening?"start":"end");return R.createUIElement(B)}));const g=new Map;if(t)for(const v of Array.from(t).sort((R,B)=>R.name<B.name?1:-1))g.set(v.name,v.getRange());const _=l._writer;u.convert(o,g,_),i&&u.convertSelection(i,t||n.markers,_);let y=Ar(h,c.selection,{sameSelectionCharacters:!0});return y=y.substr(5,y.length-11),l.destroy(),y.replace(new RegExp("model-text-with-attributes","g"),"$text")}function Yi(r,e,t={}){const n=new gt;r=r.replace(new RegExp("\\$text","g"),"model-text-with-attributes");const s=kr(r,{sameSelectionCharacters:!0,lastRangeBackward:!!t.lastRangeBackward,inlineObjectElements:t.inlineObjectElements});let i,o=null,a=null;"view"in s&&"selection"in s?(i=s.view,o=s.selection):i=s;const l=new Pt,c=new ti({schema:e});c.on("documentFragment",bh(n)),c.on("element:model-text-with-attributes",Qi()),c.on("element",vh(n)),c.on("text",Qi());let h=l.change(u=>c.convert(i.root,u,t.context||"$root"));if(n.bindElements(h,i.root),h.childCount==1&&(h=h.getChild(0)),o){const u=[];for(const g of o.getRanges())u.push(n.toModelRange(g));a=new O(u,{backward:o.isBackward});for(const[g,_]of he(t.selectionAttributes||[]))a.setAttribute(g,_)}return a?{model:h,selection:a}:h}function bh(r){return(e,t,n)=>{const s=n.convertChildren(t.viewItem,t.modelCursor);r.bindElements(t.modelCursor.parent,t.viewItem),t=Object.assign(t,s),e.stop()}}function vh(r){return(e,t,n)=>{const s=t.viewItem.name;if(!n.schema.checkChild(t.modelCursor,s))throw new Error(`Element '${s}' was not allowed in given position.`);const i=Tr(t.viewItem.getAttributes(),Zi),o=n.writer.createElement(t.viewItem.name,i);n.writer.insert(o,t.modelCursor),r.bindElements(o,t.viewItem),n.convertChildren(t.viewItem,o),t.modelRange=f._createOn(o),t.modelCursor=t.modelRange.end,e.stop()}}function Qi(){return(r,e,t)=>{if(!t.schema.checkChild(e.modelCursor,"$text"))throw new Error("Text was not allowed in given position.");let n;if(e.viewItem.is("element")){const s=Tr(e.viewItem.getAttributes(),Zi),i=e.viewItem.getChild(0);n=t.writer.createText(i.data,s)}else n=t.writer.createText(e.viewItem.data);t.writer.insert(n,e.modelCursor),e.modelRange=f._createFromPositionAndShift(e.modelCursor,n.offsetSize),e.modelCursor=e.modelRange.end,r.stop()}}function Zi(r){try{return JSON.parse(r)}catch{return r}}function eo(r){return at(r)?JSON.stringify(r):r}function*Tr(r,e){for(const[t,n]of r)yield[t,e(n)]}/**
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/function Ph(r){let e="";for(const t of r)e+=` ${t[0]}=${JSON.stringify(t[1])}`;return e}function Ch(r){const e={};for(const t of r)e[t[0]]=t[1];return JSON.stringify(e)}const Ye=Symbol("_treeDump"),Sh=20;function Ah(r,e){console.log(r,e);let t="";for(const s of r.roots)t+=s.printTree()+`
`;r[Ye][e]=t.substr(0,t.length-1);const n=r[Ye].length-Sh;n>0&&(r[Ye][n-1]=null)}function kh(r){r[Ye]=[]}function Eh(r,e){console.log("--------------------"),r[Ye][e]?console.log(r[Ye][e]):console.log("Tree log unavailable for given version: "+e)}/**
 * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
 */class Rh{_model;_logSeparator;_operationsToReplay;constructor(e,t,n){this._model=e,this._logSeparator=t,this.setStringifiedOperations(n)}setStringifiedOperations(e){if(e===""){this._operationsToReplay=[];return}this._operationsToReplay=e.split(this._logSeparator).map(t=>JSON.parse(t))}getOperationsToReplay(){return this._operationsToReplay}play(e=1e3){const t=this;return new Promise((n,s)=>{i();function i(){t.applyNextOperation().then(o=>{if(o)return n();setTimeout(i,e)}).catch(o=>{s(o)})}})}applyOperations(e){if(!(e<=0))return this.applyNextOperation().then(t=>{if(!t)return this.applyOperations(e-1)})}applyAllOperations(){return this.applyNextOperation().then(e=>{if(!e)return this.applyAllOperations()})}applyNextOperation(){const e=this._model;return new Promise(t=>{e.enqueueChange(n=>{const s=this._operationsToReplay.shift();if(!s)return t(!0);const i=_r.fromJSON(s,e.document);n.batch.addOperation(i),e.applyOperation(i),t(!1)})})}}export{E as AttributeOperation,ke as Batch,ns as BubblingEmitterMixin,Jt as BubblingEventInfo,Vc as ClickObserver,Cs as CompositionObserver,sc as Conversion,nr as ConversionHelpers,nc as DataController,Et as Differ,ie as DomEventObserver,Ms as DowncastHelpers,Bl as EditingController,mt as EditingView,vs as FakeSelectionObserver,Xt as FocusObserver,mi as History,ni as HtmlDataProcessor,ks as InputObserver,M as InsertOperation,bs as KeyObserver,gt as Mapper,wi as MarkerCollection,L as MarkerOperation,Te as Matcher,k as MergeOperation,Pt as Model,pi as ModelDocument,j as ModelDocumentFragment,U as ModelDocumentSelection,A as ModelElement,D as ModelLivePosition,ye as ModelLiveRange,we as ModelNode,We as ModelNodeList,m as ModelPosition,f as ModelRange,ze as ModelRootElement,Zs as ModelSchema,le as ModelSchemaContext,O as ModelSelection,S as ModelText,H as ModelTextProxy,ae as ModelTreeWalker,oe as ModelTypeCheckable,bi as ModelWriter,Lc as MouseObserver,P as MoveOperation,Xn as MutationObserver,N as NoOperation,Se as Observer,_r as OperationFactory,Wc as PointerObserver,W as RenameOperation,re as RootAttributeOperation,Z as RootOperation,Ps as SelectionObserver,C as SplitOperation,Fe as StylesMap,Fn as StylesProcessor,Es as TabObserver,$c as TouchObserver,js as UpcastHelpers,Li as UpcastWriter,_e as ViewAttributeElement,ge as ViewContainerElement,Ss as ViewDataTransfer,Gt as ViewDocument,ys as ViewDocumentDomEventData,se as ViewDocumentFragment,Be as ViewDocumentSelection,Ht as ViewDomConverter,qn as ViewDowncastWriter,ct as ViewEditableElement,J as ViewElement,ut as ViewEmptyElement,me as ViewNode,p as ViewPosition,w as ViewRange,ft as ViewRawElement,us as ViewRenderer,Ut as ViewRootEditableElement,Q as ViewSelection,T as ViewText,ee as ViewTextProxy,qt as ViewTokenList,pe as ViewTreeWalker,de as ViewTypeCheckable,Ve as ViewUIElement,Li as ViewUpcastWriter,si as XmlDataProcessor,dr as _DataProcessorBasicHtmlWriter,yi as _DetachOperation,Ts as _MapperCache,Rh as _OperationReplayer,Kn as _VIEW_BR_FILLER,Le as _VIEW_INLINE_FILLER,q as _VIEW_INLINE_FILLER_LENGTH,Gn as _VIEW_MARKED_NBSP_FILLER,jn as _VIEW_NBSP_FILLER,Wr as _ViewElementConversionConsumables,en as _autoParagraphEmptyModelRoots,Ch as _convertMapToStringifiedObject,Ph as _convertMapToTags,Ti as _deleteModelContent,Fs as _downcastCleanSelection,ir as _downcastConvertCollapsedSelection,sr as _downcastConvertRangeSelection,rr as _downcastCreateViewElementFromDowncastHighlightDescriptor,Zt as _downcastInsertAttributesAndChildren,ar as _downcastInsertElement,Ds as _downcastInsertStructure,Qt as _downcastInsertText,lr as _downcastInsertUIElement,Is as _downcastRemove,or as _downcastWrap,Ah as _dumpTrees,Hn as _getDataWithoutViewFiller,Er as _getModelData,Yn as _getModelNodeAfterPosition,Qn as _getModelNodeBeforePosition,$e as _getModelTextNodeAtPosition,Ii as _getSelectedModelContent,cn as _getViewData,kh as _initDocumentDumping,Si as _injectModelSelectionPostFixer,hs as _injectViewQuirksHandling,os as _injectViewUIElementHandling,rn as _insertIntoModelNodeList,Di as _insertModelContent,Bi as _insertModelObject,Ce as _isInlineViewFiller,tn as _isParagraphableModelNode,Ze as _isViewPatternMatched,Eh as _logDocument,Ei as _mergeIntersectingModelRanges,Vi as _modifyModelSelection,qe as _moveInModelNodeList,Re as _normalizeConversionConsumables,pr as _normalizeInModelNodeList,yr as _operationTransform,Yi as _parseModel,kr as _parseView,gr as _removeFromModelNodeList,ii as _setAttributeInModelNodeList,Rr as _setModelData,Sr as _setViewData,V as _startsWithViewFiller,Xi as _stringifyModel,Ar as _stringifyView,Ai as _tryFixingModelRange,Ks as _upcastConvertSelectionChange,Gs as _upcastConvertText,hr as _upcastConvertToModelFragment,nn as _wrapInModelParagraph,rh as addBackgroundStylesRules,ah as addBorderStylesRules,uh as addMarginStylesRules,fh as addPaddingStylesRules,en as autoParagraphEmptyRoots,mo as disableViewPlaceholder,fo as enableViewPlaceholder,Gi as getBoxSidesStyleShorthandValue,Ge as getBoxSidesStyleValueReducer,je as getBoxSidesStyleValues,Pr as getPositionStyleShorthandNormalizer,sn as getShorthandStylesValues,es as getViewFillerOffset,Tt as hideViewPlaceholder,Ji as isAttachmentStyleValue,$i as isColorStyleValue,qi as isLengthStyleValue,Wi as isLineStyleValue,tn as isParagraphable,Qc as isPercentageStyleValue,zi as isPositionStyleValue,Ui as isRepeatStyleValue,ji as isURLStyleValue,Lr as needsViewPlaceholder,Vr as showViewPlaceholder,ac as transformOperationSets,nn as wrapInParagraph};
